babylon.max.js 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs", [], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs"] = factory();
  8. else
  9. root["BABYLON"] = factory();
  10. })(window, function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./Legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../node_modules/tslib/tslib.es6.js":
  99. /*!******************************************!*\
  100. !*** ../node_modules/tslib/tslib.es6.js ***!
  101. \******************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  125. /*! *****************************************************************************
  126. Copyright (c) Microsoft Corporation. All rights reserved.
  127. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  128. this file except in compliance with the License. You may obtain a copy of the
  129. License at http://www.apache.org/licenses/LICENSE-2.0
  130. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  131. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  132. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  133. MERCHANTABLITY OR NON-INFRINGEMENT.
  134. See the Apache Version 2.0 License for specific language governing permissions
  135. and limitations under the License.
  136. ***************************************************************************** */
  137. /* global Reflect, Promise */
  138. var extendStatics = function(d, b) {
  139. extendStatics = Object.setPrototypeOf ||
  140. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  141. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  142. return extendStatics(d, b);
  143. };
  144. function __extends(d, b) {
  145. extendStatics(d, b);
  146. function __() { this.constructor = d; }
  147. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  148. }
  149. var __assign = function() {
  150. __assign = Object.assign || function __assign(t) {
  151. for (var s, i = 1, n = arguments.length; i < n; i++) {
  152. s = arguments[i];
  153. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  154. }
  155. return t;
  156. }
  157. return __assign.apply(this, arguments);
  158. }
  159. function __rest(s, e) {
  160. var t = {};
  161. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  162. t[p] = s[p];
  163. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  164. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  165. t[p[i]] = s[p[i]];
  166. return t;
  167. }
  168. function __decorate(decorators, target, key, desc) {
  169. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  170. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  171. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  172. return c > 3 && r && Object.defineProperty(target, key, r), r;
  173. }
  174. function __param(paramIndex, decorator) {
  175. return function (target, key) { decorator(target, key, paramIndex); }
  176. }
  177. function __metadata(metadataKey, metadataValue) {
  178. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  179. }
  180. function __awaiter(thisArg, _arguments, P, generator) {
  181. return new (P || (P = Promise))(function (resolve, reject) {
  182. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  183. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  184. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  185. step((generator = generator.apply(thisArg, _arguments || [])).next());
  186. });
  187. }
  188. function __generator(thisArg, body) {
  189. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  190. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  191. function verb(n) { return function (v) { return step([n, v]); }; }
  192. function step(op) {
  193. if (f) throw new TypeError("Generator is already executing.");
  194. while (_) try {
  195. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  196. if (y = 0, t) op = [op[0] & 2, t.value];
  197. switch (op[0]) {
  198. case 0: case 1: t = op; break;
  199. case 4: _.label++; return { value: op[1], done: false };
  200. case 5: _.label++; y = op[1]; op = [0]; continue;
  201. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  202. default:
  203. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  204. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  205. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  206. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  207. if (t[2]) _.ops.pop();
  208. _.trys.pop(); continue;
  209. }
  210. op = body.call(thisArg, _);
  211. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  212. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  213. }
  214. }
  215. function __exportStar(m, exports) {
  216. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  217. }
  218. function __values(o) {
  219. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  220. if (m) return m.call(o);
  221. return {
  222. next: function () {
  223. if (o && i >= o.length) o = void 0;
  224. return { value: o && o[i++], done: !o };
  225. }
  226. };
  227. }
  228. function __read(o, n) {
  229. var m = typeof Symbol === "function" && o[Symbol.iterator];
  230. if (!m) return o;
  231. var i = m.call(o), r, ar = [], e;
  232. try {
  233. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  234. }
  235. catch (error) { e = { error: error }; }
  236. finally {
  237. try {
  238. if (r && !r.done && (m = i["return"])) m.call(i);
  239. }
  240. finally { if (e) throw e.error; }
  241. }
  242. return ar;
  243. }
  244. function __spread() {
  245. for (var ar = [], i = 0; i < arguments.length; i++)
  246. ar = ar.concat(__read(arguments[i]));
  247. return ar;
  248. }
  249. function __await(v) {
  250. return this instanceof __await ? (this.v = v, this) : new __await(v);
  251. }
  252. function __asyncGenerator(thisArg, _arguments, generator) {
  253. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  254. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  255. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  256. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  257. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  258. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  259. function fulfill(value) { resume("next", value); }
  260. function reject(value) { resume("throw", value); }
  261. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  262. }
  263. function __asyncDelegator(o) {
  264. var i, p;
  265. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  266. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  267. }
  268. function __asyncValues(o) {
  269. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  270. var m = o[Symbol.asyncIterator], i;
  271. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  272. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  273. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  274. }
  275. function __makeTemplateObject(cooked, raw) {
  276. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  277. return cooked;
  278. };
  279. function __importStar(mod) {
  280. if (mod && mod.__esModule) return mod;
  281. var result = {};
  282. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  283. result.default = mod;
  284. return result;
  285. }
  286. function __importDefault(mod) {
  287. return (mod && mod.__esModule) ? mod : { default: mod };
  288. }
  289. /***/ }),
  290. /***/ "../node_modules/webpack/buildin/global.js":
  291. /*!*************************************************!*\
  292. !*** ../node_modules/webpack/buildin/global.js ***!
  293. \*************************************************/
  294. /*! no static exports found */
  295. /***/ (function(module, exports) {
  296. var g;
  297. // This works in non-strict mode
  298. g = (function() {
  299. return this;
  300. })();
  301. try {
  302. // This works if eval is allowed (see CSP)
  303. g = g || new Function("return this")();
  304. } catch (e) {
  305. // This works if the window reference is available
  306. if (typeof window === "object") g = window;
  307. }
  308. // g can still be undefined, but nothing to do about it...
  309. // We return undefined, instead of nothing here, so it's
  310. // easier to handle this case. if(!global) { ...}
  311. module.exports = g;
  312. /***/ }),
  313. /***/ "./Actions/action.ts":
  314. /*!***************************!*\
  315. !*** ./Actions/action.ts ***!
  316. \***************************/
  317. /*! exports provided: Action */
  318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  319. "use strict";
  320. __webpack_require__.r(__webpack_exports__);
  321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return Action; });
  322. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  323. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  324. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  325. /**
  326. * The action to be carried out following a trigger
  327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  328. */
  329. var Action = /** @class */ (function () {
  330. /**
  331. * Creates a new Action
  332. * @param triggerOptions the trigger, with or without parameters, for the action
  333. * @param condition an optional determinant of action
  334. */
  335. function Action(
  336. /** the trigger, with or without parameters, for the action */
  337. triggerOptions, condition) {
  338. this.triggerOptions = triggerOptions;
  339. /**
  340. * An event triggered prior to action being executed.
  341. */
  342. this.onBeforeExecuteObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  343. if (triggerOptions.parameter) {
  344. this.trigger = triggerOptions.trigger;
  345. this._triggerParameter = triggerOptions.parameter;
  346. }
  347. else if (triggerOptions.trigger) {
  348. this.trigger = triggerOptions.trigger;
  349. }
  350. else {
  351. this.trigger = triggerOptions;
  352. }
  353. this._nextActiveAction = this;
  354. this._condition = condition;
  355. }
  356. /**
  357. * Internal only
  358. * @hidden
  359. */
  360. Action.prototype._prepare = function () {
  361. };
  362. /**
  363. * Gets the trigger parameters
  364. * @returns the trigger parameters
  365. */
  366. Action.prototype.getTriggerParameter = function () {
  367. return this._triggerParameter;
  368. };
  369. /**
  370. * Internal only - executes current action event
  371. * @hidden
  372. */
  373. Action.prototype._executeCurrent = function (evt) {
  374. if (this._nextActiveAction._condition) {
  375. var condition = this._nextActiveAction._condition;
  376. var currentRenderId = this._actionManager.getScene().getRenderId();
  377. // We cache the current evaluation for the current frame
  378. if (condition._evaluationId === currentRenderId) {
  379. if (!condition._currentResult) {
  380. return;
  381. }
  382. }
  383. else {
  384. condition._evaluationId = currentRenderId;
  385. if (!condition.isValid()) {
  386. condition._currentResult = false;
  387. return;
  388. }
  389. condition._currentResult = true;
  390. }
  391. }
  392. this.onBeforeExecuteObservable.notifyObservers(this);
  393. this._nextActiveAction.execute(evt);
  394. this.skipToNextActiveAction();
  395. };
  396. /**
  397. * Execute placeholder for child classes
  398. * @param evt optional action event
  399. */
  400. Action.prototype.execute = function (evt) {
  401. };
  402. /**
  403. * Skips to next active action
  404. */
  405. Action.prototype.skipToNextActiveAction = function () {
  406. if (this._nextActiveAction._child) {
  407. if (!this._nextActiveAction._child._actionManager) {
  408. this._nextActiveAction._child._actionManager = this._actionManager;
  409. }
  410. this._nextActiveAction = this._nextActiveAction._child;
  411. }
  412. else {
  413. this._nextActiveAction = this;
  414. }
  415. };
  416. /**
  417. * Adds action to chain of actions, may be a DoNothingAction
  418. * @param action defines the next action to execute
  419. * @returns The action passed in
  420. * @see https://www.babylonjs-playground.com/#1T30HR#0
  421. */
  422. Action.prototype.then = function (action) {
  423. this._child = action;
  424. action._actionManager = this._actionManager;
  425. action._prepare();
  426. return action;
  427. };
  428. /**
  429. * Internal only
  430. * @hidden
  431. */
  432. Action.prototype._getProperty = function (propertyPath) {
  433. return this._actionManager._getProperty(propertyPath);
  434. };
  435. /**
  436. * Internal only
  437. * @hidden
  438. */
  439. Action.prototype._getEffectiveTarget = function (target, propertyPath) {
  440. return this._actionManager._getEffectiveTarget(target, propertyPath);
  441. };
  442. /**
  443. * Serialize placeholder for child classes
  444. * @param parent of child
  445. * @returns the serialized object
  446. */
  447. Action.prototype.serialize = function (parent) {
  448. };
  449. /**
  450. * Internal only called by serialize
  451. * @hidden
  452. */
  453. Action.prototype._serialize = function (serializedAction, parent) {
  454. var serializationObject = {
  455. type: 1,
  456. children: [],
  457. name: serializedAction.name,
  458. properties: serializedAction.properties || []
  459. };
  460. // Serialize child
  461. if (this._child) {
  462. this._child.serialize(serializationObject);
  463. }
  464. // Check if "this" has a condition
  465. if (this._condition) {
  466. var serializedCondition = this._condition.serialize();
  467. serializedCondition.children.push(serializationObject);
  468. if (parent) {
  469. parent.children.push(serializedCondition);
  470. }
  471. return serializedCondition;
  472. }
  473. if (parent) {
  474. parent.children.push(serializationObject);
  475. }
  476. return serializationObject;
  477. };
  478. /**
  479. * Internal only
  480. * @hidden
  481. */
  482. Action._SerializeValueAsString = function (value) {
  483. if (typeof value === "number") {
  484. return value.toString();
  485. }
  486. if (typeof value === "boolean") {
  487. return value ? "true" : "false";
  488. }
  489. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]) {
  490. return value.x + ", " + value.y;
  491. }
  492. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  493. return value.x + ", " + value.y + ", " + value.z;
  494. }
  495. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  496. return value.r + ", " + value.g + ", " + value.b;
  497. }
  498. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  499. return value.r + ", " + value.g + ", " + value.b + ", " + value.a;
  500. }
  501. return value; // string
  502. };
  503. /**
  504. * Internal only
  505. * @hidden
  506. */
  507. Action._GetTargetProperty = function (target) {
  508. return {
  509. name: "target",
  510. targetType: target._isMesh ? "MeshProperties"
  511. : target._isLight ? "LightProperties"
  512. : target._isCamera ? "CameraProperties"
  513. : "SceneProperties",
  514. value: target._isScene ? "Scene" : target.name
  515. };
  516. };
  517. return Action;
  518. }());
  519. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.Action"] = Action;
  520. /***/ }),
  521. /***/ "./Actions/actionEvent.ts":
  522. /*!********************************!*\
  523. !*** ./Actions/actionEvent.ts ***!
  524. \********************************/
  525. /*! exports provided: ActionEvent */
  526. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  527. "use strict";
  528. __webpack_require__.r(__webpack_exports__);
  529. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return ActionEvent; });
  530. /**
  531. * ActionEvent is the event being sent when an action is triggered.
  532. */
  533. var ActionEvent = /** @class */ (function () {
  534. /**
  535. * Creates a new ActionEvent
  536. * @param source The mesh or sprite that triggered the action
  537. * @param pointerX The X mouse cursor position at the time of the event
  538. * @param pointerY The Y mouse cursor position at the time of the event
  539. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  540. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  541. * @param additionalData additional data for the event
  542. */
  543. function ActionEvent(
  544. /** The mesh or sprite that triggered the action */
  545. source,
  546. /** The X mouse cursor position at the time of the event */
  547. pointerX,
  548. /** The Y mouse cursor position at the time of the event */
  549. pointerY,
  550. /** The mesh that is currently pointed at (can be null) */
  551. meshUnderPointer,
  552. /** the original (browser) event that triggered the ActionEvent */
  553. sourceEvent,
  554. /** additional data for the event */
  555. additionalData) {
  556. this.source = source;
  557. this.pointerX = pointerX;
  558. this.pointerY = pointerY;
  559. this.meshUnderPointer = meshUnderPointer;
  560. this.sourceEvent = sourceEvent;
  561. this.additionalData = additionalData;
  562. }
  563. /**
  564. * Helper function to auto-create an ActionEvent from a source mesh.
  565. * @param source The source mesh that triggered the event
  566. * @param evt The original (browser) event
  567. * @param additionalData additional data for the event
  568. * @returns the new ActionEvent
  569. */
  570. ActionEvent.CreateNew = function (source, evt, additionalData) {
  571. var scene = source.getScene();
  572. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  573. };
  574. /**
  575. * Helper function to auto-create an ActionEvent from a source sprite
  576. * @param source The source sprite that triggered the event
  577. * @param scene Scene associated with the sprite
  578. * @param evt The original (browser) event
  579. * @param additionalData additional data for the event
  580. * @returns the new ActionEvent
  581. */
  582. ActionEvent.CreateNewFromSprite = function (source, scene, evt, additionalData) {
  583. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  584. };
  585. /**
  586. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  587. * @param scene the scene where the event occurred
  588. * @param evt The original (browser) event
  589. * @returns the new ActionEvent
  590. */
  591. ActionEvent.CreateNewFromScene = function (scene, evt) {
  592. return new ActionEvent(null, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt);
  593. };
  594. /**
  595. * Helper function to auto-create an ActionEvent from a primitive
  596. * @param prim defines the target primitive
  597. * @param pointerPos defines the pointer position
  598. * @param evt The original (browser) event
  599. * @param additionalData additional data for the event
  600. * @returns the new ActionEvent
  601. */
  602. ActionEvent.CreateNewFromPrimitive = function (prim, pointerPos, evt, additionalData) {
  603. return new ActionEvent(prim, pointerPos.x, pointerPos.y, null, evt, additionalData);
  604. };
  605. return ActionEvent;
  606. }());
  607. /***/ }),
  608. /***/ "./Actions/actionManager.ts":
  609. /*!**********************************!*\
  610. !*** ./Actions/actionManager.ts ***!
  611. \**********************************/
  612. /*! exports provided: ActionManager */
  613. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  614. "use strict";
  615. __webpack_require__.r(__webpack_exports__);
  616. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return ActionManager; });
  617. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  618. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  619. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  620. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  621. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  622. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  623. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  624. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  625. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  626. /**
  627. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  628. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  630. */
  631. var ActionManager = /** @class */ (function () {
  632. /**
  633. * Creates a new action manager
  634. * @param scene defines the hosting scene
  635. */
  636. function ActionManager(scene) {
  637. // Members
  638. /** Gets the list of actions */
  639. this.actions = new Array();
  640. /** Gets the cursor to use when hovering items */
  641. this.hoverCursor = '';
  642. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  643. scene.actionManagers.push(this);
  644. }
  645. // Methods
  646. /**
  647. * Releases all associated resources
  648. */
  649. ActionManager.prototype.dispose = function () {
  650. var index = this._scene.actionManagers.indexOf(this);
  651. for (var i = 0; i < this.actions.length; i++) {
  652. var action = this.actions[i];
  653. ActionManager.Triggers[action.trigger]--;
  654. if (ActionManager.Triggers[action.trigger] === 0) {
  655. delete ActionManager.Triggers[action.trigger];
  656. }
  657. }
  658. if (index > -1) {
  659. this._scene.actionManagers.splice(index, 1);
  660. }
  661. };
  662. /**
  663. * Gets hosting scene
  664. * @returns the hosting scene
  665. */
  666. ActionManager.prototype.getScene = function () {
  667. return this._scene;
  668. };
  669. /**
  670. * Does this action manager handles actions of any of the given triggers
  671. * @param triggers defines the triggers to be tested
  672. * @return a boolean indicating whether one (or more) of the triggers is handled
  673. */
  674. ActionManager.prototype.hasSpecificTriggers = function (triggers) {
  675. for (var index = 0; index < this.actions.length; index++) {
  676. var action = this.actions[index];
  677. if (triggers.indexOf(action.trigger) > -1) {
  678. return true;
  679. }
  680. }
  681. return false;
  682. };
  683. /**
  684. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  685. * speed.
  686. * @param triggerA defines the trigger to be tested
  687. * @param triggerB defines the trigger to be tested
  688. * @return a boolean indicating whether one (or more) of the triggers is handled
  689. */
  690. ActionManager.prototype.hasSpecificTriggers2 = function (triggerA, triggerB) {
  691. for (var index = 0; index < this.actions.length; index++) {
  692. var action = this.actions[index];
  693. if (triggerA == action.trigger || triggerB == action.trigger) {
  694. return true;
  695. }
  696. }
  697. return false;
  698. };
  699. /**
  700. * Does this action manager handles actions of a given trigger
  701. * @param trigger defines the trigger to be tested
  702. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  703. * @return whether the trigger is handled
  704. */
  705. ActionManager.prototype.hasSpecificTrigger = function (trigger, parameterPredicate) {
  706. for (var index = 0; index < this.actions.length; index++) {
  707. var action = this.actions[index];
  708. if (action.trigger === trigger) {
  709. if (parameterPredicate) {
  710. if (parameterPredicate(action.getTriggerParameter())) {
  711. return true;
  712. }
  713. }
  714. else {
  715. return true;
  716. }
  717. }
  718. }
  719. return false;
  720. };
  721. Object.defineProperty(ActionManager.prototype, "hasPointerTriggers", {
  722. /**
  723. * Does this action manager has pointer triggers
  724. */
  725. get: function () {
  726. for (var index = 0; index < this.actions.length; index++) {
  727. var action = this.actions[index];
  728. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPointerOutTrigger) {
  729. return true;
  730. }
  731. }
  732. return false;
  733. },
  734. enumerable: true,
  735. configurable: true
  736. });
  737. Object.defineProperty(ActionManager.prototype, "hasPickTriggers", {
  738. /**
  739. * Does this action manager has pick triggers
  740. */
  741. get: function () {
  742. for (var index = 0; index < this.actions.length; index++) {
  743. var action = this.actions[index];
  744. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPickUpTrigger) {
  745. return true;
  746. }
  747. }
  748. return false;
  749. },
  750. enumerable: true,
  751. configurable: true
  752. });
  753. Object.defineProperty(ActionManager, "HasTriggers", {
  754. /**
  755. * Does exist one action manager with at least one trigger
  756. **/
  757. get: function () {
  758. for (var t in ActionManager.Triggers) {
  759. if (ActionManager.Triggers.hasOwnProperty(t)) {
  760. return true;
  761. }
  762. }
  763. return false;
  764. },
  765. enumerable: true,
  766. configurable: true
  767. });
  768. Object.defineProperty(ActionManager, "HasPickTriggers", {
  769. /**
  770. * Does exist one action manager with at least one pick trigger
  771. **/
  772. get: function () {
  773. for (var t in ActionManager.Triggers) {
  774. if (ActionManager.Triggers.hasOwnProperty(t)) {
  775. var t_int = parseInt(t);
  776. if (t_int >= ActionManager.OnPickTrigger && t_int <= ActionManager.OnPickUpTrigger) {
  777. return true;
  778. }
  779. }
  780. }
  781. return false;
  782. },
  783. enumerable: true,
  784. configurable: true
  785. });
  786. /**
  787. * Does exist one action manager that handles actions of a given trigger
  788. * @param trigger defines the trigger to be tested
  789. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  790. **/
  791. ActionManager.HasSpecificTrigger = function (trigger) {
  792. for (var t in ActionManager.Triggers) {
  793. if (ActionManager.Triggers.hasOwnProperty(t)) {
  794. var t_int = parseInt(t);
  795. if (t_int === trigger) {
  796. return true;
  797. }
  798. }
  799. }
  800. return false;
  801. };
  802. /**
  803. * Registers an action to this action manager
  804. * @param action defines the action to be registered
  805. * @return the action amended (prepared) after registration
  806. */
  807. ActionManager.prototype.registerAction = function (action) {
  808. if (action.trigger === ActionManager.OnEveryFrameTrigger) {
  809. if (this.getScene().actionManager !== this) {
  810. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Warn("OnEveryFrameTrigger can only be used with scene.actionManager");
  811. return null;
  812. }
  813. }
  814. this.actions.push(action);
  815. if (ActionManager.Triggers[action.trigger]) {
  816. ActionManager.Triggers[action.trigger]++;
  817. }
  818. else {
  819. ActionManager.Triggers[action.trigger] = 1;
  820. }
  821. action._actionManager = this;
  822. action._prepare();
  823. return action;
  824. };
  825. /**
  826. * Unregisters an action to this action manager
  827. * @param action defines the action to be unregistered
  828. * @return a boolean indicating whether the action has been unregistered
  829. */
  830. ActionManager.prototype.unregisterAction = function (action) {
  831. var index = this.actions.indexOf(action);
  832. if (index !== -1) {
  833. this.actions.splice(index, 1);
  834. ActionManager.Triggers[action.trigger] -= 1;
  835. if (ActionManager.Triggers[action.trigger] === 0) {
  836. delete ActionManager.Triggers[action.trigger];
  837. }
  838. delete action._actionManager;
  839. return true;
  840. }
  841. return false;
  842. };
  843. /**
  844. * Process a specific trigger
  845. * @param trigger defines the trigger to process
  846. * @param evt defines the event details to be processed
  847. */
  848. ActionManager.prototype.processTrigger = function (trigger, evt) {
  849. for (var index = 0; index < this.actions.length; index++) {
  850. var action = this.actions[index];
  851. if (action.trigger === trigger) {
  852. if (evt) {
  853. if (trigger === ActionManager.OnKeyUpTrigger
  854. || trigger === ActionManager.OnKeyDownTrigger) {
  855. var parameter = action.getTriggerParameter();
  856. if (parameter && parameter !== evt.sourceEvent.keyCode) {
  857. if (!parameter.toLowerCase) {
  858. continue;
  859. }
  860. var lowerCase = parameter.toLowerCase();
  861. if (lowerCase !== evt.sourceEvent.key) {
  862. var unicode = evt.sourceEvent.charCode ? evt.sourceEvent.charCode : evt.sourceEvent.keyCode;
  863. var actualkey = String.fromCharCode(unicode).toLowerCase();
  864. if (actualkey !== lowerCase) {
  865. continue;
  866. }
  867. }
  868. }
  869. }
  870. }
  871. action._executeCurrent(evt);
  872. }
  873. }
  874. };
  875. /** @hidden */
  876. ActionManager.prototype._getEffectiveTarget = function (target, propertyPath) {
  877. var properties = propertyPath.split(".");
  878. for (var index = 0; index < properties.length - 1; index++) {
  879. target = target[properties[index]];
  880. }
  881. return target;
  882. };
  883. /** @hidden */
  884. ActionManager.prototype._getProperty = function (propertyPath) {
  885. var properties = propertyPath.split(".");
  886. return properties[properties.length - 1];
  887. };
  888. /**
  889. * Serialize this manager to a JSON object
  890. * @param name defines the property name to store this manager
  891. * @returns a JSON representation of this manager
  892. */
  893. ActionManager.prototype.serialize = function (name) {
  894. var root = {
  895. children: new Array(),
  896. name: name,
  897. type: 3,
  898. properties: new Array() // Empty for root but required
  899. };
  900. for (var i = 0; i < this.actions.length; i++) {
  901. var triggerObject = {
  902. type: 0,
  903. children: new Array(),
  904. name: ActionManager.GetTriggerName(this.actions[i].trigger),
  905. properties: new Array()
  906. };
  907. var triggerOptions = this.actions[i].triggerOptions;
  908. if (triggerOptions && typeof triggerOptions !== "number") {
  909. if (triggerOptions.parameter instanceof Node) {
  910. triggerObject.properties.push(_action__WEBPACK_IMPORTED_MODULE_2__["Action"]._GetTargetProperty(triggerOptions.parameter));
  911. }
  912. else {
  913. var parameter = {};
  914. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__["DeepCopier"].DeepCopy(triggerOptions.parameter, parameter, ["mesh"]);
  915. if (triggerOptions.parameter && triggerOptions.parameter.mesh) {
  916. parameter._meshId = triggerOptions.parameter.mesh.id;
  917. }
  918. triggerObject.properties.push({ name: "parameter", targetType: null, value: parameter });
  919. }
  920. }
  921. // Serialize child action, recursively
  922. this.actions[i].serialize(triggerObject);
  923. // Add serialized trigger
  924. root.children.push(triggerObject);
  925. }
  926. return root;
  927. };
  928. /**
  929. * Creates a new ActionManager from a JSON data
  930. * @param parsedActions defines the JSON data to read from
  931. * @param object defines the hosting mesh
  932. * @param scene defines the hosting scene
  933. */
  934. ActionManager.Parse = function (parsedActions, object, scene) {
  935. var actionManager = new ActionManager(scene);
  936. if (object === null) {
  937. scene.actionManager = actionManager;
  938. }
  939. else {
  940. object.actionManager = actionManager;
  941. }
  942. // instanciate a new object
  943. var instanciate = function (name, params) {
  944. var internalClassType = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON." + name);
  945. if (internalClassType) {
  946. var newInstance = Object.create(internalClassType.prototype);
  947. newInstance.constructor.apply(newInstance, params);
  948. return newInstance;
  949. }
  950. };
  951. var parseParameter = function (name, value, target, propertyPath) {
  952. if (propertyPath === null) {
  953. // String, boolean or float
  954. var floatValue = parseFloat(value);
  955. if (value === "true" || value === "false") {
  956. return value === "true";
  957. }
  958. else {
  959. return isNaN(floatValue) ? value : floatValue;
  960. }
  961. }
  962. var effectiveTarget = propertyPath.split(".");
  963. var values = value.split(",");
  964. // Get effective Target
  965. for (var i = 0; i < effectiveTarget.length; i++) {
  966. target = target[effectiveTarget[i]];
  967. }
  968. // Return appropriate value with its type
  969. if (typeof (target) === "boolean") {
  970. return values[0] === "true";
  971. }
  972. if (typeof (target) === "string") {
  973. return values[0];
  974. }
  975. // Parameters with multiple values such as Vector3 etc.
  976. var split = new Array();
  977. for (var i = 0; i < values.length; i++) {
  978. split.push(parseFloat(values[i]));
  979. }
  980. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  981. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(split);
  982. }
  983. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"]) {
  984. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].FromArray(split);
  985. }
  986. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"]) {
  987. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(split);
  988. }
  989. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"]) {
  990. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].FromArray(split);
  991. }
  992. return parseFloat(values[0]);
  993. };
  994. // traverse graph per trigger
  995. var traverse = function (parsedAction, trigger, condition, action, combineArray) {
  996. if (combineArray === void 0) { combineArray = null; }
  997. if (parsedAction.detached) {
  998. return;
  999. }
  1000. var parameters = new Array();
  1001. var target = null;
  1002. var propertyPath = null;
  1003. var combine = parsedAction.combine && parsedAction.combine.length > 0;
  1004. // Parameters
  1005. if (parsedAction.type === 2) {
  1006. parameters.push(actionManager);
  1007. }
  1008. else {
  1009. parameters.push(trigger);
  1010. }
  1011. if (combine) {
  1012. var actions = new Array();
  1013. for (var j = 0; j < parsedAction.combine.length; j++) {
  1014. traverse(parsedAction.combine[j], ActionManager.NothingTrigger, condition, action, actions);
  1015. }
  1016. parameters.push(actions);
  1017. }
  1018. else {
  1019. for (var i = 0; i < parsedAction.properties.length; i++) {
  1020. var value = parsedAction.properties[i].value;
  1021. var name = parsedAction.properties[i].name;
  1022. var targetType = parsedAction.properties[i].targetType;
  1023. if (name === "target") {
  1024. if (targetType !== null && targetType === "SceneProperties") {
  1025. value = target = scene;
  1026. }
  1027. else {
  1028. value = target = scene.getNodeByName(value);
  1029. }
  1030. }
  1031. else if (name === "parent") {
  1032. value = scene.getNodeByName(value);
  1033. }
  1034. else if (name === "sound") {
  1035. // Can not externalize to component, so only checks for the presence off the API.
  1036. if (scene.getSoundByName) {
  1037. value = scene.getSoundByName(value);
  1038. }
  1039. }
  1040. else if (name !== "propertyPath") {
  1041. if (parsedAction.type === 2 && name === "operator") {
  1042. value = _condition__WEBPACK_IMPORTED_MODULE_1__["ValueCondition"][value];
  1043. }
  1044. else {
  1045. value = parseParameter(name, value, target, name === "value" ? propertyPath : null);
  1046. }
  1047. }
  1048. else {
  1049. propertyPath = value;
  1050. }
  1051. parameters.push(value);
  1052. }
  1053. }
  1054. if (combineArray === null) {
  1055. parameters.push(condition);
  1056. }
  1057. else {
  1058. parameters.push(null);
  1059. }
  1060. // If interpolate value action
  1061. if (parsedAction.name === "InterpolateValueAction") {
  1062. var param = parameters[parameters.length - 2];
  1063. parameters[parameters.length - 1] = param;
  1064. parameters[parameters.length - 2] = condition;
  1065. }
  1066. // Action or condition(s) and not CombineAction
  1067. var newAction = instanciate(parsedAction.name, parameters);
  1068. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_1__["Condition"] && condition !== null) {
  1069. var nothing = new _directActions__WEBPACK_IMPORTED_MODULE_3__["DoNothingAction"](trigger, condition);
  1070. if (action) {
  1071. action.then(nothing);
  1072. }
  1073. else {
  1074. actionManager.registerAction(nothing);
  1075. }
  1076. action = nothing;
  1077. }
  1078. if (combineArray === null) {
  1079. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_1__["Condition"]) {
  1080. condition = newAction;
  1081. newAction = action;
  1082. }
  1083. else {
  1084. condition = null;
  1085. if (action) {
  1086. action.then(newAction);
  1087. }
  1088. else {
  1089. actionManager.registerAction(newAction);
  1090. }
  1091. }
  1092. }
  1093. else {
  1094. combineArray.push(newAction);
  1095. }
  1096. for (var i = 0; i < parsedAction.children.length; i++) {
  1097. traverse(parsedAction.children[i], trigger, condition, newAction, null);
  1098. }
  1099. };
  1100. // triggers
  1101. for (var i = 0; i < parsedActions.children.length; i++) {
  1102. var triggerParams;
  1103. var trigger = parsedActions.children[i];
  1104. if (trigger.properties.length > 0) {
  1105. var param = trigger.properties[0].value;
  1106. var value = trigger.properties[0].targetType === null ? param : scene.getMeshByName(param);
  1107. if (value._meshId) {
  1108. value.mesh = scene.getMeshByID(value._meshId);
  1109. }
  1110. triggerParams = { trigger: ActionManager[trigger.name], parameter: value };
  1111. }
  1112. else {
  1113. triggerParams = ActionManager[trigger.name];
  1114. }
  1115. for (var j = 0; j < trigger.children.length; j++) {
  1116. if (!trigger.detached) {
  1117. traverse(trigger.children[j], triggerParams, null, null);
  1118. }
  1119. }
  1120. }
  1121. };
  1122. /**
  1123. * Get a trigger name by index
  1124. * @param trigger defines the trigger index
  1125. * @returns a trigger name
  1126. */
  1127. ActionManager.GetTriggerName = function (trigger) {
  1128. switch (trigger) {
  1129. case 0: return "NothingTrigger";
  1130. case 1: return "OnPickTrigger";
  1131. case 2: return "OnLeftPickTrigger";
  1132. case 3: return "OnRightPickTrigger";
  1133. case 4: return "OnCenterPickTrigger";
  1134. case 5: return "OnPickDownTrigger";
  1135. case 6: return "OnPickUpTrigger";
  1136. case 7: return "OnLongPressTrigger";
  1137. case 8: return "OnPointerOverTrigger";
  1138. case 9: return "OnPointerOutTrigger";
  1139. case 10: return "OnEveryFrameTrigger";
  1140. case 11: return "OnIntersectionEnterTrigger";
  1141. case 12: return "OnIntersectionExitTrigger";
  1142. case 13: return "OnKeyDownTrigger";
  1143. case 14: return "OnKeyUpTrigger";
  1144. case 15: return "OnPickOutTrigger";
  1145. default: return "";
  1146. }
  1147. };
  1148. /**
  1149. * Nothing
  1150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1151. */
  1152. ActionManager.NothingTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_NothingTrigger;
  1153. /**
  1154. * On pick
  1155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1156. */
  1157. ActionManager.OnPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnPickTrigger;
  1158. /**
  1159. * On left pick
  1160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1161. */
  1162. ActionManager.OnLeftPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnLeftPickTrigger;
  1163. /**
  1164. * On right pick
  1165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1166. */
  1167. ActionManager.OnRightPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnRightPickTrigger;
  1168. /**
  1169. * On center pick
  1170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1171. */
  1172. ActionManager.OnCenterPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnCenterPickTrigger;
  1173. /**
  1174. * On pick down
  1175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1176. */
  1177. ActionManager.OnPickDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnPickDownTrigger;
  1178. /**
  1179. * On double pick
  1180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1181. */
  1182. ActionManager.OnDoublePickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnDoublePickTrigger;
  1183. /**
  1184. * On pick up
  1185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1186. */
  1187. ActionManager.OnPickUpTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnPickUpTrigger;
  1188. /**
  1189. * On pick out.
  1190. * This trigger will only be raised if you also declared a OnPickDown
  1191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1192. */
  1193. ActionManager.OnPickOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnPickOutTrigger;
  1194. /**
  1195. * On long press
  1196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1197. */
  1198. ActionManager.OnLongPressTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnLongPressTrigger;
  1199. /**
  1200. * On pointer over
  1201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1202. */
  1203. ActionManager.OnPointerOverTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnPointerOverTrigger;
  1204. /**
  1205. * On pointer out
  1206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1207. */
  1208. ActionManager.OnPointerOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnPointerOutTrigger;
  1209. /**
  1210. * On every frame
  1211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1212. */
  1213. ActionManager.OnEveryFrameTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnEveryFrameTrigger;
  1214. /**
  1215. * On intersection enter
  1216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1217. */
  1218. ActionManager.OnIntersectionEnterTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnIntersectionEnterTrigger;
  1219. /**
  1220. * On intersection exit
  1221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1222. */
  1223. ActionManager.OnIntersectionExitTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnIntersectionExitTrigger;
  1224. /**
  1225. * On key down
  1226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1227. */
  1228. ActionManager.OnKeyDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnKeyDownTrigger;
  1229. /**
  1230. * On key up
  1231. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1232. */
  1233. ActionManager.OnKeyUpTrigger = 15;
  1234. /** Gets the list of active triggers */
  1235. ActionManager.Triggers = {};
  1236. return ActionManager;
  1237. }());
  1238. /***/ }),
  1239. /***/ "./Actions/condition.ts":
  1240. /*!******************************!*\
  1241. !*** ./Actions/condition.ts ***!
  1242. \******************************/
  1243. /*! exports provided: Condition, ValueCondition, PredicateCondition, StateCondition */
  1244. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1245. "use strict";
  1246. __webpack_require__.r(__webpack_exports__);
  1247. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return Condition; });
  1248. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return ValueCondition; });
  1249. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return PredicateCondition; });
  1250. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return StateCondition; });
  1251. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1252. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1253. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1254. /**
  1255. * A Condition applied to an Action
  1256. */
  1257. var Condition = /** @class */ (function () {
  1258. /**
  1259. * Creates a new Condition
  1260. * @param actionManager the manager of the action the condition is applied to
  1261. */
  1262. function Condition(actionManager) {
  1263. this._actionManager = actionManager;
  1264. }
  1265. /**
  1266. * Check if the current condition is valid
  1267. * @returns a boolean
  1268. */
  1269. Condition.prototype.isValid = function () {
  1270. return true;
  1271. };
  1272. /**
  1273. * Internal only
  1274. * @hidden
  1275. */
  1276. Condition.prototype._getProperty = function (propertyPath) {
  1277. return this._actionManager._getProperty(propertyPath);
  1278. };
  1279. /**
  1280. * Internal only
  1281. * @hidden
  1282. */
  1283. Condition.prototype._getEffectiveTarget = function (target, propertyPath) {
  1284. return this._actionManager._getEffectiveTarget(target, propertyPath);
  1285. };
  1286. /**
  1287. * Serialize placeholder for child classes
  1288. * @returns the serialized object
  1289. */
  1290. Condition.prototype.serialize = function () {
  1291. };
  1292. /**
  1293. * Internal only
  1294. * @hidden
  1295. */
  1296. Condition.prototype._serialize = function (serializedCondition) {
  1297. return {
  1298. type: 2,
  1299. children: [],
  1300. name: serializedCondition.name,
  1301. properties: serializedCondition.properties
  1302. };
  1303. };
  1304. return Condition;
  1305. }());
  1306. /**
  1307. * Defines specific conditional operators as extensions of Condition
  1308. */
  1309. var ValueCondition = /** @class */ (function (_super) {
  1310. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ValueCondition, _super);
  1311. /**
  1312. * Creates a new ValueCondition
  1313. * @param actionManager manager for the action the condition applies to
  1314. * @param target for the action
  1315. * @param propertyPath path to specify the property of the target the conditional operator uses
  1316. * @param value the value compared by the conditional operator against the current value of the property
  1317. * @param operator the conditional operator, default ValueCondition.IsEqual
  1318. */
  1319. function ValueCondition(actionManager, target,
  1320. /** path to specify the property of the target the conditional operator uses */
  1321. propertyPath,
  1322. /** the value compared by the conditional operator against the current value of the property */
  1323. value,
  1324. /** the conditional operator, default ValueCondition.IsEqual */
  1325. operator) {
  1326. if (operator === void 0) { operator = ValueCondition.IsEqual; }
  1327. var _this = _super.call(this, actionManager) || this;
  1328. _this.propertyPath = propertyPath;
  1329. _this.value = value;
  1330. _this.operator = operator;
  1331. _this._target = target;
  1332. _this._effectiveTarget = _this._getEffectiveTarget(target, _this.propertyPath);
  1333. _this._property = _this._getProperty(_this.propertyPath);
  1334. return _this;
  1335. }
  1336. Object.defineProperty(ValueCondition, "IsEqual", {
  1337. /**
  1338. * returns the number for IsEqual
  1339. */
  1340. get: function () {
  1341. return ValueCondition._IsEqual;
  1342. },
  1343. enumerable: true,
  1344. configurable: true
  1345. });
  1346. Object.defineProperty(ValueCondition, "IsDifferent", {
  1347. /**
  1348. * Returns the number for IsDifferent
  1349. */
  1350. get: function () {
  1351. return ValueCondition._IsDifferent;
  1352. },
  1353. enumerable: true,
  1354. configurable: true
  1355. });
  1356. Object.defineProperty(ValueCondition, "IsGreater", {
  1357. /**
  1358. * Returns the number for IsGreater
  1359. */
  1360. get: function () {
  1361. return ValueCondition._IsGreater;
  1362. },
  1363. enumerable: true,
  1364. configurable: true
  1365. });
  1366. Object.defineProperty(ValueCondition, "IsLesser", {
  1367. /**
  1368. * Returns the number for IsLesser
  1369. */
  1370. get: function () {
  1371. return ValueCondition._IsLesser;
  1372. },
  1373. enumerable: true,
  1374. configurable: true
  1375. });
  1376. /**
  1377. * Compares the given value with the property value for the specified conditional operator
  1378. * @returns the result of the comparison
  1379. */
  1380. ValueCondition.prototype.isValid = function () {
  1381. switch (this.operator) {
  1382. case ValueCondition.IsGreater:
  1383. return this._effectiveTarget[this._property] > this.value;
  1384. case ValueCondition.IsLesser:
  1385. return this._effectiveTarget[this._property] < this.value;
  1386. case ValueCondition.IsEqual:
  1387. case ValueCondition.IsDifferent:
  1388. var check;
  1389. if (this.value.equals) {
  1390. check = this.value.equals(this._effectiveTarget[this._property]);
  1391. }
  1392. else {
  1393. check = this.value === this._effectiveTarget[this._property];
  1394. }
  1395. return this.operator === ValueCondition.IsEqual ? check : !check;
  1396. }
  1397. return false;
  1398. };
  1399. /**
  1400. * Serialize the ValueCondition into a JSON compatible object
  1401. * @returns serialization object
  1402. */
  1403. ValueCondition.prototype.serialize = function () {
  1404. return this._serialize({
  1405. name: "ValueCondition",
  1406. properties: [
  1407. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1408. { name: "propertyPath", value: this.propertyPath },
  1409. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  1410. { name: "operator", value: ValueCondition.GetOperatorName(this.operator) }
  1411. ]
  1412. });
  1413. };
  1414. /**
  1415. * Gets the name of the conditional operator for the ValueCondition
  1416. * @param operator the conditional operator
  1417. * @returns the name
  1418. */
  1419. ValueCondition.GetOperatorName = function (operator) {
  1420. switch (operator) {
  1421. case ValueCondition._IsEqual: return "IsEqual";
  1422. case ValueCondition._IsDifferent: return "IsDifferent";
  1423. case ValueCondition._IsGreater: return "IsGreater";
  1424. case ValueCondition._IsLesser: return "IsLesser";
  1425. default: return "";
  1426. }
  1427. };
  1428. /**
  1429. * Internal only
  1430. * @hidden
  1431. */
  1432. ValueCondition._IsEqual = 0;
  1433. /**
  1434. * Internal only
  1435. * @hidden
  1436. */
  1437. ValueCondition._IsDifferent = 1;
  1438. /**
  1439. * Internal only
  1440. * @hidden
  1441. */
  1442. ValueCondition._IsGreater = 2;
  1443. /**
  1444. * Internal only
  1445. * @hidden
  1446. */
  1447. ValueCondition._IsLesser = 3;
  1448. return ValueCondition;
  1449. }(Condition));
  1450. /**
  1451. * Defines a predicate condition as an extension of Condition
  1452. */
  1453. var PredicateCondition = /** @class */ (function (_super) {
  1454. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PredicateCondition, _super);
  1455. /**
  1456. * Creates a new PredicateCondition
  1457. * @param actionManager manager for the action the condition applies to
  1458. * @param predicate defines the predicate function used to validate the condition
  1459. */
  1460. function PredicateCondition(actionManager,
  1461. /** defines the predicate function used to validate the condition */
  1462. predicate) {
  1463. var _this = _super.call(this, actionManager) || this;
  1464. _this.predicate = predicate;
  1465. return _this;
  1466. }
  1467. /**
  1468. * @returns the validity of the predicate condition
  1469. */
  1470. PredicateCondition.prototype.isValid = function () {
  1471. return this.predicate();
  1472. };
  1473. return PredicateCondition;
  1474. }(Condition));
  1475. /**
  1476. * Defines a state condition as an extension of Condition
  1477. */
  1478. var StateCondition = /** @class */ (function (_super) {
  1479. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StateCondition, _super);
  1480. /**
  1481. * Creates a new StateCondition
  1482. * @param actionManager manager for the action the condition applies to
  1483. * @param target of the condition
  1484. * @param value to compare with target state
  1485. */
  1486. function StateCondition(actionManager, target,
  1487. /** Value to compare with target state */
  1488. value) {
  1489. var _this = _super.call(this, actionManager) || this;
  1490. _this.value = value;
  1491. _this._target = target;
  1492. return _this;
  1493. }
  1494. /**
  1495. * Gets a boolean indicating if the current condition is met
  1496. * @returns the validity of the state
  1497. */
  1498. StateCondition.prototype.isValid = function () {
  1499. return this._target.state === this.value;
  1500. };
  1501. /**
  1502. * Serialize the StateCondition into a JSON compatible object
  1503. * @returns serialization object
  1504. */
  1505. StateCondition.prototype.serialize = function () {
  1506. return this._serialize({
  1507. name: "StateCondition",
  1508. properties: [
  1509. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1510. { name: "value", value: this.value }
  1511. ]
  1512. });
  1513. };
  1514. return StateCondition;
  1515. }(Condition));
  1516. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.ValueCondition"] = ValueCondition;
  1517. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PredicateCondition"] = PredicateCondition;
  1518. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StateCondition"] = StateCondition;
  1519. /***/ }),
  1520. /***/ "./Actions/directActions.ts":
  1521. /*!**********************************!*\
  1522. !*** ./Actions/directActions.ts ***!
  1523. \**********************************/
  1524. /*! exports provided: SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction */
  1525. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1526. "use strict";
  1527. __webpack_require__.r(__webpack_exports__);
  1528. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return SwitchBooleanAction; });
  1529. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return SetStateAction; });
  1530. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return SetValueAction; });
  1531. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return IncrementValueAction; });
  1532. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return PlayAnimationAction; });
  1533. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return StopAnimationAction; });
  1534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return DoNothingAction; });
  1535. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return CombineAction; });
  1536. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return ExecuteCodeAction; });
  1537. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return SetParentAction; });
  1538. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1539. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  1540. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  1541. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1542. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  1543. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1544. /**
  1545. * This defines an action responsible to toggle a boolean once triggered.
  1546. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1547. */
  1548. var SwitchBooleanAction = /** @class */ (function (_super) {
  1549. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SwitchBooleanAction, _super);
  1550. /**
  1551. * Instantiate the action
  1552. * @param triggerOptions defines the trigger options
  1553. * @param target defines the object containing the boolean
  1554. * @param propertyPath defines the path to the boolean property in the target object
  1555. * @param condition defines the trigger related conditions
  1556. */
  1557. function SwitchBooleanAction(triggerOptions, target, propertyPath, condition) {
  1558. var _this = _super.call(this, triggerOptions, condition) || this;
  1559. _this.propertyPath = propertyPath;
  1560. _this._target = _this._effectiveTarget = target;
  1561. return _this;
  1562. }
  1563. /** @hidden */
  1564. SwitchBooleanAction.prototype._prepare = function () {
  1565. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1566. this._property = this._getProperty(this.propertyPath);
  1567. };
  1568. /**
  1569. * Execute the action toggle the boolean value.
  1570. */
  1571. SwitchBooleanAction.prototype.execute = function () {
  1572. this._effectiveTarget[this._property] = !this._effectiveTarget[this._property];
  1573. };
  1574. /**
  1575. * Serializes the actions and its related information.
  1576. * @param parent defines the object to serialize in
  1577. * @returns the serialized object
  1578. */
  1579. SwitchBooleanAction.prototype.serialize = function (parent) {
  1580. return _super.prototype._serialize.call(this, {
  1581. name: "SwitchBooleanAction",
  1582. properties: [
  1583. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1584. { name: "propertyPath", value: this.propertyPath }
  1585. ]
  1586. }, parent);
  1587. };
  1588. return SwitchBooleanAction;
  1589. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1590. /**
  1591. * This defines an action responsible to set a the state field of the target
  1592. * to a desired value once triggered.
  1593. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1594. */
  1595. var SetStateAction = /** @class */ (function (_super) {
  1596. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetStateAction, _super);
  1597. /**
  1598. * Instantiate the action
  1599. * @param triggerOptions defines the trigger options
  1600. * @param target defines the object containing the state property
  1601. * @param value defines the value to store in the state field
  1602. * @param condition defines the trigger related conditions
  1603. */
  1604. function SetStateAction(triggerOptions, target, value, condition) {
  1605. var _this = _super.call(this, triggerOptions, condition) || this;
  1606. _this.value = value;
  1607. _this._target = target;
  1608. return _this;
  1609. }
  1610. /**
  1611. * Execute the action and store the value on the target state property.
  1612. */
  1613. SetStateAction.prototype.execute = function () {
  1614. this._target.state = this.value;
  1615. };
  1616. /**
  1617. * Serializes the actions and its related information.
  1618. * @param parent defines the object to serialize in
  1619. * @returns the serialized object
  1620. */
  1621. SetStateAction.prototype.serialize = function (parent) {
  1622. return _super.prototype._serialize.call(this, {
  1623. name: "SetStateAction",
  1624. properties: [
  1625. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1626. { name: "value", value: this.value }
  1627. ]
  1628. }, parent);
  1629. };
  1630. return SetStateAction;
  1631. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1632. /**
  1633. * This defines an action responsible to set a property of the target
  1634. * to a desired value once triggered.
  1635. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1636. */
  1637. var SetValueAction = /** @class */ (function (_super) {
  1638. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetValueAction, _super);
  1639. /**
  1640. * Instantiate the action
  1641. * @param triggerOptions defines the trigger options
  1642. * @param target defines the object containing the property
  1643. * @param propertyPath defines the path of the property to set in the target
  1644. * @param value defines the value to set in the property
  1645. * @param condition defines the trigger related conditions
  1646. */
  1647. function SetValueAction(triggerOptions, target, propertyPath, value, condition) {
  1648. var _this = _super.call(this, triggerOptions, condition) || this;
  1649. _this.propertyPath = propertyPath;
  1650. _this.value = value;
  1651. _this._target = _this._effectiveTarget = target;
  1652. return _this;
  1653. }
  1654. /** @hidden */
  1655. SetValueAction.prototype._prepare = function () {
  1656. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1657. this._property = this._getProperty(this.propertyPath);
  1658. };
  1659. /**
  1660. * Execute the action and set the targetted property to the desired value.
  1661. */
  1662. SetValueAction.prototype.execute = function () {
  1663. this._effectiveTarget[this._property] = this.value;
  1664. if (this._target.markAsDirty) {
  1665. this._target.markAsDirty(this._property);
  1666. }
  1667. };
  1668. /**
  1669. * Serializes the actions and its related information.
  1670. * @param parent defines the object to serialize in
  1671. * @returns the serialized object
  1672. */
  1673. SetValueAction.prototype.serialize = function (parent) {
  1674. return _super.prototype._serialize.call(this, {
  1675. name: "SetValueAction",
  1676. properties: [
  1677. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1678. { name: "propertyPath", value: this.propertyPath },
  1679. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1680. ]
  1681. }, parent);
  1682. };
  1683. return SetValueAction;
  1684. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1685. /**
  1686. * This defines an action responsible to increment the target value
  1687. * to a desired value once triggered.
  1688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1689. */
  1690. var IncrementValueAction = /** @class */ (function (_super) {
  1691. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IncrementValueAction, _super);
  1692. /**
  1693. * Instantiate the action
  1694. * @param triggerOptions defines the trigger options
  1695. * @param target defines the object containing the property
  1696. * @param propertyPath defines the path of the property to increment in the target
  1697. * @param value defines the value value we should increment the property by
  1698. * @param condition defines the trigger related conditions
  1699. */
  1700. function IncrementValueAction(triggerOptions, target, propertyPath, value, condition) {
  1701. var _this = _super.call(this, triggerOptions, condition) || this;
  1702. _this.propertyPath = propertyPath;
  1703. _this.value = value;
  1704. _this._target = _this._effectiveTarget = target;
  1705. return _this;
  1706. }
  1707. /** @hidden */
  1708. IncrementValueAction.prototype._prepare = function () {
  1709. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1710. this._property = this._getProperty(this.propertyPath);
  1711. if (typeof this._effectiveTarget[this._property] !== "number") {
  1712. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Warning: IncrementValueAction can only be used with number values");
  1713. }
  1714. };
  1715. /**
  1716. * Execute the action and increment the target of the value amount.
  1717. */
  1718. IncrementValueAction.prototype.execute = function () {
  1719. this._effectiveTarget[this._property] += this.value;
  1720. if (this._target.markAsDirty) {
  1721. this._target.markAsDirty(this._property);
  1722. }
  1723. };
  1724. /**
  1725. * Serializes the actions and its related information.
  1726. * @param parent defines the object to serialize in
  1727. * @returns the serialized object
  1728. */
  1729. IncrementValueAction.prototype.serialize = function (parent) {
  1730. return _super.prototype._serialize.call(this, {
  1731. name: "IncrementValueAction",
  1732. properties: [
  1733. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1734. { name: "propertyPath", value: this.propertyPath },
  1735. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1736. ]
  1737. }, parent);
  1738. };
  1739. return IncrementValueAction;
  1740. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1741. /**
  1742. * This defines an action responsible to start an animation once triggered.
  1743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1744. */
  1745. var PlayAnimationAction = /** @class */ (function (_super) {
  1746. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlayAnimationAction, _super);
  1747. /**
  1748. * Instantiate the action
  1749. * @param triggerOptions defines the trigger options
  1750. * @param target defines the target animation or animation name
  1751. * @param from defines from where the animation should start (animation frame)
  1752. * @param end defines where the animation should stop (animation frame)
  1753. * @param loop defines if the animation should loop or stop after the first play
  1754. * @param condition defines the trigger related conditions
  1755. */
  1756. function PlayAnimationAction(triggerOptions, target, from, to, loop, condition) {
  1757. var _this = _super.call(this, triggerOptions, condition) || this;
  1758. _this.from = from;
  1759. _this.to = to;
  1760. _this.loop = loop;
  1761. _this._target = target;
  1762. return _this;
  1763. }
  1764. /** @hidden */
  1765. PlayAnimationAction.prototype._prepare = function () {
  1766. };
  1767. /**
  1768. * Execute the action and play the animation.
  1769. */
  1770. PlayAnimationAction.prototype.execute = function () {
  1771. var scene = this._actionManager.getScene();
  1772. scene.beginAnimation(this._target, this.from, this.to, this.loop);
  1773. };
  1774. /**
  1775. * Serializes the actions and its related information.
  1776. * @param parent defines the object to serialize in
  1777. * @returns the serialized object
  1778. */
  1779. PlayAnimationAction.prototype.serialize = function (parent) {
  1780. return _super.prototype._serialize.call(this, {
  1781. name: "PlayAnimationAction",
  1782. properties: [
  1783. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1784. { name: "from", value: String(this.from) },
  1785. { name: "to", value: String(this.to) },
  1786. { name: "loop", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.loop) || false }
  1787. ]
  1788. }, parent);
  1789. };
  1790. return PlayAnimationAction;
  1791. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1792. /**
  1793. * This defines an action responsible to stop an animation once triggered.
  1794. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1795. */
  1796. var StopAnimationAction = /** @class */ (function (_super) {
  1797. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopAnimationAction, _super);
  1798. /**
  1799. * Instantiate the action
  1800. * @param triggerOptions defines the trigger options
  1801. * @param target defines the target animation or animation name
  1802. * @param condition defines the trigger related conditions
  1803. */
  1804. function StopAnimationAction(triggerOptions, target, condition) {
  1805. var _this = _super.call(this, triggerOptions, condition) || this;
  1806. _this._target = target;
  1807. return _this;
  1808. }
  1809. /** @hidden */
  1810. StopAnimationAction.prototype._prepare = function () {
  1811. };
  1812. /**
  1813. * Execute the action and stop the animation.
  1814. */
  1815. StopAnimationAction.prototype.execute = function () {
  1816. var scene = this._actionManager.getScene();
  1817. scene.stopAnimation(this._target);
  1818. };
  1819. /**
  1820. * Serializes the actions and its related information.
  1821. * @param parent defines the object to serialize in
  1822. * @returns the serialized object
  1823. */
  1824. StopAnimationAction.prototype.serialize = function (parent) {
  1825. return _super.prototype._serialize.call(this, {
  1826. name: "StopAnimationAction",
  1827. properties: [_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target)]
  1828. }, parent);
  1829. };
  1830. return StopAnimationAction;
  1831. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1832. /**
  1833. * This defines an action responsible that does nothing once triggered.
  1834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1835. */
  1836. var DoNothingAction = /** @class */ (function (_super) {
  1837. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DoNothingAction, _super);
  1838. /**
  1839. * Instantiate the action
  1840. * @param triggerOptions defines the trigger options
  1841. * @param condition defines the trigger related conditions
  1842. */
  1843. function DoNothingAction(triggerOptions, condition) {
  1844. if (triggerOptions === void 0) { triggerOptions = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_NothingTrigger; }
  1845. return _super.call(this, triggerOptions, condition) || this;
  1846. }
  1847. /**
  1848. * Execute the action and do nothing.
  1849. */
  1850. DoNothingAction.prototype.execute = function () {
  1851. };
  1852. /**
  1853. * Serializes the actions and its related information.
  1854. * @param parent defines the object to serialize in
  1855. * @returns the serialized object
  1856. */
  1857. DoNothingAction.prototype.serialize = function (parent) {
  1858. return _super.prototype._serialize.call(this, {
  1859. name: "DoNothingAction",
  1860. properties: []
  1861. }, parent);
  1862. };
  1863. return DoNothingAction;
  1864. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1865. /**
  1866. * This defines an action responsible to trigger several actions once triggered.
  1867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1868. */
  1869. var CombineAction = /** @class */ (function (_super) {
  1870. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CombineAction, _super);
  1871. /**
  1872. * Instantiate the action
  1873. * @param triggerOptions defines the trigger options
  1874. * @param children defines the list of aggregated animations to run
  1875. * @param condition defines the trigger related conditions
  1876. */
  1877. function CombineAction(triggerOptions, children, condition) {
  1878. var _this = _super.call(this, triggerOptions, condition) || this;
  1879. _this.children = children;
  1880. return _this;
  1881. }
  1882. /** @hidden */
  1883. CombineAction.prototype._prepare = function () {
  1884. for (var index = 0; index < this.children.length; index++) {
  1885. this.children[index]._actionManager = this._actionManager;
  1886. this.children[index]._prepare();
  1887. }
  1888. };
  1889. /**
  1890. * Execute the action and executes all the aggregated actions.
  1891. */
  1892. CombineAction.prototype.execute = function (evt) {
  1893. for (var index = 0; index < this.children.length; index++) {
  1894. this.children[index].execute(evt);
  1895. }
  1896. };
  1897. /**
  1898. * Serializes the actions and its related information.
  1899. * @param parent defines the object to serialize in
  1900. * @returns the serialized object
  1901. */
  1902. CombineAction.prototype.serialize = function (parent) {
  1903. var serializationObject = _super.prototype._serialize.call(this, {
  1904. name: "CombineAction",
  1905. properties: [],
  1906. combine: []
  1907. }, parent);
  1908. for (var i = 0; i < this.children.length; i++) {
  1909. serializationObject.combine.push(this.children[i].serialize(null));
  1910. }
  1911. return serializationObject;
  1912. };
  1913. return CombineAction;
  1914. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1915. /**
  1916. * This defines an action responsible to run code (external event) once triggered.
  1917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1918. */
  1919. var ExecuteCodeAction = /** @class */ (function (_super) {
  1920. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExecuteCodeAction, _super);
  1921. /**
  1922. * Instantiate the action
  1923. * @param triggerOptions defines the trigger options
  1924. * @param func defines the callback function to run
  1925. * @param condition defines the trigger related conditions
  1926. */
  1927. function ExecuteCodeAction(triggerOptions, func, condition) {
  1928. var _this = _super.call(this, triggerOptions, condition) || this;
  1929. _this.func = func;
  1930. return _this;
  1931. }
  1932. /**
  1933. * Execute the action and run the attached code.
  1934. */
  1935. ExecuteCodeAction.prototype.execute = function (evt) {
  1936. this.func(evt);
  1937. };
  1938. return ExecuteCodeAction;
  1939. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1940. /**
  1941. * This defines an action responsible to set the parent property of the target once triggered.
  1942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1943. */
  1944. var SetParentAction = /** @class */ (function (_super) {
  1945. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetParentAction, _super);
  1946. /**
  1947. * Instantiate the action
  1948. * @param triggerOptions defines the trigger options
  1949. * @param target defines the target containing the parent property
  1950. * @param parent defines from where the animation should start (animation frame)
  1951. * @param condition defines the trigger related conditions
  1952. */
  1953. function SetParentAction(triggerOptions, target, parent, condition) {
  1954. var _this = _super.call(this, triggerOptions, condition) || this;
  1955. _this._target = target;
  1956. _this._parent = parent;
  1957. return _this;
  1958. }
  1959. /** @hidden */
  1960. SetParentAction.prototype._prepare = function () {
  1961. };
  1962. /**
  1963. * Execute the action and set the parent property.
  1964. */
  1965. SetParentAction.prototype.execute = function () {
  1966. if (this._target.parent === this._parent) {
  1967. return;
  1968. }
  1969. var invertParentWorldMatrix = this._parent.getWorldMatrix().clone();
  1970. invertParentWorldMatrix.invert();
  1971. this._target.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this._target.position, invertParentWorldMatrix);
  1972. this._target.parent = this._parent;
  1973. };
  1974. /**
  1975. * Serializes the actions and its related information.
  1976. * @param parent defines the object to serialize in
  1977. * @returns the serialized object
  1978. */
  1979. SetParentAction.prototype.serialize = function (parent) {
  1980. return _super.prototype._serialize.call(this, {
  1981. name: "SetParentAction",
  1982. properties: [
  1983. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1984. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._parent),
  1985. ]
  1986. }, parent);
  1987. };
  1988. return SetParentAction;
  1989. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1990. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  1991. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.ExecuteCodeAction"] = ExecuteCodeAction;
  1992. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.DoNothingAction"] = DoNothingAction;
  1993. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.StopAnimationAction"] = StopAnimationAction;
  1994. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PlayAnimationAction"] = PlayAnimationAction;
  1995. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.IncrementValueAction"] = IncrementValueAction;
  1996. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetValueAction"] = SetValueAction;
  1997. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetStateAction"] = SetStateAction;
  1998. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  1999. /***/ }),
  2000. /***/ "./Actions/directAudioActions.ts":
  2001. /*!***************************************!*\
  2002. !*** ./Actions/directAudioActions.ts ***!
  2003. \***************************************/
  2004. /*! exports provided: PlaySoundAction, StopSoundAction */
  2005. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2006. "use strict";
  2007. __webpack_require__.r(__webpack_exports__);
  2008. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return PlaySoundAction; });
  2009. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return StopSoundAction; });
  2010. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2011. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2012. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2013. /**
  2014. * This defines an action helpful to play a defined sound on a triggered action.
  2015. */
  2016. var PlaySoundAction = /** @class */ (function (_super) {
  2017. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaySoundAction, _super);
  2018. /**
  2019. * Instantiate the action
  2020. * @param triggerOptions defines the trigger options
  2021. * @param sound defines the sound to play
  2022. * @param condition defines the trigger related conditions
  2023. */
  2024. function PlaySoundAction(triggerOptions, sound, condition) {
  2025. var _this = _super.call(this, triggerOptions, condition) || this;
  2026. _this._sound = sound;
  2027. return _this;
  2028. }
  2029. /** @hidden */
  2030. PlaySoundAction.prototype._prepare = function () {
  2031. };
  2032. /**
  2033. * Execute the action and play the sound.
  2034. */
  2035. PlaySoundAction.prototype.execute = function () {
  2036. if (this._sound !== undefined) {
  2037. this._sound.play();
  2038. }
  2039. };
  2040. /**
  2041. * Serializes the actions and its related information.
  2042. * @param parent defines the object to serialize in
  2043. * @returns the serialized object
  2044. */
  2045. PlaySoundAction.prototype.serialize = function (parent) {
  2046. return _super.prototype._serialize.call(this, {
  2047. name: "PlaySoundAction",
  2048. properties: [{ name: "sound", value: this._sound.name }]
  2049. }, parent);
  2050. };
  2051. return PlaySoundAction;
  2052. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2053. /**
  2054. * This defines an action helpful to stop a defined sound on a triggered action.
  2055. */
  2056. var StopSoundAction = /** @class */ (function (_super) {
  2057. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopSoundAction, _super);
  2058. /**
  2059. * Instantiate the action
  2060. * @param triggerOptions defines the trigger options
  2061. * @param sound defines the sound to stop
  2062. * @param condition defines the trigger related conditions
  2063. */
  2064. function StopSoundAction(triggerOptions, sound, condition) {
  2065. var _this = _super.call(this, triggerOptions, condition) || this;
  2066. _this._sound = sound;
  2067. return _this;
  2068. }
  2069. /** @hidden */
  2070. StopSoundAction.prototype._prepare = function () {
  2071. };
  2072. /**
  2073. * Execute the action and stop the sound.
  2074. */
  2075. StopSoundAction.prototype.execute = function () {
  2076. if (this._sound !== undefined) {
  2077. this._sound.stop();
  2078. }
  2079. };
  2080. /**
  2081. * Serializes the actions and its related information.
  2082. * @param parent defines the object to serialize in
  2083. * @returns the serialized object
  2084. */
  2085. StopSoundAction.prototype.serialize = function (parent) {
  2086. return _super.prototype._serialize.call(this, {
  2087. name: "StopSoundAction",
  2088. properties: [{ name: "sound", value: this._sound.name }]
  2089. }, parent);
  2090. };
  2091. return StopSoundAction;
  2092. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2093. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PlaySoundAction"] = StopSoundAction;
  2094. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StopSoundAction"] = StopSoundAction;
  2095. /***/ }),
  2096. /***/ "./Actions/index.ts":
  2097. /*!**************************!*\
  2098. !*** ./Actions/index.ts ***!
  2099. \**************************/
  2100. /*! exports provided: Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction */
  2101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2102. "use strict";
  2103. __webpack_require__.r(__webpack_exports__);
  2104. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _action__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  2106. /* harmony import */ var _actionEvent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./actionEvent */ "./Actions/actionEvent.ts");
  2107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _actionEvent__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  2108. /* harmony import */ var _actionManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actionManager */ "./Actions/actionManager.ts");
  2109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _actionManager__WEBPACK_IMPORTED_MODULE_2__["ActionManager"]; });
  2110. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  2111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["Condition"]; });
  2112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["ValueCondition"]; });
  2113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["PredicateCondition"]; });
  2114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["StateCondition"]; });
  2115. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  2116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SwitchBooleanAction"]; });
  2117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetStateAction"]; });
  2118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetValueAction"]; });
  2119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["IncrementValueAction"]; });
  2120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["PlayAnimationAction"]; });
  2121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["StopAnimationAction"]; });
  2122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"]; });
  2123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["CombineAction"]; });
  2124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["ExecuteCodeAction"]; });
  2125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetParentAction"]; });
  2126. /* harmony import */ var _directAudioActions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./directAudioActions */ "./Actions/directAudioActions.ts");
  2127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["PlaySoundAction"]; });
  2128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["StopSoundAction"]; });
  2129. /* harmony import */ var _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./interpolateValueAction */ "./Actions/interpolateValueAction.ts");
  2130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__["InterpolateValueAction"]; });
  2131. /***/ }),
  2132. /***/ "./Actions/interpolateValueAction.ts":
  2133. /*!*******************************************!*\
  2134. !*** ./Actions/interpolateValueAction.ts ***!
  2135. \*******************************************/
  2136. /*! exports provided: InterpolateValueAction */
  2137. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2138. "use strict";
  2139. __webpack_require__.r(__webpack_exports__);
  2140. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return InterpolateValueAction; });
  2141. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2142. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2143. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  2144. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2145. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2146. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  2147. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2148. /**
  2149. * This defines an action responsible to change the value of a property
  2150. * by interpolating between its current value and the newly set one once triggered.
  2151. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2152. */
  2153. var InterpolateValueAction = /** @class */ (function (_super) {
  2154. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InterpolateValueAction, _super);
  2155. /**
  2156. * Instantiate the action
  2157. * @param triggerOptions defines the trigger options
  2158. * @param target defines the object containing the value to interpolate
  2159. * @param propertyPath defines the path to the property in the target object
  2160. * @param value defines the target value at the end of the interpolation
  2161. * @param duration deines the time it will take for the property to interpolate to the value.
  2162. * @param condition defines the trigger related conditions
  2163. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  2164. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  2165. */
  2166. function InterpolateValueAction(triggerOptions, target, propertyPath, value, duration, condition, stopOtherAnimations, onInterpolationDone) {
  2167. if (duration === void 0) { duration = 1000; }
  2168. var _this = _super.call(this, triggerOptions, condition) || this;
  2169. /**
  2170. * Defines the time it will take for the property to interpolate to the value.
  2171. */
  2172. _this.duration = 1000;
  2173. /**
  2174. * Observable triggered once the interpolation animation has been done.
  2175. */
  2176. _this.onInterpolationDoneObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  2177. _this.propertyPath = propertyPath;
  2178. _this.value = value;
  2179. _this.duration = duration;
  2180. _this.stopOtherAnimations = stopOtherAnimations;
  2181. _this.onInterpolationDone = onInterpolationDone;
  2182. _this._target = _this._effectiveTarget = target;
  2183. return _this;
  2184. }
  2185. /** @hidden */
  2186. InterpolateValueAction.prototype._prepare = function () {
  2187. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  2188. this._property = this._getProperty(this.propertyPath);
  2189. };
  2190. /**
  2191. * Execute the action starts the value interpolation.
  2192. */
  2193. InterpolateValueAction.prototype.execute = function () {
  2194. var _this = this;
  2195. var scene = this._actionManager.getScene();
  2196. var keys = [
  2197. {
  2198. frame: 0,
  2199. value: this._effectiveTarget[this._property]
  2200. }, {
  2201. frame: 100,
  2202. value: this.value
  2203. }
  2204. ];
  2205. var dataType;
  2206. if (typeof this.value === "number") {
  2207. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT;
  2208. }
  2209. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"]) {
  2210. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_COLOR3;
  2211. }
  2212. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"]) {
  2213. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3;
  2214. }
  2215. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]) {
  2216. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_MATRIX;
  2217. }
  2218. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]) {
  2219. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_QUATERNION;
  2220. }
  2221. else {
  2222. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
  2223. return;
  2224. }
  2225. var animation = new _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"]("InterpolateValueAction", this._property, 100 * (1000.0 / this.duration), dataType, _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  2226. animation.setKeys(keys);
  2227. if (this.stopOtherAnimations) {
  2228. scene.stopAnimation(this._effectiveTarget);
  2229. }
  2230. var wrapper = function () {
  2231. _this.onInterpolationDoneObservable.notifyObservers(_this);
  2232. if (_this.onInterpolationDone) {
  2233. _this.onInterpolationDone();
  2234. }
  2235. };
  2236. scene.beginDirectAnimation(this._effectiveTarget, [animation], 0, 100, false, 1, wrapper);
  2237. };
  2238. /**
  2239. * Serializes the actions and its related information.
  2240. * @param parent defines the object to serialize in
  2241. * @returns the serialized object
  2242. */
  2243. InterpolateValueAction.prototype.serialize = function (parent) {
  2244. return _super.prototype._serialize.call(this, {
  2245. name: "InterpolateValueAction",
  2246. properties: [
  2247. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  2248. { name: "propertyPath", value: this.propertyPath },
  2249. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  2250. { name: "duration", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.duration) },
  2251. { name: "stopOtherAnimations", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.stopOtherAnimations) || false }
  2252. ]
  2253. }, parent);
  2254. };
  2255. return InterpolateValueAction;
  2256. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2257. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__["_TypeStore"].RegisteredTypes["BABYLON.InterpolateValueAction"] = _action__WEBPACK_IMPORTED_MODULE_1__["Action"];
  2258. /***/ }),
  2259. /***/ "./Animations/animatable.ts":
  2260. /*!**********************************!*\
  2261. !*** ./Animations/animatable.ts ***!
  2262. \**********************************/
  2263. /*! exports provided: Animatable */
  2264. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2265. "use strict";
  2266. __webpack_require__.r(__webpack_exports__);
  2267. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return Animatable; });
  2268. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  2269. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2270. /**
  2271. * Class used to store an actual running animation
  2272. */
  2273. var Animatable = /** @class */ (function () {
  2274. /**
  2275. * Creates a new Animatable
  2276. * @param scene defines the hosting scene
  2277. * @param target defines the target object
  2278. * @param fromFrame defines the starting frame number (default is 0)
  2279. * @param toFrame defines the ending frame number (default is 100)
  2280. * @param loopAnimation defines if the animation must loop (default is false)
  2281. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  2282. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  2283. * @param animations defines a group of animation to add to the new Animatable
  2284. * @param onAnimationLoop defines a callback to call when animation loops
  2285. */
  2286. function Animatable(scene,
  2287. /** defines the target object */
  2288. target,
  2289. /** defines the starting frame number (default is 0) */
  2290. fromFrame,
  2291. /** defines the ending frame number (default is 100) */
  2292. toFrame,
  2293. /** defines if the animation must loop (default is false) */
  2294. loopAnimation, speedRatio,
  2295. /** defines a callback to call when animation ends if it is not looping */
  2296. onAnimationEnd, animations,
  2297. /** defines a callback to call when animation loops */
  2298. onAnimationLoop) {
  2299. if (fromFrame === void 0) { fromFrame = 0; }
  2300. if (toFrame === void 0) { toFrame = 100; }
  2301. if (loopAnimation === void 0) { loopAnimation = false; }
  2302. if (speedRatio === void 0) { speedRatio = 1.0; }
  2303. this.target = target;
  2304. this.fromFrame = fromFrame;
  2305. this.toFrame = toFrame;
  2306. this.loopAnimation = loopAnimation;
  2307. this.onAnimationEnd = onAnimationEnd;
  2308. this.onAnimationLoop = onAnimationLoop;
  2309. this._localDelayOffset = null;
  2310. this._pausedDelay = null;
  2311. this._runtimeAnimations = new Array();
  2312. this._paused = false;
  2313. this._speedRatio = 1;
  2314. this._weight = -1.0;
  2315. /**
  2316. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  2317. * This will only apply for non looping animation (default is true)
  2318. */
  2319. this.disposeOnEnd = true;
  2320. /**
  2321. * Gets a boolean indicating if the animation has started
  2322. */
  2323. this.animationStarted = false;
  2324. /**
  2325. * Observer raised when the animation ends
  2326. */
  2327. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  2328. /**
  2329. * Observer raised when the animation loops
  2330. */
  2331. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  2332. this._scene = scene;
  2333. if (animations) {
  2334. this.appendAnimations(target, animations);
  2335. }
  2336. this._speedRatio = speedRatio;
  2337. scene._activeAnimatables.push(this);
  2338. }
  2339. Object.defineProperty(Animatable.prototype, "syncRoot", {
  2340. /**
  2341. * Gets the root Animatable used to synchronize and normalize animations
  2342. */
  2343. get: function () {
  2344. return this._syncRoot;
  2345. },
  2346. enumerable: true,
  2347. configurable: true
  2348. });
  2349. Object.defineProperty(Animatable.prototype, "masterFrame", {
  2350. /**
  2351. * Gets the current frame of the first RuntimeAnimation
  2352. * Used to synchronize Animatables
  2353. */
  2354. get: function () {
  2355. if (this._runtimeAnimations.length === 0) {
  2356. return 0;
  2357. }
  2358. return this._runtimeAnimations[0].currentFrame;
  2359. },
  2360. enumerable: true,
  2361. configurable: true
  2362. });
  2363. Object.defineProperty(Animatable.prototype, "weight", {
  2364. /**
  2365. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  2366. */
  2367. get: function () {
  2368. return this._weight;
  2369. },
  2370. set: function (value) {
  2371. if (value === -1) { // -1 is ok and means no weight
  2372. this._weight = -1;
  2373. return;
  2374. }
  2375. // Else weight must be in [0, 1] range
  2376. this._weight = Math.min(Math.max(value, 0), 1.0);
  2377. },
  2378. enumerable: true,
  2379. configurable: true
  2380. });
  2381. Object.defineProperty(Animatable.prototype, "speedRatio", {
  2382. /**
  2383. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  2384. */
  2385. get: function () {
  2386. return this._speedRatio;
  2387. },
  2388. set: function (value) {
  2389. for (var index = 0; index < this._runtimeAnimations.length; index++) {
  2390. var animation = this._runtimeAnimations[index];
  2391. animation._prepareForSpeedRatioChange(value);
  2392. }
  2393. this._speedRatio = value;
  2394. },
  2395. enumerable: true,
  2396. configurable: true
  2397. });
  2398. // Methods
  2399. /**
  2400. * Synchronize and normalize current Animatable with a source Animatable
  2401. * This is useful when using animation weights and when animations are not of the same length
  2402. * @param root defines the root Animatable to synchronize with
  2403. * @returns the current Animatable
  2404. */
  2405. Animatable.prototype.syncWith = function (root) {
  2406. this._syncRoot = root;
  2407. if (root) {
  2408. // Make sure this animatable will animate after the root
  2409. var index = this._scene._activeAnimatables.indexOf(this);
  2410. if (index > -1) {
  2411. this._scene._activeAnimatables.splice(index, 1);
  2412. this._scene._activeAnimatables.push(this);
  2413. }
  2414. }
  2415. return this;
  2416. };
  2417. /**
  2418. * Gets the list of runtime animations
  2419. * @returns an array of RuntimeAnimation
  2420. */
  2421. Animatable.prototype.getAnimations = function () {
  2422. return this._runtimeAnimations;
  2423. };
  2424. /**
  2425. * Adds more animations to the current animatable
  2426. * @param target defines the target of the animations
  2427. * @param animations defines the new animations to add
  2428. */
  2429. Animatable.prototype.appendAnimations = function (target, animations) {
  2430. for (var index = 0; index < animations.length; index++) {
  2431. var animation = animations[index];
  2432. this._runtimeAnimations.push(new _runtimeAnimation__WEBPACK_IMPORTED_MODULE_0__["RuntimeAnimation"](target, animation, this._scene, this));
  2433. }
  2434. };
  2435. /**
  2436. * Gets the source animation for a specific property
  2437. * @param property defines the propertyu to look for
  2438. * @returns null or the source animation for the given property
  2439. */
  2440. Animatable.prototype.getAnimationByTargetProperty = function (property) {
  2441. var runtimeAnimations = this._runtimeAnimations;
  2442. for (var index = 0; index < runtimeAnimations.length; index++) {
  2443. if (runtimeAnimations[index].animation.targetProperty === property) {
  2444. return runtimeAnimations[index].animation;
  2445. }
  2446. }
  2447. return null;
  2448. };
  2449. /**
  2450. * Gets the runtime animation for a specific property
  2451. * @param property defines the propertyu to look for
  2452. * @returns null or the runtime animation for the given property
  2453. */
  2454. Animatable.prototype.getRuntimeAnimationByTargetProperty = function (property) {
  2455. var runtimeAnimations = this._runtimeAnimations;
  2456. for (var index = 0; index < runtimeAnimations.length; index++) {
  2457. if (runtimeAnimations[index].animation.targetProperty === property) {
  2458. return runtimeAnimations[index];
  2459. }
  2460. }
  2461. return null;
  2462. };
  2463. /**
  2464. * Resets the animatable to its original state
  2465. */
  2466. Animatable.prototype.reset = function () {
  2467. var runtimeAnimations = this._runtimeAnimations;
  2468. for (var index = 0; index < runtimeAnimations.length; index++) {
  2469. runtimeAnimations[index].reset(true);
  2470. }
  2471. this._localDelayOffset = null;
  2472. this._pausedDelay = null;
  2473. };
  2474. /**
  2475. * Allows the animatable to blend with current running animations
  2476. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2477. * @param blendingSpeed defines the blending speed to use
  2478. */
  2479. Animatable.prototype.enableBlending = function (blendingSpeed) {
  2480. var runtimeAnimations = this._runtimeAnimations;
  2481. for (var index = 0; index < runtimeAnimations.length; index++) {
  2482. runtimeAnimations[index].animation.enableBlending = true;
  2483. runtimeAnimations[index].animation.blendingSpeed = blendingSpeed;
  2484. }
  2485. };
  2486. /**
  2487. * Disable animation blending
  2488. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2489. */
  2490. Animatable.prototype.disableBlending = function () {
  2491. var runtimeAnimations = this._runtimeAnimations;
  2492. for (var index = 0; index < runtimeAnimations.length; index++) {
  2493. runtimeAnimations[index].animation.enableBlending = false;
  2494. }
  2495. };
  2496. /**
  2497. * Jump directly to a given frame
  2498. * @param frame defines the frame to jump to
  2499. */
  2500. Animatable.prototype.goToFrame = function (frame) {
  2501. var runtimeAnimations = this._runtimeAnimations;
  2502. if (runtimeAnimations[0]) {
  2503. var fps = runtimeAnimations[0].animation.framePerSecond;
  2504. var currentFrame = runtimeAnimations[0].currentFrame;
  2505. var adjustTime = frame - currentFrame;
  2506. var delay = adjustTime * 1000 / (fps * this.speedRatio);
  2507. if (this._localDelayOffset === null) {
  2508. this._localDelayOffset = 0;
  2509. }
  2510. this._localDelayOffset -= delay;
  2511. }
  2512. for (var index = 0; index < runtimeAnimations.length; index++) {
  2513. runtimeAnimations[index].goToFrame(frame);
  2514. }
  2515. };
  2516. /**
  2517. * Pause the animation
  2518. */
  2519. Animatable.prototype.pause = function () {
  2520. if (this._paused) {
  2521. return;
  2522. }
  2523. this._paused = true;
  2524. };
  2525. /**
  2526. * Restart the animation
  2527. */
  2528. Animatable.prototype.restart = function () {
  2529. this._paused = false;
  2530. };
  2531. Animatable.prototype._raiseOnAnimationEnd = function () {
  2532. if (this.onAnimationEnd) {
  2533. this.onAnimationEnd();
  2534. }
  2535. this.onAnimationEndObservable.notifyObservers(this);
  2536. };
  2537. /**
  2538. * Stop and delete the current animation
  2539. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  2540. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  2541. */
  2542. Animatable.prototype.stop = function (animationName, targetMask) {
  2543. if (animationName || targetMask) {
  2544. var idx = this._scene._activeAnimatables.indexOf(this);
  2545. if (idx > -1) {
  2546. var runtimeAnimations = this._runtimeAnimations;
  2547. for (var index = runtimeAnimations.length - 1; index >= 0; index--) {
  2548. var runtimeAnimation = runtimeAnimations[index];
  2549. if (animationName && runtimeAnimation.animation.name != animationName) {
  2550. continue;
  2551. }
  2552. if (targetMask && !targetMask(runtimeAnimation.target)) {
  2553. continue;
  2554. }
  2555. runtimeAnimation.dispose();
  2556. runtimeAnimations.splice(index, 1);
  2557. }
  2558. if (runtimeAnimations.length == 0) {
  2559. this._scene._activeAnimatables.splice(idx, 1);
  2560. this._raiseOnAnimationEnd();
  2561. }
  2562. }
  2563. }
  2564. else {
  2565. var index = this._scene._activeAnimatables.indexOf(this);
  2566. if (index > -1) {
  2567. this._scene._activeAnimatables.splice(index, 1);
  2568. var runtimeAnimations = this._runtimeAnimations;
  2569. for (var index = 0; index < runtimeAnimations.length; index++) {
  2570. runtimeAnimations[index].dispose();
  2571. }
  2572. this._raiseOnAnimationEnd();
  2573. }
  2574. }
  2575. };
  2576. /**
  2577. * Wait asynchronously for the animation to end
  2578. * @returns a promise which will be fullfilled when the animation ends
  2579. */
  2580. Animatable.prototype.waitAsync = function () {
  2581. var _this = this;
  2582. return new Promise(function (resolve, reject) {
  2583. _this.onAnimationEndObservable.add(function () {
  2584. resolve(_this);
  2585. }, undefined, undefined, _this, true);
  2586. });
  2587. };
  2588. /** @hidden */
  2589. Animatable.prototype._animate = function (delay) {
  2590. var _this = this;
  2591. if (this._paused) {
  2592. this.animationStarted = false;
  2593. if (this._pausedDelay === null) {
  2594. this._pausedDelay = delay;
  2595. }
  2596. return true;
  2597. }
  2598. if (this._localDelayOffset === null) {
  2599. this._localDelayOffset = delay;
  2600. this._pausedDelay = null;
  2601. }
  2602. else if (this._pausedDelay !== null) {
  2603. this._localDelayOffset += delay - this._pausedDelay;
  2604. this._pausedDelay = null;
  2605. }
  2606. if (this._weight === 0) { // We consider that an animation with a weight === 0 is "actively" paused
  2607. return true;
  2608. }
  2609. // Animating
  2610. var running = false;
  2611. var runtimeAnimations = this._runtimeAnimations;
  2612. var index;
  2613. for (index = 0; index < runtimeAnimations.length; index++) {
  2614. var animation = runtimeAnimations[index];
  2615. var isRunning = animation.animate(delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight, function () {
  2616. _this.onAnimationLoopObservable.notifyObservers(_this);
  2617. if (_this.onAnimationLoop) {
  2618. _this.onAnimationLoop();
  2619. }
  2620. });
  2621. running = running || isRunning;
  2622. }
  2623. this.animationStarted = running;
  2624. if (!running) {
  2625. if (this.disposeOnEnd) {
  2626. // Remove from active animatables
  2627. index = this._scene._activeAnimatables.indexOf(this);
  2628. this._scene._activeAnimatables.splice(index, 1);
  2629. // Dispose all runtime animations
  2630. for (index = 0; index < runtimeAnimations.length; index++) {
  2631. runtimeAnimations[index].dispose();
  2632. }
  2633. }
  2634. this._raiseOnAnimationEnd();
  2635. if (this.disposeOnEnd) {
  2636. this.onAnimationEnd = null;
  2637. this.onAnimationLoop = null;
  2638. this.onAnimationLoopObservable.clear();
  2639. this.onAnimationEndObservable.clear();
  2640. }
  2641. }
  2642. return running;
  2643. };
  2644. return Animatable;
  2645. }());
  2646. /***/ }),
  2647. /***/ "./Animations/animation.ts":
  2648. /*!*********************************!*\
  2649. !*** ./Animations/animation.ts ***!
  2650. \*********************************/
  2651. /*! exports provided: AnimationRange, AnimationEvent, PathCursor, AnimationKeyInterpolation, Animation */
  2652. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2653. "use strict";
  2654. __webpack_require__.r(__webpack_exports__);
  2655. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return AnimationRange; });
  2656. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return AnimationEvent; });
  2657. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PathCursor", function() { return PathCursor; });
  2658. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return AnimationKeyInterpolation; });
  2659. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return Animation; });
  2660. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2661. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  2662. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node */ "./node.ts");
  2663. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  2664. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  2665. /**
  2666. * Represents the range of an animation
  2667. */
  2668. var AnimationRange = /** @class */ (function () {
  2669. /**
  2670. * Initializes the range of an animation
  2671. * @param name The name of the animation range
  2672. * @param from The starting frame of the animation
  2673. * @param to The ending frame of the animation
  2674. */
  2675. function AnimationRange(
  2676. /**The name of the animation range**/
  2677. name,
  2678. /**The starting frame of the animation */
  2679. from,
  2680. /**The ending frame of the animation*/
  2681. to) {
  2682. this.name = name;
  2683. this.from = from;
  2684. this.to = to;
  2685. }
  2686. /**
  2687. * Makes a copy of the animation range
  2688. * @returns A copy of the animation range
  2689. */
  2690. AnimationRange.prototype.clone = function () {
  2691. return new AnimationRange(this.name, this.from, this.to);
  2692. };
  2693. return AnimationRange;
  2694. }());
  2695. /**
  2696. * Composed of a frame, and an action function
  2697. */
  2698. var AnimationEvent = /** @class */ (function () {
  2699. /**
  2700. * Initializes the animation event
  2701. * @param frame The frame for which the event is triggered
  2702. * @param action The event to perform when triggered
  2703. * @param onlyOnce Specifies if the event should be triggered only once
  2704. */
  2705. function AnimationEvent(
  2706. /** The frame for which the event is triggered **/
  2707. frame,
  2708. /** The event to perform when triggered **/
  2709. action,
  2710. /** Specifies if the event should be triggered only once**/
  2711. onlyOnce) {
  2712. this.frame = frame;
  2713. this.action = action;
  2714. this.onlyOnce = onlyOnce;
  2715. /**
  2716. * Specifies if the animation event is done
  2717. */
  2718. this.isDone = false;
  2719. }
  2720. /** @hidden */
  2721. AnimationEvent.prototype._clone = function () {
  2722. return new AnimationEvent(this.frame, this.action, this.onlyOnce);
  2723. };
  2724. return AnimationEvent;
  2725. }());
  2726. /**
  2727. * A cursor which tracks a point on a path
  2728. */
  2729. var PathCursor = /** @class */ (function () {
  2730. /**
  2731. * Initializes the path cursor
  2732. * @param path The path to track
  2733. */
  2734. function PathCursor(path) {
  2735. this.path = path;
  2736. /**
  2737. * Stores path cursor callbacks for when an onchange event is triggered
  2738. */
  2739. this._onchange = new Array();
  2740. /**
  2741. * The value of the path cursor
  2742. */
  2743. this.value = 0;
  2744. /**
  2745. * The animation array of the path cursor
  2746. */
  2747. this.animations = new Array();
  2748. }
  2749. /**
  2750. * Gets the cursor point on the path
  2751. * @returns A point on the path cursor at the cursor location
  2752. */
  2753. PathCursor.prototype.getPoint = function () {
  2754. var point = this.path.getPointAtLengthPosition(this.value);
  2755. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](point.x, 0, point.y);
  2756. };
  2757. /**
  2758. * Moves the cursor ahead by the step amount
  2759. * @param step The amount to move the cursor forward
  2760. * @returns This path cursor
  2761. */
  2762. PathCursor.prototype.moveAhead = function (step) {
  2763. if (step === void 0) { step = 0.002; }
  2764. this.move(step);
  2765. return this;
  2766. };
  2767. /**
  2768. * Moves the cursor behind by the step amount
  2769. * @param step The amount to move the cursor back
  2770. * @returns This path cursor
  2771. */
  2772. PathCursor.prototype.moveBack = function (step) {
  2773. if (step === void 0) { step = 0.002; }
  2774. this.move(-step);
  2775. return this;
  2776. };
  2777. /**
  2778. * Moves the cursor by the step amount
  2779. * If the step amount is greater than one, an exception is thrown
  2780. * @param step The amount to move the cursor
  2781. * @returns This path cursor
  2782. */
  2783. PathCursor.prototype.move = function (step) {
  2784. if (Math.abs(step) > 1) {
  2785. throw "step size should be less than 1.";
  2786. }
  2787. this.value += step;
  2788. this.ensureLimits();
  2789. this.raiseOnChange();
  2790. return this;
  2791. };
  2792. /**
  2793. * Ensures that the value is limited between zero and one
  2794. * @returns This path cursor
  2795. */
  2796. PathCursor.prototype.ensureLimits = function () {
  2797. while (this.value > 1) {
  2798. this.value -= 1;
  2799. }
  2800. while (this.value < 0) {
  2801. this.value += 1;
  2802. }
  2803. return this;
  2804. };
  2805. /**
  2806. * Runs onchange callbacks on change (used by the animation engine)
  2807. * @returns This path cursor
  2808. */
  2809. PathCursor.prototype.raiseOnChange = function () {
  2810. var _this = this;
  2811. this._onchange.forEach(function (f) { return f(_this); });
  2812. return this;
  2813. };
  2814. /**
  2815. * Executes a function on change
  2816. * @param f A path cursor onchange callback
  2817. * @returns This path cursor
  2818. */
  2819. PathCursor.prototype.onchange = function (f) {
  2820. this._onchange.push(f);
  2821. return this;
  2822. };
  2823. return PathCursor;
  2824. }());
  2825. /**
  2826. * Enum for the animation key frame interpolation type
  2827. */
  2828. var AnimationKeyInterpolation;
  2829. (function (AnimationKeyInterpolation) {
  2830. /**
  2831. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  2832. */
  2833. AnimationKeyInterpolation[AnimationKeyInterpolation["STEP"] = 1] = "STEP";
  2834. })(AnimationKeyInterpolation || (AnimationKeyInterpolation = {}));
  2835. /**
  2836. * Class used to store any kind of animation
  2837. */
  2838. var Animation = /** @class */ (function () {
  2839. /**
  2840. * Initializes the animation
  2841. * @param name Name of the animation
  2842. * @param targetProperty Property to animate
  2843. * @param framePerSecond The frames per second of the animation
  2844. * @param dataType The data type of the animation
  2845. * @param loopMode The loop mode of the animation
  2846. * @param enableBlendings Specifies if blending should be enabled
  2847. */
  2848. function Animation(
  2849. /**Name of the animation */
  2850. name,
  2851. /**Property to animate */
  2852. targetProperty,
  2853. /**The frames per second of the animation */
  2854. framePerSecond,
  2855. /**The data type of the animation */
  2856. dataType,
  2857. /**The loop mode of the animation */
  2858. loopMode,
  2859. /**Specifies if blending should be enabled */
  2860. enableBlending) {
  2861. this.name = name;
  2862. this.targetProperty = targetProperty;
  2863. this.framePerSecond = framePerSecond;
  2864. this.dataType = dataType;
  2865. this.loopMode = loopMode;
  2866. this.enableBlending = enableBlending;
  2867. /**
  2868. * @hidden Internal use only
  2869. */
  2870. this._runtimeAnimations = new Array();
  2871. /**
  2872. * The set of event that will be linked to this animation
  2873. */
  2874. this._events = new Array();
  2875. /**
  2876. * Stores the blending speed of the animation
  2877. */
  2878. this.blendingSpeed = 0.01;
  2879. /**
  2880. * Stores the animation ranges for the animation
  2881. */
  2882. this._ranges = {};
  2883. this.targetPropertyPath = targetProperty.split(".");
  2884. this.dataType = dataType;
  2885. this.loopMode = loopMode === undefined ? Animation.ANIMATIONLOOPMODE_CYCLE : loopMode;
  2886. }
  2887. /**
  2888. * @hidden Internal use
  2889. */
  2890. Animation._PrepareAnimation = function (name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction) {
  2891. var dataType = undefined;
  2892. if (!isNaN(parseFloat(from)) && isFinite(from)) {
  2893. dataType = Animation.ANIMATIONTYPE_FLOAT;
  2894. }
  2895. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]) {
  2896. dataType = Animation.ANIMATIONTYPE_QUATERNION;
  2897. }
  2898. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  2899. dataType = Animation.ANIMATIONTYPE_VECTOR3;
  2900. }
  2901. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"]) {
  2902. dataType = Animation.ANIMATIONTYPE_VECTOR2;
  2903. }
  2904. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"]) {
  2905. dataType = Animation.ANIMATIONTYPE_COLOR3;
  2906. }
  2907. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"]) {
  2908. dataType = Animation.ANIMATIONTYPE_SIZE;
  2909. }
  2910. if (dataType == undefined) {
  2911. return null;
  2912. }
  2913. var animation = new Animation(name, targetProperty, framePerSecond, dataType, loopMode);
  2914. var keys = [{ frame: 0, value: from }, { frame: totalFrame, value: to }];
  2915. animation.setKeys(keys);
  2916. if (easingFunction !== undefined) {
  2917. animation.setEasingFunction(easingFunction);
  2918. }
  2919. return animation;
  2920. };
  2921. /**
  2922. * Sets up an animation
  2923. * @param property The property to animate
  2924. * @param animationType The animation type to apply
  2925. * @param framePerSecond The frames per second of the animation
  2926. * @param easingFunction The easing function used in the animation
  2927. * @returns The created animation
  2928. */
  2929. Animation.CreateAnimation = function (property, animationType, framePerSecond, easingFunction) {
  2930. var animation = new Animation(property + "Animation", property, framePerSecond, animationType, Animation.ANIMATIONLOOPMODE_CONSTANT);
  2931. animation.setEasingFunction(easingFunction);
  2932. return animation;
  2933. };
  2934. /**
  2935. * Create and start an animation on a node
  2936. * @param name defines the name of the global animation that will be run on all nodes
  2937. * @param node defines the root node where the animation will take place
  2938. * @param targetProperty defines property to animate
  2939. * @param framePerSecond defines the number of frame per second yo use
  2940. * @param totalFrame defines the number of frames in total
  2941. * @param from defines the initial value
  2942. * @param to defines the final value
  2943. * @param loopMode defines which loop mode you want to use (off by default)
  2944. * @param easingFunction defines the easing function to use (linear by default)
  2945. * @param onAnimationEnd defines the callback to call when animation end
  2946. * @returns the animatable created for this animation
  2947. */
  2948. Animation.CreateAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  2949. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  2950. if (!animation) {
  2951. return null;
  2952. }
  2953. return node.getScene().beginDirectAnimation(node, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  2954. };
  2955. /**
  2956. * Create and start an animation on a node and its descendants
  2957. * @param name defines the name of the global animation that will be run on all nodes
  2958. * @param node defines the root node where the animation will take place
  2959. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  2960. * @param targetProperty defines property to animate
  2961. * @param framePerSecond defines the number of frame per second to use
  2962. * @param totalFrame defines the number of frames in total
  2963. * @param from defines the initial value
  2964. * @param to defines the final value
  2965. * @param loopMode defines which loop mode you want to use (off by default)
  2966. * @param easingFunction defines the easing function to use (linear by default)
  2967. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  2968. * @returns the list of animatables created for all nodes
  2969. * @example https://www.babylonjs-playground.com/#MH0VLI
  2970. */
  2971. Animation.CreateAndStartHierarchyAnimation = function (name, node, directDescendantsOnly, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  2972. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  2973. if (!animation) {
  2974. return null;
  2975. }
  2976. var scene = node.getScene();
  2977. return scene.beginDirectHierarchyAnimation(node, directDescendantsOnly, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  2978. };
  2979. /**
  2980. * Creates a new animation, merges it with the existing animations and starts it
  2981. * @param name Name of the animation
  2982. * @param node Node which contains the scene that begins the animations
  2983. * @param targetProperty Specifies which property to animate
  2984. * @param framePerSecond The frames per second of the animation
  2985. * @param totalFrame The total number of frames
  2986. * @param from The frame at the beginning of the animation
  2987. * @param to The frame at the end of the animation
  2988. * @param loopMode Specifies the loop mode of the animation
  2989. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  2990. * @param onAnimationEnd Callback to run once the animation is complete
  2991. * @returns Nullable animation
  2992. */
  2993. Animation.CreateMergeAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  2994. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  2995. if (!animation) {
  2996. return null;
  2997. }
  2998. node.animations.push(animation);
  2999. return node.getScene().beginAnimation(node, 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3000. };
  3001. /**
  3002. * Transition property of an host to the target Value
  3003. * @param property The property to transition
  3004. * @param targetValue The target Value of the property
  3005. * @param host The object where the property to animate belongs
  3006. * @param scene Scene used to run the animation
  3007. * @param frameRate Framerate (in frame/s) to use
  3008. * @param transition The transition type we want to use
  3009. * @param duration The duration of the animation, in milliseconds
  3010. * @param onAnimationEnd Callback trigger at the end of the animation
  3011. * @returns Nullable animation
  3012. */
  3013. Animation.TransitionTo = function (property, targetValue, host, scene, frameRate, transition, duration, onAnimationEnd) {
  3014. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  3015. if (duration <= 0) {
  3016. host[property] = targetValue;
  3017. if (onAnimationEnd) {
  3018. onAnimationEnd();
  3019. }
  3020. return null;
  3021. }
  3022. var endFrame = frameRate * (duration / 1000);
  3023. transition.setKeys([{
  3024. frame: 0,
  3025. value: host[property].clone ? host[property].clone() : host[property]
  3026. },
  3027. {
  3028. frame: endFrame,
  3029. value: targetValue
  3030. }]);
  3031. if (!host.animations) {
  3032. host.animations = [];
  3033. }
  3034. host.animations.push(transition);
  3035. var animation = scene.beginAnimation(host, 0, endFrame, false);
  3036. animation.onAnimationEnd = onAnimationEnd;
  3037. return animation;
  3038. };
  3039. Object.defineProperty(Animation.prototype, "runtimeAnimations", {
  3040. /**
  3041. * Return the array of runtime animations currently using this animation
  3042. */
  3043. get: function () {
  3044. return this._runtimeAnimations;
  3045. },
  3046. enumerable: true,
  3047. configurable: true
  3048. });
  3049. Object.defineProperty(Animation.prototype, "hasRunningRuntimeAnimations", {
  3050. /**
  3051. * Specifies if any of the runtime animations are currently running
  3052. */
  3053. get: function () {
  3054. for (var _i = 0, _a = this._runtimeAnimations; _i < _a.length; _i++) {
  3055. var runtimeAnimation = _a[_i];
  3056. if (!runtimeAnimation.isStopped) {
  3057. return true;
  3058. }
  3059. }
  3060. return false;
  3061. },
  3062. enumerable: true,
  3063. configurable: true
  3064. });
  3065. // Methods
  3066. /**
  3067. * Converts the animation to a string
  3068. * @param fullDetails support for multiple levels of logging within scene loading
  3069. * @returns String form of the animation
  3070. */
  3071. Animation.prototype.toString = function (fullDetails) {
  3072. var ret = "Name: " + this.name + ", property: " + this.targetProperty;
  3073. ret += ", datatype: " + (["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"])[this.dataType];
  3074. ret += ", nKeys: " + (this._keys ? this._keys.length : "none");
  3075. ret += ", nRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  3076. if (fullDetails) {
  3077. ret += ", Ranges: {";
  3078. var first = true;
  3079. for (var name in this._ranges) {
  3080. if (first) {
  3081. ret += ", ";
  3082. first = false;
  3083. }
  3084. ret += name;
  3085. }
  3086. ret += "}";
  3087. }
  3088. return ret;
  3089. };
  3090. /**
  3091. * Add an event to this animation
  3092. * @param event Event to add
  3093. */
  3094. Animation.prototype.addEvent = function (event) {
  3095. this._events.push(event);
  3096. };
  3097. /**
  3098. * Remove all events found at the given frame
  3099. * @param frame The frame to remove events from
  3100. */
  3101. Animation.prototype.removeEvents = function (frame) {
  3102. for (var index = 0; index < this._events.length; index++) {
  3103. if (this._events[index].frame === frame) {
  3104. this._events.splice(index, 1);
  3105. index--;
  3106. }
  3107. }
  3108. };
  3109. /**
  3110. * Retrieves all the events from the animation
  3111. * @returns Events from the animation
  3112. */
  3113. Animation.prototype.getEvents = function () {
  3114. return this._events;
  3115. };
  3116. /**
  3117. * Creates an animation range
  3118. * @param name Name of the animation range
  3119. * @param from Starting frame of the animation range
  3120. * @param to Ending frame of the animation
  3121. */
  3122. Animation.prototype.createRange = function (name, from, to) {
  3123. // check name not already in use; could happen for bones after serialized
  3124. if (!this._ranges[name]) {
  3125. this._ranges[name] = new AnimationRange(name, from, to);
  3126. }
  3127. };
  3128. /**
  3129. * Deletes an animation range by name
  3130. * @param name Name of the animation range to delete
  3131. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3132. */
  3133. Animation.prototype.deleteRange = function (name, deleteFrames) {
  3134. if (deleteFrames === void 0) { deleteFrames = true; }
  3135. var range = this._ranges[name];
  3136. if (!range) {
  3137. return;
  3138. }
  3139. if (deleteFrames) {
  3140. var from = range.from;
  3141. var to = range.to;
  3142. // this loop MUST go high to low for multiple splices to work
  3143. for (var key = this._keys.length - 1; key >= 0; key--) {
  3144. if (this._keys[key].frame >= from && this._keys[key].frame <= to) {
  3145. this._keys.splice(key, 1);
  3146. }
  3147. }
  3148. }
  3149. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  3150. };
  3151. /**
  3152. * Gets the animation range by name, or null if not defined
  3153. * @param name Name of the animation range
  3154. * @returns Nullable animation range
  3155. */
  3156. Animation.prototype.getRange = function (name) {
  3157. return this._ranges[name];
  3158. };
  3159. /**
  3160. * Gets the key frames from the animation
  3161. * @returns The key frames of the animation
  3162. */
  3163. Animation.prototype.getKeys = function () {
  3164. return this._keys;
  3165. };
  3166. /**
  3167. * Gets the highest frame rate of the animation
  3168. * @returns Highest frame rate of the animation
  3169. */
  3170. Animation.prototype.getHighestFrame = function () {
  3171. var ret = 0;
  3172. for (var key = 0, nKeys = this._keys.length; key < nKeys; key++) {
  3173. if (ret < this._keys[key].frame) {
  3174. ret = this._keys[key].frame;
  3175. }
  3176. }
  3177. return ret;
  3178. };
  3179. /**
  3180. * Gets the easing function of the animation
  3181. * @returns Easing function of the animation
  3182. */
  3183. Animation.prototype.getEasingFunction = function () {
  3184. return this._easingFunction;
  3185. };
  3186. /**
  3187. * Sets the easing function of the animation
  3188. * @param easingFunction A custom mathematical formula for animation
  3189. */
  3190. Animation.prototype.setEasingFunction = function (easingFunction) {
  3191. this._easingFunction = easingFunction;
  3192. };
  3193. /**
  3194. * Interpolates a scalar linearly
  3195. * @param startValue Start value of the animation curve
  3196. * @param endValue End value of the animation curve
  3197. * @param gradient Scalar amount to interpolate
  3198. * @returns Interpolated scalar value
  3199. */
  3200. Animation.prototype.floatInterpolateFunction = function (startValue, endValue, gradient) {
  3201. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Lerp(startValue, endValue, gradient);
  3202. };
  3203. /**
  3204. * Interpolates a scalar cubically
  3205. * @param startValue Start value of the animation curve
  3206. * @param outTangent End tangent of the animation
  3207. * @param endValue End value of the animation curve
  3208. * @param inTangent Start tangent of the animation curve
  3209. * @param gradient Scalar amount to interpolate
  3210. * @returns Interpolated scalar value
  3211. */
  3212. Animation.prototype.floatInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3213. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3214. };
  3215. /**
  3216. * Interpolates a quaternion using a spherical linear interpolation
  3217. * @param startValue Start value of the animation curve
  3218. * @param endValue End value of the animation curve
  3219. * @param gradient Scalar amount to interpolate
  3220. * @returns Interpolated quaternion value
  3221. */
  3222. Animation.prototype.quaternionInterpolateFunction = function (startValue, endValue, gradient) {
  3223. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Slerp(startValue, endValue, gradient);
  3224. };
  3225. /**
  3226. * Interpolates a quaternion cubically
  3227. * @param startValue Start value of the animation curve
  3228. * @param outTangent End tangent of the animation curve
  3229. * @param endValue End value of the animation curve
  3230. * @param inTangent Start tangent of the animation curve
  3231. * @param gradient Scalar amount to interpolate
  3232. * @returns Interpolated quaternion value
  3233. */
  3234. Animation.prototype.quaternionInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3235. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Hermite(startValue, outTangent, endValue, inTangent, gradient).normalize();
  3236. };
  3237. /**
  3238. * Interpolates a Vector3 linearl
  3239. * @param startValue Start value of the animation curve
  3240. * @param endValue End value of the animation curve
  3241. * @param gradient Scalar amount to interpolate
  3242. * @returns Interpolated scalar value
  3243. */
  3244. Animation.prototype.vector3InterpolateFunction = function (startValue, endValue, gradient) {
  3245. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(startValue, endValue, gradient);
  3246. };
  3247. /**
  3248. * Interpolates a Vector3 cubically
  3249. * @param startValue Start value of the animation curve
  3250. * @param outTangent End tangent of the animation
  3251. * @param endValue End value of the animation curve
  3252. * @param inTangent Start tangent of the animation curve
  3253. * @param gradient Scalar amount to interpolate
  3254. * @returns InterpolatedVector3 value
  3255. */
  3256. Animation.prototype.vector3InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3257. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3258. };
  3259. /**
  3260. * Interpolates a Vector2 linearly
  3261. * @param startValue Start value of the animation curve
  3262. * @param endValue End value of the animation curve
  3263. * @param gradient Scalar amount to interpolate
  3264. * @returns Interpolated Vector2 value
  3265. */
  3266. Animation.prototype.vector2InterpolateFunction = function (startValue, endValue, gradient) {
  3267. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(startValue, endValue, gradient);
  3268. };
  3269. /**
  3270. * Interpolates a Vector2 cubically
  3271. * @param startValue Start value of the animation curve
  3272. * @param outTangent End tangent of the animation
  3273. * @param endValue End value of the animation curve
  3274. * @param inTangent Start tangent of the animation curve
  3275. * @param gradient Scalar amount to interpolate
  3276. * @returns Interpolated Vector2 value
  3277. */
  3278. Animation.prototype.vector2InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3279. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3280. };
  3281. /**
  3282. * Interpolates a size linearly
  3283. * @param startValue Start value of the animation curve
  3284. * @param endValue End value of the animation curve
  3285. * @param gradient Scalar amount to interpolate
  3286. * @returns Interpolated Size value
  3287. */
  3288. Animation.prototype.sizeInterpolateFunction = function (startValue, endValue, gradient) {
  3289. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Lerp(startValue, endValue, gradient);
  3290. };
  3291. /**
  3292. * Interpolates a Color3 linearly
  3293. * @param startValue Start value of the animation curve
  3294. * @param endValue End value of the animation curve
  3295. * @param gradient Scalar amount to interpolate
  3296. * @returns Interpolated Color3 value
  3297. */
  3298. Animation.prototype.color3InterpolateFunction = function (startValue, endValue, gradient) {
  3299. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Lerp(startValue, endValue, gradient);
  3300. };
  3301. /**
  3302. * @hidden Internal use only
  3303. */
  3304. Animation.prototype._getKeyValue = function (value) {
  3305. if (typeof value === "function") {
  3306. return value();
  3307. }
  3308. return value;
  3309. };
  3310. /**
  3311. * @hidden Internal use only
  3312. */
  3313. Animation.prototype._interpolate = function (currentFrame, repeatCount, workValue, loopMode, offsetValue, highLimitValue) {
  3314. if (loopMode === Animation.ANIMATIONLOOPMODE_CONSTANT && repeatCount > 0) {
  3315. return highLimitValue.clone ? highLimitValue.clone() : highLimitValue;
  3316. }
  3317. var keys = this.getKeys();
  3318. // Try to get a hash to find the right key
  3319. var startKeyIndex = Math.max(0, Math.min(keys.length - 1, Math.floor(keys.length * (currentFrame - keys[0].frame) / (keys[keys.length - 1].frame - keys[0].frame)) - 1));
  3320. if (keys[startKeyIndex].frame >= currentFrame) {
  3321. while (startKeyIndex - 1 >= 0 && keys[startKeyIndex].frame >= currentFrame) {
  3322. startKeyIndex--;
  3323. }
  3324. }
  3325. for (var key = startKeyIndex; key < keys.length; key++) {
  3326. var endKey = keys[key + 1];
  3327. if (endKey.frame >= currentFrame) {
  3328. var startKey = keys[key];
  3329. var startValue = this._getKeyValue(startKey.value);
  3330. if (startKey.interpolation === AnimationKeyInterpolation.STEP) {
  3331. return startValue;
  3332. }
  3333. var endValue = this._getKeyValue(endKey.value);
  3334. var useTangent = startKey.outTangent !== undefined && endKey.inTangent !== undefined;
  3335. var frameDelta = endKey.frame - startKey.frame;
  3336. // gradient : percent of currentFrame between the frame inf and the frame sup
  3337. var gradient = (currentFrame - startKey.frame) / frameDelta;
  3338. // check for easingFunction and correction of gradient
  3339. var easingFunction = this.getEasingFunction();
  3340. if (easingFunction != null) {
  3341. gradient = easingFunction.ease(gradient);
  3342. }
  3343. switch (this.dataType) {
  3344. // Float
  3345. case Animation.ANIMATIONTYPE_FLOAT:
  3346. var floatValue = useTangent ? this.floatInterpolateFunctionWithTangents(startValue, startKey.outTangent * frameDelta, endValue, endKey.inTangent * frameDelta, gradient) : this.floatInterpolateFunction(startValue, endValue, gradient);
  3347. switch (loopMode) {
  3348. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3349. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3350. return floatValue;
  3351. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3352. return offsetValue * repeatCount + floatValue;
  3353. }
  3354. break;
  3355. // Quaternion
  3356. case Animation.ANIMATIONTYPE_QUATERNION:
  3357. var quatValue = useTangent ? this.quaternionInterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.quaternionInterpolateFunction(startValue, endValue, gradient);
  3358. switch (loopMode) {
  3359. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3360. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3361. return quatValue;
  3362. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3363. return quatValue.addInPlace(offsetValue.scale(repeatCount));
  3364. }
  3365. return quatValue;
  3366. // Vector3
  3367. case Animation.ANIMATIONTYPE_VECTOR3:
  3368. var vec3Value = useTangent ? this.vector3InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector3InterpolateFunction(startValue, endValue, gradient);
  3369. switch (loopMode) {
  3370. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3371. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3372. return vec3Value;
  3373. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3374. return vec3Value.add(offsetValue.scale(repeatCount));
  3375. }
  3376. // Vector2
  3377. case Animation.ANIMATIONTYPE_VECTOR2:
  3378. var vec2Value = useTangent ? this.vector2InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector2InterpolateFunction(startValue, endValue, gradient);
  3379. switch (loopMode) {
  3380. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3381. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3382. return vec2Value;
  3383. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3384. return vec2Value.add(offsetValue.scale(repeatCount));
  3385. }
  3386. // Size
  3387. case Animation.ANIMATIONTYPE_SIZE:
  3388. switch (loopMode) {
  3389. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3390. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3391. return this.sizeInterpolateFunction(startValue, endValue, gradient);
  3392. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3393. return this.sizeInterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3394. }
  3395. // Color3
  3396. case Animation.ANIMATIONTYPE_COLOR3:
  3397. switch (loopMode) {
  3398. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3399. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3400. return this.color3InterpolateFunction(startValue, endValue, gradient);
  3401. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3402. return this.color3InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3403. }
  3404. // Matrix
  3405. case Animation.ANIMATIONTYPE_MATRIX:
  3406. switch (loopMode) {
  3407. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3408. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3409. if (Animation.AllowMatricesInterpolation) {
  3410. return this.matrixInterpolateFunction(startValue, endValue, gradient, workValue);
  3411. }
  3412. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3413. return startValue;
  3414. }
  3415. default:
  3416. break;
  3417. }
  3418. break;
  3419. }
  3420. }
  3421. return this._getKeyValue(keys[keys.length - 1].value);
  3422. };
  3423. /**
  3424. * Defines the function to use to interpolate matrices
  3425. * @param startValue defines the start matrix
  3426. * @param endValue defines the end matrix
  3427. * @param gradient defines the gradient between both matrices
  3428. * @param result defines an optional target matrix where to store the interpolation
  3429. * @returns the interpolated matrix
  3430. */
  3431. Animation.prototype.matrixInterpolateFunction = function (startValue, endValue, gradient, result) {
  3432. if (Animation.AllowMatrixDecomposeForInterpolation) {
  3433. if (result) {
  3434. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(startValue, endValue, gradient, result);
  3435. return result;
  3436. }
  3437. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(startValue, endValue, gradient);
  3438. }
  3439. if (result) {
  3440. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(startValue, endValue, gradient, result);
  3441. return result;
  3442. }
  3443. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(startValue, endValue, gradient);
  3444. };
  3445. /**
  3446. * Makes a copy of the animation
  3447. * @returns Cloned animation
  3448. */
  3449. Animation.prototype.clone = function () {
  3450. var clone = new Animation(this.name, this.targetPropertyPath.join("."), this.framePerSecond, this.dataType, this.loopMode);
  3451. clone.enableBlending = this.enableBlending;
  3452. clone.blendingSpeed = this.blendingSpeed;
  3453. if (this._keys) {
  3454. clone.setKeys(this._keys);
  3455. }
  3456. if (this._ranges) {
  3457. clone._ranges = {};
  3458. for (var name in this._ranges) {
  3459. var range = this._ranges[name];
  3460. if (!range) {
  3461. continue;
  3462. }
  3463. clone._ranges[name] = range.clone();
  3464. }
  3465. }
  3466. return clone;
  3467. };
  3468. /**
  3469. * Sets the key frames of the animation
  3470. * @param values The animation key frames to set
  3471. */
  3472. Animation.prototype.setKeys = function (values) {
  3473. this._keys = values.slice(0);
  3474. };
  3475. /**
  3476. * Serializes the animation to an object
  3477. * @returns Serialized object
  3478. */
  3479. Animation.prototype.serialize = function () {
  3480. var serializationObject = {};
  3481. serializationObject.name = this.name;
  3482. serializationObject.property = this.targetProperty;
  3483. serializationObject.framePerSecond = this.framePerSecond;
  3484. serializationObject.dataType = this.dataType;
  3485. serializationObject.loopBehavior = this.loopMode;
  3486. serializationObject.enableBlending = this.enableBlending;
  3487. serializationObject.blendingSpeed = this.blendingSpeed;
  3488. var dataType = this.dataType;
  3489. serializationObject.keys = [];
  3490. var keys = this.getKeys();
  3491. for (var index = 0; index < keys.length; index++) {
  3492. var animationKey = keys[index];
  3493. var key = {};
  3494. key.frame = animationKey.frame;
  3495. switch (dataType) {
  3496. case Animation.ANIMATIONTYPE_FLOAT:
  3497. key.values = [animationKey.value];
  3498. break;
  3499. case Animation.ANIMATIONTYPE_QUATERNION:
  3500. case Animation.ANIMATIONTYPE_MATRIX:
  3501. case Animation.ANIMATIONTYPE_VECTOR3:
  3502. case Animation.ANIMATIONTYPE_COLOR3:
  3503. key.values = animationKey.value.asArray();
  3504. break;
  3505. }
  3506. serializationObject.keys.push(key);
  3507. }
  3508. serializationObject.ranges = [];
  3509. for (var name in this._ranges) {
  3510. var source = this._ranges[name];
  3511. if (!source) {
  3512. continue;
  3513. }
  3514. var range = {};
  3515. range.name = name;
  3516. range.from = source.from;
  3517. range.to = source.to;
  3518. serializationObject.ranges.push(range);
  3519. }
  3520. return serializationObject;
  3521. };
  3522. Object.defineProperty(Animation, "ANIMATIONTYPE_FLOAT", {
  3523. /**
  3524. * Get the float animation type
  3525. */
  3526. get: function () {
  3527. return Animation._ANIMATIONTYPE_FLOAT;
  3528. },
  3529. enumerable: true,
  3530. configurable: true
  3531. });
  3532. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR3", {
  3533. /**
  3534. * Get the Vector3 animation type
  3535. */
  3536. get: function () {
  3537. return Animation._ANIMATIONTYPE_VECTOR3;
  3538. },
  3539. enumerable: true,
  3540. configurable: true
  3541. });
  3542. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR2", {
  3543. /**
  3544. * Get the Vector2 animation type
  3545. */
  3546. get: function () {
  3547. return Animation._ANIMATIONTYPE_VECTOR2;
  3548. },
  3549. enumerable: true,
  3550. configurable: true
  3551. });
  3552. Object.defineProperty(Animation, "ANIMATIONTYPE_SIZE", {
  3553. /**
  3554. * Get the Size animation type
  3555. */
  3556. get: function () {
  3557. return Animation._ANIMATIONTYPE_SIZE;
  3558. },
  3559. enumerable: true,
  3560. configurable: true
  3561. });
  3562. Object.defineProperty(Animation, "ANIMATIONTYPE_QUATERNION", {
  3563. /**
  3564. * Get the Quaternion animation type
  3565. */
  3566. get: function () {
  3567. return Animation._ANIMATIONTYPE_QUATERNION;
  3568. },
  3569. enumerable: true,
  3570. configurable: true
  3571. });
  3572. Object.defineProperty(Animation, "ANIMATIONTYPE_MATRIX", {
  3573. /**
  3574. * Get the Matrix animation type
  3575. */
  3576. get: function () {
  3577. return Animation._ANIMATIONTYPE_MATRIX;
  3578. },
  3579. enumerable: true,
  3580. configurable: true
  3581. });
  3582. Object.defineProperty(Animation, "ANIMATIONTYPE_COLOR3", {
  3583. /**
  3584. * Get the Color3 animation type
  3585. */
  3586. get: function () {
  3587. return Animation._ANIMATIONTYPE_COLOR3;
  3588. },
  3589. enumerable: true,
  3590. configurable: true
  3591. });
  3592. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_RELATIVE", {
  3593. /**
  3594. * Get the Relative Loop Mode
  3595. */
  3596. get: function () {
  3597. return Animation._ANIMATIONLOOPMODE_RELATIVE;
  3598. },
  3599. enumerable: true,
  3600. configurable: true
  3601. });
  3602. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CYCLE", {
  3603. /**
  3604. * Get the Cycle Loop Mode
  3605. */
  3606. get: function () {
  3607. return Animation._ANIMATIONLOOPMODE_CYCLE;
  3608. },
  3609. enumerable: true,
  3610. configurable: true
  3611. });
  3612. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CONSTANT", {
  3613. /**
  3614. * Get the Constant Loop Mode
  3615. */
  3616. get: function () {
  3617. return Animation._ANIMATIONLOOPMODE_CONSTANT;
  3618. },
  3619. enumerable: true,
  3620. configurable: true
  3621. });
  3622. /** @hidden */
  3623. Animation._UniversalLerp = function (left, right, amount) {
  3624. var constructor = left.constructor;
  3625. if (constructor.Lerp) { // Lerp supported
  3626. return constructor.Lerp(left, right, amount);
  3627. }
  3628. else if (constructor.Slerp) { // Slerp supported
  3629. return constructor.Slerp(left, right, amount);
  3630. }
  3631. else if (left.toFixed) { // Number
  3632. return left * (1.0 - amount) + amount * right;
  3633. }
  3634. else { // Blending not supported
  3635. return right;
  3636. }
  3637. };
  3638. /**
  3639. * Parses an animation object and creates an animation
  3640. * @param parsedAnimation Parsed animation object
  3641. * @returns Animation object
  3642. */
  3643. Animation.Parse = function (parsedAnimation) {
  3644. var animation = new Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
  3645. var dataType = parsedAnimation.dataType;
  3646. var keys = [];
  3647. var data;
  3648. var index;
  3649. if (parsedAnimation.enableBlending) {
  3650. animation.enableBlending = parsedAnimation.enableBlending;
  3651. }
  3652. if (parsedAnimation.blendingSpeed) {
  3653. animation.blendingSpeed = parsedAnimation.blendingSpeed;
  3654. }
  3655. for (index = 0; index < parsedAnimation.keys.length; index++) {
  3656. var key = parsedAnimation.keys[index];
  3657. var inTangent;
  3658. var outTangent;
  3659. switch (dataType) {
  3660. case Animation.ANIMATIONTYPE_FLOAT:
  3661. data = key.values[0];
  3662. if (key.values.length >= 1) {
  3663. inTangent = key.values[1];
  3664. }
  3665. if (key.values.length >= 2) {
  3666. outTangent = key.values[2];
  3667. }
  3668. break;
  3669. case Animation.ANIMATIONTYPE_QUATERNION:
  3670. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values);
  3671. if (key.values.length >= 8) {
  3672. var _inTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(4, 8));
  3673. if (!_inTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3674. inTangent = _inTangent;
  3675. }
  3676. }
  3677. if (key.values.length >= 12) {
  3678. var _outTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(8, 12));
  3679. if (!_outTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3680. outTangent = _outTangent;
  3681. }
  3682. }
  3683. break;
  3684. case Animation.ANIMATIONTYPE_MATRIX:
  3685. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromArray(key.values);
  3686. break;
  3687. case Animation.ANIMATIONTYPE_COLOR3:
  3688. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(key.values);
  3689. break;
  3690. case Animation.ANIMATIONTYPE_VECTOR3:
  3691. default:
  3692. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(key.values);
  3693. break;
  3694. }
  3695. var keyData = {};
  3696. keyData.frame = key.frame;
  3697. keyData.value = data;
  3698. if (inTangent != undefined) {
  3699. keyData.inTangent = inTangent;
  3700. }
  3701. if (outTangent != undefined) {
  3702. keyData.outTangent = outTangent;
  3703. }
  3704. keys.push(keyData);
  3705. }
  3706. animation.setKeys(keys);
  3707. if (parsedAnimation.ranges) {
  3708. for (index = 0; index < parsedAnimation.ranges.length; index++) {
  3709. data = parsedAnimation.ranges[index];
  3710. animation.createRange(data.name, data.from, data.to);
  3711. }
  3712. }
  3713. return animation;
  3714. };
  3715. /**
  3716. * Appends the serialized animations from the source animations
  3717. * @param source Source containing the animations
  3718. * @param destination Target to store the animations
  3719. */
  3720. Animation.AppendSerializedAnimations = function (source, destination) {
  3721. _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["SerializationHelper"].AppendSerializedAnimations(source, destination);
  3722. };
  3723. /**
  3724. * Use matrix interpolation instead of using direct key value when animating matrices
  3725. */
  3726. Animation.AllowMatricesInterpolation = false;
  3727. /**
  3728. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3729. */
  3730. Animation.AllowMatrixDecomposeForInterpolation = true;
  3731. // Statics
  3732. /**
  3733. * Float animation type
  3734. */
  3735. Animation._ANIMATIONTYPE_FLOAT = 0;
  3736. /**
  3737. * Vector3 animation type
  3738. */
  3739. Animation._ANIMATIONTYPE_VECTOR3 = 1;
  3740. /**
  3741. * Quaternion animation type
  3742. */
  3743. Animation._ANIMATIONTYPE_QUATERNION = 2;
  3744. /**
  3745. * Matrix animation type
  3746. */
  3747. Animation._ANIMATIONTYPE_MATRIX = 3;
  3748. /**
  3749. * Color3 animation type
  3750. */
  3751. Animation._ANIMATIONTYPE_COLOR3 = 4;
  3752. /**
  3753. * Vector2 animation type
  3754. */
  3755. Animation._ANIMATIONTYPE_VECTOR2 = 5;
  3756. /**
  3757. * Size animation type
  3758. */
  3759. Animation._ANIMATIONTYPE_SIZE = 6;
  3760. /**
  3761. * Relative Loop Mode
  3762. */
  3763. Animation._ANIMATIONLOOPMODE_RELATIVE = 0;
  3764. /**
  3765. * Cycle Loop Mode
  3766. */
  3767. Animation._ANIMATIONLOOPMODE_CYCLE = 1;
  3768. /**
  3769. * Constant Loop Mode
  3770. */
  3771. Animation._ANIMATIONLOOPMODE_CONSTANT = 2;
  3772. return Animation;
  3773. }());
  3774. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"]._AnimationParser = Animation.Parse;
  3775. _node__WEBPACK_IMPORTED_MODULE_2__["Node"]._AnimationRangeFactory = function (name, from, to) { return new AnimationRange(name, from, to); };
  3776. /***/ }),
  3777. /***/ "./Animations/animationGroup.ts":
  3778. /*!**************************************!*\
  3779. !*** ./Animations/animationGroup.ts ***!
  3780. \**************************************/
  3781. /*! exports provided: TargetedAnimation, AnimationGroup */
  3782. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3783. "use strict";
  3784. __webpack_require__.r(__webpack_exports__);
  3785. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return TargetedAnimation; });
  3786. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return AnimationGroup; });
  3787. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  3788. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  3789. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  3790. /**
  3791. * This class defines the direct association between an animation and a target
  3792. */
  3793. var TargetedAnimation = /** @class */ (function () {
  3794. function TargetedAnimation() {
  3795. }
  3796. return TargetedAnimation;
  3797. }());
  3798. /**
  3799. * Use this class to create coordinated animations on multiple targets
  3800. */
  3801. var AnimationGroup = /** @class */ (function () {
  3802. /**
  3803. * Instantiates a new Animation Group.
  3804. * This helps managing several animations at once.
  3805. * @see http://doc.babylonjs.com/how_to/group
  3806. * @param name Defines the name of the group
  3807. * @param scene Defines the scene the group belongs to
  3808. */
  3809. function AnimationGroup(
  3810. /** The name of the animation group */
  3811. name, scene) {
  3812. if (scene === void 0) { scene = null; }
  3813. this.name = name;
  3814. this._targetedAnimations = new Array();
  3815. this._animatables = new Array();
  3816. this._from = Number.MAX_VALUE;
  3817. this._to = -Number.MAX_VALUE;
  3818. this._speedRatio = 1;
  3819. /**
  3820. * This observable will notify when one animation have ended
  3821. */
  3822. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3823. /**
  3824. * Observer raised when one animation loops
  3825. */
  3826. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3827. /**
  3828. * This observable will notify when all animations have ended.
  3829. */
  3830. this.onAnimationGroupEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3831. /**
  3832. * This observable will notify when all animations have paused.
  3833. */
  3834. this.onAnimationGroupPauseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3835. /**
  3836. * This observable will notify when all animations are playing.
  3837. */
  3838. this.onAnimationGroupPlayObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3839. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  3840. this.uniqueId = this._scene.getUniqueId();
  3841. this._scene.animationGroups.push(this);
  3842. }
  3843. Object.defineProperty(AnimationGroup.prototype, "from", {
  3844. /**
  3845. * Gets the first frame
  3846. */
  3847. get: function () {
  3848. return this._from;
  3849. },
  3850. enumerable: true,
  3851. configurable: true
  3852. });
  3853. Object.defineProperty(AnimationGroup.prototype, "to", {
  3854. /**
  3855. * Gets the last frame
  3856. */
  3857. get: function () {
  3858. return this._to;
  3859. },
  3860. enumerable: true,
  3861. configurable: true
  3862. });
  3863. Object.defineProperty(AnimationGroup.prototype, "isStarted", {
  3864. /**
  3865. * Define if the animations are started
  3866. */
  3867. get: function () {
  3868. return this._isStarted;
  3869. },
  3870. enumerable: true,
  3871. configurable: true
  3872. });
  3873. Object.defineProperty(AnimationGroup.prototype, "isPlaying", {
  3874. /**
  3875. * Gets a value indicating that the current group is playing
  3876. */
  3877. get: function () {
  3878. return this._isStarted && !this._isPaused;
  3879. },
  3880. enumerable: true,
  3881. configurable: true
  3882. });
  3883. Object.defineProperty(AnimationGroup.prototype, "speedRatio", {
  3884. /**
  3885. * Gets or sets the speed ratio to use for all animations
  3886. */
  3887. get: function () {
  3888. return this._speedRatio;
  3889. },
  3890. /**
  3891. * Gets or sets the speed ratio to use for all animations
  3892. */
  3893. set: function (value) {
  3894. if (this._speedRatio === value) {
  3895. return;
  3896. }
  3897. this._speedRatio = value;
  3898. for (var index = 0; index < this._animatables.length; index++) {
  3899. var animatable = this._animatables[index];
  3900. animatable.speedRatio = this._speedRatio;
  3901. }
  3902. },
  3903. enumerable: true,
  3904. configurable: true
  3905. });
  3906. Object.defineProperty(AnimationGroup.prototype, "targetedAnimations", {
  3907. /**
  3908. * Gets the targeted animations for this animation group
  3909. */
  3910. get: function () {
  3911. return this._targetedAnimations;
  3912. },
  3913. enumerable: true,
  3914. configurable: true
  3915. });
  3916. Object.defineProperty(AnimationGroup.prototype, "animatables", {
  3917. /**
  3918. * returning the list of animatables controlled by this animation group.
  3919. */
  3920. get: function () {
  3921. return this._animatables;
  3922. },
  3923. enumerable: true,
  3924. configurable: true
  3925. });
  3926. /**
  3927. * Add an animation (with its target) in the group
  3928. * @param animation defines the animation we want to add
  3929. * @param target defines the target of the animation
  3930. * @returns the TargetedAnimation object
  3931. */
  3932. AnimationGroup.prototype.addTargetedAnimation = function (animation, target) {
  3933. var targetedAnimation = {
  3934. animation: animation,
  3935. target: target
  3936. };
  3937. var keys = animation.getKeys();
  3938. if (this._from > keys[0].frame) {
  3939. this._from = keys[0].frame;
  3940. }
  3941. if (this._to < keys[keys.length - 1].frame) {
  3942. this._to = keys[keys.length - 1].frame;
  3943. }
  3944. this._targetedAnimations.push(targetedAnimation);
  3945. return targetedAnimation;
  3946. };
  3947. /**
  3948. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  3949. * It can add constant keys at begin or end
  3950. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  3951. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  3952. * @returns the animation group
  3953. */
  3954. AnimationGroup.prototype.normalize = function (beginFrame, endFrame) {
  3955. if (beginFrame === void 0) { beginFrame = null; }
  3956. if (endFrame === void 0) { endFrame = null; }
  3957. if (beginFrame == null) {
  3958. beginFrame = this._from;
  3959. }
  3960. if (endFrame == null) {
  3961. endFrame = this._to;
  3962. }
  3963. for (var index = 0; index < this._targetedAnimations.length; index++) {
  3964. var targetedAnimation = this._targetedAnimations[index];
  3965. var keys = targetedAnimation.animation.getKeys();
  3966. var startKey = keys[0];
  3967. var endKey = keys[keys.length - 1];
  3968. if (startKey.frame > beginFrame) {
  3969. var newKey = {
  3970. frame: beginFrame,
  3971. value: startKey.value,
  3972. inTangent: startKey.inTangent,
  3973. outTangent: startKey.outTangent,
  3974. interpolation: startKey.interpolation
  3975. };
  3976. keys.splice(0, 0, newKey);
  3977. }
  3978. if (endKey.frame < endFrame) {
  3979. var newKey = {
  3980. frame: endFrame,
  3981. value: endKey.value,
  3982. inTangent: endKey.outTangent,
  3983. outTangent: endKey.outTangent,
  3984. interpolation: endKey.interpolation
  3985. };
  3986. keys.push(newKey);
  3987. }
  3988. }
  3989. this._from = beginFrame;
  3990. this._to = endFrame;
  3991. return this;
  3992. };
  3993. /**
  3994. * Start all animations on given targets
  3995. * @param loop defines if animations must loop
  3996. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  3997. * @param from defines the from key (optional)
  3998. * @param to defines the to key (optional)
  3999. * @returns the current animation group
  4000. */
  4001. AnimationGroup.prototype.start = function (loop, speedRatio, from, to) {
  4002. var _this = this;
  4003. if (loop === void 0) { loop = false; }
  4004. if (speedRatio === void 0) { speedRatio = 1; }
  4005. if (this._isStarted || this._targetedAnimations.length === 0) {
  4006. return this;
  4007. }
  4008. var _loop_1 = function (targetedAnimation) {
  4009. var animatable = this_1._scene.beginDirectAnimation(targetedAnimation.target, [targetedAnimation.animation], from !== undefined ? from : this_1._from, to !== undefined ? to : this_1._to, loop, speedRatio);
  4010. animatable.onAnimationEnd = function () {
  4011. _this.onAnimationEndObservable.notifyObservers(targetedAnimation);
  4012. _this._checkAnimationGroupEnded(animatable);
  4013. };
  4014. animatable.onAnimationLoop = function () {
  4015. _this.onAnimationLoopObservable.notifyObservers(targetedAnimation);
  4016. };
  4017. this_1._animatables.push(animatable);
  4018. };
  4019. var this_1 = this;
  4020. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4021. var targetedAnimation = _a[_i];
  4022. _loop_1(targetedAnimation);
  4023. }
  4024. this._speedRatio = speedRatio;
  4025. if (from !== undefined && to !== undefined && from > to && this._speedRatio > 0) {
  4026. this._speedRatio = -speedRatio;
  4027. }
  4028. this._isStarted = true;
  4029. this._isPaused = false;
  4030. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4031. return this;
  4032. };
  4033. /**
  4034. * Pause all animations
  4035. * @returns the animation group
  4036. */
  4037. AnimationGroup.prototype.pause = function () {
  4038. if (!this._isStarted) {
  4039. return this;
  4040. }
  4041. this._isPaused = true;
  4042. for (var index = 0; index < this._animatables.length; index++) {
  4043. var animatable = this._animatables[index];
  4044. animatable.pause();
  4045. }
  4046. this.onAnimationGroupPauseObservable.notifyObservers(this);
  4047. return this;
  4048. };
  4049. /**
  4050. * Play all animations to initial state
  4051. * This function will start() the animations if they were not started or will restart() them if they were paused
  4052. * @param loop defines if animations must loop
  4053. * @returns the animation group
  4054. */
  4055. AnimationGroup.prototype.play = function (loop) {
  4056. // only if all animatables are ready and exist
  4057. if (this.isStarted && this._animatables.length === this._targetedAnimations.length) {
  4058. if (loop !== undefined) {
  4059. for (var index = 0; index < this._animatables.length; index++) {
  4060. var animatable = this._animatables[index];
  4061. animatable.loopAnimation = loop;
  4062. }
  4063. }
  4064. this.restart();
  4065. }
  4066. else {
  4067. this.stop();
  4068. this.start(loop, this._speedRatio);
  4069. }
  4070. this._isPaused = false;
  4071. return this;
  4072. };
  4073. /**
  4074. * Reset all animations to initial state
  4075. * @returns the animation group
  4076. */
  4077. AnimationGroup.prototype.reset = function () {
  4078. if (!this._isStarted) {
  4079. return this;
  4080. }
  4081. for (var index = 0; index < this._animatables.length; index++) {
  4082. var animatable = this._animatables[index];
  4083. animatable.reset();
  4084. }
  4085. return this;
  4086. };
  4087. /**
  4088. * Restart animations from key 0
  4089. * @returns the animation group
  4090. */
  4091. AnimationGroup.prototype.restart = function () {
  4092. if (!this._isStarted) {
  4093. return this;
  4094. }
  4095. for (var index = 0; index < this._animatables.length; index++) {
  4096. var animatable = this._animatables[index];
  4097. animatable.restart();
  4098. }
  4099. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4100. return this;
  4101. };
  4102. /**
  4103. * Stop all animations
  4104. * @returns the animation group
  4105. */
  4106. AnimationGroup.prototype.stop = function () {
  4107. if (!this._isStarted) {
  4108. return this;
  4109. }
  4110. var list = this._animatables.slice();
  4111. for (var index = 0; index < list.length; index++) {
  4112. list[index].stop();
  4113. }
  4114. this._isStarted = false;
  4115. return this;
  4116. };
  4117. /**
  4118. * Set animation weight for all animatables
  4119. * @param weight defines the weight to use
  4120. * @return the animationGroup
  4121. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4122. */
  4123. AnimationGroup.prototype.setWeightForAllAnimatables = function (weight) {
  4124. for (var index = 0; index < this._animatables.length; index++) {
  4125. var animatable = this._animatables[index];
  4126. animatable.weight = weight;
  4127. }
  4128. return this;
  4129. };
  4130. /**
  4131. * Synchronize and normalize all animatables with a source animatable
  4132. * @param root defines the root animatable to synchronize with
  4133. * @return the animationGroup
  4134. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4135. */
  4136. AnimationGroup.prototype.syncAllAnimationsWith = function (root) {
  4137. for (var index = 0; index < this._animatables.length; index++) {
  4138. var animatable = this._animatables[index];
  4139. animatable.syncWith(root);
  4140. }
  4141. return this;
  4142. };
  4143. /**
  4144. * Goes to a specific frame in this animation group
  4145. * @param frame the frame number to go to
  4146. * @return the animationGroup
  4147. */
  4148. AnimationGroup.prototype.goToFrame = function (frame) {
  4149. if (!this._isStarted) {
  4150. return this;
  4151. }
  4152. for (var index = 0; index < this._animatables.length; index++) {
  4153. var animatable = this._animatables[index];
  4154. animatable.goToFrame(frame);
  4155. }
  4156. return this;
  4157. };
  4158. /**
  4159. * Dispose all associated resources
  4160. */
  4161. AnimationGroup.prototype.dispose = function () {
  4162. this._targetedAnimations = [];
  4163. this._animatables = [];
  4164. var index = this._scene.animationGroups.indexOf(this);
  4165. if (index > -1) {
  4166. this._scene.animationGroups.splice(index, 1);
  4167. }
  4168. this.onAnimationEndObservable.clear();
  4169. this.onAnimationGroupEndObservable.clear();
  4170. this.onAnimationGroupPauseObservable.clear();
  4171. this.onAnimationGroupPlayObservable.clear();
  4172. this.onAnimationLoopObservable.clear();
  4173. };
  4174. AnimationGroup.prototype._checkAnimationGroupEnded = function (animatable) {
  4175. // animatable should be taken out of the array
  4176. var idx = this._animatables.indexOf(animatable);
  4177. if (idx > -1) {
  4178. this._animatables.splice(idx, 1);
  4179. }
  4180. // all animatables were removed? animation group ended!
  4181. if (this._animatables.length === 0) {
  4182. this._isStarted = false;
  4183. this.onAnimationGroupEndObservable.notifyObservers(this);
  4184. }
  4185. };
  4186. // Statics
  4187. /**
  4188. * Returns a new AnimationGroup object parsed from the source provided.
  4189. * @param parsedAnimationGroup defines the source
  4190. * @param scene defines the scene that will receive the animationGroup
  4191. * @returns a new AnimationGroup
  4192. */
  4193. AnimationGroup.Parse = function (parsedAnimationGroup, scene) {
  4194. var animationGroup = new AnimationGroup(parsedAnimationGroup.name, scene);
  4195. for (var i = 0; i < parsedAnimationGroup.targetedAnimations.length; i++) {
  4196. var targetedAnimation = parsedAnimationGroup.targetedAnimations[i];
  4197. var animation = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].Parse(targetedAnimation.animation);
  4198. var id = targetedAnimation.targetId;
  4199. if (targetedAnimation.animation.property === "influence") { // morph target animation
  4200. var morphTarget = scene.getMorphTargetById(id);
  4201. if (morphTarget) {
  4202. animationGroup.addTargetedAnimation(animation, morphTarget);
  4203. }
  4204. }
  4205. else {
  4206. var targetNode = scene.getNodeByID(id);
  4207. if (targetNode != null) {
  4208. animationGroup.addTargetedAnimation(animation, targetNode);
  4209. }
  4210. }
  4211. }
  4212. if (parsedAnimationGroup.from !== null && parsedAnimationGroup.from !== null) {
  4213. animationGroup.normalize(parsedAnimationGroup.from, parsedAnimationGroup.to);
  4214. }
  4215. return animationGroup;
  4216. };
  4217. /**
  4218. * Returns the string "AnimationGroup"
  4219. * @returns "AnimationGroup"
  4220. */
  4221. AnimationGroup.prototype.getClassName = function () {
  4222. return "AnimationGroup";
  4223. };
  4224. /**
  4225. * Creates a detailled string about the object
  4226. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4227. * @returns a string representing the object
  4228. */
  4229. AnimationGroup.prototype.toString = function (fullDetails) {
  4230. var ret = "Name: " + this.name;
  4231. ret += ", type: " + this.getClassName();
  4232. if (fullDetails) {
  4233. ret += ", from: " + this._from;
  4234. ret += ", to: " + this._to;
  4235. ret += ", isStarted: " + this._isStarted;
  4236. ret += ", speedRatio: " + this._speedRatio;
  4237. ret += ", targetedAnimations length: " + this._targetedAnimations.length;
  4238. ret += ", animatables length: " + this._animatables;
  4239. }
  4240. return ret;
  4241. };
  4242. return AnimationGroup;
  4243. }());
  4244. /***/ }),
  4245. /***/ "./Animations/animationPropertiesOverride.ts":
  4246. /*!***************************************************!*\
  4247. !*** ./Animations/animationPropertiesOverride.ts ***!
  4248. \***************************************************/
  4249. /*! exports provided: AnimationPropertiesOverride */
  4250. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4251. "use strict";
  4252. __webpack_require__.r(__webpack_exports__);
  4253. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return AnimationPropertiesOverride; });
  4254. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  4255. /**
  4256. * Class used to override all child animations of a given target
  4257. */
  4258. var AnimationPropertiesOverride = /** @class */ (function () {
  4259. function AnimationPropertiesOverride() {
  4260. /**
  4261. * Gets or sets a value indicating if animation blending must be used
  4262. */
  4263. this.enableBlending = false;
  4264. /**
  4265. * Gets or sets the blending speed to use when enableBlending is true
  4266. */
  4267. this.blendingSpeed = 0.01;
  4268. /**
  4269. * Gets or sets the default loop mode to use
  4270. */
  4271. this.loopMode = _Animations_animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONLOOPMODE_CYCLE;
  4272. }
  4273. return AnimationPropertiesOverride;
  4274. }());
  4275. /***/ }),
  4276. /***/ "./Animations/easing.ts":
  4277. /*!******************************!*\
  4278. !*** ./Animations/easing.ts ***!
  4279. \******************************/
  4280. /*! exports provided: EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase */
  4281. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4282. "use strict";
  4283. __webpack_require__.r(__webpack_exports__);
  4284. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return EasingFunction; });
  4285. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return CircleEase; });
  4286. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return BackEase; });
  4287. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return BounceEase; });
  4288. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return CubicEase; });
  4289. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return ElasticEase; });
  4290. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return ExponentialEase; });
  4291. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return PowerEase; });
  4292. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return QuadraticEase; });
  4293. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return QuarticEase; });
  4294. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return QuinticEase; });
  4295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return SineEase; });
  4296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return BezierCurveEase; });
  4297. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  4298. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  4299. /**
  4300. * Base class used for every default easing function.
  4301. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4302. */
  4303. var EasingFunction = /** @class */ (function () {
  4304. function EasingFunction() {
  4305. this._easingMode = EasingFunction.EASINGMODE_EASEIN;
  4306. }
  4307. /**
  4308. * Sets the easing mode of the current function.
  4309. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4310. */
  4311. EasingFunction.prototype.setEasingMode = function (easingMode) {
  4312. var n = Math.min(Math.max(easingMode, 0), 2);
  4313. this._easingMode = n;
  4314. };
  4315. /**
  4316. * Gets the current easing mode.
  4317. * @returns the easing mode
  4318. */
  4319. EasingFunction.prototype.getEasingMode = function () {
  4320. return this._easingMode;
  4321. };
  4322. /**
  4323. * @hidden
  4324. */
  4325. EasingFunction.prototype.easeInCore = function (gradient) {
  4326. throw new Error('You must implement this method');
  4327. };
  4328. /**
  4329. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4330. * of the easing function.
  4331. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4332. * @returns the corresponding value on the curve defined by the easing function
  4333. */
  4334. EasingFunction.prototype.ease = function (gradient) {
  4335. switch (this._easingMode) {
  4336. case EasingFunction.EASINGMODE_EASEIN:
  4337. return this.easeInCore(gradient);
  4338. case EasingFunction.EASINGMODE_EASEOUT:
  4339. return (1 - this.easeInCore(1 - gradient));
  4340. }
  4341. if (gradient >= 0.5) {
  4342. return (((1 - this.easeInCore((1 - gradient) * 2)) * 0.5) + 0.5);
  4343. }
  4344. return (this.easeInCore(gradient * 2) * 0.5);
  4345. };
  4346. /**
  4347. * Interpolation follows the mathematical formula associated with the easing function.
  4348. */
  4349. EasingFunction.EASINGMODE_EASEIN = 0;
  4350. /**
  4351. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4352. */
  4353. EasingFunction.EASINGMODE_EASEOUT = 1;
  4354. /**
  4355. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4356. */
  4357. EasingFunction.EASINGMODE_EASEINOUT = 2;
  4358. return EasingFunction;
  4359. }());
  4360. /**
  4361. * Easing function with a circle shape (see link below).
  4362. * @see https://easings.net/#easeInCirc
  4363. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4364. */
  4365. var CircleEase = /** @class */ (function (_super) {
  4366. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleEase, _super);
  4367. function CircleEase() {
  4368. return _super !== null && _super.apply(this, arguments) || this;
  4369. }
  4370. /** @hidden */
  4371. CircleEase.prototype.easeInCore = function (gradient) {
  4372. gradient = Math.max(0, Math.min(1, gradient));
  4373. return (1.0 - Math.sqrt(1.0 - (gradient * gradient)));
  4374. };
  4375. return CircleEase;
  4376. }(EasingFunction));
  4377. /**
  4378. * Easing function with a ease back shape (see link below).
  4379. * @see https://easings.net/#easeInBack
  4380. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4381. */
  4382. var BackEase = /** @class */ (function (_super) {
  4383. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackEase, _super);
  4384. /**
  4385. * Instantiates a back ease easing
  4386. * @see https://easings.net/#easeInBack
  4387. * @param amplitude Defines the amplitude of the function
  4388. */
  4389. function BackEase(
  4390. /** Defines the amplitude of the function */
  4391. amplitude) {
  4392. if (amplitude === void 0) { amplitude = 1; }
  4393. var _this = _super.call(this) || this;
  4394. _this.amplitude = amplitude;
  4395. return _this;
  4396. }
  4397. /** @hidden */
  4398. BackEase.prototype.easeInCore = function (gradient) {
  4399. var num = Math.max(0, this.amplitude);
  4400. return (Math.pow(gradient, 3.0) - ((gradient * num) * Math.sin(3.1415926535897931 * gradient)));
  4401. };
  4402. return BackEase;
  4403. }(EasingFunction));
  4404. /**
  4405. * Easing function with a bouncing shape (see link below).
  4406. * @see https://easings.net/#easeInBounce
  4407. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4408. */
  4409. var BounceEase = /** @class */ (function (_super) {
  4410. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BounceEase, _super);
  4411. /**
  4412. * Instantiates a bounce easing
  4413. * @see https://easings.net/#easeInBounce
  4414. * @param bounces Defines the number of bounces
  4415. * @param bounciness Defines the amplitude of the bounce
  4416. */
  4417. function BounceEase(
  4418. /** Defines the number of bounces */
  4419. bounces,
  4420. /** Defines the amplitude of the bounce */
  4421. bounciness) {
  4422. if (bounces === void 0) { bounces = 3; }
  4423. if (bounciness === void 0) { bounciness = 2; }
  4424. var _this = _super.call(this) || this;
  4425. _this.bounces = bounces;
  4426. _this.bounciness = bounciness;
  4427. return _this;
  4428. }
  4429. /** @hidden */
  4430. BounceEase.prototype.easeInCore = function (gradient) {
  4431. var y = Math.max(0.0, this.bounces);
  4432. var bounciness = this.bounciness;
  4433. if (bounciness <= 1.0) {
  4434. bounciness = 1.001;
  4435. }
  4436. var num9 = Math.pow(bounciness, y);
  4437. var num5 = 1.0 - bounciness;
  4438. var num4 = ((1.0 - num9) / num5) + (num9 * 0.5);
  4439. var num15 = gradient * num4;
  4440. var num65 = Math.log((-num15 * (1.0 - bounciness)) + 1.0) / Math.log(bounciness);
  4441. var num3 = Math.floor(num65);
  4442. var num13 = num3 + 1.0;
  4443. var num8 = (1.0 - Math.pow(bounciness, num3)) / (num5 * num4);
  4444. var num12 = (1.0 - Math.pow(bounciness, num13)) / (num5 * num4);
  4445. var num7 = (num8 + num12) * 0.5;
  4446. var num6 = gradient - num7;
  4447. var num2 = num7 - num8;
  4448. return (((-Math.pow(1.0 / bounciness, y - num3) / (num2 * num2)) * (num6 - num2)) * (num6 + num2));
  4449. };
  4450. return BounceEase;
  4451. }(EasingFunction));
  4452. /**
  4453. * Easing function with a power of 3 shape (see link below).
  4454. * @see https://easings.net/#easeInCubic
  4455. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4456. */
  4457. var CubicEase = /** @class */ (function (_super) {
  4458. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubicEase, _super);
  4459. function CubicEase() {
  4460. return _super !== null && _super.apply(this, arguments) || this;
  4461. }
  4462. /** @hidden */
  4463. CubicEase.prototype.easeInCore = function (gradient) {
  4464. return (gradient * gradient * gradient);
  4465. };
  4466. return CubicEase;
  4467. }(EasingFunction));
  4468. /**
  4469. * Easing function with an elastic shape (see link below).
  4470. * @see https://easings.net/#easeInElastic
  4471. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4472. */
  4473. var ElasticEase = /** @class */ (function (_super) {
  4474. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ElasticEase, _super);
  4475. /**
  4476. * Instantiates an elastic easing function
  4477. * @see https://easings.net/#easeInElastic
  4478. * @param oscillations Defines the number of oscillations
  4479. * @param springiness Defines the amplitude of the oscillations
  4480. */
  4481. function ElasticEase(
  4482. /** Defines the number of oscillations*/
  4483. oscillations,
  4484. /** Defines the amplitude of the oscillations*/
  4485. springiness) {
  4486. if (oscillations === void 0) { oscillations = 3; }
  4487. if (springiness === void 0) { springiness = 3; }
  4488. var _this = _super.call(this) || this;
  4489. _this.oscillations = oscillations;
  4490. _this.springiness = springiness;
  4491. return _this;
  4492. }
  4493. /** @hidden */
  4494. ElasticEase.prototype.easeInCore = function (gradient) {
  4495. var num2;
  4496. var num3 = Math.max(0.0, this.oscillations);
  4497. var num = Math.max(0.0, this.springiness);
  4498. if (num == 0) {
  4499. num2 = gradient;
  4500. }
  4501. else {
  4502. num2 = (Math.exp(num * gradient) - 1.0) / (Math.exp(num) - 1.0);
  4503. }
  4504. return (num2 * Math.sin(((6.2831853071795862 * num3) + 1.5707963267948966) * gradient));
  4505. };
  4506. return ElasticEase;
  4507. }(EasingFunction));
  4508. /**
  4509. * Easing function with an exponential shape (see link below).
  4510. * @see https://easings.net/#easeInExpo
  4511. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4512. */
  4513. var ExponentialEase = /** @class */ (function (_super) {
  4514. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExponentialEase, _super);
  4515. /**
  4516. * Instantiates an exponential easing function
  4517. * @see https://easings.net/#easeInExpo
  4518. * @param exponent Defines the exponent of the function
  4519. */
  4520. function ExponentialEase(
  4521. /** Defines the exponent of the function */
  4522. exponent) {
  4523. if (exponent === void 0) { exponent = 2; }
  4524. var _this = _super.call(this) || this;
  4525. _this.exponent = exponent;
  4526. return _this;
  4527. }
  4528. /** @hidden */
  4529. ExponentialEase.prototype.easeInCore = function (gradient) {
  4530. if (this.exponent <= 0) {
  4531. return gradient;
  4532. }
  4533. return ((Math.exp(this.exponent * gradient) - 1.0) / (Math.exp(this.exponent) - 1.0));
  4534. };
  4535. return ExponentialEase;
  4536. }(EasingFunction));
  4537. /**
  4538. * Easing function with a power shape (see link below).
  4539. * @see https://easings.net/#easeInQuad
  4540. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4541. */
  4542. var PowerEase = /** @class */ (function (_super) {
  4543. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PowerEase, _super);
  4544. /**
  4545. * Instantiates an power base easing function
  4546. * @see https://easings.net/#easeInQuad
  4547. * @param power Defines the power of the function
  4548. */
  4549. function PowerEase(
  4550. /** Defines the power of the function */
  4551. power) {
  4552. if (power === void 0) { power = 2; }
  4553. var _this = _super.call(this) || this;
  4554. _this.power = power;
  4555. return _this;
  4556. }
  4557. /** @hidden */
  4558. PowerEase.prototype.easeInCore = function (gradient) {
  4559. var y = Math.max(0.0, this.power);
  4560. return Math.pow(gradient, y);
  4561. };
  4562. return PowerEase;
  4563. }(EasingFunction));
  4564. /**
  4565. * Easing function with a power of 2 shape (see link below).
  4566. * @see https://easings.net/#easeInQuad
  4567. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4568. */
  4569. var QuadraticEase = /** @class */ (function (_super) {
  4570. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuadraticEase, _super);
  4571. function QuadraticEase() {
  4572. return _super !== null && _super.apply(this, arguments) || this;
  4573. }
  4574. /** @hidden */
  4575. QuadraticEase.prototype.easeInCore = function (gradient) {
  4576. return (gradient * gradient);
  4577. };
  4578. return QuadraticEase;
  4579. }(EasingFunction));
  4580. /**
  4581. * Easing function with a power of 4 shape (see link below).
  4582. * @see https://easings.net/#easeInQuart
  4583. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4584. */
  4585. var QuarticEase = /** @class */ (function (_super) {
  4586. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuarticEase, _super);
  4587. function QuarticEase() {
  4588. return _super !== null && _super.apply(this, arguments) || this;
  4589. }
  4590. /** @hidden */
  4591. QuarticEase.prototype.easeInCore = function (gradient) {
  4592. return (gradient * gradient * gradient * gradient);
  4593. };
  4594. return QuarticEase;
  4595. }(EasingFunction));
  4596. /**
  4597. * Easing function with a power of 5 shape (see link below).
  4598. * @see https://easings.net/#easeInQuint
  4599. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4600. */
  4601. var QuinticEase = /** @class */ (function (_super) {
  4602. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuinticEase, _super);
  4603. function QuinticEase() {
  4604. return _super !== null && _super.apply(this, arguments) || this;
  4605. }
  4606. /** @hidden */
  4607. QuinticEase.prototype.easeInCore = function (gradient) {
  4608. return (gradient * gradient * gradient * gradient * gradient);
  4609. };
  4610. return QuinticEase;
  4611. }(EasingFunction));
  4612. /**
  4613. * Easing function with a sin shape (see link below).
  4614. * @see https://easings.net/#easeInSine
  4615. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4616. */
  4617. var SineEase = /** @class */ (function (_super) {
  4618. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SineEase, _super);
  4619. function SineEase() {
  4620. return _super !== null && _super.apply(this, arguments) || this;
  4621. }
  4622. /** @hidden */
  4623. SineEase.prototype.easeInCore = function (gradient) {
  4624. return (1.0 - Math.sin(1.5707963267948966 * (1.0 - gradient)));
  4625. };
  4626. return SineEase;
  4627. }(EasingFunction));
  4628. /**
  4629. * Easing function with a bezier shape (see link below).
  4630. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4631. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4632. */
  4633. var BezierCurveEase = /** @class */ (function (_super) {
  4634. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BezierCurveEase, _super);
  4635. /**
  4636. * Instantiates a bezier function
  4637. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4638. * @param x1 Defines the x component of the start tangent in the bezier curve
  4639. * @param y1 Defines the y component of the start tangent in the bezier curve
  4640. * @param x2 Defines the x component of the end tangent in the bezier curve
  4641. * @param y2 Defines the y component of the end tangent in the bezier curve
  4642. */
  4643. function BezierCurveEase(
  4644. /** Defines the x component of the start tangent in the bezier curve */
  4645. x1,
  4646. /** Defines the y component of the start tangent in the bezier curve */
  4647. y1,
  4648. /** Defines the x component of the end tangent in the bezier curve */
  4649. x2,
  4650. /** Defines the y component of the end tangent in the bezier curve */
  4651. y2) {
  4652. if (x1 === void 0) { x1 = 0; }
  4653. if (y1 === void 0) { y1 = 0; }
  4654. if (x2 === void 0) { x2 = 1; }
  4655. if (y2 === void 0) { y2 = 1; }
  4656. var _this = _super.call(this) || this;
  4657. _this.x1 = x1;
  4658. _this.y1 = y1;
  4659. _this.x2 = x2;
  4660. _this.y2 = y2;
  4661. return _this;
  4662. }
  4663. /** @hidden */
  4664. BezierCurveEase.prototype.easeInCore = function (gradient) {
  4665. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"].Interpolate(gradient, this.x1, this.y1, this.x2, this.y2);
  4666. };
  4667. return BezierCurveEase;
  4668. }(EasingFunction));
  4669. /***/ }),
  4670. /***/ "./Animations/index.ts":
  4671. /*!*****************************!*\
  4672. !*** ./Animations/index.ts ***!
  4673. \*****************************/
  4674. /*! exports provided: Animatable, AnimationRange, AnimationEvent, PathCursor, AnimationKeyInterpolation, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation */
  4675. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4676. "use strict";
  4677. __webpack_require__.r(__webpack_exports__);
  4678. /* harmony import */ var _animatable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animatable */ "./Animations/animatable.ts");
  4679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _animatable__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  4680. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  4681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["AnimationRange"]; });
  4682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["AnimationEvent"]; });
  4683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PathCursor", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["PathCursor"]; });
  4684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["AnimationKeyInterpolation"]; });
  4685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]; });
  4686. /* harmony import */ var _animationGroup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./animationGroup */ "./Animations/animationGroup.ts");
  4687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  4688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  4689. /* harmony import */ var _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./animationPropertiesOverride */ "./Animations/animationPropertiesOverride.ts");
  4690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__["AnimationPropertiesOverride"]; });
  4691. /* harmony import */ var _easing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./easing */ "./Animations/easing.ts");
  4692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["EasingFunction"]; });
  4693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CircleEase"]; });
  4694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BackEase"]; });
  4695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BounceEase"]; });
  4696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CubicEase"]; });
  4697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ElasticEase"]; });
  4698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ExponentialEase"]; });
  4699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["PowerEase"]; });
  4700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuadraticEase"]; });
  4701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuarticEase"]; });
  4702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuinticEase"]; });
  4703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["SineEase"]; });
  4704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BezierCurveEase"]; });
  4705. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  4706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__["RuntimeAnimation"]; });
  4707. /***/ }),
  4708. /***/ "./Animations/runtimeAnimation.ts":
  4709. /*!****************************************!*\
  4710. !*** ./Animations/runtimeAnimation.ts ***!
  4711. \****************************************/
  4712. /*! exports provided: RuntimeAnimation */
  4713. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4714. "use strict";
  4715. __webpack_require__.r(__webpack_exports__);
  4716. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return RuntimeAnimation; });
  4717. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  4718. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  4719. // Static values to help the garbage collector
  4720. // Quaternion
  4721. var _staticOffsetValueQuaternion = Object.freeze(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"](0, 0, 0, 0));
  4722. // Vector3
  4723. var _staticOffsetValueVector3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero());
  4724. // Vector2
  4725. var _staticOffsetValueVector2 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero());
  4726. // Size
  4727. var _staticOffsetValueSize = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Zero());
  4728. // Color3
  4729. var _staticOffsetValueColor3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Black());
  4730. /**
  4731. * Defines a runtime animation
  4732. */
  4733. var RuntimeAnimation = /** @class */ (function () {
  4734. /**
  4735. * Create a new RuntimeAnimation object
  4736. * @param target defines the target of the animation
  4737. * @param animation defines the source animation object
  4738. * @param scene defines the hosting scene
  4739. * @param host defines the initiating Animatable
  4740. */
  4741. function RuntimeAnimation(target, animation, scene, host) {
  4742. var _this = this;
  4743. this._events = new Array();
  4744. /**
  4745. * The current frame of the runtime animation
  4746. */
  4747. this._currentFrame = 0;
  4748. /**
  4749. * The original value of the runtime animation
  4750. */
  4751. this._originalValue = new Array();
  4752. /**
  4753. * The offsets cache of the runtime animation
  4754. */
  4755. this._offsetsCache = {};
  4756. /**
  4757. * The high limits cache of the runtime animation
  4758. */
  4759. this._highLimitsCache = {};
  4760. /**
  4761. * Specifies if the runtime animation has been stopped
  4762. */
  4763. this._stopped = false;
  4764. /**
  4765. * The blending factor of the runtime animation
  4766. */
  4767. this._blendingFactor = 0;
  4768. /**
  4769. * The target path of the runtime animation
  4770. */
  4771. this._targetPath = "";
  4772. /**
  4773. * The weight of the runtime animation
  4774. */
  4775. this._weight = 1.0;
  4776. /**
  4777. * The ratio offset of the runtime animation
  4778. */
  4779. this._ratioOffset = 0;
  4780. /**
  4781. * The previous delay of the runtime animation
  4782. */
  4783. this._previousDelay = 0;
  4784. /**
  4785. * The previous ratio of the runtime animation
  4786. */
  4787. this._previousRatio = 0;
  4788. this._animation = animation;
  4789. this._target = target;
  4790. this._scene = scene;
  4791. this._host = host;
  4792. animation._runtimeAnimations.push(this);
  4793. // Cloning events locally
  4794. var events = animation.getEvents();
  4795. if (events && events.length > 0) {
  4796. events.forEach(function (e) {
  4797. _this._events.push(e._clone());
  4798. });
  4799. }
  4800. }
  4801. Object.defineProperty(RuntimeAnimation.prototype, "currentFrame", {
  4802. /**
  4803. * Gets the current frame of the runtime animation
  4804. */
  4805. get: function () {
  4806. return this._currentFrame;
  4807. },
  4808. enumerable: true,
  4809. configurable: true
  4810. });
  4811. Object.defineProperty(RuntimeAnimation.prototype, "weight", {
  4812. /**
  4813. * Gets the weight of the runtime animation
  4814. */
  4815. get: function () {
  4816. return this._weight;
  4817. },
  4818. enumerable: true,
  4819. configurable: true
  4820. });
  4821. Object.defineProperty(RuntimeAnimation.prototype, "currentValue", {
  4822. /**
  4823. * Gets the current value of the runtime animation
  4824. */
  4825. get: function () {
  4826. return this._currentValue;
  4827. },
  4828. enumerable: true,
  4829. configurable: true
  4830. });
  4831. Object.defineProperty(RuntimeAnimation.prototype, "targetPath", {
  4832. /**
  4833. * Gets the target path of the runtime animation
  4834. */
  4835. get: function () {
  4836. return this._targetPath;
  4837. },
  4838. enumerable: true,
  4839. configurable: true
  4840. });
  4841. Object.defineProperty(RuntimeAnimation.prototype, "target", {
  4842. /**
  4843. * Gets the actual target of the runtime animation
  4844. */
  4845. get: function () {
  4846. return this._activeTarget;
  4847. },
  4848. enumerable: true,
  4849. configurable: true
  4850. });
  4851. Object.defineProperty(RuntimeAnimation.prototype, "animation", {
  4852. /**
  4853. * Gets the animation from the runtime animation
  4854. */
  4855. get: function () {
  4856. return this._animation;
  4857. },
  4858. enumerable: true,
  4859. configurable: true
  4860. });
  4861. /**
  4862. * Resets the runtime animation to the beginning
  4863. * @param restoreOriginal defines whether to restore the target property to the original value
  4864. */
  4865. RuntimeAnimation.prototype.reset = function (restoreOriginal) {
  4866. if (restoreOriginal === void 0) { restoreOriginal = false; }
  4867. if (restoreOriginal) {
  4868. if (this._target instanceof Array) {
  4869. var index = 0;
  4870. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  4871. var target = _a[_i];
  4872. if (this._originalValue[index] !== undefined) {
  4873. this._setValue(target, this._originalValue[index], -1);
  4874. }
  4875. index++;
  4876. }
  4877. }
  4878. else {
  4879. if (this._originalValue[0] !== undefined) {
  4880. this._setValue(this._target, this._originalValue[0], -1);
  4881. }
  4882. }
  4883. }
  4884. this._offsetsCache = {};
  4885. this._highLimitsCache = {};
  4886. this._currentFrame = 0;
  4887. this._blendingFactor = 0;
  4888. this._originalValue = new Array();
  4889. // Events
  4890. for (var index = 0; index < this._events.length; index++) {
  4891. this._events[index].isDone = false;
  4892. }
  4893. };
  4894. /**
  4895. * Specifies if the runtime animation is stopped
  4896. * @returns Boolean specifying if the runtime animation is stopped
  4897. */
  4898. RuntimeAnimation.prototype.isStopped = function () {
  4899. return this._stopped;
  4900. };
  4901. /**
  4902. * Disposes of the runtime animation
  4903. */
  4904. RuntimeAnimation.prototype.dispose = function () {
  4905. var index = this._animation.runtimeAnimations.indexOf(this);
  4906. if (index > -1) {
  4907. this._animation.runtimeAnimations.splice(index, 1);
  4908. }
  4909. };
  4910. /**
  4911. * Interpolates the animation from the current frame
  4912. * @param currentFrame The frame to interpolate the animation to
  4913. * @param repeatCount The number of times that the animation should loop
  4914. * @param loopMode The type of looping mode to use
  4915. * @param offsetValue Animation offset value
  4916. * @param highLimitValue The high limit value
  4917. * @returns The interpolated value
  4918. */
  4919. RuntimeAnimation.prototype._interpolate = function (currentFrame, repeatCount, loopMode, offsetValue, highLimitValue) {
  4920. this._currentFrame = currentFrame;
  4921. if (this._animation.dataType === _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_MATRIX && !this._workValue) {
  4922. this._workValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Zero();
  4923. }
  4924. return this._animation._interpolate(currentFrame, repeatCount, this._workValue, loopMode, offsetValue, highLimitValue);
  4925. };
  4926. /**
  4927. * Apply the interpolated value to the target
  4928. * @param currentValue defines the value computed by the animation
  4929. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4930. */
  4931. RuntimeAnimation.prototype.setValue = function (currentValue, weight) {
  4932. if (weight === void 0) { weight = 1.0; }
  4933. if (this._target instanceof Array) {
  4934. var index = 0;
  4935. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  4936. var target = _a[_i];
  4937. this._setValue(target, currentValue, weight, index);
  4938. index++;
  4939. }
  4940. }
  4941. else {
  4942. this._setValue(this._target, currentValue, weight);
  4943. }
  4944. };
  4945. RuntimeAnimation.prototype._setValue = function (target, currentValue, weight, targetIndex) {
  4946. if (targetIndex === void 0) { targetIndex = 0; }
  4947. // Set value
  4948. var path;
  4949. var destination;
  4950. var targetPropertyPath = this._animation.targetPropertyPath;
  4951. if (targetPropertyPath.length > 1) {
  4952. var property = target[targetPropertyPath[0]];
  4953. for (var index = 1; index < targetPropertyPath.length - 1; index++) {
  4954. property = property[targetPropertyPath[index]];
  4955. }
  4956. path = targetPropertyPath[targetPropertyPath.length - 1];
  4957. destination = property;
  4958. }
  4959. else {
  4960. path = targetPropertyPath[0];
  4961. destination = target;
  4962. }
  4963. this._targetPath = path;
  4964. this._activeTarget = destination;
  4965. this._weight = weight;
  4966. if (this._originalValue[targetIndex] === undefined) {
  4967. var originalValue = void 0;
  4968. if (destination.getRestPose && path === "_matrix") { // For bones
  4969. originalValue = destination.getRestPose();
  4970. }
  4971. else {
  4972. originalValue = destination[path];
  4973. }
  4974. if (originalValue && originalValue.clone) {
  4975. this._originalValue[targetIndex] = originalValue.clone();
  4976. }
  4977. else {
  4978. this._originalValue[targetIndex] = originalValue;
  4979. }
  4980. }
  4981. // Blending
  4982. var enableBlending = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
  4983. if (enableBlending && this._blendingFactor <= 1.0) {
  4984. if (!this._originalBlendValue) {
  4985. var originalValue = destination[path];
  4986. if (originalValue.clone) {
  4987. this._originalBlendValue = originalValue.clone();
  4988. }
  4989. else {
  4990. this._originalBlendValue = originalValue;
  4991. }
  4992. }
  4993. if (this._originalBlendValue.m) { // Matrix
  4994. if (_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].AllowMatrixDecomposeForInterpolation) {
  4995. if (this._currentValue) {
  4996. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  4997. }
  4998. else {
  4999. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5000. }
  5001. }
  5002. else {
  5003. if (this._currentValue) {
  5004. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5005. }
  5006. else {
  5007. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5008. }
  5009. }
  5010. }
  5011. else {
  5012. this._currentValue = _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]._UniversalLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5013. }
  5014. var blendingSpeed = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
  5015. this._blendingFactor += blendingSpeed;
  5016. }
  5017. else {
  5018. this._currentValue = currentValue;
  5019. }
  5020. if (weight !== -1.0) {
  5021. this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[targetIndex]);
  5022. }
  5023. else {
  5024. destination[path] = this._currentValue;
  5025. }
  5026. if (target.markAsDirty) {
  5027. target.markAsDirty(this._animation.targetProperty);
  5028. }
  5029. };
  5030. /**
  5031. * Gets the loop pmode of the runtime animation
  5032. * @returns Loop Mode
  5033. */
  5034. RuntimeAnimation.prototype._getCorrectLoopMode = function () {
  5035. if (this._target && this._target.animationPropertiesOverride) {
  5036. return this._target.animationPropertiesOverride.loopMode;
  5037. }
  5038. return this._animation.loopMode;
  5039. };
  5040. /**
  5041. * Move the current animation to a given frame
  5042. * @param frame defines the frame to move to
  5043. */
  5044. RuntimeAnimation.prototype.goToFrame = function (frame) {
  5045. var keys = this._animation.getKeys();
  5046. if (frame < keys[0].frame) {
  5047. frame = keys[0].frame;
  5048. }
  5049. else if (frame > keys[keys.length - 1].frame) {
  5050. frame = keys[keys.length - 1].frame;
  5051. }
  5052. var currentValue = this._interpolate(frame, 0, this._getCorrectLoopMode());
  5053. this.setValue(currentValue, -1);
  5054. };
  5055. /**
  5056. * @hidden Internal use only
  5057. */
  5058. RuntimeAnimation.prototype._prepareForSpeedRatioChange = function (newSpeedRatio) {
  5059. var newRatio = this._previousDelay * (this._animation.framePerSecond * newSpeedRatio) / 1000.0;
  5060. this._ratioOffset = this._previousRatio - newRatio;
  5061. };
  5062. /**
  5063. * Execute the current animation
  5064. * @param delay defines the delay to add to the current frame
  5065. * @param from defines the lower bound of the animation range
  5066. * @param to defines the upper bound of the animation range
  5067. * @param loop defines if the current animation must loop
  5068. * @param speedRatio defines the current speed ratio
  5069. * @param weight defines the weight of the animation (default is -1 so no weight)
  5070. * @param onLoop optional callback called when animation loops
  5071. * @returns a boolean indicating if the animation is running
  5072. */
  5073. RuntimeAnimation.prototype.animate = function (delay, from, to, loop, speedRatio, weight, onLoop) {
  5074. if (weight === void 0) { weight = -1.0; }
  5075. var targetPropertyPath = this._animation.targetPropertyPath;
  5076. if (!targetPropertyPath || targetPropertyPath.length < 1) {
  5077. this._stopped = true;
  5078. return false;
  5079. }
  5080. var returnValue = true;
  5081. var keys = this._animation.getKeys();
  5082. // Adding a start key at frame 0 if missing
  5083. if (keys[0].frame !== 0) {
  5084. var newKey = { frame: 0, value: keys[0].value };
  5085. keys.splice(0, 0, newKey);
  5086. }
  5087. // Adding a duplicate key when there is only one key at frame zero
  5088. else if (keys.length === 1) {
  5089. var newKey = { frame: 0.001, value: keys[0].value };
  5090. keys.push(newKey);
  5091. }
  5092. // Check limits
  5093. if (from < keys[0].frame || from > keys[keys.length - 1].frame) {
  5094. from = keys[0].frame;
  5095. }
  5096. if (to < keys[0].frame || to > keys[keys.length - 1].frame) {
  5097. to = keys[keys.length - 1].frame;
  5098. }
  5099. //to and from cannot be the same key
  5100. if (from === to) {
  5101. if (from > keys[0].frame) {
  5102. from--;
  5103. }
  5104. else if (to < keys[keys.length - 1].frame) {
  5105. to++;
  5106. }
  5107. }
  5108. // Compute ratio
  5109. var range = to - from;
  5110. var offsetValue;
  5111. // ratio represents the frame delta between from and to
  5112. var ratio = (delay * (this._animation.framePerSecond * speedRatio) / 1000.0) + this._ratioOffset;
  5113. var highLimitValue = 0;
  5114. this._previousDelay = delay;
  5115. this._previousRatio = ratio;
  5116. if (((to > from && ratio >= range) || (from > to && ratio <= range)) && !loop) { // If we are out of range and not looping get back to caller
  5117. returnValue = false;
  5118. highLimitValue = this._animation._getKeyValue(keys[keys.length - 1].value);
  5119. }
  5120. else {
  5121. // Get max value if required
  5122. if (this._getCorrectLoopMode() !== _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE) {
  5123. var keyOffset = to.toString() + from.toString();
  5124. if (!this._offsetsCache[keyOffset]) {
  5125. var fromValue = this._interpolate(from, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5126. var toValue = this._interpolate(to, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5127. switch (this._animation.dataType) {
  5128. // Float
  5129. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5130. this._offsetsCache[keyOffset] = toValue - fromValue;
  5131. break;
  5132. // Quaternion
  5133. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5134. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5135. break;
  5136. // Vector3
  5137. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5138. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5139. // Vector2
  5140. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5141. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5142. // Size
  5143. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5144. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5145. // Color3
  5146. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5147. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5148. default:
  5149. break;
  5150. }
  5151. this._highLimitsCache[keyOffset] = toValue;
  5152. }
  5153. highLimitValue = this._highLimitsCache[keyOffset];
  5154. offsetValue = this._offsetsCache[keyOffset];
  5155. }
  5156. }
  5157. if (offsetValue === undefined) {
  5158. switch (this._animation.dataType) {
  5159. // Float
  5160. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5161. offsetValue = 0;
  5162. break;
  5163. // Quaternion
  5164. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5165. offsetValue = _staticOffsetValueQuaternion;
  5166. break;
  5167. // Vector3
  5168. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5169. offsetValue = _staticOffsetValueVector3;
  5170. break;
  5171. // Vector2
  5172. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5173. offsetValue = _staticOffsetValueVector2;
  5174. break;
  5175. // Size
  5176. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5177. offsetValue = _staticOffsetValueSize;
  5178. break;
  5179. // Color3
  5180. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5181. offsetValue = _staticOffsetValueColor3;
  5182. }
  5183. }
  5184. // Compute value
  5185. var repeatCount = (ratio / range) >> 0;
  5186. var currentFrame = returnValue ? from + ratio % range : to;
  5187. // Need to normalize?
  5188. if (this._host && this._host.syncRoot) {
  5189. var syncRoot = this._host.syncRoot;
  5190. var hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);
  5191. currentFrame = from + (to - from) * hostNormalizedFrame;
  5192. }
  5193. // Reset events if looping
  5194. var events = this._events;
  5195. if (range > 0 && this.currentFrame > currentFrame ||
  5196. range < 0 && this.currentFrame < currentFrame) {
  5197. if (onLoop) {
  5198. onLoop();
  5199. }
  5200. // Need to reset animation events
  5201. for (var index = 0; index < events.length; index++) {
  5202. if (!events[index].onlyOnce) {
  5203. // reset event, the animation is looping
  5204. events[index].isDone = false;
  5205. }
  5206. }
  5207. }
  5208. var currentValue = this._interpolate(currentFrame, repeatCount, this._getCorrectLoopMode(), offsetValue, highLimitValue);
  5209. // Set value
  5210. this.setValue(currentValue, weight);
  5211. // Check events
  5212. for (var index = 0; index < events.length; index++) {
  5213. // Make sure current frame has passed event frame and that event frame is within the current range
  5214. // Also, handle both forward and reverse animations
  5215. if ((range > 0 && currentFrame >= events[index].frame && events[index].frame >= from) ||
  5216. (range < 0 && currentFrame <= events[index].frame && events[index].frame <= from)) {
  5217. var event = events[index];
  5218. if (!event.isDone) {
  5219. // If event should be done only once, remove it.
  5220. if (event.onlyOnce) {
  5221. events.splice(index, 1);
  5222. index--;
  5223. }
  5224. event.isDone = true;
  5225. event.action(currentFrame);
  5226. } // Don't do anything if the event has already be done.
  5227. }
  5228. }
  5229. if (!returnValue) {
  5230. this._stopped = true;
  5231. }
  5232. return returnValue;
  5233. };
  5234. return RuntimeAnimation;
  5235. }());
  5236. /***/ }),
  5237. /***/ "./Audio/analyser.ts":
  5238. /*!***************************!*\
  5239. !*** ./Audio/analyser.ts ***!
  5240. \***************************/
  5241. /*! exports provided: Analyser */
  5242. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5243. "use strict";
  5244. __webpack_require__.r(__webpack_exports__);
  5245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return Analyser; });
  5246. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5247. /**
  5248. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5250. */
  5251. var Analyser = /** @class */ (function () {
  5252. /**
  5253. * Creates a new analyser
  5254. * @param scene defines hosting scene
  5255. */
  5256. function Analyser(scene) {
  5257. /**
  5258. * Gets or sets the smoothing
  5259. * @ignorenaming
  5260. */
  5261. this.SMOOTHING = 0.75;
  5262. /**
  5263. * Gets or sets the FFT table size
  5264. * @ignorenaming
  5265. */
  5266. this.FFT_SIZE = 512;
  5267. /**
  5268. * Gets or sets the bar graph amplitude
  5269. * @ignorenaming
  5270. */
  5271. this.BARGRAPHAMPLITUDE = 256;
  5272. /**
  5273. * Gets or sets the position of the debug canvas
  5274. * @ignorenaming
  5275. */
  5276. this.DEBUGCANVASPOS = { x: 20, y: 20 };
  5277. /**
  5278. * Gets or sets the debug canvas size
  5279. * @ignorenaming
  5280. */
  5281. this.DEBUGCANVASSIZE = { width: 320, height: 200 };
  5282. this._scene = scene;
  5283. this._audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine;
  5284. if (this._audioEngine.canUseWebAudio && this._audioEngine.audioContext) {
  5285. this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser();
  5286. this._webAudioAnalyser.minDecibels = -140;
  5287. this._webAudioAnalyser.maxDecibels = 0;
  5288. this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5289. this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5290. this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount);
  5291. }
  5292. }
  5293. /**
  5294. * Get the number of data values you will have to play with for the visualization
  5295. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5296. * @returns a number
  5297. */
  5298. Analyser.prototype.getFrequencyBinCount = function () {
  5299. if (this._audioEngine.canUseWebAudio) {
  5300. return this._webAudioAnalyser.frequencyBinCount;
  5301. }
  5302. else {
  5303. return 0;
  5304. }
  5305. };
  5306. /**
  5307. * Gets the current frequency data as a byte array
  5308. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5309. * @returns a Uint8Array
  5310. */
  5311. Analyser.prototype.getByteFrequencyData = function () {
  5312. if (this._audioEngine.canUseWebAudio) {
  5313. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5314. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5315. this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs);
  5316. }
  5317. return this._byteFreqs;
  5318. };
  5319. /**
  5320. * Gets the current waveform as a byte array
  5321. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5322. * @returns a Uint8Array
  5323. */
  5324. Analyser.prototype.getByteTimeDomainData = function () {
  5325. if (this._audioEngine.canUseWebAudio) {
  5326. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5327. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5328. this._webAudioAnalyser.getByteTimeDomainData(this._byteTime);
  5329. }
  5330. return this._byteTime;
  5331. };
  5332. /**
  5333. * Gets the current frequency data as a float array
  5334. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5335. * @returns a Float32Array
  5336. */
  5337. Analyser.prototype.getFloatFrequencyData = function () {
  5338. if (this._audioEngine.canUseWebAudio) {
  5339. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5340. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5341. this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs);
  5342. }
  5343. return this._floatFreqs;
  5344. };
  5345. /**
  5346. * Renders the debug canvas
  5347. */
  5348. Analyser.prototype.drawDebugCanvas = function () {
  5349. var _this = this;
  5350. if (this._audioEngine.canUseWebAudio) {
  5351. if (!this._debugCanvas) {
  5352. this._debugCanvas = document.createElement("canvas");
  5353. this._debugCanvas.width = this.DEBUGCANVASSIZE.width;
  5354. this._debugCanvas.height = this.DEBUGCANVASSIZE.height;
  5355. this._debugCanvas.style.position = "absolute";
  5356. this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px";
  5357. this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px";
  5358. this._debugCanvasContext = this._debugCanvas.getContext("2d");
  5359. document.body.appendChild(this._debugCanvas);
  5360. this._registerFunc = function () {
  5361. _this.drawDebugCanvas();
  5362. };
  5363. this._scene.registerBeforeRender(this._registerFunc);
  5364. }
  5365. if (this._registerFunc && this._debugCanvasContext) {
  5366. var workingArray = this.getByteFrequencyData();
  5367. this._debugCanvasContext.fillStyle = 'rgb(0, 0, 0)';
  5368. this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
  5369. // Draw the frequency domain chart.
  5370. for (var i = 0; i < this.getFrequencyBinCount(); i++) {
  5371. var value = workingArray[i];
  5372. var percent = value / this.BARGRAPHAMPLITUDE;
  5373. var height = this.DEBUGCANVASSIZE.height * percent;
  5374. var offset = this.DEBUGCANVASSIZE.height - height - 1;
  5375. var barWidth = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount();
  5376. var hue = i / this.getFrequencyBinCount() * 360;
  5377. this._debugCanvasContext.fillStyle = 'hsl(' + hue + ', 100%, 50%)';
  5378. this._debugCanvasContext.fillRect(i * barWidth, offset, barWidth, height);
  5379. }
  5380. }
  5381. }
  5382. };
  5383. /**
  5384. * Stops rendering the debug canvas and removes it
  5385. */
  5386. Analyser.prototype.stopDebugCanvas = function () {
  5387. if (this._debugCanvas) {
  5388. if (this._registerFunc) {
  5389. this._scene.unregisterBeforeRender(this._registerFunc);
  5390. this._registerFunc = null;
  5391. }
  5392. document.body.removeChild(this._debugCanvas);
  5393. this._debugCanvas = null;
  5394. this._debugCanvasContext = null;
  5395. }
  5396. };
  5397. /**
  5398. * Connects two audio nodes
  5399. * @param inputAudioNode defines first node to connect
  5400. * @param outputAudioNode defines second node to connect
  5401. */
  5402. Analyser.prototype.connectAudioNodes = function (inputAudioNode, outputAudioNode) {
  5403. if (this._audioEngine.canUseWebAudio) {
  5404. inputAudioNode.connect(this._webAudioAnalyser);
  5405. this._webAudioAnalyser.connect(outputAudioNode);
  5406. }
  5407. };
  5408. /**
  5409. * Releases all associated resources
  5410. */
  5411. Analyser.prototype.dispose = function () {
  5412. if (this._audioEngine.canUseWebAudio) {
  5413. this._webAudioAnalyser.disconnect();
  5414. }
  5415. };
  5416. return Analyser;
  5417. }());
  5418. /***/ }),
  5419. /***/ "./Audio/audioEngine.ts":
  5420. /*!******************************!*\
  5421. !*** ./Audio/audioEngine.ts ***!
  5422. \******************************/
  5423. /*! exports provided: AudioEngine */
  5424. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5425. "use strict";
  5426. __webpack_require__.r(__webpack_exports__);
  5427. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return AudioEngine; });
  5428. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  5429. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  5430. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5431. // Sets the default audio engine to Babylon.js
  5432. _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].AudioEngineFactory = function (hostElement) { return new AudioEngine(hostElement); };
  5433. /**
  5434. * This represents the default audio engine used in babylon.
  5435. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5436. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5437. */
  5438. var AudioEngine = /** @class */ (function () {
  5439. /**
  5440. * Instantiates a new audio engine.
  5441. *
  5442. * There should be only one per page as some browsers restrict the number
  5443. * of audio contexts you can create.
  5444. * @param hostElement defines the host element where to display the mute icon if necessary
  5445. */
  5446. function AudioEngine(hostElement) {
  5447. if (hostElement === void 0) { hostElement = null; }
  5448. var _this = this;
  5449. this._audioContext = null;
  5450. this._audioContextInitialized = false;
  5451. this._muteButton = null;
  5452. /**
  5453. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5454. */
  5455. this.canUseWebAudio = false;
  5456. /**
  5457. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5458. * @ignoreNaming
  5459. */
  5460. this.WarnedWebAudioUnsupported = false;
  5461. /**
  5462. * Gets whether or not mp3 are supported by your browser.
  5463. */
  5464. this.isMP3supported = false;
  5465. /**
  5466. * Gets whether or not ogg are supported by your browser.
  5467. */
  5468. this.isOGGsupported = false;
  5469. /**
  5470. * Gets whether audio has been unlocked on the device.
  5471. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5472. * a user interaction has happened.
  5473. */
  5474. this.unlocked = true;
  5475. /**
  5476. * Defines if the audio engine relies on a custom unlocked button.
  5477. * In this case, the embedded button will not be displayed.
  5478. */
  5479. this.useCustomUnlockedButton = false;
  5480. /**
  5481. * Event raised when audio has been unlocked on the browser.
  5482. */
  5483. this.onAudioUnlockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5484. /**
  5485. * Event raised when audio has been locked on the browser.
  5486. */
  5487. this.onAudioLockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5488. this._tryToRun = false;
  5489. this._onResize = function () {
  5490. _this._moveButtonToTopLeft();
  5491. };
  5492. if (typeof window.AudioContext !== 'undefined' || typeof window.webkitAudioContext !== 'undefined') {
  5493. window.AudioContext = window.AudioContext || window.webkitAudioContext;
  5494. this.canUseWebAudio = true;
  5495. }
  5496. var audioElem = document.createElement('audio');
  5497. this._hostElement = hostElement;
  5498. try {
  5499. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, '')) {
  5500. this.isMP3supported = true;
  5501. }
  5502. }
  5503. catch (e) {
  5504. // protect error during capability check.
  5505. }
  5506. try {
  5507. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) {
  5508. this.isOGGsupported = true;
  5509. }
  5510. }
  5511. catch (e) {
  5512. // protect error during capability check.
  5513. }
  5514. }
  5515. Object.defineProperty(AudioEngine.prototype, "audioContext", {
  5516. /**
  5517. * Gets the current AudioContext if available.
  5518. */
  5519. get: function () {
  5520. if (!this._audioContextInitialized) {
  5521. this._initializeAudioContext();
  5522. }
  5523. else {
  5524. if (!this.unlocked && !this._muteButton) {
  5525. this._displayMuteButton();
  5526. }
  5527. }
  5528. return this._audioContext;
  5529. },
  5530. enumerable: true,
  5531. configurable: true
  5532. });
  5533. /**
  5534. * Flags the audio engine in Locked state.
  5535. * This happens due to new browser policies preventing audio to autoplay.
  5536. */
  5537. AudioEngine.prototype.lock = function () {
  5538. this._triggerSuspendedState();
  5539. };
  5540. /**
  5541. * Unlocks the audio engine once a user action has been done on the dom.
  5542. * This is helpful to resume play once browser policies have been satisfied.
  5543. */
  5544. AudioEngine.prototype.unlock = function () {
  5545. this._triggerRunningState();
  5546. };
  5547. AudioEngine.prototype._resumeAudioContext = function () {
  5548. var result;
  5549. if (this._audioContext.resume) {
  5550. result = this._audioContext.resume();
  5551. }
  5552. return result || Promise.resolve();
  5553. };
  5554. AudioEngine.prototype._initializeAudioContext = function () {
  5555. try {
  5556. if (this.canUseWebAudio) {
  5557. this._audioContext = new AudioContext();
  5558. // create a global volume gain node
  5559. this.masterGain = this._audioContext.createGain();
  5560. this.masterGain.gain.value = 1;
  5561. this.masterGain.connect(this._audioContext.destination);
  5562. this._audioContextInitialized = true;
  5563. if (this._audioContext.state === "running") {
  5564. // Do not wait for the promise to unlock.
  5565. this._triggerRunningState();
  5566. }
  5567. }
  5568. }
  5569. catch (e) {
  5570. this.canUseWebAudio = false;
  5571. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Web Audio: " + e.message);
  5572. }
  5573. };
  5574. AudioEngine.prototype._triggerRunningState = function () {
  5575. var _this = this;
  5576. if (this._tryToRun) {
  5577. return;
  5578. }
  5579. this._tryToRun = true;
  5580. this._resumeAudioContext()
  5581. .then(function () {
  5582. _this._tryToRun = false;
  5583. if (_this._muteButton) {
  5584. _this._hideMuteButton();
  5585. }
  5586. }).catch(function () {
  5587. _this._tryToRun = false;
  5588. _this.unlocked = false;
  5589. });
  5590. // Notify users that the audio stack is unlocked/unmuted
  5591. this.unlocked = true;
  5592. this.onAudioUnlockedObservable.notifyObservers(this);
  5593. };
  5594. AudioEngine.prototype._triggerSuspendedState = function () {
  5595. this.unlocked = false;
  5596. this.onAudioLockedObservable.notifyObservers(this);
  5597. this._displayMuteButton();
  5598. };
  5599. AudioEngine.prototype._displayMuteButton = function () {
  5600. var _this = this;
  5601. if (this.useCustomUnlockedButton) {
  5602. return;
  5603. }
  5604. this._muteButton = document.createElement("BUTTON");
  5605. this._muteButton.className = "babylonUnmuteIcon";
  5606. this._muteButton.id = "babylonUnmuteIconBtn";
  5607. this._muteButton.title = "Unmute";
  5608. var css = ".babylonUnmuteIcon { position: absolute; left: 20px; top: 20px; height: 40px; width: 60px; background-color: rgba(51,51,51,0.7); background-image: url(data:image/svg+xml;charset=UTF-8,%3Csvg%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2239%22%20height%3D%2232%22%20viewBox%3D%220%200%2039%2032%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M9.625%2018.938l-0.031%200.016h-4.953q-0.016%200-0.031-0.016v-12.453q0-0.016%200.031-0.016h4.953q0.031%200%200.031%200.016v12.453zM12.125%207.688l8.719-8.703v27.453l-8.719-8.719-0.016-0.047v-9.938zM23.359%207.875l1.406-1.406%204.219%204.203%204.203-4.203%201.422%201.406-4.219%204.219%204.219%204.203-1.484%201.359-4.141-4.156-4.219%204.219-1.406-1.422%204.219-4.203z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E); background-size: 80%; background-repeat:no-repeat; background-position: center; background-position-y: 4px; border: none; outline: none; transition: transform 0.125s ease-out; cursor: pointer; z-index: 9999; } .babylonUnmuteIcon:hover { transform: scale(1.05) } .babylonUnmuteIcon:active { background-color: rgba(51,51,51,1) }";
  5609. var style = document.createElement('style');
  5610. style.appendChild(document.createTextNode(css));
  5611. document.getElementsByTagName('head')[0].appendChild(style);
  5612. document.body.appendChild(this._muteButton);
  5613. this._moveButtonToTopLeft();
  5614. this._muteButton.addEventListener('touchend', function () {
  5615. _this._triggerRunningState();
  5616. }, true);
  5617. this._muteButton.addEventListener('click', function () {
  5618. _this._triggerRunningState();
  5619. }, true);
  5620. window.addEventListener("resize", this._onResize);
  5621. };
  5622. AudioEngine.prototype._moveButtonToTopLeft = function () {
  5623. if (this._hostElement && this._muteButton) {
  5624. this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px";
  5625. this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px";
  5626. }
  5627. };
  5628. AudioEngine.prototype._hideMuteButton = function () {
  5629. if (this._muteButton) {
  5630. document.body.removeChild(this._muteButton);
  5631. this._muteButton = null;
  5632. }
  5633. };
  5634. /**
  5635. * Destroy and release the resources associated with the audio ccontext.
  5636. */
  5637. AudioEngine.prototype.dispose = function () {
  5638. if (this.canUseWebAudio && this._audioContextInitialized) {
  5639. if (this._connectedAnalyser && this._audioContext) {
  5640. this._connectedAnalyser.stopDebugCanvas();
  5641. this._connectedAnalyser.dispose();
  5642. this.masterGain.disconnect();
  5643. this.masterGain.connect(this._audioContext.destination);
  5644. this._connectedAnalyser = null;
  5645. }
  5646. this.masterGain.gain.value = 1;
  5647. }
  5648. this.WarnedWebAudioUnsupported = false;
  5649. this._hideMuteButton();
  5650. window.removeEventListener("resize", this._onResize);
  5651. this.onAudioUnlockedObservable.clear();
  5652. this.onAudioLockedObservable.clear();
  5653. };
  5654. /**
  5655. * Gets the global volume sets on the master gain.
  5656. * @returns the global volume if set or -1 otherwise
  5657. */
  5658. AudioEngine.prototype.getGlobalVolume = function () {
  5659. if (this.canUseWebAudio && this._audioContextInitialized) {
  5660. return this.masterGain.gain.value;
  5661. }
  5662. else {
  5663. return -1;
  5664. }
  5665. };
  5666. /**
  5667. * Sets the global volume of your experience (sets on the master gain).
  5668. * @param newVolume Defines the new global volume of the application
  5669. */
  5670. AudioEngine.prototype.setGlobalVolume = function (newVolume) {
  5671. if (this.canUseWebAudio && this._audioContextInitialized) {
  5672. this.masterGain.gain.value = newVolume;
  5673. }
  5674. };
  5675. /**
  5676. * Connect the audio engine to an audio analyser allowing some amazing
  5677. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5679. * @param analyser The analyser to connect to the engine
  5680. */
  5681. AudioEngine.prototype.connectToAnalyser = function (analyser) {
  5682. if (this._connectedAnalyser) {
  5683. this._connectedAnalyser.stopDebugCanvas();
  5684. }
  5685. if (this.canUseWebAudio && this._audioContextInitialized && this._audioContext) {
  5686. this._connectedAnalyser = analyser;
  5687. this.masterGain.disconnect();
  5688. this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination);
  5689. }
  5690. };
  5691. return AudioEngine;
  5692. }());
  5693. /***/ }),
  5694. /***/ "./Audio/audioSceneComponent.ts":
  5695. /*!**************************************!*\
  5696. !*** ./Audio/audioSceneComponent.ts ***!
  5697. \**************************************/
  5698. /*! exports provided: AudioSceneComponent */
  5699. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5700. "use strict";
  5701. __webpack_require__.r(__webpack_exports__);
  5702. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return AudioSceneComponent; });
  5703. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  5704. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  5705. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5706. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  5707. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  5708. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  5709. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  5710. // Adds the parser to the scene parsers.
  5711. _abstractScene__WEBPACK_IMPORTED_MODULE_6__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO, function (parsedData, scene, container, rootUrl) {
  5712. // TODO: add sound
  5713. var loadedSounds = [];
  5714. var loadedSound;
  5715. container.sounds = container.sounds || [];
  5716. if (parsedData.sounds !== undefined && parsedData.sounds !== null) {
  5717. for (var index = 0, cache = parsedData.sounds.length; index < cache; index++) {
  5718. var parsedSound = parsedData.sounds[index];
  5719. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine.canUseWebAudio) {
  5720. if (!parsedSound.url) {
  5721. parsedSound.url = parsedSound.name;
  5722. }
  5723. if (!loadedSounds[parsedSound.url]) {
  5724. loadedSound = _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl);
  5725. loadedSounds[parsedSound.url] = loadedSound;
  5726. container.sounds.push(loadedSound);
  5727. }
  5728. else {
  5729. container.sounds.push(_sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl, loadedSounds[parsedSound.url]));
  5730. }
  5731. }
  5732. else {
  5733. container.sounds.push(new _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"](parsedSound.name, null, scene));
  5734. }
  5735. }
  5736. }
  5737. loadedSounds = [];
  5738. });
  5739. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "mainSoundTrack", {
  5740. get: function () {
  5741. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  5742. if (!compo) {
  5743. compo = new AudioSceneComponent(this);
  5744. this._addComponent(compo);
  5745. }
  5746. if (!this._mainSoundTrack) {
  5747. this._mainSoundTrack = new _soundTrack__WEBPACK_IMPORTED_MODULE_1__["SoundTrack"](this, { mainTrack: true });
  5748. }
  5749. return this._mainSoundTrack;
  5750. },
  5751. enumerable: true,
  5752. configurable: true
  5753. });
  5754. _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype.getSoundByName = function (name) {
  5755. var index;
  5756. for (index = 0; index < this.mainSoundTrack.soundCollection.length; index++) {
  5757. if (this.mainSoundTrack.soundCollection[index].name === name) {
  5758. return this.mainSoundTrack.soundCollection[index];
  5759. }
  5760. }
  5761. if (this.soundTracks) {
  5762. for (var sdIndex = 0; sdIndex < this.soundTracks.length; sdIndex++) {
  5763. for (index = 0; index < this.soundTracks[sdIndex].soundCollection.length; index++) {
  5764. if (this.soundTracks[sdIndex].soundCollection[index].name === name) {
  5765. return this.soundTracks[sdIndex].soundCollection[index];
  5766. }
  5767. }
  5768. }
  5769. }
  5770. return null;
  5771. };
  5772. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "audioEnabled", {
  5773. get: function () {
  5774. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  5775. if (!compo) {
  5776. compo = new AudioSceneComponent(this);
  5777. this._addComponent(compo);
  5778. }
  5779. return compo.audioEnabled;
  5780. },
  5781. set: function (value) {
  5782. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  5783. if (!compo) {
  5784. compo = new AudioSceneComponent(this);
  5785. this._addComponent(compo);
  5786. }
  5787. if (value) {
  5788. compo.enableAudio();
  5789. }
  5790. else {
  5791. compo.disableAudio();
  5792. }
  5793. },
  5794. enumerable: true,
  5795. configurable: true
  5796. });
  5797. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "headphone", {
  5798. get: function () {
  5799. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  5800. if (!compo) {
  5801. compo = new AudioSceneComponent(this);
  5802. this._addComponent(compo);
  5803. }
  5804. return compo.headphone;
  5805. },
  5806. set: function (value) {
  5807. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  5808. if (!compo) {
  5809. compo = new AudioSceneComponent(this);
  5810. this._addComponent(compo);
  5811. }
  5812. if (value) {
  5813. compo.switchAudioModeForHeadphones();
  5814. }
  5815. else {
  5816. compo.switchAudioModeForNormalSpeakers();
  5817. }
  5818. },
  5819. enumerable: true,
  5820. configurable: true
  5821. });
  5822. /**
  5823. * Defines the sound scene component responsible to manage any sounds
  5824. * in a given scene.
  5825. */
  5826. var AudioSceneComponent = /** @class */ (function () {
  5827. /**
  5828. * Creates a new instance of the component for the given scene
  5829. * @param scene Defines the scene to register the component in
  5830. */
  5831. function AudioSceneComponent(scene) {
  5832. /**
  5833. * The component name helpfull to identify the component in the list of scene components.
  5834. */
  5835. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO;
  5836. this._audioEnabled = true;
  5837. this._headphone = false;
  5838. this.scene = scene;
  5839. scene.soundTracks = new Array();
  5840. scene.sounds = new Array();
  5841. }
  5842. Object.defineProperty(AudioSceneComponent.prototype, "audioEnabled", {
  5843. /**
  5844. * Gets whether audio is enabled or not.
  5845. * Please use related enable/disable method to switch state.
  5846. */
  5847. get: function () {
  5848. return this._audioEnabled;
  5849. },
  5850. enumerable: true,
  5851. configurable: true
  5852. });
  5853. Object.defineProperty(AudioSceneComponent.prototype, "headphone", {
  5854. /**
  5855. * Gets whether audio is outputing to headphone or not.
  5856. * Please use the according Switch methods to change output.
  5857. */
  5858. get: function () {
  5859. return this._headphone;
  5860. },
  5861. enumerable: true,
  5862. configurable: true
  5863. });
  5864. /**
  5865. * Registers the component in a given scene
  5866. */
  5867. AudioSceneComponent.prototype.register = function () {
  5868. this.scene._afterRenderStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDER_AUDIO, this, this._afterRender);
  5869. };
  5870. /**
  5871. * Rebuilds the elements related to this component in case of
  5872. * context lost for instance.
  5873. */
  5874. AudioSceneComponent.prototype.rebuild = function () {
  5875. // Nothing to do here. (Not rendering related)
  5876. };
  5877. /**
  5878. * Serializes the component data to the specified json object
  5879. * @param serializationObject The object to serialize to
  5880. */
  5881. AudioSceneComponent.prototype.serialize = function (serializationObject) {
  5882. serializationObject.sounds = [];
  5883. if (this.scene.soundTracks) {
  5884. for (var index = 0; index < this.scene.soundTracks.length; index++) {
  5885. var soundtrack = this.scene.soundTracks[index];
  5886. for (var soundId = 0; soundId < soundtrack.soundCollection.length; soundId++) {
  5887. serializationObject.sounds.push(soundtrack.soundCollection[soundId].serialize());
  5888. }
  5889. }
  5890. }
  5891. };
  5892. /**
  5893. * Adds all the element from the container to the scene
  5894. * @param container the container holding the elements
  5895. */
  5896. AudioSceneComponent.prototype.addFromContainer = function (container) {
  5897. var _this = this;
  5898. if (!container.sounds) {
  5899. return;
  5900. }
  5901. container.sounds.forEach(function (sound) {
  5902. sound.play();
  5903. sound.autoplay = true;
  5904. _this.scene.mainSoundTrack.AddSound(sound);
  5905. });
  5906. };
  5907. /**
  5908. * Removes all the elements in the container from the scene
  5909. * @param container contains the elements to remove
  5910. */
  5911. AudioSceneComponent.prototype.removeFromContainer = function (container) {
  5912. var _this = this;
  5913. if (!container.sounds) {
  5914. return;
  5915. }
  5916. container.sounds.forEach(function (sound) {
  5917. sound.stop();
  5918. sound.autoplay = false;
  5919. _this.scene.mainSoundTrack.RemoveSound(sound);
  5920. });
  5921. };
  5922. /**
  5923. * Disposes the component and the associated ressources.
  5924. */
  5925. AudioSceneComponent.prototype.dispose = function () {
  5926. var scene = this.scene;
  5927. if (scene._mainSoundTrack) {
  5928. scene.mainSoundTrack.dispose();
  5929. }
  5930. if (scene.soundTracks) {
  5931. for (var scIndex = 0; scIndex < scene.soundTracks.length; scIndex++) {
  5932. scene.soundTracks[scIndex].dispose();
  5933. }
  5934. }
  5935. };
  5936. /**
  5937. * Disables audio in the associated scene.
  5938. */
  5939. AudioSceneComponent.prototype.disableAudio = function () {
  5940. var scene = this.scene;
  5941. this._audioEnabled = false;
  5942. var i;
  5943. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  5944. scene.mainSoundTrack.soundCollection[i].pause();
  5945. }
  5946. if (scene.soundTracks) {
  5947. for (i = 0; i < scene.soundTracks.length; i++) {
  5948. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  5949. scene.soundTracks[i].soundCollection[j].pause();
  5950. }
  5951. }
  5952. }
  5953. };
  5954. /**
  5955. * Enables audio in the associated scene.
  5956. */
  5957. AudioSceneComponent.prototype.enableAudio = function () {
  5958. var scene = this.scene;
  5959. this._audioEnabled = true;
  5960. var i;
  5961. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  5962. if (scene.mainSoundTrack.soundCollection[i].isPaused) {
  5963. scene.mainSoundTrack.soundCollection[i].play();
  5964. }
  5965. }
  5966. if (scene.soundTracks) {
  5967. for (i = 0; i < scene.soundTracks.length; i++) {
  5968. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  5969. if (scene.soundTracks[i].soundCollection[j].isPaused) {
  5970. scene.soundTracks[i].soundCollection[j].play();
  5971. }
  5972. }
  5973. }
  5974. }
  5975. };
  5976. /**
  5977. * Switch audio to headphone output.
  5978. */
  5979. AudioSceneComponent.prototype.switchAudioModeForHeadphones = function () {
  5980. var scene = this.scene;
  5981. this._headphone = true;
  5982. scene.mainSoundTrack.switchPanningModelToHRTF();
  5983. if (scene.soundTracks) {
  5984. for (var i = 0; i < scene.soundTracks.length; i++) {
  5985. scene.soundTracks[i].switchPanningModelToHRTF();
  5986. }
  5987. }
  5988. };
  5989. /**
  5990. * Switch audio to normal speakers.
  5991. */
  5992. AudioSceneComponent.prototype.switchAudioModeForNormalSpeakers = function () {
  5993. var scene = this.scene;
  5994. this._headphone = false;
  5995. scene.mainSoundTrack.switchPanningModelToEqualPower();
  5996. if (scene.soundTracks) {
  5997. for (var i = 0; i < scene.soundTracks.length; i++) {
  5998. scene.soundTracks[i].switchPanningModelToEqualPower();
  5999. }
  6000. }
  6001. };
  6002. AudioSceneComponent.prototype._afterRender = function () {
  6003. var scene = this.scene;
  6004. if (!this._audioEnabled || !scene._mainSoundTrack || !scene.soundTracks || (scene._mainSoundTrack.soundCollection.length === 0 && scene.soundTracks.length === 1)) {
  6005. return;
  6006. }
  6007. var listeningCamera;
  6008. var audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine;
  6009. if (scene.activeCameras.length > 0) {
  6010. listeningCamera = scene.activeCameras[0];
  6011. }
  6012. else {
  6013. listeningCamera = scene.activeCamera;
  6014. }
  6015. if (listeningCamera && audioEngine.audioContext) {
  6016. audioEngine.audioContext.listener.setPosition(listeningCamera.position.x, listeningCamera.position.y, listeningCamera.position.z);
  6017. // for VR cameras
  6018. if (listeningCamera.rigCameras && listeningCamera.rigCameras.length > 0) {
  6019. listeningCamera = listeningCamera.rigCameras[0];
  6020. }
  6021. var mat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(listeningCamera.getViewMatrix());
  6022. var cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1), mat);
  6023. cameraDirection.normalize();
  6024. // To avoid some errors on GearVR
  6025. if (!isNaN(cameraDirection.x) && !isNaN(cameraDirection.y) && !isNaN(cameraDirection.z)) {
  6026. audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
  6027. }
  6028. var i;
  6029. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6030. var sound = scene.mainSoundTrack.soundCollection[i];
  6031. if (sound.useCustomAttenuation) {
  6032. sound.updateDistanceFromListener();
  6033. }
  6034. }
  6035. if (scene.soundTracks) {
  6036. for (i = 0; i < scene.soundTracks.length; i++) {
  6037. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6038. sound = scene.soundTracks[i].soundCollection[j];
  6039. if (sound.useCustomAttenuation) {
  6040. sound.updateDistanceFromListener();
  6041. }
  6042. }
  6043. }
  6044. }
  6045. }
  6046. };
  6047. return AudioSceneComponent;
  6048. }());
  6049. _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"]._SceneComponentInitialization = function (scene) {
  6050. var compo = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6051. if (!compo) {
  6052. compo = new AudioSceneComponent(scene);
  6053. scene._addComponent(compo);
  6054. }
  6055. };
  6056. /***/ }),
  6057. /***/ "./Audio/index.ts":
  6058. /*!************************!*\
  6059. !*** ./Audio/index.ts ***!
  6060. \************************/
  6061. /*! exports provided: Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound */
  6062. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6063. "use strict";
  6064. __webpack_require__.r(__webpack_exports__);
  6065. /* harmony import */ var _analyser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./analyser */ "./Audio/analyser.ts");
  6066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _analyser__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  6067. /* harmony import */ var _audioEngine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./audioEngine */ "./Audio/audioEngine.ts");
  6068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _audioEngine__WEBPACK_IMPORTED_MODULE_1__["AudioEngine"]; });
  6069. /* harmony import */ var _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./audioSceneComponent */ "./Audio/audioSceneComponent.ts");
  6070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__["AudioSceneComponent"]; });
  6071. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _sound__WEBPACK_IMPORTED_MODULE_3__["Sound"]; });
  6073. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _soundTrack__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  6075. /* harmony import */ var _weightedsound__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./weightedsound */ "./Audio/weightedsound.ts");
  6076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _weightedsound__WEBPACK_IMPORTED_MODULE_5__["WeightedSound"]; });
  6077. /***/ }),
  6078. /***/ "./Audio/sound.ts":
  6079. /*!************************!*\
  6080. !*** ./Audio/sound.ts ***!
  6081. \************************/
  6082. /*! exports provided: Sound */
  6083. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6084. "use strict";
  6085. __webpack_require__.r(__webpack_exports__);
  6086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return Sound; });
  6087. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  6088. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  6089. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6090. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6091. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  6092. /**
  6093. * Defines a sound that can be played in the application.
  6094. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  6095. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6096. */
  6097. var Sound = /** @class */ (function () {
  6098. /**
  6099. * Create a sound and attach it to a scene
  6100. * @param name Name of your sound
  6101. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  6102. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  6103. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  6104. */
  6105. function Sound(name, urlOrArrayBuffer, scene, readyToPlayCallback, options) {
  6106. if (readyToPlayCallback === void 0) { readyToPlayCallback = null; }
  6107. var _this = this;
  6108. /**
  6109. * Does the sound autoplay once loaded.
  6110. */
  6111. this.autoplay = false;
  6112. /**
  6113. * Does the sound loop after it finishes playing once.
  6114. */
  6115. this.loop = false;
  6116. /**
  6117. * Does the sound use a custom attenuation curve to simulate the falloff
  6118. * happening when the source gets further away from the camera.
  6119. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6120. */
  6121. this.useCustomAttenuation = false;
  6122. /**
  6123. * Is this sound currently played.
  6124. */
  6125. this.isPlaying = false;
  6126. /**
  6127. * Is this sound currently paused.
  6128. */
  6129. this.isPaused = false;
  6130. /**
  6131. * Does this sound enables spatial sound.
  6132. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6133. */
  6134. this.spatialSound = false;
  6135. /**
  6136. * Define the reference distance the sound should be heard perfectly.
  6137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6138. */
  6139. this.refDistance = 1;
  6140. /**
  6141. * Define the roll off factor of spatial sounds.
  6142. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6143. */
  6144. this.rolloffFactor = 1;
  6145. /**
  6146. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  6147. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6148. */
  6149. this.maxDistance = 100;
  6150. /**
  6151. * Define the distance attenuation model the sound will follow.
  6152. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6153. */
  6154. this.distanceModel = "linear";
  6155. /**
  6156. * Observable event when the current playing sound finishes.
  6157. */
  6158. this.onEndedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6159. this._panningModel = "equalpower";
  6160. this._playbackRate = 1;
  6161. this._streaming = false;
  6162. this._startTime = 0;
  6163. this._startOffset = 0;
  6164. this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  6165. /** @hidden */
  6166. this._positionInEmitterSpace = false;
  6167. this._localDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 0, 0);
  6168. this._volume = 1;
  6169. this._isReadyToPlay = false;
  6170. this._isDirectional = false;
  6171. // Used if you'd like to create a directional sound.
  6172. // If not set, the sound will be omnidirectional
  6173. this._coneInnerAngle = 360;
  6174. this._coneOuterAngle = 360;
  6175. this._coneOuterGain = 0;
  6176. this._isOutputConnected = false;
  6177. this._urlType = "Unknown";
  6178. this.name = name;
  6179. this._scene = scene;
  6180. Sound._SceneComponentInitialization(scene);
  6181. this._readyToPlayCallback = readyToPlayCallback;
  6182. // Default custom attenuation function is a linear attenuation
  6183. this._customAttenuationFunction = function (currentVolume, currentDistance, maxDistance, refDistance, rolloffFactor) {
  6184. if (currentDistance < maxDistance) {
  6185. return currentVolume * (1 - currentDistance / maxDistance);
  6186. }
  6187. else {
  6188. return 0;
  6189. }
  6190. };
  6191. if (options) {
  6192. this.autoplay = options.autoplay || false;
  6193. this.loop = options.loop || false;
  6194. // if volume === 0, we need another way to check this option
  6195. if (options.volume !== undefined) {
  6196. this._volume = options.volume;
  6197. }
  6198. this.spatialSound = options.spatialSound || false;
  6199. this.maxDistance = options.maxDistance || 100;
  6200. this.useCustomAttenuation = options.useCustomAttenuation || false;
  6201. this.rolloffFactor = options.rolloffFactor || 1;
  6202. this.refDistance = options.refDistance || 1;
  6203. this.distanceModel = options.distanceModel || "linear";
  6204. this._playbackRate = options.playbackRate || 1;
  6205. this._streaming = options.streaming || false;
  6206. }
  6207. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6208. this._soundGain = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createGain();
  6209. this._soundGain.gain.value = this._volume;
  6210. this._inputAudioNode = this._soundGain;
  6211. this._outputAudioNode = this._soundGain;
  6212. if (this.spatialSound) {
  6213. this._createSpatialParameters();
  6214. }
  6215. this._scene.mainSoundTrack.AddSound(this);
  6216. var validParameter = true;
  6217. // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound
  6218. if (urlOrArrayBuffer) {
  6219. try {
  6220. if (typeof (urlOrArrayBuffer) === "string") {
  6221. this._urlType = "String";
  6222. }
  6223. else if (urlOrArrayBuffer instanceof ArrayBuffer) {
  6224. this._urlType = "ArrayBuffer";
  6225. }
  6226. else if (urlOrArrayBuffer instanceof MediaStream) {
  6227. this._urlType = "MediaStream";
  6228. }
  6229. else if (Array.isArray(urlOrArrayBuffer)) {
  6230. this._urlType = "Array";
  6231. }
  6232. var urls = [];
  6233. var codecSupportedFound = false;
  6234. switch (this._urlType) {
  6235. case "MediaStream":
  6236. this._streaming = true;
  6237. this._isReadyToPlay = true;
  6238. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);
  6239. if (this.autoplay) {
  6240. this.play();
  6241. }
  6242. if (this._readyToPlayCallback) {
  6243. this._readyToPlayCallback();
  6244. }
  6245. break;
  6246. case "ArrayBuffer":
  6247. if (urlOrArrayBuffer.byteLength > 0) {
  6248. codecSupportedFound = true;
  6249. this._soundLoaded(urlOrArrayBuffer);
  6250. }
  6251. break;
  6252. case "String":
  6253. urls.push(urlOrArrayBuffer);
  6254. case "Array":
  6255. if (urls.length === 0) {
  6256. urls = urlOrArrayBuffer;
  6257. }
  6258. // If we found a supported format, we load it immediately and stop the loop
  6259. for (var i = 0; i < urls.length; i++) {
  6260. var url = urls[i];
  6261. if (url.indexOf(".mp3", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isMP3supported) {
  6262. codecSupportedFound = true;
  6263. }
  6264. if (url.indexOf(".ogg", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isOGGsupported) {
  6265. codecSupportedFound = true;
  6266. }
  6267. if (url.indexOf(".wav", url.length - 4) !== -1) {
  6268. codecSupportedFound = true;
  6269. }
  6270. if (url.indexOf("blob:") !== -1) {
  6271. codecSupportedFound = true;
  6272. }
  6273. if (codecSupportedFound) {
  6274. // Loading sound using XHR2
  6275. if (!this._streaming) {
  6276. this._scene._loadFile(url, function (data) {
  6277. _this._soundLoaded(data);
  6278. }, undefined, true, true, function (exception) {
  6279. if (exception) {
  6280. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("XHR " + exception.status + " error on: " + url + ".");
  6281. }
  6282. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Sound creation aborted.");
  6283. _this._scene.mainSoundTrack.RemoveSound(_this);
  6284. });
  6285. }
  6286. // Streaming sound using HTML5 Audio tag
  6287. else {
  6288. this._htmlAudioElement = new Audio(url);
  6289. this._htmlAudioElement.controls = false;
  6290. this._htmlAudioElement.loop = this.loop;
  6291. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetCorsBehavior(url, this._htmlAudioElement);
  6292. this._htmlAudioElement.preload = "auto";
  6293. this._htmlAudioElement.addEventListener("canplaythrough", function () {
  6294. _this._isReadyToPlay = true;
  6295. if (_this.autoplay) {
  6296. _this.play();
  6297. }
  6298. if (_this._readyToPlayCallback) {
  6299. _this._readyToPlayCallback();
  6300. }
  6301. });
  6302. document.body.appendChild(this._htmlAudioElement);
  6303. this._htmlAudioElement.load();
  6304. }
  6305. break;
  6306. }
  6307. }
  6308. break;
  6309. default:
  6310. validParameter = false;
  6311. break;
  6312. }
  6313. if (!validParameter) {
  6314. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.");
  6315. }
  6316. else {
  6317. if (!codecSupportedFound) {
  6318. this._isReadyToPlay = true;
  6319. // Simulating a ready to play event to avoid breaking code path
  6320. if (this._readyToPlayCallback) {
  6321. window.setTimeout(function () {
  6322. if (_this._readyToPlayCallback) {
  6323. _this._readyToPlayCallback();
  6324. }
  6325. }, 1000);
  6326. }
  6327. }
  6328. }
  6329. }
  6330. catch (ex) {
  6331. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Unexpected error. Sound creation aborted.");
  6332. this._scene.mainSoundTrack.RemoveSound(this);
  6333. }
  6334. }
  6335. }
  6336. else {
  6337. // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers
  6338. this._scene.mainSoundTrack.AddSound(this);
  6339. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported) {
  6340. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Web Audio is not supported by your browser.");
  6341. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported = true;
  6342. }
  6343. // Simulating a ready to play event to avoid breaking code for non web audio browsers
  6344. if (this._readyToPlayCallback) {
  6345. window.setTimeout(function () {
  6346. if (_this._readyToPlayCallback) {
  6347. _this._readyToPlayCallback();
  6348. }
  6349. }, 1000);
  6350. }
  6351. }
  6352. }
  6353. /**
  6354. * Release the sound and its associated resources
  6355. */
  6356. Sound.prototype.dispose = function () {
  6357. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6358. if (this.isPlaying) {
  6359. this.stop();
  6360. }
  6361. this._isReadyToPlay = false;
  6362. if (this.soundTrackId === -1) {
  6363. this._scene.mainSoundTrack.RemoveSound(this);
  6364. }
  6365. else if (this._scene.soundTracks) {
  6366. this._scene.soundTracks[this.soundTrackId].RemoveSound(this);
  6367. }
  6368. if (this._soundGain) {
  6369. this._soundGain.disconnect();
  6370. this._soundGain = null;
  6371. }
  6372. if (this._soundPanner) {
  6373. this._soundPanner.disconnect();
  6374. this._soundPanner = null;
  6375. }
  6376. if (this._soundSource) {
  6377. this._soundSource.disconnect();
  6378. this._soundSource = null;
  6379. }
  6380. this._audioBuffer = null;
  6381. if (this._htmlAudioElement) {
  6382. this._htmlAudioElement.pause();
  6383. this._htmlAudioElement.src = "";
  6384. document.body.removeChild(this._htmlAudioElement);
  6385. }
  6386. if (this._streamingSource) {
  6387. this._streamingSource.disconnect();
  6388. }
  6389. if (this._connectedTransformNode && this._registerFunc) {
  6390. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6391. this._connectedTransformNode = null;
  6392. }
  6393. }
  6394. };
  6395. /**
  6396. * Gets if the sounds is ready to be played or not.
  6397. * @returns true if ready, otherwise false
  6398. */
  6399. Sound.prototype.isReady = function () {
  6400. return this._isReadyToPlay;
  6401. };
  6402. Sound.prototype._soundLoaded = function (audioData) {
  6403. var _this = this;
  6404. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6405. return;
  6406. }
  6407. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.decodeAudioData(audioData, function (buffer) {
  6408. _this._audioBuffer = buffer;
  6409. _this._isReadyToPlay = true;
  6410. if (_this.autoplay) {
  6411. _this.play();
  6412. }
  6413. if (_this._readyToPlayCallback) {
  6414. _this._readyToPlayCallback();
  6415. }
  6416. }, function (err) { _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while decoding audio data for: " + _this.name + " / Error: " + err); });
  6417. };
  6418. /**
  6419. * Sets the data of the sound from an audiobuffer
  6420. * @param audioBuffer The audioBuffer containing the data
  6421. */
  6422. Sound.prototype.setAudioBuffer = function (audioBuffer) {
  6423. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6424. this._audioBuffer = audioBuffer;
  6425. this._isReadyToPlay = true;
  6426. }
  6427. };
  6428. /**
  6429. * Updates the current sounds options such as maxdistance, loop...
  6430. * @param options A JSON object containing values named as the object properties
  6431. */
  6432. Sound.prototype.updateOptions = function (options) {
  6433. if (options) {
  6434. this.loop = options.loop || this.loop;
  6435. this.maxDistance = options.maxDistance || this.maxDistance;
  6436. this.useCustomAttenuation = options.useCustomAttenuation || this.useCustomAttenuation;
  6437. this.rolloffFactor = options.rolloffFactor || this.rolloffFactor;
  6438. this.refDistance = options.refDistance || this.refDistance;
  6439. this.distanceModel = options.distanceModel || this.distanceModel;
  6440. this._playbackRate = options.playbackRate || this._playbackRate;
  6441. this._updateSpatialParameters();
  6442. if (this.isPlaying) {
  6443. if (this._streaming && this._htmlAudioElement) {
  6444. this._htmlAudioElement.playbackRate = this._playbackRate;
  6445. }
  6446. else {
  6447. if (this._soundSource) {
  6448. this._soundSource.playbackRate.value = this._playbackRate;
  6449. }
  6450. }
  6451. }
  6452. }
  6453. };
  6454. Sound.prototype._createSpatialParameters = function () {
  6455. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6456. if (this._scene.headphone) {
  6457. this._panningModel = "HRTF";
  6458. }
  6459. this._soundPanner = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createPanner();
  6460. this._updateSpatialParameters();
  6461. this._soundPanner.connect(this._outputAudioNode);
  6462. this._inputAudioNode = this._soundPanner;
  6463. }
  6464. };
  6465. Sound.prototype._updateSpatialParameters = function () {
  6466. if (this.spatialSound && this._soundPanner) {
  6467. if (this.useCustomAttenuation) {
  6468. // Tricks to disable in a way embedded Web Audio attenuation
  6469. this._soundPanner.distanceModel = "linear";
  6470. this._soundPanner.maxDistance = Number.MAX_VALUE;
  6471. this._soundPanner.refDistance = 1;
  6472. this._soundPanner.rolloffFactor = 1;
  6473. this._soundPanner.panningModel = this._panningModel;
  6474. }
  6475. else {
  6476. this._soundPanner.distanceModel = this.distanceModel;
  6477. this._soundPanner.maxDistance = this.maxDistance;
  6478. this._soundPanner.refDistance = this.refDistance;
  6479. this._soundPanner.rolloffFactor = this.rolloffFactor;
  6480. this._soundPanner.panningModel = this._panningModel;
  6481. }
  6482. }
  6483. };
  6484. /**
  6485. * Switch the panning model to HRTF:
  6486. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  6487. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6488. */
  6489. Sound.prototype.switchPanningModelToHRTF = function () {
  6490. this._panningModel = "HRTF";
  6491. this._switchPanningModel();
  6492. };
  6493. /**
  6494. * Switch the panning model to Equal Power:
  6495. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  6496. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6497. */
  6498. Sound.prototype.switchPanningModelToEqualPower = function () {
  6499. this._panningModel = "equalpower";
  6500. this._switchPanningModel();
  6501. };
  6502. Sound.prototype._switchPanningModel = function () {
  6503. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6504. this._soundPanner.panningModel = this._panningModel;
  6505. }
  6506. };
  6507. /**
  6508. * Connect this sound to a sound track audio node like gain...
  6509. * @param soundTrackAudioNode the sound track audio node to connect to
  6510. */
  6511. Sound.prototype.connectToSoundTrackAudioNode = function (soundTrackAudioNode) {
  6512. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6513. if (this._isOutputConnected) {
  6514. this._outputAudioNode.disconnect();
  6515. }
  6516. this._outputAudioNode.connect(soundTrackAudioNode);
  6517. this._isOutputConnected = true;
  6518. }
  6519. };
  6520. /**
  6521. * Transform this sound into a directional source
  6522. * @param coneInnerAngle Size of the inner cone in degree
  6523. * @param coneOuterAngle Size of the outer cone in degree
  6524. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  6525. */
  6526. Sound.prototype.setDirectionalCone = function (coneInnerAngle, coneOuterAngle, coneOuterGain) {
  6527. if (coneOuterAngle < coneInnerAngle) {
  6528. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
  6529. return;
  6530. }
  6531. this._coneInnerAngle = coneInnerAngle;
  6532. this._coneOuterAngle = coneOuterAngle;
  6533. this._coneOuterGain = coneOuterGain;
  6534. this._isDirectional = true;
  6535. if (this.isPlaying && this.loop) {
  6536. this.stop();
  6537. this.play();
  6538. }
  6539. };
  6540. Object.defineProperty(Sound.prototype, "directionalConeInnerAngle", {
  6541. /**
  6542. * Gets or sets the inner angle for the directional cone.
  6543. */
  6544. get: function () {
  6545. return this._coneInnerAngle;
  6546. },
  6547. /**
  6548. * Gets or sets the inner angle for the directional cone.
  6549. */
  6550. set: function (value) {
  6551. if (value != this._coneInnerAngle) {
  6552. if (this._coneOuterAngle < value) {
  6553. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6554. return;
  6555. }
  6556. this._coneInnerAngle = value;
  6557. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6558. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6559. }
  6560. }
  6561. },
  6562. enumerable: true,
  6563. configurable: true
  6564. });
  6565. Object.defineProperty(Sound.prototype, "directionalConeOuterAngle", {
  6566. /**
  6567. * Gets or sets the outer angle for the directional cone.
  6568. */
  6569. get: function () {
  6570. return this._coneOuterAngle;
  6571. },
  6572. /**
  6573. * Gets or sets the outer angle for the directional cone.
  6574. */
  6575. set: function (value) {
  6576. if (value != this._coneOuterAngle) {
  6577. if (value < this._coneInnerAngle) {
  6578. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6579. return;
  6580. }
  6581. this._coneOuterAngle = value;
  6582. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6583. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6584. }
  6585. }
  6586. },
  6587. enumerable: true,
  6588. configurable: true
  6589. });
  6590. /**
  6591. * Sets the position of the emitter if spatial sound is enabled
  6592. * @param newPosition Defines the new posisiton
  6593. */
  6594. Sound.prototype.setPosition = function (newPosition) {
  6595. this._position = newPosition;
  6596. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner && !isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  6597. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6598. }
  6599. };
  6600. /**
  6601. * Sets the local direction of the emitter if spatial sound is enabled
  6602. * @param newLocalDirection Defines the new local direction
  6603. */
  6604. Sound.prototype.setLocalDirectionToMesh = function (newLocalDirection) {
  6605. this._localDirection = newLocalDirection;
  6606. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {
  6607. this._updateDirection();
  6608. }
  6609. };
  6610. Sound.prototype._updateDirection = function () {
  6611. if (!this._connectedTransformNode || !this._soundPanner) {
  6612. return;
  6613. }
  6614. var mat = this._connectedTransformNode.getWorldMatrix();
  6615. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(this._localDirection, mat);
  6616. direction.normalize();
  6617. this._soundPanner.setOrientation(direction.x, direction.y, direction.z);
  6618. };
  6619. /** @hidden */
  6620. Sound.prototype.updateDistanceFromListener = function () {
  6621. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
  6622. var distance = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
  6623. this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);
  6624. }
  6625. };
  6626. /**
  6627. * Sets a new custom attenuation function for the sound.
  6628. * @param callback Defines the function used for the attenuation
  6629. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6630. */
  6631. Sound.prototype.setAttenuationFunction = function (callback) {
  6632. this._customAttenuationFunction = callback;
  6633. };
  6634. /**
  6635. * Play the sound
  6636. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  6637. * @param offset (optional) Start the sound setting it at a specific time
  6638. */
  6639. Sound.prototype.play = function (time, offset) {
  6640. var _this = this;
  6641. if (this._isReadyToPlay && this._scene.audioEnabled && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6642. try {
  6643. if (this._startOffset < 0) {
  6644. time = -this._startOffset;
  6645. this._startOffset = 0;
  6646. }
  6647. var startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  6648. if (!this._soundSource || !this._streamingSource) {
  6649. if (this.spatialSound && this._soundPanner) {
  6650. if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  6651. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6652. }
  6653. if (this._isDirectional) {
  6654. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6655. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6656. this._soundPanner.coneOuterGain = this._coneOuterGain;
  6657. if (this._connectedTransformNode) {
  6658. this._updateDirection();
  6659. }
  6660. else {
  6661. this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);
  6662. }
  6663. }
  6664. }
  6665. }
  6666. if (this._streaming) {
  6667. if (!this._streamingSource) {
  6668. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);
  6669. this._htmlAudioElement.onended = function () { _this._onended(); };
  6670. this._htmlAudioElement.playbackRate = this._playbackRate;
  6671. }
  6672. this._streamingSource.disconnect();
  6673. this._streamingSource.connect(this._inputAudioNode);
  6674. if (this._htmlAudioElement) {
  6675. // required to manage properly the new suspended default state of Chrome
  6676. // When the option 'streaming: true' is used, we need first to wait for
  6677. // the audio engine to be unlocked by a user gesture before trying to play
  6678. // an HTML Audio elememt
  6679. var tryToPlay = function () {
  6680. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.unlocked) {
  6681. var playPromise = _this._htmlAudioElement.play();
  6682. // In browsers that don’t yet support this functionality,
  6683. // playPromise won’t be defined.
  6684. if (playPromise !== undefined) {
  6685. playPromise.catch(function (error) {
  6686. // Automatic playback failed.
  6687. // Waiting for the audio engine to be unlocked by user click on unmute
  6688. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  6689. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  6690. });
  6691. }
  6692. }
  6693. else {
  6694. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  6695. }
  6696. };
  6697. tryToPlay();
  6698. }
  6699. }
  6700. else {
  6701. this._soundSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createBufferSource();
  6702. this._soundSource.buffer = this._audioBuffer;
  6703. this._soundSource.connect(this._inputAudioNode);
  6704. this._soundSource.loop = this.loop;
  6705. this._soundSource.playbackRate.value = this._playbackRate;
  6706. this._soundSource.onended = function () { _this._onended(); };
  6707. if (this._soundSource.buffer) {
  6708. this._soundSource.start(startTime, this.isPaused ? this._startOffset % this._soundSource.buffer.duration : offset ? offset : 0);
  6709. }
  6710. }
  6711. this._startTime = startTime;
  6712. this.isPlaying = true;
  6713. this.isPaused = false;
  6714. }
  6715. catch (ex) {
  6716. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while trying to play audio: " + this.name + ", " + ex.message);
  6717. }
  6718. }
  6719. };
  6720. Sound.prototype._onended = function () {
  6721. this.isPlaying = false;
  6722. if (this.onended) {
  6723. this.onended();
  6724. }
  6725. this.onEndedObservable.notifyObservers(this);
  6726. };
  6727. /**
  6728. * Stop the sound
  6729. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  6730. */
  6731. Sound.prototype.stop = function (time) {
  6732. if (this.isPlaying) {
  6733. if (this._streaming) {
  6734. if (this._htmlAudioElement) {
  6735. this._htmlAudioElement.pause();
  6736. // Test needed for Firefox or it will generate an Invalid State Error
  6737. if (this._htmlAudioElement.currentTime > 0) {
  6738. this._htmlAudioElement.currentTime = 0;
  6739. }
  6740. }
  6741. else {
  6742. this._streamingSource.disconnect();
  6743. }
  6744. }
  6745. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext && this._soundSource) {
  6746. var stopTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  6747. this._soundSource.stop(stopTime);
  6748. this._soundSource.onended = function () { };
  6749. if (!this.isPaused) {
  6750. this._startOffset = 0;
  6751. }
  6752. }
  6753. this.isPlaying = false;
  6754. }
  6755. };
  6756. /**
  6757. * Put the sound in pause
  6758. */
  6759. Sound.prototype.pause = function () {
  6760. if (this.isPlaying) {
  6761. this.isPaused = true;
  6762. if (this._streaming) {
  6763. if (this._htmlAudioElement) {
  6764. this._htmlAudioElement.pause();
  6765. }
  6766. else {
  6767. this._streamingSource.disconnect();
  6768. }
  6769. }
  6770. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6771. this.stop(0);
  6772. this._startOffset += _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime - this._startTime;
  6773. }
  6774. }
  6775. };
  6776. /**
  6777. * Sets a dedicated volume for this sounds
  6778. * @param newVolume Define the new volume of the sound
  6779. * @param time Define in how long the sound should be at this value
  6780. */
  6781. Sound.prototype.setVolume = function (newVolume, time) {
  6782. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._soundGain) {
  6783. if (time && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6784. this._soundGain.gain.cancelScheduledValues(_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  6785. this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  6786. this._soundGain.gain.linearRampToValueAtTime(newVolume, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time);
  6787. }
  6788. else {
  6789. this._soundGain.gain.value = newVolume;
  6790. }
  6791. }
  6792. this._volume = newVolume;
  6793. };
  6794. /**
  6795. * Set the sound play back rate
  6796. * @param newPlaybackRate Define the playback rate the sound should be played at
  6797. */
  6798. Sound.prototype.setPlaybackRate = function (newPlaybackRate) {
  6799. this._playbackRate = newPlaybackRate;
  6800. if (this.isPlaying) {
  6801. if (this._streaming && this._htmlAudioElement) {
  6802. this._htmlAudioElement.playbackRate = this._playbackRate;
  6803. }
  6804. else if (this._soundSource) {
  6805. this._soundSource.playbackRate.value = this._playbackRate;
  6806. }
  6807. }
  6808. };
  6809. /**
  6810. * Gets the volume of the sound.
  6811. * @returns the volume of the sound
  6812. */
  6813. Sound.prototype.getVolume = function () {
  6814. return this._volume;
  6815. };
  6816. /**
  6817. * Attach the sound to a dedicated mesh
  6818. * @param transformNode The transform node to connect the sound with
  6819. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  6820. */
  6821. Sound.prototype.attachToMesh = function (transformNode) {
  6822. var _this = this;
  6823. if (this._connectedTransformNode && this._registerFunc) {
  6824. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6825. this._registerFunc = null;
  6826. }
  6827. this._connectedTransformNode = transformNode;
  6828. if (!this.spatialSound) {
  6829. this.spatialSound = true;
  6830. this._createSpatialParameters();
  6831. if (this.isPlaying && this.loop) {
  6832. this.stop();
  6833. this.play();
  6834. }
  6835. }
  6836. this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);
  6837. this._registerFunc = function (transformNode) { return _this._onRegisterAfterWorldMatrixUpdate(transformNode); };
  6838. this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);
  6839. };
  6840. /**
  6841. * Detach the sound from the previously attached mesh
  6842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  6843. */
  6844. Sound.prototype.detachFromMesh = function () {
  6845. if (this._connectedTransformNode && this._registerFunc) {
  6846. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6847. this._registerFunc = null;
  6848. this._connectedTransformNode = null;
  6849. }
  6850. };
  6851. Sound.prototype._onRegisterAfterWorldMatrixUpdate = function (node) {
  6852. if (!node.getBoundingInfo) {
  6853. return;
  6854. }
  6855. var mesh = node;
  6856. if (this._positionInEmitterSpace) {
  6857. mesh.worldMatrixFromCache.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0]);
  6858. this.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0].getTranslation());
  6859. }
  6860. else {
  6861. var boundingInfo = mesh.getBoundingInfo();
  6862. this.setPosition(boundingInfo.boundingSphere.centerWorld);
  6863. }
  6864. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._isDirectional && this.isPlaying) {
  6865. this._updateDirection();
  6866. }
  6867. };
  6868. /**
  6869. * Clone the current sound in the scene.
  6870. * @returns the new sound clone
  6871. */
  6872. Sound.prototype.clone = function () {
  6873. var _this = this;
  6874. if (!this._streaming) {
  6875. var setBufferAndRun = function () {
  6876. if (_this._isReadyToPlay) {
  6877. clonedSound._audioBuffer = _this.getAudioBuffer();
  6878. clonedSound._isReadyToPlay = true;
  6879. if (clonedSound.autoplay) {
  6880. clonedSound.play();
  6881. }
  6882. }
  6883. else {
  6884. window.setTimeout(setBufferAndRun, 300);
  6885. }
  6886. };
  6887. var currentOptions = {
  6888. autoplay: this.autoplay, loop: this.loop,
  6889. volume: this._volume, spatialSound: this.spatialSound, maxDistance: this.maxDistance,
  6890. useCustomAttenuation: this.useCustomAttenuation, rolloffFactor: this.rolloffFactor,
  6891. refDistance: this.refDistance, distanceModel: this.distanceModel
  6892. };
  6893. var clonedSound = new Sound(this.name + "_cloned", new ArrayBuffer(0), this._scene, null, currentOptions);
  6894. if (this.useCustomAttenuation) {
  6895. clonedSound.setAttenuationFunction(this._customAttenuationFunction);
  6896. }
  6897. clonedSound.setPosition(this._position);
  6898. clonedSound.setPlaybackRate(this._playbackRate);
  6899. setBufferAndRun();
  6900. return clonedSound;
  6901. }
  6902. // Can't clone a streaming sound
  6903. else {
  6904. return null;
  6905. }
  6906. };
  6907. /**
  6908. * Gets the current underlying audio buffer containing the data
  6909. * @returns the audio buffer
  6910. */
  6911. Sound.prototype.getAudioBuffer = function () {
  6912. return this._audioBuffer;
  6913. };
  6914. /**
  6915. * Serializes the Sound in a JSON representation
  6916. * @returns the JSON representation of the sound
  6917. */
  6918. Sound.prototype.serialize = function () {
  6919. var serializationObject = {
  6920. name: this.name,
  6921. url: this.name,
  6922. autoplay: this.autoplay,
  6923. loop: this.loop,
  6924. volume: this._volume,
  6925. spatialSound: this.spatialSound,
  6926. maxDistance: this.maxDistance,
  6927. rolloffFactor: this.rolloffFactor,
  6928. refDistance: this.refDistance,
  6929. distanceModel: this.distanceModel,
  6930. playbackRate: this._playbackRate,
  6931. panningModel: this._panningModel,
  6932. soundTrackId: this.soundTrackId
  6933. };
  6934. if (this.spatialSound) {
  6935. if (this._connectedTransformNode) {
  6936. serializationObject.connectedMeshId = this._connectedTransformNode.id;
  6937. }
  6938. serializationObject.position = this._position.asArray();
  6939. serializationObject.refDistance = this.refDistance;
  6940. serializationObject.distanceModel = this.distanceModel;
  6941. serializationObject.isDirectional = this._isDirectional;
  6942. serializationObject.localDirectionToMesh = this._localDirection.asArray();
  6943. serializationObject.coneInnerAngle = this._coneInnerAngle;
  6944. serializationObject.coneOuterAngle = this._coneOuterAngle;
  6945. serializationObject.coneOuterGain = this._coneOuterGain;
  6946. }
  6947. return serializationObject;
  6948. };
  6949. /**
  6950. * Parse a JSON representation of a sound to innstantiate in a given scene
  6951. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  6952. * @param scene Define the scene the new parsed sound should be created in
  6953. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  6954. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  6955. * @returns the newly parsed sound
  6956. */
  6957. Sound.Parse = function (parsedSound, scene, rootUrl, sourceSound) {
  6958. var soundName = parsedSound.name;
  6959. var soundUrl;
  6960. if (parsedSound.url) {
  6961. soundUrl = rootUrl + parsedSound.url;
  6962. }
  6963. else {
  6964. soundUrl = rootUrl + soundName;
  6965. }
  6966. var options = {
  6967. autoplay: parsedSound.autoplay, loop: parsedSound.loop, volume: parsedSound.volume,
  6968. spatialSound: parsedSound.spatialSound, maxDistance: parsedSound.maxDistance,
  6969. rolloffFactor: parsedSound.rolloffFactor,
  6970. refDistance: parsedSound.refDistance,
  6971. distanceModel: parsedSound.distanceModel,
  6972. playbackRate: parsedSound.playbackRate
  6973. };
  6974. var newSound;
  6975. if (!sourceSound) {
  6976. newSound = new Sound(soundName, soundUrl, scene, function () { scene._removePendingData(newSound); }, options);
  6977. scene._addPendingData(newSound);
  6978. }
  6979. else {
  6980. var setBufferAndRun = function () {
  6981. if (sourceSound._isReadyToPlay) {
  6982. newSound._audioBuffer = sourceSound.getAudioBuffer();
  6983. newSound._isReadyToPlay = true;
  6984. if (newSound.autoplay) {
  6985. newSound.play();
  6986. }
  6987. }
  6988. else {
  6989. window.setTimeout(setBufferAndRun, 300);
  6990. }
  6991. };
  6992. newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);
  6993. setBufferAndRun();
  6994. }
  6995. if (parsedSound.position) {
  6996. var soundPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.position);
  6997. newSound.setPosition(soundPosition);
  6998. }
  6999. if (parsedSound.isDirectional) {
  7000. newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);
  7001. if (parsedSound.localDirectionToMesh) {
  7002. var localDirectionToMesh = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.localDirectionToMesh);
  7003. newSound.setLocalDirectionToMesh(localDirectionToMesh);
  7004. }
  7005. }
  7006. if (parsedSound.connectedMeshId) {
  7007. var connectedMesh = scene.getMeshByID(parsedSound.connectedMeshId);
  7008. if (connectedMesh) {
  7009. newSound.attachToMesh(connectedMesh);
  7010. }
  7011. }
  7012. return newSound;
  7013. };
  7014. /** @hidden */
  7015. Sound._SceneComponentInitialization = function (_) {
  7016. throw "Import AudioSceneComponent before creating sound.";
  7017. };
  7018. return Sound;
  7019. }());
  7020. /***/ }),
  7021. /***/ "./Audio/soundTrack.ts":
  7022. /*!*****************************!*\
  7023. !*** ./Audio/soundTrack.ts ***!
  7024. \*****************************/
  7025. /*! exports provided: SoundTrack */
  7026. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7027. "use strict";
  7028. __webpack_require__.r(__webpack_exports__);
  7029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return SoundTrack; });
  7030. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  7031. /**
  7032. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  7033. * It will be also used in a future release to apply effects on a specific track.
  7034. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7035. */
  7036. var SoundTrack = /** @class */ (function () {
  7037. /**
  7038. * Creates a new sound track.
  7039. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7040. * @param scene Define the scene the sound track belongs to
  7041. * @param options
  7042. */
  7043. function SoundTrack(scene, options) {
  7044. if (options === void 0) { options = {}; }
  7045. /**
  7046. * The unique identifier of the sound track in the scene.
  7047. */
  7048. this.id = -1;
  7049. this._isMainTrack = false;
  7050. this._isInitialized = false;
  7051. this._scene = scene;
  7052. this.soundCollection = new Array();
  7053. this._options = options;
  7054. if (!this._isMainTrack && this._scene.soundTracks) {
  7055. this._scene.soundTracks.push(this);
  7056. this.id = this._scene.soundTracks.length - 1;
  7057. }
  7058. }
  7059. SoundTrack.prototype._initializeSoundTrackAudioGraph = function () {
  7060. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext) {
  7061. this._outputAudioNode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext.createGain();
  7062. this._outputAudioNode.connect(_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7063. if (this._options) {
  7064. if (this._options.volume) {
  7065. this._outputAudioNode.gain.value = this._options.volume;
  7066. }
  7067. if (this._options.mainTrack) {
  7068. this._isMainTrack = this._options.mainTrack;
  7069. }
  7070. }
  7071. this._isInitialized = true;
  7072. }
  7073. };
  7074. /**
  7075. * Release the sound track and its associated resources
  7076. */
  7077. SoundTrack.prototype.dispose = function () {
  7078. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7079. if (this._connectedAnalyser) {
  7080. this._connectedAnalyser.stopDebugCanvas();
  7081. }
  7082. while (this.soundCollection.length) {
  7083. this.soundCollection[0].dispose();
  7084. }
  7085. if (this._outputAudioNode) {
  7086. this._outputAudioNode.disconnect();
  7087. }
  7088. this._outputAudioNode = null;
  7089. }
  7090. };
  7091. /**
  7092. * Adds a sound to this sound track
  7093. * @param sound define the cound to add
  7094. * @ignoreNaming
  7095. */
  7096. SoundTrack.prototype.AddSound = function (sound) {
  7097. if (!this._isInitialized) {
  7098. this._initializeSoundTrackAudioGraph();
  7099. }
  7100. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7101. sound.connectToSoundTrackAudioNode(this._outputAudioNode);
  7102. }
  7103. if (sound.soundTrackId) {
  7104. if (sound.soundTrackId === -1) {
  7105. this._scene.mainSoundTrack.RemoveSound(sound);
  7106. }
  7107. else if (this._scene.soundTracks) {
  7108. this._scene.soundTracks[sound.soundTrackId].RemoveSound(sound);
  7109. }
  7110. }
  7111. this.soundCollection.push(sound);
  7112. sound.soundTrackId = this.id;
  7113. };
  7114. /**
  7115. * Removes a sound to this sound track
  7116. * @param sound define the cound to remove
  7117. * @ignoreNaming
  7118. */
  7119. SoundTrack.prototype.RemoveSound = function (sound) {
  7120. var index = this.soundCollection.indexOf(sound);
  7121. if (index !== -1) {
  7122. this.soundCollection.splice(index, 1);
  7123. }
  7124. };
  7125. /**
  7126. * Set a global volume for the full sound track.
  7127. * @param newVolume Define the new volume of the sound track
  7128. */
  7129. SoundTrack.prototype.setVolume = function (newVolume) {
  7130. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7131. this._outputAudioNode.gain.value = newVolume;
  7132. }
  7133. };
  7134. /**
  7135. * Switch the panning model to HRTF:
  7136. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  7137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7138. */
  7139. SoundTrack.prototype.switchPanningModelToHRTF = function () {
  7140. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7141. for (var i = 0; i < this.soundCollection.length; i++) {
  7142. this.soundCollection[i].switchPanningModelToHRTF();
  7143. }
  7144. }
  7145. };
  7146. /**
  7147. * Switch the panning model to Equal Power:
  7148. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  7149. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7150. */
  7151. SoundTrack.prototype.switchPanningModelToEqualPower = function () {
  7152. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7153. for (var i = 0; i < this.soundCollection.length; i++) {
  7154. this.soundCollection[i].switchPanningModelToEqualPower();
  7155. }
  7156. }
  7157. };
  7158. /**
  7159. * Connect the sound track to an audio analyser allowing some amazing
  7160. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  7161. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  7162. * @param analyser The analyser to connect to the engine
  7163. */
  7164. SoundTrack.prototype.connectToAnalyser = function (analyser) {
  7165. if (this._connectedAnalyser) {
  7166. this._connectedAnalyser.stopDebugCanvas();
  7167. }
  7168. this._connectedAnalyser = analyser;
  7169. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7170. this._outputAudioNode.disconnect();
  7171. this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7172. }
  7173. };
  7174. return SoundTrack;
  7175. }());
  7176. /***/ }),
  7177. /***/ "./Audio/weightedsound.ts":
  7178. /*!********************************!*\
  7179. !*** ./Audio/weightedsound.ts ***!
  7180. \********************************/
  7181. /*! exports provided: WeightedSound */
  7182. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7183. "use strict";
  7184. __webpack_require__.r(__webpack_exports__);
  7185. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return WeightedSound; });
  7186. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  7187. /**
  7188. * Wraps one or more Sound objects and selects one with random weight for playback.
  7189. */
  7190. var WeightedSound = /** @class */ (function () {
  7191. /**
  7192. * Creates a new WeightedSound from the list of sounds given.
  7193. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  7194. * @param sounds Array of Sounds that will be selected from.
  7195. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  7196. */
  7197. function WeightedSound(loop, sounds, weights) {
  7198. var _this = this;
  7199. /** When true a Sound will be selected and played when the current playing Sound completes. */
  7200. this.loop = false;
  7201. this._coneInnerAngle = 360;
  7202. this._coneOuterAngle = 360;
  7203. this._volume = 1;
  7204. /** A Sound is currently playing. */
  7205. this.isPlaying = false;
  7206. /** A Sound is currently paused. */
  7207. this.isPaused = false;
  7208. this._sounds = [];
  7209. this._weights = [];
  7210. if (sounds.length !== weights.length) {
  7211. throw new Error('Sounds length does not equal weights length');
  7212. }
  7213. this.loop = loop;
  7214. this._weights = weights;
  7215. // Normalize the weights
  7216. var weightSum = 0;
  7217. for (var _i = 0, weights_1 = weights; _i < weights_1.length; _i++) {
  7218. var weight = weights_1[_i];
  7219. weightSum += weight;
  7220. }
  7221. var invWeightSum = weightSum > 0 ? 1 / weightSum : 0;
  7222. for (var i = 0; i < this._weights.length; i++) {
  7223. this._weights[i] *= invWeightSum;
  7224. }
  7225. this._sounds = sounds;
  7226. for (var _a = 0, _b = this._sounds; _a < _b.length; _a++) {
  7227. var sound = _b[_a];
  7228. sound.onEndedObservable.add(function () { _this._onended(); });
  7229. }
  7230. }
  7231. Object.defineProperty(WeightedSound.prototype, "directionalConeInnerAngle", {
  7232. /**
  7233. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  7234. */
  7235. get: function () {
  7236. return this._coneInnerAngle;
  7237. },
  7238. /**
  7239. * The size of cone in degress for a directional sound in which there will be no attenuation.
  7240. */
  7241. set: function (value) {
  7242. if (value !== this._coneInnerAngle) {
  7243. if (this._coneOuterAngle < value) {
  7244. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7245. return;
  7246. }
  7247. this._coneInnerAngle = value;
  7248. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7249. var sound = _a[_i];
  7250. sound.directionalConeInnerAngle = value;
  7251. }
  7252. }
  7253. },
  7254. enumerable: true,
  7255. configurable: true
  7256. });
  7257. Object.defineProperty(WeightedSound.prototype, "directionalConeOuterAngle", {
  7258. /**
  7259. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7260. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7261. */
  7262. get: function () {
  7263. return this._coneOuterAngle;
  7264. },
  7265. /**
  7266. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7267. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7268. */
  7269. set: function (value) {
  7270. if (value !== this._coneOuterAngle) {
  7271. if (value < this._coneInnerAngle) {
  7272. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7273. return;
  7274. }
  7275. this._coneOuterAngle = value;
  7276. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7277. var sound = _a[_i];
  7278. sound.directionalConeOuterAngle = value;
  7279. }
  7280. }
  7281. },
  7282. enumerable: true,
  7283. configurable: true
  7284. });
  7285. Object.defineProperty(WeightedSound.prototype, "volume", {
  7286. /**
  7287. * Playback volume.
  7288. */
  7289. get: function () {
  7290. return this._volume;
  7291. },
  7292. /**
  7293. * Playback volume.
  7294. */
  7295. set: function (value) {
  7296. if (value !== this._volume) {
  7297. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7298. var sound = _a[_i];
  7299. sound.setVolume(value);
  7300. }
  7301. }
  7302. },
  7303. enumerable: true,
  7304. configurable: true
  7305. });
  7306. WeightedSound.prototype._onended = function () {
  7307. if (this._currentIndex !== undefined) {
  7308. this._sounds[this._currentIndex].autoplay = false;
  7309. }
  7310. if (this.loop && this.isPlaying) {
  7311. this.play();
  7312. }
  7313. else {
  7314. this.isPlaying = false;
  7315. }
  7316. };
  7317. /**
  7318. * Suspend playback
  7319. */
  7320. WeightedSound.prototype.pause = function () {
  7321. this.isPaused = true;
  7322. if (this._currentIndex !== undefined) {
  7323. this._sounds[this._currentIndex].pause();
  7324. }
  7325. };
  7326. /**
  7327. * Stop playback
  7328. */
  7329. WeightedSound.prototype.stop = function () {
  7330. this.isPlaying = false;
  7331. if (this._currentIndex !== undefined) {
  7332. this._sounds[this._currentIndex].stop();
  7333. }
  7334. };
  7335. /**
  7336. * Start playback.
  7337. * @param startOffset Position the clip head at a specific time in seconds.
  7338. */
  7339. WeightedSound.prototype.play = function (startOffset) {
  7340. if (!this.isPaused) {
  7341. this.stop();
  7342. var randomValue = Math.random();
  7343. var total = 0;
  7344. for (var i = 0; i < this._weights.length; i++) {
  7345. total += this._weights[i];
  7346. if (randomValue <= total) {
  7347. this._currentIndex = i;
  7348. break;
  7349. }
  7350. }
  7351. }
  7352. var sound = this._sounds[this._currentIndex];
  7353. if (sound.isReady()) {
  7354. sound.play(0, this.isPaused ? undefined : startOffset);
  7355. }
  7356. else {
  7357. sound.autoplay = true;
  7358. }
  7359. this.isPlaying = true;
  7360. this.isPaused = false;
  7361. };
  7362. return WeightedSound;
  7363. }());
  7364. /***/ }),
  7365. /***/ "./Behaviors/Cameras/autoRotationBehavior.ts":
  7366. /*!***************************************************!*\
  7367. !*** ./Behaviors/Cameras/autoRotationBehavior.ts ***!
  7368. \***************************************************/
  7369. /*! exports provided: AutoRotationBehavior */
  7370. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7371. "use strict";
  7372. __webpack_require__.r(__webpack_exports__);
  7373. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return AutoRotationBehavior; });
  7374. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  7375. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  7376. /**
  7377. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  7378. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7379. */
  7380. var AutoRotationBehavior = /** @class */ (function () {
  7381. function AutoRotationBehavior() {
  7382. this._zoomStopsAnimation = false;
  7383. this._idleRotationSpeed = 0.05;
  7384. this._idleRotationWaitTime = 2000;
  7385. this._idleRotationSpinupTime = 2000;
  7386. this._isPointerDown = false;
  7387. this._lastFrameTime = null;
  7388. this._lastInteractionTime = -Infinity;
  7389. this._cameraRotationSpeed = 0;
  7390. this._lastFrameRadius = 0;
  7391. }
  7392. Object.defineProperty(AutoRotationBehavior.prototype, "name", {
  7393. /**
  7394. * Gets the name of the behavior.
  7395. */
  7396. get: function () {
  7397. return "AutoRotation";
  7398. },
  7399. enumerable: true,
  7400. configurable: true
  7401. });
  7402. Object.defineProperty(AutoRotationBehavior.prototype, "zoomStopsAnimation", {
  7403. /**
  7404. * Gets the flag that indicates if user zooming should stop animation.
  7405. */
  7406. get: function () {
  7407. return this._zoomStopsAnimation;
  7408. },
  7409. /**
  7410. * Sets the flag that indicates if user zooming should stop animation.
  7411. */
  7412. set: function (flag) {
  7413. this._zoomStopsAnimation = flag;
  7414. },
  7415. enumerable: true,
  7416. configurable: true
  7417. });
  7418. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpeed", {
  7419. /**
  7420. * Gets the default speed at which the camera rotates around the model.
  7421. */
  7422. get: function () {
  7423. return this._idleRotationSpeed;
  7424. },
  7425. /**
  7426. * Sets the default speed at which the camera rotates around the model.
  7427. */
  7428. set: function (speed) {
  7429. this._idleRotationSpeed = speed;
  7430. },
  7431. enumerable: true,
  7432. configurable: true
  7433. });
  7434. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationWaitTime", {
  7435. /**
  7436. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  7437. */
  7438. get: function () {
  7439. return this._idleRotationWaitTime;
  7440. },
  7441. /**
  7442. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  7443. */
  7444. set: function (time) {
  7445. this._idleRotationWaitTime = time;
  7446. },
  7447. enumerable: true,
  7448. configurable: true
  7449. });
  7450. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpinupTime", {
  7451. /**
  7452. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7453. */
  7454. get: function () {
  7455. return this._idleRotationSpinupTime;
  7456. },
  7457. /**
  7458. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7459. */
  7460. set: function (time) {
  7461. this._idleRotationSpinupTime = time;
  7462. },
  7463. enumerable: true,
  7464. configurable: true
  7465. });
  7466. Object.defineProperty(AutoRotationBehavior.prototype, "rotationInProgress", {
  7467. /**
  7468. * Gets a value indicating if the camera is currently rotating because of this behavior
  7469. */
  7470. get: function () {
  7471. return Math.abs(this._cameraRotationSpeed) > 0;
  7472. },
  7473. enumerable: true,
  7474. configurable: true
  7475. });
  7476. /**
  7477. * Initializes the behavior.
  7478. */
  7479. AutoRotationBehavior.prototype.init = function () {
  7480. // Do notihng
  7481. };
  7482. /**
  7483. * Attaches the behavior to its arc rotate camera.
  7484. * @param camera Defines the camera to attach the behavior to
  7485. */
  7486. AutoRotationBehavior.prototype.attach = function (camera) {
  7487. var _this = this;
  7488. this._attachedCamera = camera;
  7489. var scene = this._attachedCamera.getScene();
  7490. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  7491. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  7492. _this._isPointerDown = true;
  7493. return;
  7494. }
  7495. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  7496. _this._isPointerDown = false;
  7497. }
  7498. });
  7499. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  7500. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7501. var dt = 0;
  7502. if (_this._lastFrameTime != null) {
  7503. dt = now - _this._lastFrameTime;
  7504. }
  7505. _this._lastFrameTime = now;
  7506. // Stop the animation if there is user interaction and the animation should stop for this interaction
  7507. _this._applyUserInteraction();
  7508. var timeToRotation = now - _this._lastInteractionTime - _this._idleRotationWaitTime;
  7509. var scale = Math.max(Math.min(timeToRotation / (_this._idleRotationSpinupTime), 1), 0);
  7510. _this._cameraRotationSpeed = _this._idleRotationSpeed * scale;
  7511. // Step camera rotation by rotation speed
  7512. if (_this._attachedCamera) {
  7513. _this._attachedCamera.alpha -= _this._cameraRotationSpeed * (dt / 1000);
  7514. }
  7515. });
  7516. };
  7517. /**
  7518. * Detaches the behavior from its current arc rotate camera.
  7519. */
  7520. AutoRotationBehavior.prototype.detach = function () {
  7521. if (!this._attachedCamera) {
  7522. return;
  7523. }
  7524. var scene = this._attachedCamera.getScene();
  7525. if (this._onPrePointerObservableObserver) {
  7526. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  7527. }
  7528. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  7529. this._attachedCamera = null;
  7530. };
  7531. /**
  7532. * Returns true if user is scrolling.
  7533. * @return true if user is scrolling.
  7534. */
  7535. AutoRotationBehavior.prototype._userIsZooming = function () {
  7536. if (!this._attachedCamera) {
  7537. return false;
  7538. }
  7539. return this._attachedCamera.inertialRadiusOffset !== 0;
  7540. };
  7541. AutoRotationBehavior.prototype._shouldAnimationStopForInteraction = function () {
  7542. if (!this._attachedCamera) {
  7543. return false;
  7544. }
  7545. var zoomHasHitLimit = false;
  7546. if (this._lastFrameRadius === this._attachedCamera.radius && this._attachedCamera.inertialRadiusOffset !== 0) {
  7547. zoomHasHitLimit = true;
  7548. }
  7549. // Update the record of previous radius - works as an approx. indicator of hitting radius limits
  7550. this._lastFrameRadius = this._attachedCamera.radius;
  7551. return this._zoomStopsAnimation ? zoomHasHitLimit : this._userIsZooming();
  7552. };
  7553. /**
  7554. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  7555. */
  7556. AutoRotationBehavior.prototype._applyUserInteraction = function () {
  7557. if (this._userIsMoving() && !this._shouldAnimationStopForInteraction()) {
  7558. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7559. }
  7560. };
  7561. // Tools
  7562. AutoRotationBehavior.prototype._userIsMoving = function () {
  7563. if (!this._attachedCamera) {
  7564. return false;
  7565. }
  7566. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  7567. this._attachedCamera.inertialBetaOffset !== 0 ||
  7568. this._attachedCamera.inertialRadiusOffset !== 0 ||
  7569. this._attachedCamera.inertialPanningX !== 0 ||
  7570. this._attachedCamera.inertialPanningY !== 0 ||
  7571. this._isPointerDown;
  7572. };
  7573. return AutoRotationBehavior;
  7574. }());
  7575. /***/ }),
  7576. /***/ "./Behaviors/Cameras/bouncingBehavior.ts":
  7577. /*!***********************************************!*\
  7578. !*** ./Behaviors/Cameras/bouncingBehavior.ts ***!
  7579. \***********************************************/
  7580. /*! exports provided: BouncingBehavior */
  7581. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7582. "use strict";
  7583. __webpack_require__.r(__webpack_exports__);
  7584. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return BouncingBehavior; });
  7585. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  7586. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  7587. /**
  7588. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  7589. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7590. */
  7591. var BouncingBehavior = /** @class */ (function () {
  7592. function BouncingBehavior() {
  7593. /**
  7594. * The duration of the animation, in milliseconds
  7595. */
  7596. this.transitionDuration = 450;
  7597. /**
  7598. * Length of the distance animated by the transition when lower radius is reached
  7599. */
  7600. this.lowerRadiusTransitionRange = 2;
  7601. /**
  7602. * Length of the distance animated by the transition when upper radius is reached
  7603. */
  7604. this.upperRadiusTransitionRange = -2;
  7605. this._autoTransitionRange = false;
  7606. // Animations
  7607. this._radiusIsAnimating = false;
  7608. this._radiusBounceTransition = null;
  7609. this._animatables = new Array();
  7610. }
  7611. Object.defineProperty(BouncingBehavior.prototype, "name", {
  7612. /**
  7613. * Gets the name of the behavior.
  7614. */
  7615. get: function () {
  7616. return "Bouncing";
  7617. },
  7618. enumerable: true,
  7619. configurable: true
  7620. });
  7621. Object.defineProperty(BouncingBehavior.prototype, "autoTransitionRange", {
  7622. /**
  7623. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7624. */
  7625. get: function () {
  7626. return this._autoTransitionRange;
  7627. },
  7628. /**
  7629. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7630. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  7631. */
  7632. set: function (value) {
  7633. var _this = this;
  7634. if (this._autoTransitionRange === value) {
  7635. return;
  7636. }
  7637. this._autoTransitionRange = value;
  7638. var camera = this._attachedCamera;
  7639. if (!camera) {
  7640. return;
  7641. }
  7642. if (value) {
  7643. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  7644. if (!mesh) {
  7645. return;
  7646. }
  7647. mesh.computeWorldMatrix(true);
  7648. var diagonal = mesh.getBoundingInfo().diagonalLength;
  7649. _this.lowerRadiusTransitionRange = diagonal * 0.05;
  7650. _this.upperRadiusTransitionRange = diagonal * 0.05;
  7651. });
  7652. }
  7653. else if (this._onMeshTargetChangedObserver) {
  7654. camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  7655. }
  7656. },
  7657. enumerable: true,
  7658. configurable: true
  7659. });
  7660. /**
  7661. * Initializes the behavior.
  7662. */
  7663. BouncingBehavior.prototype.init = function () {
  7664. // Do notihng
  7665. };
  7666. /**
  7667. * Attaches the behavior to its arc rotate camera.
  7668. * @param camera Defines the camera to attach the behavior to
  7669. */
  7670. BouncingBehavior.prototype.attach = function (camera) {
  7671. var _this = this;
  7672. this._attachedCamera = camera;
  7673. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  7674. if (!_this._attachedCamera) {
  7675. return;
  7676. }
  7677. // Add the bounce animation to the lower radius limit
  7678. if (_this._isRadiusAtLimit(_this._attachedCamera.lowerRadiusLimit)) {
  7679. _this._applyBoundRadiusAnimation(_this.lowerRadiusTransitionRange);
  7680. }
  7681. // Add the bounce animation to the upper radius limit
  7682. if (_this._isRadiusAtLimit(_this._attachedCamera.upperRadiusLimit)) {
  7683. _this._applyBoundRadiusAnimation(_this.upperRadiusTransitionRange);
  7684. }
  7685. });
  7686. };
  7687. /**
  7688. * Detaches the behavior from its current arc rotate camera.
  7689. */
  7690. BouncingBehavior.prototype.detach = function () {
  7691. if (!this._attachedCamera) {
  7692. return;
  7693. }
  7694. if (this._onAfterCheckInputsObserver) {
  7695. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  7696. }
  7697. if (this._onMeshTargetChangedObserver) {
  7698. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  7699. }
  7700. this._attachedCamera = null;
  7701. };
  7702. /**
  7703. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  7704. * @param radiusLimit The limit to check against.
  7705. * @return Bool to indicate if at limit.
  7706. */
  7707. BouncingBehavior.prototype._isRadiusAtLimit = function (radiusLimit) {
  7708. if (!this._attachedCamera) {
  7709. return false;
  7710. }
  7711. if (this._attachedCamera.radius === radiusLimit && !this._radiusIsAnimating) {
  7712. return true;
  7713. }
  7714. return false;
  7715. };
  7716. /**
  7717. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  7718. * @param radiusDelta The delta by which to animate to. Can be negative.
  7719. */
  7720. BouncingBehavior.prototype._applyBoundRadiusAnimation = function (radiusDelta) {
  7721. var _this = this;
  7722. if (!this._attachedCamera) {
  7723. return;
  7724. }
  7725. if (!this._radiusBounceTransition) {
  7726. BouncingBehavior.EasingFunction.setEasingMode(BouncingBehavior.EasingMode);
  7727. this._radiusBounceTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT, 60, BouncingBehavior.EasingFunction);
  7728. }
  7729. // Prevent zoom until bounce has completed
  7730. this._cachedWheelPrecision = this._attachedCamera.wheelPrecision;
  7731. this._attachedCamera.wheelPrecision = Infinity;
  7732. this._attachedCamera.inertialRadiusOffset = 0;
  7733. // Animate to the radius limit
  7734. this.stopAllAnimations();
  7735. this._radiusIsAnimating = true;
  7736. var animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].TransitionTo("radius", this._attachedCamera.radius + radiusDelta, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusBounceTransition, this.transitionDuration, function () { return _this._clearAnimationLocks(); });
  7737. if (animatable) {
  7738. this._animatables.push(animatable);
  7739. }
  7740. };
  7741. /**
  7742. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  7743. */
  7744. BouncingBehavior.prototype._clearAnimationLocks = function () {
  7745. this._radiusIsAnimating = false;
  7746. if (this._attachedCamera) {
  7747. this._attachedCamera.wheelPrecision = this._cachedWheelPrecision;
  7748. }
  7749. };
  7750. /**
  7751. * Stops and removes all animations that have been applied to the camera
  7752. */
  7753. BouncingBehavior.prototype.stopAllAnimations = function () {
  7754. if (this._attachedCamera) {
  7755. this._attachedCamera.animations = [];
  7756. }
  7757. while (this._animatables.length) {
  7758. this._animatables[0].onAnimationEnd = null;
  7759. this._animatables[0].stop();
  7760. this._animatables.shift();
  7761. }
  7762. };
  7763. /**
  7764. * The easing function used by animations
  7765. */
  7766. BouncingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["BackEase"](0.3);
  7767. /**
  7768. * The easing mode used by animations
  7769. */
  7770. BouncingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEOUT;
  7771. return BouncingBehavior;
  7772. }());
  7773. /***/ }),
  7774. /***/ "./Behaviors/Cameras/framingBehavior.ts":
  7775. /*!**********************************************!*\
  7776. !*** ./Behaviors/Cameras/framingBehavior.ts ***!
  7777. \**********************************************/
  7778. /*! exports provided: FramingBehavior */
  7779. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7780. "use strict";
  7781. __webpack_require__.r(__webpack_exports__);
  7782. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return FramingBehavior; });
  7783. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  7784. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  7785. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  7786. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  7787. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  7788. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  7789. /**
  7790. * The framing behavior (FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  7791. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7792. */
  7793. var FramingBehavior = /** @class */ (function () {
  7794. function FramingBehavior() {
  7795. this._mode = FramingBehavior.FitFrustumSidesMode;
  7796. this._radiusScale = 1.0;
  7797. this._positionScale = 0.5;
  7798. this._defaultElevation = 0.3;
  7799. this._elevationReturnTime = 1500;
  7800. this._elevationReturnWaitTime = 1000;
  7801. this._zoomStopsAnimation = false;
  7802. this._framingTime = 1500;
  7803. /**
  7804. * Define if the behavior should automatically change the configured
  7805. * camera limits and sensibilities.
  7806. */
  7807. this.autoCorrectCameraLimitsAndSensibility = true;
  7808. this._isPointerDown = false;
  7809. this._lastInteractionTime = -Infinity;
  7810. // Framing control
  7811. this._animatables = new Array();
  7812. this._betaIsAnimating = false;
  7813. }
  7814. Object.defineProperty(FramingBehavior.prototype, "name", {
  7815. /**
  7816. * Gets the name of the behavior.
  7817. */
  7818. get: function () {
  7819. return "Framing";
  7820. },
  7821. enumerable: true,
  7822. configurable: true
  7823. });
  7824. Object.defineProperty(FramingBehavior.prototype, "mode", {
  7825. /**
  7826. * Gets current mode used by the behavior.
  7827. */
  7828. get: function () {
  7829. return this._mode;
  7830. },
  7831. /**
  7832. * Sets the current mode used by the behavior
  7833. */
  7834. set: function (mode) {
  7835. this._mode = mode;
  7836. },
  7837. enumerable: true,
  7838. configurable: true
  7839. });
  7840. Object.defineProperty(FramingBehavior.prototype, "radiusScale", {
  7841. /**
  7842. * Gets the scale applied to the radius
  7843. */
  7844. get: function () {
  7845. return this._radiusScale;
  7846. },
  7847. /**
  7848. * Sets the scale applied to the radius (1 by default)
  7849. */
  7850. set: function (radius) {
  7851. this._radiusScale = radius;
  7852. },
  7853. enumerable: true,
  7854. configurable: true
  7855. });
  7856. Object.defineProperty(FramingBehavior.prototype, "positionScale", {
  7857. /**
  7858. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  7859. */
  7860. get: function () {
  7861. return this._positionScale;
  7862. },
  7863. /**
  7864. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  7865. */
  7866. set: function (scale) {
  7867. this._positionScale = scale;
  7868. },
  7869. enumerable: true,
  7870. configurable: true
  7871. });
  7872. Object.defineProperty(FramingBehavior.prototype, "defaultElevation", {
  7873. /**
  7874. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  7875. * behaviour is triggered, in radians.
  7876. */
  7877. get: function () {
  7878. return this._defaultElevation;
  7879. },
  7880. /**
  7881. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  7882. * behaviour is triggered, in radians.
  7883. */
  7884. set: function (elevation) {
  7885. this._defaultElevation = elevation;
  7886. },
  7887. enumerable: true,
  7888. configurable: true
  7889. });
  7890. Object.defineProperty(FramingBehavior.prototype, "elevationReturnTime", {
  7891. /**
  7892. * Gets the time (in milliseconds) taken to return to the default beta position.
  7893. * Negative value indicates camera should not return to default.
  7894. */
  7895. get: function () {
  7896. return this._elevationReturnTime;
  7897. },
  7898. /**
  7899. * Sets the time (in milliseconds) taken to return to the default beta position.
  7900. * Negative value indicates camera should not return to default.
  7901. */
  7902. set: function (speed) {
  7903. this._elevationReturnTime = speed;
  7904. },
  7905. enumerable: true,
  7906. configurable: true
  7907. });
  7908. Object.defineProperty(FramingBehavior.prototype, "elevationReturnWaitTime", {
  7909. /**
  7910. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  7911. */
  7912. get: function () {
  7913. return this._elevationReturnWaitTime;
  7914. },
  7915. /**
  7916. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  7917. */
  7918. set: function (time) {
  7919. this._elevationReturnWaitTime = time;
  7920. },
  7921. enumerable: true,
  7922. configurable: true
  7923. });
  7924. Object.defineProperty(FramingBehavior.prototype, "zoomStopsAnimation", {
  7925. /**
  7926. * Gets the flag that indicates if user zooming should stop animation.
  7927. */
  7928. get: function () {
  7929. return this._zoomStopsAnimation;
  7930. },
  7931. /**
  7932. * Sets the flag that indicates if user zooming should stop animation.
  7933. */
  7934. set: function (flag) {
  7935. this._zoomStopsAnimation = flag;
  7936. },
  7937. enumerable: true,
  7938. configurable: true
  7939. });
  7940. Object.defineProperty(FramingBehavior.prototype, "framingTime", {
  7941. /**
  7942. * Gets the transition time when framing the mesh, in milliseconds
  7943. */
  7944. get: function () {
  7945. return this._framingTime;
  7946. },
  7947. /**
  7948. * Sets the transition time when framing the mesh, in milliseconds
  7949. */
  7950. set: function (time) {
  7951. this._framingTime = time;
  7952. },
  7953. enumerable: true,
  7954. configurable: true
  7955. });
  7956. /**
  7957. * Initializes the behavior.
  7958. */
  7959. FramingBehavior.prototype.init = function () {
  7960. // Do notihng
  7961. };
  7962. /**
  7963. * Attaches the behavior to its arc rotate camera.
  7964. * @param camera Defines the camera to attach the behavior to
  7965. */
  7966. FramingBehavior.prototype.attach = function (camera) {
  7967. var _this = this;
  7968. this._attachedCamera = camera;
  7969. var scene = this._attachedCamera.getScene();
  7970. FramingBehavior.EasingFunction.setEasingMode(FramingBehavior.EasingMode);
  7971. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  7972. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  7973. _this._isPointerDown = true;
  7974. return;
  7975. }
  7976. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  7977. _this._isPointerDown = false;
  7978. }
  7979. });
  7980. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  7981. if (mesh) {
  7982. _this.zoomOnMesh(mesh);
  7983. }
  7984. });
  7985. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  7986. // Stop the animation if there is user interaction and the animation should stop for this interaction
  7987. _this._applyUserInteraction();
  7988. // Maintain the camera above the ground. If the user pulls the camera beneath the ground plane, lift it
  7989. // back to the default position after a given timeout
  7990. _this._maintainCameraAboveGround();
  7991. });
  7992. };
  7993. /**
  7994. * Detaches the behavior from its current arc rotate camera.
  7995. */
  7996. FramingBehavior.prototype.detach = function () {
  7997. if (!this._attachedCamera) {
  7998. return;
  7999. }
  8000. var scene = this._attachedCamera.getScene();
  8001. if (this._onPrePointerObservableObserver) {
  8002. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  8003. }
  8004. if (this._onAfterCheckInputsObserver) {
  8005. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8006. }
  8007. if (this._onMeshTargetChangedObserver) {
  8008. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8009. }
  8010. this._attachedCamera = null;
  8011. };
  8012. /**
  8013. * Targets the given mesh and updates zoom level accordingly.
  8014. * @param mesh The mesh to target.
  8015. * @param radius Optional. If a cached radius position already exists, overrides default.
  8016. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8017. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8018. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8019. */
  8020. FramingBehavior.prototype.zoomOnMesh = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8021. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8022. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8023. mesh.computeWorldMatrix(true);
  8024. var boundingBox = mesh.getBoundingInfo().boundingBox;
  8025. this.zoomOnBoundingInfo(boundingBox.minimumWorld, boundingBox.maximumWorld, focusOnOriginXZ, onAnimationEnd);
  8026. };
  8027. /**
  8028. * Targets the given mesh with its children and updates zoom level accordingly.
  8029. * @param mesh The mesh to target.
  8030. * @param radius Optional. If a cached radius position already exists, overrides default.
  8031. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8032. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8033. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8034. */
  8035. FramingBehavior.prototype.zoomOnMeshHierarchy = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8036. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8037. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8038. mesh.computeWorldMatrix(true);
  8039. var boundingBox = mesh.getHierarchyBoundingVectors(true);
  8040. this.zoomOnBoundingInfo(boundingBox.min, boundingBox.max, focusOnOriginXZ, onAnimationEnd);
  8041. };
  8042. /**
  8043. * Targets the given meshes with their children and updates zoom level accordingly.
  8044. * @param meshes The mesh to target.
  8045. * @param radius Optional. If a cached radius position already exists, overrides default.
  8046. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8047. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8048. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8049. */
  8050. FramingBehavior.prototype.zoomOnMeshesHierarchy = function (meshes, focusOnOriginXZ, onAnimationEnd) {
  8051. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8052. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8053. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  8054. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  8055. for (var i = 0; i < meshes.length; i++) {
  8056. var boundingInfo = meshes[i].getHierarchyBoundingVectors(true);
  8057. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.min, min, max);
  8058. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.max, min, max);
  8059. }
  8060. this.zoomOnBoundingInfo(min, max, focusOnOriginXZ, onAnimationEnd);
  8061. };
  8062. /**
  8063. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  8064. * @param minimumWorld Determines the smaller position of the bounding box extend
  8065. * @param maximumWorld Determines the bigger position of the bounding box extend
  8066. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8067. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8068. */
  8069. FramingBehavior.prototype.zoomOnBoundingInfo = function (minimumWorld, maximumWorld, focusOnOriginXZ, onAnimationEnd) {
  8070. var _this = this;
  8071. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8072. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8073. var zoomTarget;
  8074. if (!this._attachedCamera) {
  8075. return;
  8076. }
  8077. // Find target by interpolating from bottom of bounding box in world-space to top via framingPositionY
  8078. var bottom = minimumWorld.y;
  8079. var top = maximumWorld.y;
  8080. var zoomTargetY = bottom + (top - bottom) * this._positionScale;
  8081. var radiusWorld = maximumWorld.subtract(minimumWorld).scale(0.5);
  8082. if (focusOnOriginXZ) {
  8083. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, zoomTargetY, 0);
  8084. }
  8085. else {
  8086. var centerWorld = minimumWorld.add(radiusWorld);
  8087. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](centerWorld.x, zoomTargetY, centerWorld.z);
  8088. }
  8089. if (!this._vectorTransition) {
  8090. this._vectorTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("target", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
  8091. }
  8092. this._betaIsAnimating = true;
  8093. var animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
  8094. if (animatable) {
  8095. this._animatables.push(animatable);
  8096. }
  8097. // sets the radius and lower radius bounds
  8098. // Small delta ensures camera is not always at lower zoom limit.
  8099. var radius = 0;
  8100. if (this._mode === FramingBehavior.FitFrustumSidesMode) {
  8101. var position = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8102. if (this.autoCorrectCameraLimitsAndSensibility) {
  8103. this._attachedCamera.lowerRadiusLimit = radiusWorld.length() + this._attachedCamera.minZ;
  8104. }
  8105. radius = position;
  8106. }
  8107. else if (this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8108. radius = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8109. if (this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null) {
  8110. this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ;
  8111. }
  8112. }
  8113. // Set sensibilities
  8114. if (this.autoCorrectCameraLimitsAndSensibility) {
  8115. var extend = maximumWorld.subtract(minimumWorld).length();
  8116. this._attachedCamera.panningSensibility = 5000 / extend;
  8117. this._attachedCamera.wheelPrecision = 100 / radius;
  8118. }
  8119. // transition to new radius
  8120. if (!this._radiusTransition) {
  8121. this._radiusTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8122. }
  8123. animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function () {
  8124. _this.stopAllAnimations();
  8125. if (onAnimationEnd) {
  8126. onAnimationEnd();
  8127. }
  8128. if (_this._attachedCamera && _this._attachedCamera.useInputToRestoreState) {
  8129. _this._attachedCamera.storeState();
  8130. }
  8131. });
  8132. if (animatable) {
  8133. this._animatables.push(animatable);
  8134. }
  8135. };
  8136. /**
  8137. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  8138. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  8139. * frustum width.
  8140. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  8141. * to fully enclose the mesh in the viewing frustum.
  8142. */
  8143. FramingBehavior.prototype._calculateLowerRadiusFromModelBoundingSphere = function (minimumWorld, maximumWorld) {
  8144. var size = maximumWorld.subtract(minimumWorld);
  8145. var boxVectorGlobalDiagonal = size.length();
  8146. var frustumSlope = this._getFrustumSlope();
  8147. // Formula for setting distance
  8148. // (Good explanation: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene)
  8149. var radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
  8150. // Horizon distance
  8151. var radius = radiusWithoutFraming * this._radiusScale;
  8152. var distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
  8153. var distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
  8154. var distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
  8155. var camera = this._attachedCamera;
  8156. if (!camera) {
  8157. return 0;
  8158. }
  8159. if (camera.lowerRadiusLimit && this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8160. // Don't exceed the requested limit
  8161. distance = distance < camera.lowerRadiusLimit ? camera.lowerRadiusLimit : distance;
  8162. }
  8163. // Don't exceed the upper radius limit
  8164. if (camera.upperRadiusLimit) {
  8165. distance = distance > camera.upperRadiusLimit ? camera.upperRadiusLimit : distance;
  8166. }
  8167. return distance;
  8168. };
  8169. /**
  8170. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  8171. * is automatically returned to its default position (expected to be above ground plane).
  8172. */
  8173. FramingBehavior.prototype._maintainCameraAboveGround = function () {
  8174. var _this = this;
  8175. if (this._elevationReturnTime < 0) {
  8176. return;
  8177. }
  8178. var timeSinceInteraction = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now - this._lastInteractionTime;
  8179. var defaultBeta = Math.PI * 0.5 - this._defaultElevation;
  8180. var limitBeta = Math.PI * 0.5;
  8181. // Bring the camera back up if below the ground plane
  8182. if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > limitBeta && timeSinceInteraction >= this._elevationReturnWaitTime) {
  8183. this._betaIsAnimating = true;
  8184. //Transition to new position
  8185. this.stopAllAnimations();
  8186. if (!this._betaTransition) {
  8187. this._betaTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("beta", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8188. }
  8189. var animatabe = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("beta", defaultBeta, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, function () {
  8190. _this._clearAnimationLocks();
  8191. _this.stopAllAnimations();
  8192. });
  8193. if (animatabe) {
  8194. this._animatables.push(animatabe);
  8195. }
  8196. }
  8197. };
  8198. /**
  8199. * Returns the frustum slope based on the canvas ratio and camera FOV
  8200. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  8201. */
  8202. FramingBehavior.prototype._getFrustumSlope = function () {
  8203. // Calculate the viewport ratio
  8204. // Aspect Ratio is Height/Width.
  8205. var camera = this._attachedCamera;
  8206. if (!camera) {
  8207. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"].Zero();
  8208. }
  8209. var engine = camera.getScene().getEngine();
  8210. var aspectRatio = engine.getAspectRatio(camera);
  8211. // Camera FOV is the vertical field of view (top-bottom) in radians.
  8212. // Slope of the frustum top/bottom planes in view space, relative to the forward vector.
  8213. var frustumSlopeY = Math.tan(camera.fov / 2);
  8214. // Slope of the frustum left/right planes in view space, relative to the forward vector.
  8215. // Provides the amount that one side (e.g. left) of the frustum gets wider for every unit
  8216. // along the forward vector.
  8217. var frustumSlopeX = frustumSlopeY * aspectRatio;
  8218. return new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](frustumSlopeX, frustumSlopeY);
  8219. };
  8220. /**
  8221. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  8222. */
  8223. FramingBehavior.prototype._clearAnimationLocks = function () {
  8224. this._betaIsAnimating = false;
  8225. };
  8226. /**
  8227. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  8228. */
  8229. FramingBehavior.prototype._applyUserInteraction = function () {
  8230. if (this.isUserIsMoving) {
  8231. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now;
  8232. this.stopAllAnimations();
  8233. this._clearAnimationLocks();
  8234. }
  8235. };
  8236. /**
  8237. * Stops and removes all animations that have been applied to the camera
  8238. */
  8239. FramingBehavior.prototype.stopAllAnimations = function () {
  8240. if (this._attachedCamera) {
  8241. this._attachedCamera.animations = [];
  8242. }
  8243. while (this._animatables.length) {
  8244. if (this._animatables[0]) {
  8245. this._animatables[0].onAnimationEnd = null;
  8246. this._animatables[0].stop();
  8247. }
  8248. this._animatables.shift();
  8249. }
  8250. };
  8251. Object.defineProperty(FramingBehavior.prototype, "isUserIsMoving", {
  8252. /**
  8253. * Gets a value indicating if the user is moving the camera
  8254. */
  8255. get: function () {
  8256. if (!this._attachedCamera) {
  8257. return false;
  8258. }
  8259. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  8260. this._attachedCamera.inertialBetaOffset !== 0 ||
  8261. this._attachedCamera.inertialRadiusOffset !== 0 ||
  8262. this._attachedCamera.inertialPanningX !== 0 ||
  8263. this._attachedCamera.inertialPanningY !== 0 ||
  8264. this._isPointerDown;
  8265. },
  8266. enumerable: true,
  8267. configurable: true
  8268. });
  8269. /**
  8270. * The easing function used by animations
  8271. */
  8272. FramingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]();
  8273. /**
  8274. * The easing mode used by animations
  8275. */
  8276. FramingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEINOUT;
  8277. // Statics
  8278. /**
  8279. * The camera can move all the way towards the mesh.
  8280. */
  8281. FramingBehavior.IgnoreBoundsSizeMode = 0;
  8282. /**
  8283. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  8284. */
  8285. FramingBehavior.FitFrustumSidesMode = 1;
  8286. return FramingBehavior;
  8287. }());
  8288. /***/ }),
  8289. /***/ "./Behaviors/Cameras/index.ts":
  8290. /*!************************************!*\
  8291. !*** ./Behaviors/Cameras/index.ts ***!
  8292. \************************************/
  8293. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior */
  8294. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8295. "use strict";
  8296. __webpack_require__.r(__webpack_exports__);
  8297. /* harmony import */ var _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  8298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  8299. /* harmony import */ var _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  8300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__["BouncingBehavior"]; });
  8301. /* harmony import */ var _framingBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  8302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _framingBehavior__WEBPACK_IMPORTED_MODULE_2__["FramingBehavior"]; });
  8303. /***/ }),
  8304. /***/ "./Behaviors/Meshes/attachToBoxBehavior.ts":
  8305. /*!*************************************************!*\
  8306. !*** ./Behaviors/Meshes/attachToBoxBehavior.ts ***!
  8307. \*************************************************/
  8308. /*! exports provided: AttachToBoxBehavior */
  8309. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8310. "use strict";
  8311. __webpack_require__.r(__webpack_exports__);
  8312. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return AttachToBoxBehavior; });
  8313. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8314. /**
  8315. * @hidden
  8316. */
  8317. var FaceDirectionInfo = /** @class */ (function () {
  8318. function FaceDirectionInfo(direction, rotatedDirection, diff, ignore) {
  8319. if (rotatedDirection === void 0) { rotatedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](); }
  8320. if (diff === void 0) { diff = 0; }
  8321. if (ignore === void 0) { ignore = false; }
  8322. this.direction = direction;
  8323. this.rotatedDirection = rotatedDirection;
  8324. this.diff = diff;
  8325. this.ignore = ignore;
  8326. }
  8327. return FaceDirectionInfo;
  8328. }());
  8329. /**
  8330. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  8331. */
  8332. var AttachToBoxBehavior = /** @class */ (function () {
  8333. /**
  8334. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  8335. * @param ui The transform node that should be attched to the mesh
  8336. */
  8337. function AttachToBoxBehavior(ui) {
  8338. this.ui = ui;
  8339. /**
  8340. * The name of the behavior
  8341. */
  8342. this.name = "AttachToBoxBehavior";
  8343. /**
  8344. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  8345. */
  8346. this.distanceAwayFromFace = 0.15;
  8347. /**
  8348. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  8349. */
  8350. this.distanceAwayFromBottomOfFace = 0.15;
  8351. this._faceVectors = [new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Down()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Left()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Forward()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Forward().scaleInPlace(-1))];
  8352. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8353. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  8354. this._zeroVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  8355. this._lookAtTmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8356. /* Does nothing */
  8357. }
  8358. /**
  8359. * Initializes the behavior
  8360. */
  8361. AttachToBoxBehavior.prototype.init = function () {
  8362. /* Does nothing */
  8363. };
  8364. AttachToBoxBehavior.prototype._closestFace = function (targetDirection) {
  8365. var _this = this;
  8366. // Go over each face and calculate the angle between the face's normal and targetDirection
  8367. this._faceVectors.forEach(function (v) {
  8368. if (!_this._target.rotationQuaternion) {
  8369. _this._target.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this._target.rotation.y, _this._target.rotation.x, _this._target.rotation.z);
  8370. }
  8371. _this._target.rotationQuaternion.toRotationMatrix(_this._tmpMatrix);
  8372. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(v.direction, _this._tmpMatrix, v.rotatedDirection);
  8373. v.diff = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetAngleBetweenVectors(v.rotatedDirection, targetDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v.rotatedDirection, targetDirection));
  8374. });
  8375. // Return the face information of the one with the normal closeset to target direction
  8376. return this._faceVectors.reduce(function (min, p) {
  8377. if (min.ignore) {
  8378. return p;
  8379. }
  8380. else if (p.ignore) {
  8381. return min;
  8382. }
  8383. else {
  8384. return min.diff < p.diff ? min : p;
  8385. }
  8386. }, this._faceVectors[0]);
  8387. };
  8388. AttachToBoxBehavior.prototype._lookAtToRef = function (pos, up, ref) {
  8389. if (up === void 0) { up = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0); }
  8390. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LookAtLHToRef(this._zeroVector, pos, up, this._lookAtTmpMatrix);
  8391. this._lookAtTmpMatrix.invert();
  8392. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._lookAtTmpMatrix, ref);
  8393. };
  8394. /**
  8395. * Attaches the AttachToBoxBehavior to the passed in mesh
  8396. * @param target The mesh that the specified node will be attached to
  8397. */
  8398. AttachToBoxBehavior.prototype.attach = function (target) {
  8399. var _this = this;
  8400. this._target = target;
  8401. this._scene = this._target.getScene();
  8402. // Every frame, update the app bars position
  8403. this._onRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  8404. if (!_this._scene.activeCamera) {
  8405. return;
  8406. }
  8407. // Find the face closest to the cameras position
  8408. var cameraPos = _this._scene.activeCamera.position;
  8409. if (_this._scene.activeCamera.devicePosition) {
  8410. cameraPos = _this._scene.activeCamera.devicePosition;
  8411. }
  8412. var facing = _this._closestFace(cameraPos.subtract(target.position));
  8413. if (_this._scene.activeCamera.leftCamera) {
  8414. _this._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8415. }
  8416. else {
  8417. _this._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8418. }
  8419. // Get camera up direction
  8420. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), _this._tmpMatrix, _this._tmpVector);
  8421. // Ignore faces to not select a parrelel face for the up vector of the UI
  8422. _this._faceVectors.forEach(function (v) {
  8423. if (facing.direction.x && v.direction.x) {
  8424. v.ignore = true;
  8425. }
  8426. if (facing.direction.y && v.direction.y) {
  8427. v.ignore = true;
  8428. }
  8429. if (facing.direction.z && v.direction.z) {
  8430. v.ignore = true;
  8431. }
  8432. });
  8433. var facingUp = _this._closestFace(_this._tmpVector);
  8434. // Unignore faces
  8435. _this._faceVectors.forEach(function (v) {
  8436. v.ignore = false;
  8437. });
  8438. // Position the app bar on that face
  8439. _this.ui.position.copyFrom(target.position);
  8440. if (facing.direction.x) {
  8441. facing.rotatedDirection.scaleToRef((target.scaling.x / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8442. _this.ui.position.addInPlace(_this._tmpVector);
  8443. }
  8444. if (facing.direction.y) {
  8445. facing.rotatedDirection.scaleToRef((target.scaling.y / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8446. _this.ui.position.addInPlace(_this._tmpVector);
  8447. }
  8448. if (facing.direction.z) {
  8449. facing.rotatedDirection.scaleToRef((target.scaling.z / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8450. _this.ui.position.addInPlace(_this._tmpVector);
  8451. }
  8452. // Rotate to be oriented properly to the camera
  8453. if (!_this.ui.rotationQuaternion) {
  8454. _this.ui.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this.ui.rotation.y, _this.ui.rotation.x, _this.ui.rotation.z);
  8455. }
  8456. facing.rotatedDirection.scaleToRef(-1, _this._tmpVector);
  8457. _this._lookAtToRef(_this._tmpVector, facingUp.rotatedDirection, _this.ui.rotationQuaternion);
  8458. // Place ui the correct distance from the bottom of the mesh
  8459. if (facingUp.direction.x) {
  8460. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.x / 2, _this._tmpVector);
  8461. }
  8462. if (facingUp.direction.y) {
  8463. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.y / 2, _this._tmpVector);
  8464. }
  8465. if (facingUp.direction.z) {
  8466. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.z / 2, _this._tmpVector);
  8467. }
  8468. _this.ui.position.addInPlace(_this._tmpVector);
  8469. });
  8470. };
  8471. /**
  8472. * Detaches the behavior from the mesh
  8473. */
  8474. AttachToBoxBehavior.prototype.detach = function () {
  8475. this._scene.onBeforeRenderObservable.remove(this._onRenderObserver);
  8476. };
  8477. return AttachToBoxBehavior;
  8478. }());
  8479. /***/ }),
  8480. /***/ "./Behaviors/Meshes/fadeInOutBehavior.ts":
  8481. /*!***********************************************!*\
  8482. !*** ./Behaviors/Meshes/fadeInOutBehavior.ts ***!
  8483. \***********************************************/
  8484. /*! exports provided: FadeInOutBehavior */
  8485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8486. "use strict";
  8487. __webpack_require__.r(__webpack_exports__);
  8488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return FadeInOutBehavior; });
  8489. /**
  8490. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  8491. */
  8492. var FadeInOutBehavior = /** @class */ (function () {
  8493. /**
  8494. * Instatiates the FadeInOutBehavior
  8495. */
  8496. function FadeInOutBehavior() {
  8497. var _this = this;
  8498. /**
  8499. * Time in milliseconds to delay before fading in (Default: 0)
  8500. */
  8501. this.delay = 0;
  8502. /**
  8503. * Time in milliseconds for the mesh to fade in (Default: 300)
  8504. */
  8505. this.fadeInTime = 300;
  8506. this._millisecondsPerFrame = 1000 / 60;
  8507. this._hovered = false;
  8508. this._hoverValue = 0;
  8509. this._ownerNode = null;
  8510. this._update = function () {
  8511. if (_this._ownerNode) {
  8512. _this._hoverValue += _this._hovered ? _this._millisecondsPerFrame : -_this._millisecondsPerFrame;
  8513. _this._setAllVisibility(_this._ownerNode, (_this._hoverValue - _this.delay) / _this.fadeInTime);
  8514. if (_this._ownerNode.visibility > 1) {
  8515. _this._setAllVisibility(_this._ownerNode, 1);
  8516. _this._hoverValue = _this.fadeInTime + _this.delay;
  8517. return;
  8518. }
  8519. else if (_this._ownerNode.visibility < 0) {
  8520. _this._setAllVisibility(_this._ownerNode, 0);
  8521. if (_this._hoverValue < 0) {
  8522. _this._hoverValue = 0;
  8523. return;
  8524. }
  8525. }
  8526. setTimeout(_this._update, _this._millisecondsPerFrame);
  8527. }
  8528. };
  8529. }
  8530. Object.defineProperty(FadeInOutBehavior.prototype, "name", {
  8531. /**
  8532. * The name of the behavior
  8533. */
  8534. get: function () {
  8535. return "FadeInOut";
  8536. },
  8537. enumerable: true,
  8538. configurable: true
  8539. });
  8540. /**
  8541. * Initializes the behavior
  8542. */
  8543. FadeInOutBehavior.prototype.init = function () {
  8544. };
  8545. /**
  8546. * Attaches the fade behavior on the passed in mesh
  8547. * @param ownerNode The mesh that will be faded in/out once attached
  8548. */
  8549. FadeInOutBehavior.prototype.attach = function (ownerNode) {
  8550. this._ownerNode = ownerNode;
  8551. this._setAllVisibility(this._ownerNode, 0);
  8552. };
  8553. /**
  8554. * Detaches the behavior from the mesh
  8555. */
  8556. FadeInOutBehavior.prototype.detach = function () {
  8557. this._ownerNode = null;
  8558. };
  8559. /**
  8560. * Triggers the mesh to begin fading in or out
  8561. * @param value if the object should fade in or out (true to fade in)
  8562. */
  8563. FadeInOutBehavior.prototype.fadeIn = function (value) {
  8564. this._hovered = value;
  8565. this._update();
  8566. };
  8567. FadeInOutBehavior.prototype._setAllVisibility = function (mesh, value) {
  8568. var _this = this;
  8569. mesh.visibility = value;
  8570. mesh.getChildMeshes().forEach(function (c) {
  8571. _this._setAllVisibility(c, value);
  8572. });
  8573. };
  8574. return FadeInOutBehavior;
  8575. }());
  8576. /***/ }),
  8577. /***/ "./Behaviors/Meshes/index.ts":
  8578. /*!***********************************!*\
  8579. !*** ./Behaviors/Meshes/index.ts ***!
  8580. \***********************************/
  8581. /*! exports provided: AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  8582. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8583. "use strict";
  8584. __webpack_require__.r(__webpack_exports__);
  8585. /* harmony import */ var _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./attachToBoxBehavior */ "./Behaviors/Meshes/attachToBoxBehavior.ts");
  8586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  8587. /* harmony import */ var _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fadeInOutBehavior */ "./Behaviors/Meshes/fadeInOutBehavior.ts");
  8588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  8589. /* harmony import */ var _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./multiPointerScaleBehavior */ "./Behaviors/Meshes/multiPointerScaleBehavior.ts");
  8590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__["MultiPointerScaleBehavior"]; });
  8591. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__["PointerDragBehavior"]; });
  8593. /* harmony import */ var _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  8594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__["SixDofDragBehavior"]; });
  8595. /***/ }),
  8596. /***/ "./Behaviors/Meshes/multiPointerScaleBehavior.ts":
  8597. /*!*******************************************************!*\
  8598. !*** ./Behaviors/Meshes/multiPointerScaleBehavior.ts ***!
  8599. \*******************************************************/
  8600. /*! exports provided: MultiPointerScaleBehavior */
  8601. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8602. "use strict";
  8603. __webpack_require__.r(__webpack_exports__);
  8604. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return MultiPointerScaleBehavior; });
  8605. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8606. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8607. /**
  8608. * A behavior that when attached to a mesh will allow the mesh to be scaled
  8609. */
  8610. var MultiPointerScaleBehavior = /** @class */ (function () {
  8611. /**
  8612. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  8613. */
  8614. function MultiPointerScaleBehavior() {
  8615. this._startDistance = 0;
  8616. this._initialScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8617. this._targetScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8618. this._sceneRenderObserver = null;
  8619. this._dragBehaviorA = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8620. this._dragBehaviorA.moveAttached = false;
  8621. this._dragBehaviorB = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8622. this._dragBehaviorB.moveAttached = false;
  8623. }
  8624. Object.defineProperty(MultiPointerScaleBehavior.prototype, "name", {
  8625. /**
  8626. * The name of the behavior
  8627. */
  8628. get: function () {
  8629. return "MultiPointerScale";
  8630. },
  8631. enumerable: true,
  8632. configurable: true
  8633. });
  8634. /**
  8635. * Initializes the behavior
  8636. */
  8637. MultiPointerScaleBehavior.prototype.init = function () { };
  8638. MultiPointerScaleBehavior.prototype._getCurrentDistance = function () {
  8639. return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length();
  8640. };
  8641. /**
  8642. * Attaches the scale behavior the passed in mesh
  8643. * @param ownerNode The mesh that will be scaled around once attached
  8644. */
  8645. MultiPointerScaleBehavior.prototype.attach = function (ownerNode) {
  8646. var _this = this;
  8647. this._ownerNode = ownerNode;
  8648. // Create 2 drag behaviors such that each will only be triggered by a separate pointer
  8649. this._dragBehaviorA.onDragStartObservable.add(function (e) {
  8650. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  8651. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  8652. _this._dragBehaviorA.releaseDrag();
  8653. }
  8654. else {
  8655. _this._initialScale.copyFrom(ownerNode.scaling);
  8656. _this._startDistance = _this._getCurrentDistance();
  8657. }
  8658. }
  8659. });
  8660. this._dragBehaviorB.onDragStartObservable.add(function (e) {
  8661. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  8662. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  8663. _this._dragBehaviorB.releaseDrag();
  8664. }
  8665. else {
  8666. _this._initialScale.copyFrom(ownerNode.scaling);
  8667. _this._startDistance = _this._getCurrentDistance();
  8668. }
  8669. }
  8670. });
  8671. // Once both drag behaviors are active scale based on the distance between the two pointers
  8672. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  8673. behavior.onDragObservable.add(function () {
  8674. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  8675. var ratio = _this._getCurrentDistance() / _this._startDistance;
  8676. _this._initialScale.scaleToRef(ratio, _this._targetScale);
  8677. }
  8678. });
  8679. });
  8680. ownerNode.addBehavior(this._dragBehaviorA);
  8681. ownerNode.addBehavior(this._dragBehaviorB);
  8682. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  8683. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  8684. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  8685. var change = _this._targetScale.subtract(ownerNode.scaling).scaleInPlace(0.1);
  8686. if (change.length() > 0.01) {
  8687. ownerNode.scaling.addInPlace(change);
  8688. }
  8689. }
  8690. });
  8691. };
  8692. /**
  8693. * Detaches the behavior from the mesh
  8694. */
  8695. MultiPointerScaleBehavior.prototype.detach = function () {
  8696. var _this = this;
  8697. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  8698. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  8699. behavior.onDragStartObservable.clear();
  8700. behavior.onDragObservable.clear();
  8701. _this._ownerNode.removeBehavior(behavior);
  8702. });
  8703. };
  8704. return MultiPointerScaleBehavior;
  8705. }());
  8706. /***/ }),
  8707. /***/ "./Behaviors/Meshes/pointerDragBehavior.ts":
  8708. /*!*************************************************!*\
  8709. !*** ./Behaviors/Meshes/pointerDragBehavior.ts ***!
  8710. \*************************************************/
  8711. /*! exports provided: PointerDragBehavior */
  8712. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8713. "use strict";
  8714. __webpack_require__.r(__webpack_exports__);
  8715. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return PointerDragBehavior; });
  8716. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  8717. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  8718. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  8719. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8720. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  8721. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  8722. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  8723. /**
  8724. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  8725. */
  8726. var PointerDragBehavior = /** @class */ (function () {
  8727. /**
  8728. * Creates a pointer drag behavior that can be attached to a mesh
  8729. * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)
  8730. */
  8731. function PointerDragBehavior(options) {
  8732. /**
  8733. * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
  8734. */
  8735. this.maxDragAngle = 0;
  8736. /**
  8737. * @hidden
  8738. */
  8739. this._useAlternatePickedPointAboveMaxDragAngle = false;
  8740. /**
  8741. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  8742. */
  8743. this.currentDraggingPointerID = -1;
  8744. /**
  8745. * If the behavior is currently in a dragging state
  8746. */
  8747. this.dragging = false;
  8748. /**
  8749. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  8750. */
  8751. this.dragDeltaRatio = 0.2;
  8752. /**
  8753. * If the drag plane orientation should be updated during the dragging (Default: true)
  8754. */
  8755. this.updateDragPlane = true;
  8756. // Debug mode will display drag planes to help visualize behavior
  8757. this._debugMode = false;
  8758. this._moving = false;
  8759. /**
  8760. * Fires each time the attached mesh is dragged with the pointer
  8761. * * delta between last drag position and current drag position in world space
  8762. * * dragDistance along the drag axis
  8763. * * dragPlaneNormal normal of the current drag plane used during the drag
  8764. * * dragPlanePoint in world space where the drag intersects the drag plane
  8765. */
  8766. this.onDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  8767. /**
  8768. * Fires each time a drag begins (eg. mouse down on mesh)
  8769. */
  8770. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  8771. /**
  8772. * Fires each time a drag ends (eg. mouse release after drag)
  8773. */
  8774. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  8775. /**
  8776. * If the attached mesh should be moved when dragged
  8777. */
  8778. this.moveAttached = true;
  8779. /**
  8780. * If the drag behavior will react to drag events (Default: true)
  8781. */
  8782. this.enabled = true;
  8783. /**
  8784. * If camera controls should be detached during the drag
  8785. */
  8786. this.detachCameraControls = true;
  8787. /**
  8788. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  8789. */
  8790. this.useObjectOrienationForDragging = true;
  8791. /**
  8792. * Predicate to determine if it is valid to move the object to a new position when it is moved
  8793. */
  8794. this.validateDrag = function (targetPosition) { return true; };
  8795. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8796. this._alternatePickedPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8797. this._worldDragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8798. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8799. this._attachedElement = null;
  8800. this._startDragRay = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]());
  8801. this._lastPointerRay = {};
  8802. this._dragDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  8803. // Variables to avoid instantiation in the below method
  8804. this._pointA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8805. this._pointB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8806. this._pointC = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8807. this._lineA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8808. this._lineB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8809. this._localAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8810. this._lookAt = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8811. this._options = options ? options : {};
  8812. var optionCount = 0;
  8813. if (this._options.dragAxis) {
  8814. optionCount++;
  8815. }
  8816. if (this._options.dragPlaneNormal) {
  8817. optionCount++;
  8818. }
  8819. if (optionCount > 1) {
  8820. throw "Multiple drag modes specified in dragBehavior options. Only one expected";
  8821. }
  8822. }
  8823. Object.defineProperty(PointerDragBehavior.prototype, "name", {
  8824. /**
  8825. * The name of the behavior
  8826. */
  8827. get: function () {
  8828. return "PointerDrag";
  8829. },
  8830. enumerable: true,
  8831. configurable: true
  8832. });
  8833. /**
  8834. * Initializes the behavior
  8835. */
  8836. PointerDragBehavior.prototype.init = function () { };
  8837. /**
  8838. * Attaches the drag behavior the passed in mesh
  8839. * @param ownerNode The mesh that will be dragged around once attached
  8840. */
  8841. PointerDragBehavior.prototype.attach = function (ownerNode) {
  8842. var _this = this;
  8843. this._scene = ownerNode.getScene();
  8844. this._attachedNode = ownerNode;
  8845. // Initialize drag plane to not interfere with existing scene
  8846. if (!PointerDragBehavior._planeScene) {
  8847. if (this._debugMode) {
  8848. PointerDragBehavior._planeScene = this._scene;
  8849. }
  8850. else {
  8851. PointerDragBehavior._planeScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  8852. PointerDragBehavior._planeScene.detachControl();
  8853. this._scene.getEngine().scenes.pop();
  8854. this._scene.onDisposeObservable.addOnce(function () {
  8855. PointerDragBehavior._planeScene.dispose();
  8856. PointerDragBehavior._planeScene = null;
  8857. });
  8858. }
  8859. }
  8860. this._dragPlane = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreatePlane("pointerDragPlane", this._debugMode ? 1 : 10000, PointerDragBehavior._planeScene, false, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].DOUBLESIDE);
  8861. // State of the drag
  8862. this.lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8863. var pickPredicate = function (m) {
  8864. return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
  8865. };
  8866. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  8867. if (!_this.enabled) {
  8868. return;
  8869. }
  8870. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN) {
  8871. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.pickedPoint && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  8872. _this._startDrag(pointerInfo.event.pointerId, pointerInfo.pickInfo.ray, pointerInfo.pickInfo.pickedPoint);
  8873. }
  8874. }
  8875. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP) {
  8876. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  8877. _this.releaseDrag();
  8878. }
  8879. }
  8880. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  8881. var pointerId = pointerInfo.event.pointerId;
  8882. // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved
  8883. if (_this.currentDraggingPointerID === PointerDragBehavior._AnyMouseID && pointerId !== PointerDragBehavior._AnyMouseID && pointerInfo.event.pointerType == "mouse") {
  8884. if (_this._lastPointerRay[_this.currentDraggingPointerID]) {
  8885. _this._lastPointerRay[pointerId] = _this._lastPointerRay[_this.currentDraggingPointerID];
  8886. delete _this._lastPointerRay[_this.currentDraggingPointerID];
  8887. }
  8888. _this.currentDraggingPointerID = pointerId;
  8889. }
  8890. // Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()
  8891. if (!_this._lastPointerRay[pointerId]) {
  8892. _this._lastPointerRay[pointerId] = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]());
  8893. }
  8894. if (pointerInfo.pickInfo && pointerInfo.pickInfo.ray) {
  8895. _this._lastPointerRay[pointerId].origin.copyFrom(pointerInfo.pickInfo.ray.origin);
  8896. _this._lastPointerRay[pointerId].direction.copyFrom(pointerInfo.pickInfo.ray.direction);
  8897. if (_this.currentDraggingPointerID == pointerId && _this.dragging) {
  8898. _this._moveDrag(pointerInfo.pickInfo.ray);
  8899. }
  8900. }
  8901. }
  8902. });
  8903. this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  8904. if (_this._moving && _this.moveAttached) {
  8905. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(_this._attachedNode);
  8906. // Slowly move mesh to avoid jitter
  8907. _this._targetPosition.subtractToRef((_this._attachedNode).absolutePosition, _this._tmpVector);
  8908. _this._tmpVector.scaleInPlace(_this.dragDeltaRatio);
  8909. (_this._attachedNode).getAbsolutePosition().addToRef(_this._tmpVector, _this._tmpVector);
  8910. if (_this.validateDrag(_this._tmpVector)) {
  8911. (_this._attachedNode).setAbsolutePosition(_this._tmpVector);
  8912. }
  8913. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(_this._attachedNode);
  8914. }
  8915. });
  8916. };
  8917. /**
  8918. * Force relase the drag action by code.
  8919. */
  8920. PointerDragBehavior.prototype.releaseDrag = function () {
  8921. this.dragging = false;
  8922. this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerID });
  8923. this.currentDraggingPointerID = -1;
  8924. this._moving = false;
  8925. // Reattach camera controls
  8926. if (this.detachCameraControls && this._attachedElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  8927. this._scene.activeCamera.attachControl(this._attachedElement, true);
  8928. }
  8929. };
  8930. /**
  8931. * Simulates the start of a pointer drag event on the behavior
  8932. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  8933. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  8934. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  8935. */
  8936. PointerDragBehavior.prototype.startDrag = function (pointerId, fromRay, startPickedPoint) {
  8937. if (pointerId === void 0) { pointerId = PointerDragBehavior._AnyMouseID; }
  8938. this._startDrag(pointerId, fromRay, startPickedPoint);
  8939. var lastRay = this._lastPointerRay[pointerId];
  8940. if (pointerId === PointerDragBehavior._AnyMouseID) {
  8941. lastRay = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]];
  8942. }
  8943. if (lastRay) {
  8944. // if there was a last pointer ray drag the object there
  8945. this._moveDrag(lastRay);
  8946. }
  8947. };
  8948. PointerDragBehavior.prototype._startDrag = function (pointerId, fromRay, startPickedPoint) {
  8949. if (!this._scene.activeCamera || this.dragging || !this._attachedNode) {
  8950. return;
  8951. }
  8952. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(this._attachedNode);
  8953. // Create start ray from the camera to the object
  8954. if (fromRay) {
  8955. this._startDragRay.direction.copyFrom(fromRay.direction);
  8956. this._startDragRay.origin.copyFrom(fromRay.origin);
  8957. }
  8958. else {
  8959. this._startDragRay.origin.copyFrom(this._scene.activeCamera.position);
  8960. this._attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector);
  8961. this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction);
  8962. }
  8963. this._updateDragPlanePosition(this._startDragRay, startPickedPoint ? startPickedPoint : this._tmpVector);
  8964. var pickedPoint = this._pickWithRayOnDragPlane(this._startDragRay);
  8965. if (pickedPoint) {
  8966. this.dragging = true;
  8967. this.currentDraggingPointerID = pointerId;
  8968. this.lastDragPosition.copyFrom(pickedPoint);
  8969. this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: this.currentDraggingPointerID });
  8970. this._targetPosition.copyFrom((this._attachedNode).absolutePosition);
  8971. // Detatch camera controls
  8972. if (this.detachCameraControls && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  8973. if (this._scene.activeCamera.inputs.attachedElement) {
  8974. this._attachedElement = this._scene.activeCamera.inputs.attachedElement;
  8975. this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement);
  8976. }
  8977. else {
  8978. this._attachedElement = null;
  8979. }
  8980. }
  8981. }
  8982. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(this._attachedNode);
  8983. };
  8984. PointerDragBehavior.prototype._moveDrag = function (ray) {
  8985. this._moving = true;
  8986. var pickedPoint = this._pickWithRayOnDragPlane(ray);
  8987. if (pickedPoint) {
  8988. if (this.updateDragPlane) {
  8989. this._updateDragPlanePosition(ray, pickedPoint);
  8990. }
  8991. var dragLength = 0;
  8992. // depending on the drag mode option drag accordingly
  8993. if (this._options.dragAxis) {
  8994. // Convert local drag axis to world
  8995. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis);
  8996. // Project delta drag from the drag plane onto the drag axis
  8997. pickedPoint.subtractToRef(this.lastDragPosition, this._tmpVector);
  8998. dragLength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._tmpVector, this._worldDragAxis);
  8999. this._worldDragAxis.scaleToRef(dragLength, this._dragDelta);
  9000. }
  9001. else {
  9002. dragLength = this._dragDelta.length();
  9003. pickedPoint.subtractToRef(this.lastDragPosition, this._dragDelta);
  9004. }
  9005. this._targetPosition.addInPlace(this._dragDelta);
  9006. this.onDragObservable.notifyObservers({ dragDistance: dragLength, delta: this._dragDelta, dragPlanePoint: pickedPoint, dragPlaneNormal: this._dragPlane.forward, pointerId: this.currentDraggingPointerID });
  9007. this.lastDragPosition.copyFrom(pickedPoint);
  9008. }
  9009. };
  9010. PointerDragBehavior.prototype._pickWithRayOnDragPlane = function (ray) {
  9011. var _this = this;
  9012. if (!ray) {
  9013. return null;
  9014. }
  9015. // Calculate angle between plane normal and ray
  9016. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, ray.direction));
  9017. // Correct if ray is casted from oposite side
  9018. if (angle > Math.PI / 2) {
  9019. angle = Math.PI - angle;
  9020. }
  9021. // If the angle is too perpendicular to the plane pick another point on the plane where it is looking
  9022. if (this.maxDragAngle > 0 && angle > this.maxDragAngle) {
  9023. if (this._useAlternatePickedPointAboveMaxDragAngle) {
  9024. // Invert ray direction along the towards object axis
  9025. this._tmpVector.copyFrom(ray.direction);
  9026. (this._attachedNode).absolutePosition.subtractToRef(ray.origin, this._alternatePickedPoint);
  9027. this._alternatePickedPoint.normalize();
  9028. this._alternatePickedPoint.scaleInPlace(-2 * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._alternatePickedPoint, this._tmpVector));
  9029. this._tmpVector.addInPlace(this._alternatePickedPoint);
  9030. // Project resulting vector onto the drag plane and add it to the attached nodes absolute position to get a picked point
  9031. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, this._tmpVector);
  9032. this._dragPlane.forward.scaleToRef(-dot, this._alternatePickedPoint);
  9033. this._alternatePickedPoint.addInPlace(this._tmpVector);
  9034. this._alternatePickedPoint.addInPlace((this._attachedNode).absolutePosition);
  9035. return this._alternatePickedPoint;
  9036. }
  9037. else {
  9038. return null;
  9039. }
  9040. }
  9041. var pickResult = PointerDragBehavior._planeScene.pickWithRay(ray, function (m) { return m == _this._dragPlane; });
  9042. if (pickResult && pickResult.hit && pickResult.pickedMesh && pickResult.pickedPoint) {
  9043. return pickResult.pickedPoint;
  9044. }
  9045. else {
  9046. return null;
  9047. }
  9048. };
  9049. // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera
  9050. PointerDragBehavior.prototype._updateDragPlanePosition = function (ray, dragPlanePosition) {
  9051. this._pointA.copyFrom(dragPlanePosition);
  9052. if (this._options.dragAxis) {
  9053. this.useObjectOrienationForDragging ? _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragAxis);
  9054. // Calculate plane normal in direction of camera but perpendicular to drag axis
  9055. this._pointA.addToRef(this._localAxis, this._pointB); // towards drag axis
  9056. ray.origin.subtractToRef(this._pointA, this._pointC);
  9057. this._pointA.addToRef(this._pointC.normalize(), this._pointC); // towards camera
  9058. // Get perpendicular line from direction to camera and drag axis
  9059. this._pointB.subtractToRef(this._pointA, this._lineA);
  9060. this._pointC.subtractToRef(this._pointA, this._lineB);
  9061. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lineB, this._lookAt);
  9062. // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendiculat to camera
  9063. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lookAt, this._lookAt);
  9064. this._lookAt.normalize();
  9065. this._dragPlane.position.copyFrom(this._pointA);
  9066. this._pointA.addToRef(this._lookAt, this._lookAt);
  9067. this._dragPlane.lookAt(this._lookAt);
  9068. }
  9069. else if (this._options.dragPlaneNormal) {
  9070. this.useObjectOrienationForDragging ? _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragPlaneNormal, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragPlaneNormal);
  9071. this._dragPlane.position.copyFrom(this._pointA);
  9072. this._pointA.addToRef(this._localAxis, this._lookAt);
  9073. this._dragPlane.lookAt(this._lookAt);
  9074. }
  9075. else {
  9076. this._dragPlane.position.copyFrom(this._pointA);
  9077. this._dragPlane.lookAt(ray.origin);
  9078. }
  9079. this._dragPlane.computeWorldMatrix(true);
  9080. };
  9081. /**
  9082. * Detaches the behavior from the mesh
  9083. */
  9084. PointerDragBehavior.prototype.detach = function () {
  9085. if (this._pointerObserver) {
  9086. this._scene.onPointerObservable.remove(this._pointerObserver);
  9087. }
  9088. if (this._beforeRenderObserver) {
  9089. this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  9090. }
  9091. };
  9092. PointerDragBehavior._AnyMouseID = -2;
  9093. return PointerDragBehavior;
  9094. }());
  9095. /***/ }),
  9096. /***/ "./Behaviors/Meshes/sixDofDragBehavior.ts":
  9097. /*!************************************************!*\
  9098. !*** ./Behaviors/Meshes/sixDofDragBehavior.ts ***!
  9099. \************************************************/
  9100. /*! exports provided: SixDofDragBehavior */
  9101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9102. "use strict";
  9103. __webpack_require__.r(__webpack_exports__);
  9104. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return SixDofDragBehavior; });
  9105. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  9106. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9107. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9108. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9109. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9110. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  9111. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9112. /**
  9113. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  9114. */
  9115. var SixDofDragBehavior = /** @class */ (function () {
  9116. /**
  9117. * Instantiates a behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  9118. */
  9119. function SixDofDragBehavior() {
  9120. this._sceneRenderObserver = null;
  9121. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9122. this._moving = false;
  9123. this._startingOrientation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9124. /**
  9125. * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)
  9126. */
  9127. this.zDragFactor = 3;
  9128. /**
  9129. * If the object should rotate to face the drag origin
  9130. */
  9131. this.rotateDraggedObject = true;
  9132. /**
  9133. * If the behavior is currently in a dragging state
  9134. */
  9135. this.dragging = false;
  9136. /**
  9137. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  9138. */
  9139. this.dragDeltaRatio = 0.2;
  9140. /**
  9141. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9142. */
  9143. this.currentDraggingPointerID = -1;
  9144. /**
  9145. * If camera controls should be detached during the drag
  9146. */
  9147. this.detachCameraControls = true;
  9148. /**
  9149. * Fires each time a drag starts
  9150. */
  9151. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9152. /**
  9153. * Fires each time a drag ends (eg. mouse release after drag)
  9154. */
  9155. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9156. }
  9157. Object.defineProperty(SixDofDragBehavior.prototype, "name", {
  9158. /**
  9159. * The name of the behavior
  9160. */
  9161. get: function () {
  9162. return "SixDofDrag";
  9163. },
  9164. enumerable: true,
  9165. configurable: true
  9166. });
  9167. /**
  9168. * Initializes the behavior
  9169. */
  9170. SixDofDragBehavior.prototype.init = function () { };
  9171. /**
  9172. * Attaches the scale behavior the passed in mesh
  9173. * @param ownerNode The mesh that will be scaled around once attached
  9174. */
  9175. SixDofDragBehavior.prototype.attach = function (ownerNode) {
  9176. var _this = this;
  9177. this._ownerNode = ownerNode;
  9178. this._scene = this._ownerNode.getScene();
  9179. if (!SixDofDragBehavior._virtualScene) {
  9180. SixDofDragBehavior._virtualScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9181. SixDofDragBehavior._virtualScene.detachControl();
  9182. this._scene.getEngine().scenes.pop();
  9183. }
  9184. var pickedMesh = null;
  9185. var lastSixDofOriginPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9186. // Setup virtual meshes to be used for dragging without dirtying the existing scene
  9187. this._virtualOriginMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9188. this._virtualOriginMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9189. this._virtualDragMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9190. this._virtualDragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9191. var pickPredicate = function (m) {
  9192. return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
  9193. };
  9194. var attachedElement = null;
  9195. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9196. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  9197. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9198. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9199. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9200. }
  9201. pickedMesh = _this._ownerNode;
  9202. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9203. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9204. // Set position and orientation of the controller
  9205. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9206. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9207. // Attach the virtual drag mesh to the virtual origin mesh so it can be dragged
  9208. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9209. pickedMesh.computeWorldMatrix();
  9210. _this._virtualDragMesh.position.copyFrom(pickedMesh.absolutePosition);
  9211. if (!pickedMesh.rotationQuaternion) {
  9212. pickedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(pickedMesh.rotation.y, pickedMesh.rotation.x, pickedMesh.rotation.z);
  9213. }
  9214. var oldParent = pickedMesh.parent;
  9215. pickedMesh.setParent(null);
  9216. _this._virtualDragMesh.rotationQuaternion.copyFrom(pickedMesh.rotationQuaternion);
  9217. pickedMesh.setParent(oldParent);
  9218. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9219. // Update state
  9220. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9221. _this.dragging = true;
  9222. _this.currentDraggingPointerID = pointerInfo.event.pointerId;
  9223. // Detatch camera controls
  9224. if (_this.detachCameraControls && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9225. if (_this._scene.activeCamera.inputs.attachedElement) {
  9226. attachedElement = _this._scene.activeCamera.inputs.attachedElement;
  9227. _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
  9228. }
  9229. else {
  9230. attachedElement = null;
  9231. }
  9232. }
  9233. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9234. _this.onDragStartObservable.notifyObservers({});
  9235. }
  9236. }
  9237. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP) {
  9238. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9239. _this.dragging = false;
  9240. _this._moving = false;
  9241. _this.currentDraggingPointerID = -1;
  9242. pickedMesh = null;
  9243. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9244. // Reattach camera controls
  9245. if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9246. _this._scene.activeCamera.attachControl(attachedElement, true);
  9247. }
  9248. _this.onDragEndObservable.notifyObservers({});
  9249. }
  9250. }
  9251. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE) {
  9252. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
  9253. var zDragFactor = _this.zDragFactor;
  9254. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9255. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9256. zDragFactor = 0;
  9257. }
  9258. // Calculate controller drag distance in controller space
  9259. var originDragDifference = pointerInfo.pickInfo.ray.origin.subtract(lastSixDofOriginPosition);
  9260. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9261. var localOriginDragDifference = -_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(originDragDifference, pointerInfo.pickInfo.ray.direction);
  9262. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9263. // Determine how much the controller moved to/away towards the dragged object and use this to move the object further when its further away
  9264. _this._virtualDragMesh.position.z -= _this._virtualDragMesh.position.z < 1 ? localOriginDragDifference * _this.zDragFactor : localOriginDragDifference * zDragFactor * _this._virtualDragMesh.position.z;
  9265. if (_this._virtualDragMesh.position.z < 0) {
  9266. _this._virtualDragMesh.position.z = 0;
  9267. }
  9268. // Update the controller position
  9269. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9270. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9271. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9272. // Move the virtualObjectsPosition into the picked mesh's space if needed
  9273. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9274. if (pickedMesh.parent) {
  9275. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._targetPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(pickedMesh.parent.getWorldMatrix()), _this._targetPosition);
  9276. }
  9277. if (!_this._moving) {
  9278. _this._startingOrientation.copyFrom(_this._virtualDragMesh.rotationQuaternion);
  9279. }
  9280. _this._moving = true;
  9281. }
  9282. }
  9283. });
  9284. var tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9285. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9286. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9287. if (_this.dragging && _this._moving && pickedMesh) {
  9288. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9289. // Slowly move mesh to avoid jitter
  9290. pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
  9291. if (_this.rotateDraggedObject) {
  9292. // Get change in rotation
  9293. tmpQuaternion.copyFrom(_this._startingOrientation);
  9294. tmpQuaternion.x = -tmpQuaternion.x;
  9295. tmpQuaternion.y = -tmpQuaternion.y;
  9296. tmpQuaternion.z = -tmpQuaternion.z;
  9297. _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
  9298. // Convert change in rotation to only y axis rotation
  9299. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
  9300. tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
  9301. // Slowly move mesh to avoid jitter
  9302. var oldParent = pickedMesh.parent;
  9303. // Only rotate the mesh if it's parent has uniform scaling
  9304. if (!oldParent || (oldParent.scaling && !oldParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  9305. pickedMesh.setParent(null);
  9306. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
  9307. pickedMesh.setParent(oldParent);
  9308. }
  9309. }
  9310. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9311. }
  9312. });
  9313. };
  9314. /**
  9315. * Detaches the behavior from the mesh
  9316. */
  9317. SixDofDragBehavior.prototype.detach = function () {
  9318. if (this._scene) {
  9319. this._scene.onPointerObservable.remove(this._pointerObserver);
  9320. }
  9321. if (this._ownerNode) {
  9322. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9323. }
  9324. if (this._virtualOriginMesh) {
  9325. this._virtualOriginMesh.dispose();
  9326. }
  9327. if (this._virtualDragMesh) {
  9328. this._virtualDragMesh.dispose();
  9329. }
  9330. this.onDragEndObservable.clear();
  9331. this.onDragStartObservable.clear();
  9332. };
  9333. return SixDofDragBehavior;
  9334. }());
  9335. /***/ }),
  9336. /***/ "./Behaviors/index.ts":
  9337. /*!****************************!*\
  9338. !*** ./Behaviors/index.ts ***!
  9339. \****************************/
  9340. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  9341. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9342. "use strict";
  9343. __webpack_require__.r(__webpack_exports__);
  9344. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Cameras/index */ "./Behaviors/Cameras/index.ts");
  9345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  9346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  9347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  9348. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Meshes/index */ "./Behaviors/Meshes/index.ts");
  9349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["AttachToBoxBehavior"]; });
  9350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  9351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["MultiPointerScaleBehavior"]; });
  9352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["PointerDragBehavior"]; });
  9353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["SixDofDragBehavior"]; });
  9354. /***/ }),
  9355. /***/ "./Bones/bone.ts":
  9356. /*!***********************!*\
  9357. !*** ./Bones/bone.ts ***!
  9358. \***********************/
  9359. /*! exports provided: Bone */
  9360. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9361. "use strict";
  9362. __webpack_require__.r(__webpack_exports__);
  9363. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return Bone; });
  9364. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  9365. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  9366. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  9367. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  9368. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  9369. /**
  9370. * Class used to store bone information
  9371. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9372. */
  9373. var Bone = /** @class */ (function (_super) {
  9374. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Bone, _super);
  9375. /**
  9376. * Create a new bone
  9377. * @param name defines the bone name
  9378. * @param skeleton defines the parent skeleton
  9379. * @param parentBone defines the parent (can be null if the bone is the root)
  9380. * @param localMatrix defines the local matrix
  9381. * @param restPose defines the rest pose matrix
  9382. * @param baseMatrix defines the base matrix
  9383. * @param index defines index of the bone in the hiearchy
  9384. */
  9385. function Bone(
  9386. /**
  9387. * defines the bone name
  9388. */
  9389. name, skeleton, parentBone, localMatrix, restPose, baseMatrix, index) {
  9390. if (parentBone === void 0) { parentBone = null; }
  9391. if (localMatrix === void 0) { localMatrix = null; }
  9392. if (restPose === void 0) { restPose = null; }
  9393. if (baseMatrix === void 0) { baseMatrix = null; }
  9394. if (index === void 0) { index = null; }
  9395. var _this = _super.call(this, name, skeleton.getScene(), false) || this;
  9396. _this.name = name;
  9397. /**
  9398. * Gets the list of child bones
  9399. */
  9400. _this.children = new Array();
  9401. /** Gets the animations associated with this bone */
  9402. _this.animations = new Array();
  9403. /**
  9404. * @hidden Internal only
  9405. * Set this value to map this bone to a different index in the transform matrices
  9406. * Set this value to -1 to exclude the bone from the transform matrices
  9407. */
  9408. _this._index = null;
  9409. _this._absoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9410. _this._invertedAbsoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9411. _this._scalingDeterminant = 1;
  9412. _this._worldTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9413. _this._needToDecompose = true;
  9414. _this._needToCompose = false;
  9415. /** @hidden */
  9416. _this._linkedTransformNode = null;
  9417. _this._skeleton = skeleton;
  9418. _this._localMatrix = localMatrix ? localMatrix.clone() : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  9419. _this._restPose = restPose ? restPose : _this._localMatrix.clone();
  9420. _this._baseMatrix = baseMatrix ? baseMatrix : _this._localMatrix.clone();
  9421. _this._index = index;
  9422. skeleton.bones.push(_this);
  9423. _this.setParent(parentBone, false);
  9424. if (baseMatrix || localMatrix) {
  9425. _this._updateDifferenceMatrix();
  9426. }
  9427. return _this;
  9428. }
  9429. Object.defineProperty(Bone.prototype, "_matrix", {
  9430. /** @hidden */
  9431. get: function () {
  9432. this._compose();
  9433. return this._localMatrix;
  9434. },
  9435. /** @hidden */
  9436. set: function (value) {
  9437. this._localMatrix.copyFrom(value);
  9438. this._needToDecompose = true;
  9439. },
  9440. enumerable: true,
  9441. configurable: true
  9442. });
  9443. // Members
  9444. /**
  9445. * Gets the parent skeleton
  9446. * @returns a skeleton
  9447. */
  9448. Bone.prototype.getSkeleton = function () {
  9449. return this._skeleton;
  9450. };
  9451. /**
  9452. * Gets parent bone
  9453. * @returns a bone or null if the bone is the root of the bone hierarchy
  9454. */
  9455. Bone.prototype.getParent = function () {
  9456. return this._parent;
  9457. };
  9458. /**
  9459. * Sets the parent bone
  9460. * @param parent defines the parent (can be null if the bone is the root)
  9461. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9462. */
  9463. Bone.prototype.setParent = function (parent, updateDifferenceMatrix) {
  9464. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9465. if (this._parent === parent) {
  9466. return;
  9467. }
  9468. if (this._parent) {
  9469. var index = this._parent.children.indexOf(this);
  9470. if (index !== -1) {
  9471. this._parent.children.splice(index, 1);
  9472. }
  9473. }
  9474. this._parent = parent;
  9475. if (this._parent) {
  9476. this._parent.children.push(this);
  9477. }
  9478. if (updateDifferenceMatrix) {
  9479. this._updateDifferenceMatrix();
  9480. }
  9481. this.markAsDirty();
  9482. };
  9483. /**
  9484. * Gets the local matrix
  9485. * @returns a matrix
  9486. */
  9487. Bone.prototype.getLocalMatrix = function () {
  9488. this._compose();
  9489. return this._localMatrix;
  9490. };
  9491. /**
  9492. * Gets the base matrix (initial matrix which remains unchanged)
  9493. * @returns a matrix
  9494. */
  9495. Bone.prototype.getBaseMatrix = function () {
  9496. return this._baseMatrix;
  9497. };
  9498. /**
  9499. * Gets the rest pose matrix
  9500. * @returns a matrix
  9501. */
  9502. Bone.prototype.getRestPose = function () {
  9503. return this._restPose;
  9504. };
  9505. /**
  9506. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9507. */
  9508. Bone.prototype.getWorldMatrix = function () {
  9509. return this._worldTransform;
  9510. };
  9511. /**
  9512. * Sets the local matrix to rest pose matrix
  9513. */
  9514. Bone.prototype.returnToRest = function () {
  9515. this.updateMatrix(this._restPose.clone());
  9516. };
  9517. /**
  9518. * Gets the inverse of the absolute transform matrix.
  9519. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9520. * @returns a matrix
  9521. */
  9522. Bone.prototype.getInvertedAbsoluteTransform = function () {
  9523. return this._invertedAbsoluteTransform;
  9524. };
  9525. /**
  9526. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9527. * @returns a matrix
  9528. */
  9529. Bone.prototype.getAbsoluteTransform = function () {
  9530. return this._absoluteTransform;
  9531. };
  9532. /**
  9533. * Links with the given transform node.
  9534. * The local matrix of this bone is copied from the transform node every frame.
  9535. * @param transformNode defines the transform node to link to
  9536. */
  9537. Bone.prototype.linkTransformNode = function (transformNode) {
  9538. if (this._linkedTransformNode) {
  9539. this._skeleton._numBonesWithLinkedTransformNode--;
  9540. }
  9541. this._linkedTransformNode = transformNode;
  9542. if (this._linkedTransformNode) {
  9543. this._skeleton._numBonesWithLinkedTransformNode++;
  9544. }
  9545. };
  9546. Object.defineProperty(Bone.prototype, "position", {
  9547. // Properties (matches AbstractMesh properties)
  9548. /** Gets or sets current position (in local space) */
  9549. get: function () {
  9550. this._decompose();
  9551. return this._localPosition;
  9552. },
  9553. set: function (newPosition) {
  9554. this._decompose();
  9555. this._localPosition.copyFrom(newPosition);
  9556. this._markAsDirtyAndCompose();
  9557. },
  9558. enumerable: true,
  9559. configurable: true
  9560. });
  9561. Object.defineProperty(Bone.prototype, "rotation", {
  9562. /** Gets or sets current rotation (in local space) */
  9563. get: function () {
  9564. return this.getRotation();
  9565. },
  9566. set: function (newRotation) {
  9567. this.setRotation(newRotation);
  9568. },
  9569. enumerable: true,
  9570. configurable: true
  9571. });
  9572. Object.defineProperty(Bone.prototype, "rotationQuaternion", {
  9573. /** Gets or sets current rotation quaternion (in local space) */
  9574. get: function () {
  9575. this._decompose();
  9576. return this._localRotation;
  9577. },
  9578. set: function (newRotation) {
  9579. this.setRotationQuaternion(newRotation);
  9580. },
  9581. enumerable: true,
  9582. configurable: true
  9583. });
  9584. Object.defineProperty(Bone.prototype, "scaling", {
  9585. /** Gets or sets current scaling (in local space) */
  9586. get: function () {
  9587. return this.getScale();
  9588. },
  9589. set: function (newScaling) {
  9590. this.setScale(newScaling);
  9591. },
  9592. enumerable: true,
  9593. configurable: true
  9594. });
  9595. Object.defineProperty(Bone.prototype, "animationPropertiesOverride", {
  9596. /**
  9597. * Gets the animation properties override
  9598. */
  9599. get: function () {
  9600. return this._skeleton.animationPropertiesOverride;
  9601. },
  9602. enumerable: true,
  9603. configurable: true
  9604. });
  9605. // Methods
  9606. Bone.prototype._decompose = function () {
  9607. if (!this._needToDecompose) {
  9608. return;
  9609. }
  9610. this._needToDecompose = false;
  9611. if (!this._localScaling) {
  9612. this._localScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9613. this._localRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Zero();
  9614. this._localPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9615. }
  9616. this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition);
  9617. };
  9618. Bone.prototype._compose = function () {
  9619. if (!this._needToCompose) {
  9620. return;
  9621. }
  9622. this._needToCompose = false;
  9623. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix);
  9624. };
  9625. /**
  9626. * Update the base and local matrices
  9627. * @param matrix defines the new base or local matrix
  9628. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9629. * @param updateLocalMatrix defines if the local matrix should be updated
  9630. */
  9631. Bone.prototype.updateMatrix = function (matrix, updateDifferenceMatrix, updateLocalMatrix) {
  9632. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9633. if (updateLocalMatrix === void 0) { updateLocalMatrix = true; }
  9634. this._baseMatrix.copyFrom(matrix);
  9635. if (updateDifferenceMatrix) {
  9636. this._updateDifferenceMatrix();
  9637. }
  9638. if (updateLocalMatrix) {
  9639. this._localMatrix.copyFrom(matrix);
  9640. this._markAsDirtyAndDecompose();
  9641. }
  9642. else {
  9643. this.markAsDirty();
  9644. }
  9645. };
  9646. /** @hidden */
  9647. Bone.prototype._updateDifferenceMatrix = function (rootMatrix, updateChildren) {
  9648. if (updateChildren === void 0) { updateChildren = true; }
  9649. if (!rootMatrix) {
  9650. rootMatrix = this._baseMatrix;
  9651. }
  9652. if (this._parent) {
  9653. rootMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  9654. }
  9655. else {
  9656. this._absoluteTransform.copyFrom(rootMatrix);
  9657. }
  9658. this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);
  9659. if (updateChildren) {
  9660. for (var index = 0; index < this.children.length; index++) {
  9661. this.children[index]._updateDifferenceMatrix();
  9662. }
  9663. }
  9664. this._scalingDeterminant = (this._absoluteTransform.determinant() < 0 ? -1 : 1);
  9665. };
  9666. /**
  9667. * Flag the bone as dirty (Forcing it to update everything)
  9668. */
  9669. Bone.prototype.markAsDirty = function () {
  9670. this._currentRenderId++;
  9671. this._childRenderId++;
  9672. this._skeleton._markAsDirty();
  9673. };
  9674. Bone.prototype._markAsDirtyAndCompose = function () {
  9675. this.markAsDirty();
  9676. this._needToCompose = true;
  9677. };
  9678. Bone.prototype._markAsDirtyAndDecompose = function () {
  9679. this.markAsDirty();
  9680. this._needToDecompose = true;
  9681. };
  9682. /**
  9683. * Copy an animation range from another bone
  9684. * @param source defines the source bone
  9685. * @param rangeName defines the range name to copy
  9686. * @param frameOffset defines the frame offset
  9687. * @param rescaleAsRequired defines if rescaling must be applied if required
  9688. * @param skelDimensionsRatio defines the scaling ratio
  9689. * @returns true if operation was successful
  9690. */
  9691. Bone.prototype.copyAnimationRange = function (source, rangeName, frameOffset, rescaleAsRequired, skelDimensionsRatio) {
  9692. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  9693. if (skelDimensionsRatio === void 0) { skelDimensionsRatio = null; }
  9694. // all animation may be coming from a library skeleton, so may need to create animation
  9695. if (this.animations.length === 0) {
  9696. this.animations.push(new _Animations_animation__WEBPACK_IMPORTED_MODULE_3__["Animation"](this.name, "_matrix", source.animations[0].framePerSecond, _Animations_animation__WEBPACK_IMPORTED_MODULE_3__["Animation"].ANIMATIONTYPE_MATRIX, 0));
  9697. this.animations[0].setKeys([]);
  9698. }
  9699. // get animation info / verify there is such a range from the source bone
  9700. var sourceRange = source.animations[0].getRange(rangeName);
  9701. if (!sourceRange) {
  9702. return false;
  9703. }
  9704. var from = sourceRange.from;
  9705. var to = sourceRange.to;
  9706. var sourceKeys = source.animations[0].getKeys();
  9707. // rescaling prep
  9708. var sourceBoneLength = source.length;
  9709. var sourceParent = source.getParent();
  9710. var parent = this.getParent();
  9711. var parentScalingReqd = rescaleAsRequired && sourceParent && sourceBoneLength && this.length && sourceBoneLength !== this.length;
  9712. var parentRatio = parentScalingReqd && parent && sourceParent ? parent.length / sourceParent.length : 1;
  9713. var dimensionsScalingReqd = rescaleAsRequired && !parent && skelDimensionsRatio && (skelDimensionsRatio.x !== 1 || skelDimensionsRatio.y !== 1 || skelDimensionsRatio.z !== 1);
  9714. var destKeys = this.animations[0].getKeys();
  9715. // loop vars declaration
  9716. var orig;
  9717. var origTranslation;
  9718. var mat;
  9719. for (var key = 0, nKeys = sourceKeys.length; key < nKeys; key++) {
  9720. orig = sourceKeys[key];
  9721. if (orig.frame >= from && orig.frame <= to) {
  9722. if (rescaleAsRequired) {
  9723. mat = orig.value.clone();
  9724. // scale based on parent ratio, when bone has parent
  9725. if (parentScalingReqd) {
  9726. origTranslation = mat.getTranslation();
  9727. mat.setTranslation(origTranslation.scaleInPlace(parentRatio));
  9728. // scale based on skeleton dimension ratio when root bone, and value is passed
  9729. }
  9730. else if (dimensionsScalingReqd && skelDimensionsRatio) {
  9731. origTranslation = mat.getTranslation();
  9732. mat.setTranslation(origTranslation.multiplyInPlace(skelDimensionsRatio));
  9733. // use original when root bone, and no data for skelDimensionsRatio
  9734. }
  9735. else {
  9736. mat = orig.value;
  9737. }
  9738. }
  9739. else {
  9740. mat = orig.value;
  9741. }
  9742. destKeys.push({ frame: orig.frame + frameOffset, value: mat });
  9743. }
  9744. }
  9745. this.animations[0].createRange(rangeName, from + frameOffset, to + frameOffset);
  9746. return true;
  9747. };
  9748. /**
  9749. * Translate the bone in local or world space
  9750. * @param vec The amount to translate the bone
  9751. * @param space The space that the translation is in
  9752. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9753. */
  9754. Bone.prototype.translate = function (vec, space, mesh) {
  9755. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9756. var lm = this.getLocalMatrix();
  9757. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  9758. lm.addAtIndex(12, vec.x);
  9759. lm.addAtIndex(13, vec.y);
  9760. lm.addAtIndex(14, vec.z);
  9761. }
  9762. else {
  9763. var wm = null;
  9764. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  9765. if (mesh) {
  9766. wm = mesh.getWorldMatrix();
  9767. }
  9768. this._skeleton.computeAbsoluteTransforms();
  9769. var tmat = Bone._tmpMats[0];
  9770. var tvec = Bone._tmpVecs[0];
  9771. if (this._parent) {
  9772. if (mesh && wm) {
  9773. tmat.copyFrom(this._parent.getAbsoluteTransform());
  9774. tmat.multiplyToRef(wm, tmat);
  9775. }
  9776. else {
  9777. tmat.copyFrom(this._parent.getAbsoluteTransform());
  9778. }
  9779. }
  9780. tmat.setTranslationFromFloats(0, 0, 0);
  9781. tmat.invert();
  9782. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vec, tmat, tvec);
  9783. lm.addAtIndex(12, tvec.x);
  9784. lm.addAtIndex(13, tvec.y);
  9785. lm.addAtIndex(14, tvec.z);
  9786. }
  9787. this._markAsDirtyAndDecompose();
  9788. };
  9789. /**
  9790. * Set the postion of the bone in local or world space
  9791. * @param position The position to set the bone
  9792. * @param space The space that the position is in
  9793. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9794. */
  9795. Bone.prototype.setPosition = function (position, space, mesh) {
  9796. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9797. var lm = this.getLocalMatrix();
  9798. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  9799. lm.setTranslationFromFloats(position.x, position.y, position.z);
  9800. }
  9801. else {
  9802. var wm = null;
  9803. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  9804. if (mesh) {
  9805. wm = mesh.getWorldMatrix();
  9806. }
  9807. this._skeleton.computeAbsoluteTransforms();
  9808. var tmat = Bone._tmpMats[0];
  9809. var vec = Bone._tmpVecs[0];
  9810. if (this._parent) {
  9811. if (mesh && wm) {
  9812. tmat.copyFrom(this._parent.getAbsoluteTransform());
  9813. tmat.multiplyToRef(wm, tmat);
  9814. }
  9815. else {
  9816. tmat.copyFrom(this._parent.getAbsoluteTransform());
  9817. }
  9818. }
  9819. tmat.invert();
  9820. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, vec);
  9821. lm.setTranslationFromFloats(vec.x, vec.y, vec.z);
  9822. }
  9823. this._markAsDirtyAndDecompose();
  9824. };
  9825. /**
  9826. * Set the absolute position of the bone (world space)
  9827. * @param position The position to set the bone
  9828. * @param mesh The mesh that this bone is attached to
  9829. */
  9830. Bone.prototype.setAbsolutePosition = function (position, mesh) {
  9831. this.setPosition(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh);
  9832. };
  9833. /**
  9834. * Scale the bone on the x, y and z axes (in local space)
  9835. * @param x The amount to scale the bone on the x axis
  9836. * @param y The amount to scale the bone on the y axis
  9837. * @param z The amount to scale the bone on the z axis
  9838. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9839. */
  9840. Bone.prototype.scale = function (x, y, z, scaleChildren) {
  9841. if (scaleChildren === void 0) { scaleChildren = false; }
  9842. var locMat = this.getLocalMatrix();
  9843. // Apply new scaling on top of current local matrix
  9844. var scaleMat = Bone._tmpMats[0];
  9845. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(x, y, z, scaleMat);
  9846. scaleMat.multiplyToRef(locMat, locMat);
  9847. // Invert scaling matrix and apply the inverse to all children
  9848. scaleMat.invert();
  9849. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9850. var child = _a[_i];
  9851. var cm = child.getLocalMatrix();
  9852. cm.multiplyToRef(scaleMat, cm);
  9853. cm.multiplyAtIndex(12, x);
  9854. cm.multiplyAtIndex(13, y);
  9855. cm.multiplyAtIndex(14, z);
  9856. child._markAsDirtyAndDecompose();
  9857. }
  9858. this._markAsDirtyAndDecompose();
  9859. if (scaleChildren) {
  9860. for (var _b = 0, _c = this.children; _b < _c.length; _b++) {
  9861. var child = _c[_b];
  9862. child.scale(x, y, z, scaleChildren);
  9863. }
  9864. }
  9865. };
  9866. /**
  9867. * Set the bone scaling in local space
  9868. * @param scale defines the scaling vector
  9869. */
  9870. Bone.prototype.setScale = function (scale) {
  9871. this._decompose();
  9872. this._localScaling.copyFrom(scale);
  9873. this._markAsDirtyAndCompose();
  9874. };
  9875. /**
  9876. * Gets the current scaling in local space
  9877. * @returns the current scaling vector
  9878. */
  9879. Bone.prototype.getScale = function () {
  9880. this._decompose();
  9881. return this._localScaling;
  9882. };
  9883. /**
  9884. * Gets the current scaling in local space and stores it in a target vector
  9885. * @param result defines the target vector
  9886. */
  9887. Bone.prototype.getScaleToRef = function (result) {
  9888. this._decompose();
  9889. result.copyFrom(this._localScaling);
  9890. };
  9891. /**
  9892. * Set the yaw, pitch, and roll of the bone in local or world space
  9893. * @param yaw The rotation of the bone on the y axis
  9894. * @param pitch The rotation of the bone on the x axis
  9895. * @param roll The rotation of the bone on the z axis
  9896. * @param space The space that the axes of rotation are in
  9897. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9898. */
  9899. Bone.prototype.setYawPitchRoll = function (yaw, pitch, roll, space, mesh) {
  9900. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9901. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  9902. var quat = Bone._tmpQuat;
  9903. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationYawPitchRollToRef(yaw, pitch, roll, quat);
  9904. this.setRotationQuaternion(quat, space, mesh);
  9905. return;
  9906. }
  9907. var rotMatInv = Bone._tmpMats[0];
  9908. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  9909. return;
  9910. }
  9911. var rotMat = Bone._tmpMats[1];
  9912. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yaw, pitch, roll, rotMat);
  9913. rotMatInv.multiplyToRef(rotMat, rotMat);
  9914. this._rotateWithMatrix(rotMat, space, mesh);
  9915. };
  9916. /**
  9917. * Add a rotation to the bone on an axis in local or world space
  9918. * @param axis The axis to rotate the bone on
  9919. * @param amount The amount to rotate the bone
  9920. * @param space The space that the axis is in
  9921. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9922. */
  9923. Bone.prototype.rotate = function (axis, amount, space, mesh) {
  9924. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9925. var rmat = Bone._tmpMats[0];
  9926. rmat.setTranslationFromFloats(0, 0, 0);
  9927. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, amount, rmat);
  9928. this._rotateWithMatrix(rmat, space, mesh);
  9929. };
  9930. /**
  9931. * Set the rotation of the bone to a particular axis angle in local or world space
  9932. * @param axis The axis to rotate the bone on
  9933. * @param angle The angle that the bone should be rotated to
  9934. * @param space The space that the axis is in
  9935. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9936. */
  9937. Bone.prototype.setAxisAngle = function (axis, angle, space, mesh) {
  9938. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9939. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  9940. var quat = Bone._tmpQuat;
  9941. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationAxisToRef(axis, angle, quat);
  9942. this.setRotationQuaternion(quat, space, mesh);
  9943. return;
  9944. }
  9945. var rotMatInv = Bone._tmpMats[0];
  9946. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  9947. return;
  9948. }
  9949. var rotMat = Bone._tmpMats[1];
  9950. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, angle, rotMat);
  9951. rotMatInv.multiplyToRef(rotMat, rotMat);
  9952. this._rotateWithMatrix(rotMat, space, mesh);
  9953. };
  9954. /**
  9955. * Set the euler rotation of the bone in local of world space
  9956. * @param rotation The euler rotation that the bone should be set to
  9957. * @param space The space that the rotation is in
  9958. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9959. */
  9960. Bone.prototype.setRotation = function (rotation, space, mesh) {
  9961. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9962. this.setYawPitchRoll(rotation.y, rotation.x, rotation.z, space, mesh);
  9963. };
  9964. /**
  9965. * Set the quaternion rotation of the bone in local of world space
  9966. * @param quat The quaternion rotation that the bone should be set to
  9967. * @param space The space that the rotation is in
  9968. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9969. */
  9970. Bone.prototype.setRotationQuaternion = function (quat, space, mesh) {
  9971. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9972. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  9973. this._decompose();
  9974. this._localRotation.copyFrom(quat);
  9975. this._markAsDirtyAndCompose();
  9976. return;
  9977. }
  9978. var rotMatInv = Bone._tmpMats[0];
  9979. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  9980. return;
  9981. }
  9982. var rotMat = Bone._tmpMats[1];
  9983. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromQuaternionToRef(quat, rotMat);
  9984. rotMatInv.multiplyToRef(rotMat, rotMat);
  9985. this._rotateWithMatrix(rotMat, space, mesh);
  9986. };
  9987. /**
  9988. * Set the rotation matrix of the bone in local of world space
  9989. * @param rotMat The rotation matrix that the bone should be set to
  9990. * @param space The space that the rotation is in
  9991. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9992. */
  9993. Bone.prototype.setRotationMatrix = function (rotMat, space, mesh) {
  9994. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9995. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  9996. var quat = Bone._tmpQuat;
  9997. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(rotMat, quat);
  9998. this.setRotationQuaternion(quat, space, mesh);
  9999. return;
  10000. }
  10001. var rotMatInv = Bone._tmpMats[0];
  10002. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10003. return;
  10004. }
  10005. var rotMat2 = Bone._tmpMats[1];
  10006. rotMat2.copyFrom(rotMat);
  10007. rotMatInv.multiplyToRef(rotMat, rotMat2);
  10008. this._rotateWithMatrix(rotMat2, space, mesh);
  10009. };
  10010. Bone.prototype._rotateWithMatrix = function (rmat, space, mesh) {
  10011. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10012. var lmat = this.getLocalMatrix();
  10013. var lx = lmat.m[12];
  10014. var ly = lmat.m[13];
  10015. var lz = lmat.m[14];
  10016. var parent = this.getParent();
  10017. var parentScale = Bone._tmpMats[3];
  10018. var parentScaleInv = Bone._tmpMats[4];
  10019. if (parent && space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD) {
  10020. if (mesh) {
  10021. parentScale.copyFrom(mesh.getWorldMatrix());
  10022. parent.getAbsoluteTransform().multiplyToRef(parentScale, parentScale);
  10023. }
  10024. else {
  10025. parentScale.copyFrom(parent.getAbsoluteTransform());
  10026. }
  10027. parentScaleInv.copyFrom(parentScale);
  10028. parentScaleInv.invert();
  10029. lmat.multiplyToRef(parentScale, lmat);
  10030. lmat.multiplyToRef(rmat, lmat);
  10031. lmat.multiplyToRef(parentScaleInv, lmat);
  10032. }
  10033. else {
  10034. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD && mesh) {
  10035. parentScale.copyFrom(mesh.getWorldMatrix());
  10036. parentScaleInv.copyFrom(parentScale);
  10037. parentScaleInv.invert();
  10038. lmat.multiplyToRef(parentScale, lmat);
  10039. lmat.multiplyToRef(rmat, lmat);
  10040. lmat.multiplyToRef(parentScaleInv, lmat);
  10041. }
  10042. else {
  10043. lmat.multiplyToRef(rmat, lmat);
  10044. }
  10045. }
  10046. lmat.setTranslationFromFloats(lx, ly, lz);
  10047. this.computeAbsoluteTransforms();
  10048. this._markAsDirtyAndDecompose();
  10049. };
  10050. Bone.prototype._getNegativeRotationToRef = function (rotMatInv, mesh) {
  10051. var scaleMatrix = Bone._tmpMats[2];
  10052. rotMatInv.copyFrom(this.getAbsoluteTransform());
  10053. if (mesh) {
  10054. rotMatInv.multiplyToRef(mesh.getWorldMatrix(), rotMatInv);
  10055. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(mesh.scaling.x, mesh.scaling.y, mesh.scaling.z, scaleMatrix);
  10056. }
  10057. rotMatInv.invert();
  10058. if (isNaN(rotMatInv.m[0])) {
  10059. // Matrix failed to invert.
  10060. // This can happen if scale is zero for example.
  10061. return false;
  10062. }
  10063. scaleMatrix.multiplyAtIndex(0, this._scalingDeterminant);
  10064. rotMatInv.multiplyToRef(scaleMatrix, rotMatInv);
  10065. return true;
  10066. };
  10067. /**
  10068. * Get the position of the bone in local or world space
  10069. * @param space The space that the returned position is in
  10070. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10071. * @returns The position of the bone
  10072. */
  10073. Bone.prototype.getPosition = function (space, mesh) {
  10074. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10075. if (mesh === void 0) { mesh = null; }
  10076. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10077. this.getPositionToRef(space, mesh, pos);
  10078. return pos;
  10079. };
  10080. /**
  10081. * Copy the position of the bone to a vector3 in local or world space
  10082. * @param space The space that the returned position is in
  10083. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10084. * @param result The vector3 to copy the position to
  10085. */
  10086. Bone.prototype.getPositionToRef = function (space, mesh, result) {
  10087. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10088. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10089. var lm = this.getLocalMatrix();
  10090. result.x = lm.m[12];
  10091. result.y = lm.m[13];
  10092. result.z = lm.m[14];
  10093. }
  10094. else {
  10095. var wm = null;
  10096. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10097. if (mesh) {
  10098. wm = mesh.getWorldMatrix();
  10099. }
  10100. this._skeleton.computeAbsoluteTransforms();
  10101. var tmat = Bone._tmpMats[0];
  10102. if (mesh && wm) {
  10103. tmat.copyFrom(this.getAbsoluteTransform());
  10104. tmat.multiplyToRef(wm, tmat);
  10105. }
  10106. else {
  10107. tmat = this.getAbsoluteTransform();
  10108. }
  10109. result.x = tmat.m[12];
  10110. result.y = tmat.m[13];
  10111. result.z = tmat.m[14];
  10112. }
  10113. };
  10114. /**
  10115. * Get the absolute position of the bone (world space)
  10116. * @param mesh The mesh that this bone is attached to
  10117. * @returns The absolute position of the bone
  10118. */
  10119. Bone.prototype.getAbsolutePosition = function (mesh) {
  10120. if (mesh === void 0) { mesh = null; }
  10121. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10122. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, pos);
  10123. return pos;
  10124. };
  10125. /**
  10126. * Copy the absolute position of the bone (world space) to the result param
  10127. * @param mesh The mesh that this bone is attached to
  10128. * @param result The vector3 to copy the absolute position to
  10129. */
  10130. Bone.prototype.getAbsolutePositionToRef = function (mesh, result) {
  10131. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, result);
  10132. };
  10133. /**
  10134. * Compute the absolute transforms of this bone and its children
  10135. */
  10136. Bone.prototype.computeAbsoluteTransforms = function () {
  10137. this._compose();
  10138. if (this._parent) {
  10139. this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10140. }
  10141. else {
  10142. this._absoluteTransform.copyFrom(this._localMatrix);
  10143. var poseMatrix = this._skeleton.getPoseMatrix();
  10144. if (poseMatrix) {
  10145. this._absoluteTransform.multiplyToRef(poseMatrix, this._absoluteTransform);
  10146. }
  10147. }
  10148. var children = this.children;
  10149. var len = children.length;
  10150. for (var i = 0; i < len; i++) {
  10151. children[i].computeAbsoluteTransforms();
  10152. }
  10153. };
  10154. /**
  10155. * Get the world direction from an axis that is in the local space of the bone
  10156. * @param localAxis The local direction that is used to compute the world direction
  10157. * @param mesh The mesh that this bone is attached to
  10158. * @returns The world direction
  10159. */
  10160. Bone.prototype.getDirection = function (localAxis, mesh) {
  10161. if (mesh === void 0) { mesh = null; }
  10162. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10163. this.getDirectionToRef(localAxis, mesh, result);
  10164. return result;
  10165. };
  10166. /**
  10167. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  10168. * @param localAxis The local direction that is used to compute the world direction
  10169. * @param mesh The mesh that this bone is attached to
  10170. * @param result The vector3 that the world direction will be copied to
  10171. */
  10172. Bone.prototype.getDirectionToRef = function (localAxis, mesh, result) {
  10173. if (mesh === void 0) { mesh = null; }
  10174. var wm = null;
  10175. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10176. if (mesh) {
  10177. wm = mesh.getWorldMatrix();
  10178. }
  10179. this._skeleton.computeAbsoluteTransforms();
  10180. var mat = Bone._tmpMats[0];
  10181. mat.copyFrom(this.getAbsoluteTransform());
  10182. if (mesh && wm) {
  10183. mat.multiplyToRef(wm, mat);
  10184. }
  10185. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(localAxis, mat, result);
  10186. result.normalize();
  10187. };
  10188. /**
  10189. * Get the euler rotation of the bone in local or world space
  10190. * @param space The space that the rotation should be in
  10191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10192. * @returns The euler rotation
  10193. */
  10194. Bone.prototype.getRotation = function (space, mesh) {
  10195. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10196. if (mesh === void 0) { mesh = null; }
  10197. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10198. this.getRotationToRef(space, mesh, result);
  10199. return result;
  10200. };
  10201. /**
  10202. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  10203. * @param space The space that the rotation should be in
  10204. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10205. * @param result The vector3 that the rotation should be copied to
  10206. */
  10207. Bone.prototype.getRotationToRef = function (space, mesh, result) {
  10208. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10209. if (mesh === void 0) { mesh = null; }
  10210. var quat = Bone._tmpQuat;
  10211. this.getRotationQuaternionToRef(space, mesh, quat);
  10212. quat.toEulerAnglesToRef(result);
  10213. };
  10214. /**
  10215. * Get the quaternion rotation of the bone in either local or world space
  10216. * @param space The space that the rotation should be in
  10217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10218. * @returns The quaternion rotation
  10219. */
  10220. Bone.prototype.getRotationQuaternion = function (space, mesh) {
  10221. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10222. if (mesh === void 0) { mesh = null; }
  10223. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10224. this.getRotationQuaternionToRef(space, mesh, result);
  10225. return result;
  10226. };
  10227. /**
  10228. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  10229. * @param space The space that the rotation should be in
  10230. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10231. * @param result The quaternion that the rotation should be copied to
  10232. */
  10233. Bone.prototype.getRotationQuaternionToRef = function (space, mesh, result) {
  10234. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10235. if (mesh === void 0) { mesh = null; }
  10236. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10237. this._decompose();
  10238. result.copyFrom(this._localRotation);
  10239. }
  10240. else {
  10241. var mat = Bone._tmpMats[0];
  10242. var amat = this.getAbsoluteTransform();
  10243. if (mesh) {
  10244. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10245. }
  10246. else {
  10247. mat.copyFrom(amat);
  10248. }
  10249. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10250. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10251. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10252. mat.decompose(undefined, result, undefined);
  10253. }
  10254. };
  10255. /**
  10256. * Get the rotation matrix of the bone in local or world space
  10257. * @param space The space that the rotation should be in
  10258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10259. * @returns The rotation matrix
  10260. */
  10261. Bone.prototype.getRotationMatrix = function (space, mesh) {
  10262. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10263. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  10264. this.getRotationMatrixToRef(space, mesh, result);
  10265. return result;
  10266. };
  10267. /**
  10268. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  10269. * @param space The space that the rotation should be in
  10270. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10271. * @param result The quaternion that the rotation should be copied to
  10272. */
  10273. Bone.prototype.getRotationMatrixToRef = function (space, mesh, result) {
  10274. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10275. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10276. this.getLocalMatrix().getRotationMatrixToRef(result);
  10277. }
  10278. else {
  10279. var mat = Bone._tmpMats[0];
  10280. var amat = this.getAbsoluteTransform();
  10281. if (mesh) {
  10282. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10283. }
  10284. else {
  10285. mat.copyFrom(amat);
  10286. }
  10287. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10288. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10289. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10290. mat.getRotationMatrixToRef(result);
  10291. }
  10292. };
  10293. /**
  10294. * Get the world position of a point that is in the local space of the bone
  10295. * @param position The local position
  10296. * @param mesh The mesh that this bone is attached to
  10297. * @returns The world position
  10298. */
  10299. Bone.prototype.getAbsolutePositionFromLocal = function (position, mesh) {
  10300. if (mesh === void 0) { mesh = null; }
  10301. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10302. this.getAbsolutePositionFromLocalToRef(position, mesh, result);
  10303. return result;
  10304. };
  10305. /**
  10306. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  10307. * @param position The local position
  10308. * @param mesh The mesh that this bone is attached to
  10309. * @param result The vector3 that the world position should be copied to
  10310. */
  10311. Bone.prototype.getAbsolutePositionFromLocalToRef = function (position, mesh, result) {
  10312. if (mesh === void 0) { mesh = null; }
  10313. var wm = null;
  10314. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10315. if (mesh) {
  10316. wm = mesh.getWorldMatrix();
  10317. }
  10318. this._skeleton.computeAbsoluteTransforms();
  10319. var tmat = Bone._tmpMats[0];
  10320. if (mesh && wm) {
  10321. tmat.copyFrom(this.getAbsoluteTransform());
  10322. tmat.multiplyToRef(wm, tmat);
  10323. }
  10324. else {
  10325. tmat = this.getAbsoluteTransform();
  10326. }
  10327. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10328. };
  10329. /**
  10330. * Get the local position of a point that is in world space
  10331. * @param position The world position
  10332. * @param mesh The mesh that this bone is attached to
  10333. * @returns The local position
  10334. */
  10335. Bone.prototype.getLocalPositionFromAbsolute = function (position, mesh) {
  10336. if (mesh === void 0) { mesh = null; }
  10337. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10338. this.getLocalPositionFromAbsoluteToRef(position, mesh, result);
  10339. return result;
  10340. };
  10341. /**
  10342. * Get the local position of a point that is in world space and copy it to the result param
  10343. * @param position The world position
  10344. * @param mesh The mesh that this bone is attached to
  10345. * @param result The vector3 that the local position should be copied to
  10346. */
  10347. Bone.prototype.getLocalPositionFromAbsoluteToRef = function (position, mesh, result) {
  10348. if (mesh === void 0) { mesh = null; }
  10349. var wm = null;
  10350. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10351. if (mesh) {
  10352. wm = mesh.getWorldMatrix();
  10353. }
  10354. this._skeleton.computeAbsoluteTransforms();
  10355. var tmat = Bone._tmpMats[0];
  10356. tmat.copyFrom(this.getAbsoluteTransform());
  10357. if (mesh && wm) {
  10358. tmat.multiplyToRef(wm, tmat);
  10359. }
  10360. tmat.invert();
  10361. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10362. };
  10363. Bone._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  10364. Bone._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10365. Bone._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  10366. return Bone;
  10367. }(_node__WEBPACK_IMPORTED_MODULE_4__["Node"]));
  10368. /***/ }),
  10369. /***/ "./Bones/boneIKController.ts":
  10370. /*!***********************************!*\
  10371. !*** ./Bones/boneIKController.ts ***!
  10372. \***********************************/
  10373. /*! exports provided: BoneIKController */
  10374. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10375. "use strict";
  10376. __webpack_require__.r(__webpack_exports__);
  10377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return BoneIKController; });
  10378. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10379. /**
  10380. * Class used to apply inverse kinematics to bones
  10381. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  10382. */
  10383. var BoneIKController = /** @class */ (function () {
  10384. /**
  10385. * Creates a new BoneIKController
  10386. * @param mesh defines the mesh to control
  10387. * @param bone defines the bone to control
  10388. * @param options defines options to set up the controller
  10389. */
  10390. function BoneIKController(mesh, bone, options) {
  10391. /**
  10392. * Gets or sets the target position
  10393. */
  10394. this.targetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10395. /**
  10396. * Gets or sets the pole target position
  10397. */
  10398. this.poleTargetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10399. /**
  10400. * Gets or sets the pole target local offset
  10401. */
  10402. this.poleTargetLocalOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10403. /**
  10404. * Gets or sets the pole angle
  10405. */
  10406. this.poleAngle = 0;
  10407. /**
  10408. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  10409. */
  10410. this.slerpAmount = 1;
  10411. this._bone1Quat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10412. this._bone1Mat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  10413. this._bone2Ang = Math.PI;
  10414. this._maxAngle = Math.PI;
  10415. this._rightHandedSystem = false;
  10416. this._bendAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right();
  10417. this._slerping = false;
  10418. this._adjustRoll = 0;
  10419. this._bone2 = bone;
  10420. this._bone1 = bone.getParent();
  10421. if (!this._bone1) {
  10422. return;
  10423. }
  10424. this.mesh = mesh;
  10425. var bonePos = bone.getPosition();
  10426. if (bone.getAbsoluteTransform().determinant() > 0) {
  10427. this._rightHandedSystem = true;
  10428. this._bendAxis.x = 0;
  10429. this._bendAxis.y = 0;
  10430. this._bendAxis.z = -1;
  10431. if (bonePos.x > bonePos.y && bonePos.x > bonePos.z) {
  10432. this._adjustRoll = Math.PI * .5;
  10433. this._bendAxis.z = 1;
  10434. }
  10435. }
  10436. if (this._bone1.length) {
  10437. var boneScale1 = this._bone1.getScale();
  10438. var boneScale2 = this._bone2.getScale();
  10439. this._bone1Length = this._bone1.length * boneScale1.y * this.mesh.scaling.y;
  10440. this._bone2Length = this._bone2.length * boneScale2.y * this.mesh.scaling.y;
  10441. }
  10442. else if (this._bone1.children[0]) {
  10443. mesh.computeWorldMatrix(true);
  10444. var pos1 = this._bone2.children[0].getAbsolutePosition(mesh);
  10445. var pos2 = this._bone2.getAbsolutePosition(mesh);
  10446. var pos3 = this._bone1.getAbsolutePosition(mesh);
  10447. this._bone1Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos1, pos2);
  10448. this._bone2Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos2, pos3);
  10449. }
  10450. this._bone1.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, mesh, this._bone1Mat);
  10451. this.maxAngle = Math.PI;
  10452. if (options) {
  10453. if (options.targetMesh) {
  10454. this.targetMesh = options.targetMesh;
  10455. this.targetMesh.computeWorldMatrix(true);
  10456. }
  10457. if (options.poleTargetMesh) {
  10458. this.poleTargetMesh = options.poleTargetMesh;
  10459. this.poleTargetMesh.computeWorldMatrix(true);
  10460. }
  10461. else if (options.poleTargetBone) {
  10462. this.poleTargetBone = options.poleTargetBone;
  10463. }
  10464. else if (this._bone1.getParent()) {
  10465. this.poleTargetBone = this._bone1.getParent();
  10466. }
  10467. if (options.poleTargetLocalOffset) {
  10468. this.poleTargetLocalOffset.copyFrom(options.poleTargetLocalOffset);
  10469. }
  10470. if (options.poleAngle) {
  10471. this.poleAngle = options.poleAngle;
  10472. }
  10473. if (options.bendAxis) {
  10474. this._bendAxis.copyFrom(options.bendAxis);
  10475. }
  10476. if (options.maxAngle) {
  10477. this.maxAngle = options.maxAngle;
  10478. }
  10479. if (options.slerpAmount) {
  10480. this.slerpAmount = options.slerpAmount;
  10481. }
  10482. }
  10483. }
  10484. Object.defineProperty(BoneIKController.prototype, "maxAngle", {
  10485. /**
  10486. * Gets or sets maximum allowed angle
  10487. */
  10488. get: function () {
  10489. return this._maxAngle;
  10490. },
  10491. set: function (value) {
  10492. this._setMaxAngle(value);
  10493. },
  10494. enumerable: true,
  10495. configurable: true
  10496. });
  10497. BoneIKController.prototype._setMaxAngle = function (ang) {
  10498. if (ang < 0) {
  10499. ang = 0;
  10500. }
  10501. if (ang > Math.PI || ang == undefined) {
  10502. ang = Math.PI;
  10503. }
  10504. this._maxAngle = ang;
  10505. var a = this._bone1Length;
  10506. var b = this._bone2Length;
  10507. this._maxReach = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(ang));
  10508. };
  10509. /**
  10510. * Force the controller to update the bones
  10511. */
  10512. BoneIKController.prototype.update = function () {
  10513. var bone1 = this._bone1;
  10514. if (!bone1) {
  10515. return;
  10516. }
  10517. var target = this.targetPosition;
  10518. var poleTarget = this.poleTargetPosition;
  10519. var mat1 = BoneIKController._tmpMats[0];
  10520. var mat2 = BoneIKController._tmpMats[1];
  10521. if (this.targetMesh) {
  10522. target.copyFrom(this.targetMesh.getAbsolutePosition());
  10523. }
  10524. if (this.poleTargetBone) {
  10525. this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, poleTarget);
  10526. }
  10527. else if (this.poleTargetMesh) {
  10528. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), poleTarget);
  10529. }
  10530. var bonePos = BoneIKController._tmpVecs[0];
  10531. var zaxis = BoneIKController._tmpVecs[1];
  10532. var xaxis = BoneIKController._tmpVecs[2];
  10533. var yaxis = BoneIKController._tmpVecs[3];
  10534. var upAxis = BoneIKController._tmpVecs[4];
  10535. var _tmpQuat = BoneIKController._tmpQuat;
  10536. bone1.getAbsolutePositionToRef(this.mesh, bonePos);
  10537. poleTarget.subtractToRef(bonePos, upAxis);
  10538. if (upAxis.x == 0 && upAxis.y == 0 && upAxis.z == 0) {
  10539. upAxis.y = 1;
  10540. }
  10541. else {
  10542. upAxis.normalize();
  10543. }
  10544. target.subtractToRef(bonePos, yaxis);
  10545. yaxis.normalize();
  10546. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, upAxis, zaxis);
  10547. zaxis.normalize();
  10548. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, zaxis, xaxis);
  10549. xaxis.normalize();
  10550. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, mat1);
  10551. var a = this._bone1Length;
  10552. var b = this._bone2Length;
  10553. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(bonePos, target);
  10554. if (this._maxReach > 0) {
  10555. c = Math.min(this._maxReach, c);
  10556. }
  10557. var acosa = (b * b + c * c - a * a) / (2 * b * c);
  10558. var acosb = (c * c + a * a - b * b) / (2 * c * a);
  10559. if (acosa > 1) {
  10560. acosa = 1;
  10561. }
  10562. if (acosb > 1) {
  10563. acosb = 1;
  10564. }
  10565. if (acosa < -1) {
  10566. acosa = -1;
  10567. }
  10568. if (acosb < -1) {
  10569. acosb = -1;
  10570. }
  10571. var angA = Math.acos(acosa);
  10572. var angB = Math.acos(acosb);
  10573. var angC = -angA - angB;
  10574. if (this._rightHandedSystem) {
  10575. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationYawPitchRollToRef(0, 0, this._adjustRoll, mat2);
  10576. mat2.multiplyToRef(mat1, mat1);
  10577. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(this._bendAxis, angB, mat2);
  10578. mat2.multiplyToRef(mat1, mat1);
  10579. }
  10580. else {
  10581. var _tmpVec = BoneIKController._tmpVecs[5];
  10582. _tmpVec.copyFrom(this._bendAxis);
  10583. _tmpVec.x *= -1;
  10584. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(_tmpVec, -angB, mat2);
  10585. mat2.multiplyToRef(mat1, mat1);
  10586. }
  10587. if (this.poleAngle) {
  10588. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(yaxis, this.poleAngle, mat2);
  10589. mat1.multiplyToRef(mat2, mat1);
  10590. }
  10591. if (this._bone1) {
  10592. if (this.slerpAmount < 1) {
  10593. if (!this._slerping) {
  10594. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat);
  10595. }
  10596. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(mat1, _tmpQuat);
  10597. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].SlerpToRef(this._bone1Quat, _tmpQuat, this.slerpAmount, this._bone1Quat);
  10598. angC = this._bone2Ang * (1.0 - this.slerpAmount) + angC * this.slerpAmount;
  10599. this._bone1.setRotationQuaternion(this._bone1Quat, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10600. this._slerping = true;
  10601. }
  10602. else {
  10603. this._bone1.setRotationMatrix(mat1, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10604. this._bone1Mat.copyFrom(mat1);
  10605. this._slerping = false;
  10606. }
  10607. }
  10608. this._bone2.setAxisAngle(this._bendAxis, angC, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].LOCAL);
  10609. this._bone2Ang = angC;
  10610. };
  10611. BoneIKController._tmpVecs = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  10612. BoneIKController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10613. BoneIKController._tmpMats = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity()];
  10614. return BoneIKController;
  10615. }());
  10616. /***/ }),
  10617. /***/ "./Bones/boneLookController.ts":
  10618. /*!*************************************!*\
  10619. !*** ./Bones/boneLookController.ts ***!
  10620. \*************************************/
  10621. /*! exports provided: BoneLookController */
  10622. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10623. "use strict";
  10624. __webpack_require__.r(__webpack_exports__);
  10625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return BoneLookController; });
  10626. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  10627. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10628. /**
  10629. * Class used to make a bone look toward a point in space
  10630. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  10631. */
  10632. var BoneLookController = /** @class */ (function () {
  10633. /**
  10634. * Create a BoneLookController
  10635. * @param mesh the mesh that the bone belongs to
  10636. * @param bone the bone that will be looking to the target
  10637. * @param target the target Vector3 to look at
  10638. * @param settings optional settings:
  10639. * * maxYaw: the maximum angle the bone will yaw to
  10640. * * minYaw: the minimum angle the bone will yaw to
  10641. * * maxPitch: the maximum angle the bone will pitch to
  10642. * * minPitch: the minimum angle the bone will yaw to
  10643. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  10644. * * upAxis: the up axis of the coordinate system
  10645. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  10646. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  10647. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  10648. * * adjustYaw: used to make an adjustment to the yaw of the bone
  10649. * * adjustPitch: used to make an adjustment to the pitch of the bone
  10650. * * adjustRoll: used to make an adjustment to the roll of the bone
  10651. **/
  10652. function BoneLookController(mesh, bone, target, options) {
  10653. /**
  10654. * The up axis of the coordinate system that is used when the bone is rotated
  10655. */
  10656. this.upAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up();
  10657. /**
  10658. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  10659. */
  10660. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  10661. /**
  10662. * Used to make an adjustment to the yaw of the bone
  10663. */
  10664. this.adjustYaw = 0;
  10665. /**
  10666. * Used to make an adjustment to the pitch of the bone
  10667. */
  10668. this.adjustPitch = 0;
  10669. /**
  10670. * Used to make an adjustment to the roll of the bone
  10671. */
  10672. this.adjustRoll = 0;
  10673. /**
  10674. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  10675. */
  10676. this.slerpAmount = 1;
  10677. this._boneQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10678. this._slerping = false;
  10679. this._firstFrameSkipped = false;
  10680. this._fowardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Forward();
  10681. this.mesh = mesh;
  10682. this.bone = bone;
  10683. this.target = target;
  10684. if (options) {
  10685. if (options.adjustYaw) {
  10686. this.adjustYaw = options.adjustYaw;
  10687. }
  10688. if (options.adjustPitch) {
  10689. this.adjustPitch = options.adjustPitch;
  10690. }
  10691. if (options.adjustRoll) {
  10692. this.adjustRoll = options.adjustRoll;
  10693. }
  10694. if (options.maxYaw != null) {
  10695. this.maxYaw = options.maxYaw;
  10696. }
  10697. else {
  10698. this.maxYaw = Math.PI;
  10699. }
  10700. if (options.minYaw != null) {
  10701. this.minYaw = options.minYaw;
  10702. }
  10703. else {
  10704. this.minYaw = -Math.PI;
  10705. }
  10706. if (options.maxPitch != null) {
  10707. this.maxPitch = options.maxPitch;
  10708. }
  10709. else {
  10710. this.maxPitch = Math.PI;
  10711. }
  10712. if (options.minPitch != null) {
  10713. this.minPitch = options.minPitch;
  10714. }
  10715. else {
  10716. this.minPitch = -Math.PI;
  10717. }
  10718. if (options.slerpAmount != null) {
  10719. this.slerpAmount = options.slerpAmount;
  10720. }
  10721. if (options.upAxis != null) {
  10722. this.upAxis = options.upAxis;
  10723. }
  10724. if (options.upAxisSpace != null) {
  10725. this.upAxisSpace = options.upAxisSpace;
  10726. }
  10727. if (options.yawAxis != null || options.pitchAxis != null) {
  10728. var newYawAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y;
  10729. var newPitchAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].X;
  10730. if (options.yawAxis != null) {
  10731. newYawAxis = options.yawAxis.clone();
  10732. newYawAxis.normalize();
  10733. }
  10734. if (options.pitchAxis != null) {
  10735. newPitchAxis = options.pitchAxis.clone();
  10736. newPitchAxis.normalize();
  10737. }
  10738. var newRollAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(newPitchAxis, newYawAxis);
  10739. this._transformYawPitch = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  10740. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(newPitchAxis, newYawAxis, newRollAxis, this._transformYawPitch);
  10741. this._transformYawPitchInv = this._transformYawPitch.clone();
  10742. this._transformYawPitch.invert();
  10743. }
  10744. }
  10745. if (!bone.getParent() && this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE) {
  10746. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  10747. }
  10748. }
  10749. Object.defineProperty(BoneLookController.prototype, "minYaw", {
  10750. /**
  10751. * Gets or sets the minimum yaw angle that the bone can look to
  10752. */
  10753. get: function () {
  10754. return this._minYaw;
  10755. },
  10756. set: function (value) {
  10757. this._minYaw = value;
  10758. this._minYawSin = Math.sin(value);
  10759. this._minYawCos = Math.cos(value);
  10760. if (this._maxYaw != null) {
  10761. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  10762. this._yawRange = this._maxYaw - this._minYaw;
  10763. }
  10764. },
  10765. enumerable: true,
  10766. configurable: true
  10767. });
  10768. Object.defineProperty(BoneLookController.prototype, "maxYaw", {
  10769. /**
  10770. * Gets or sets the maximum yaw angle that the bone can look to
  10771. */
  10772. get: function () {
  10773. return this._maxYaw;
  10774. },
  10775. set: function (value) {
  10776. this._maxYaw = value;
  10777. this._maxYawSin = Math.sin(value);
  10778. this._maxYawCos = Math.cos(value);
  10779. if (this._minYaw != null) {
  10780. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  10781. this._yawRange = this._maxYaw - this._minYaw;
  10782. }
  10783. },
  10784. enumerable: true,
  10785. configurable: true
  10786. });
  10787. Object.defineProperty(BoneLookController.prototype, "minPitch", {
  10788. /**
  10789. * Gets or sets the minimum pitch angle that the bone can look to
  10790. */
  10791. get: function () {
  10792. return this._minPitch;
  10793. },
  10794. set: function (value) {
  10795. this._minPitch = value;
  10796. this._minPitchTan = Math.tan(value);
  10797. },
  10798. enumerable: true,
  10799. configurable: true
  10800. });
  10801. Object.defineProperty(BoneLookController.prototype, "maxPitch", {
  10802. /**
  10803. * Gets or sets the maximum pitch angle that the bone can look to
  10804. */
  10805. get: function () {
  10806. return this._maxPitch;
  10807. },
  10808. set: function (value) {
  10809. this._maxPitch = value;
  10810. this._maxPitchTan = Math.tan(value);
  10811. },
  10812. enumerable: true,
  10813. configurable: true
  10814. });
  10815. /**
  10816. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  10817. */
  10818. BoneLookController.prototype.update = function () {
  10819. //skip the first frame when slerping so that the mesh rotation is correct
  10820. if (this.slerpAmount < 1 && !this._firstFrameSkipped) {
  10821. this._firstFrameSkipped = true;
  10822. return;
  10823. }
  10824. var bone = this.bone;
  10825. var bonePos = BoneLookController._tmpVecs[0];
  10826. bone.getAbsolutePositionToRef(this.mesh, bonePos);
  10827. var target = this.target;
  10828. var _tmpMat1 = BoneLookController._tmpMats[0];
  10829. var _tmpMat2 = BoneLookController._tmpMats[1];
  10830. var mesh = this.mesh;
  10831. var parentBone = bone.getParent();
  10832. var upAxis = BoneLookController._tmpVecs[1];
  10833. upAxis.copyFrom(this.upAxis);
  10834. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && parentBone) {
  10835. if (this._transformYawPitch) {
  10836. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(upAxis, this._transformYawPitchInv, upAxis);
  10837. }
  10838. parentBone.getDirectionToRef(upAxis, this.mesh, upAxis);
  10839. }
  10840. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10841. mesh.getDirectionToRef(upAxis, upAxis);
  10842. if (mesh.scaling.x != 1 || mesh.scaling.y != 1 || mesh.scaling.z != 1) {
  10843. upAxis.normalize();
  10844. }
  10845. }
  10846. var checkYaw = false;
  10847. var checkPitch = false;
  10848. if (this._maxYaw != Math.PI || this._minYaw != -Math.PI) {
  10849. checkYaw = true;
  10850. }
  10851. if (this._maxPitch != Math.PI || this._minPitch != -Math.PI) {
  10852. checkPitch = true;
  10853. }
  10854. if (checkYaw || checkPitch) {
  10855. var spaceMat = BoneLookController._tmpMats[2];
  10856. var spaceMatInv = BoneLookController._tmpMats[3];
  10857. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && upAxis.y == 1 && parentBone) {
  10858. parentBone.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, spaceMat);
  10859. }
  10860. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL && upAxis.y == 1 && !parentBone) {
  10861. spaceMat.copyFrom(mesh.getWorldMatrix());
  10862. }
  10863. else {
  10864. var forwardAxis = BoneLookController._tmpVecs[2];
  10865. forwardAxis.copyFrom(this._fowardAxis);
  10866. if (this._transformYawPitch) {
  10867. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(forwardAxis, this._transformYawPitchInv, forwardAxis);
  10868. }
  10869. if (parentBone) {
  10870. parentBone.getDirectionToRef(forwardAxis, this.mesh, forwardAxis);
  10871. }
  10872. else {
  10873. mesh.getDirectionToRef(forwardAxis, forwardAxis);
  10874. }
  10875. var rightAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(upAxis, forwardAxis);
  10876. rightAxis.normalize();
  10877. var forwardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(rightAxis, upAxis);
  10878. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(rightAxis, upAxis, forwardAxis, spaceMat);
  10879. }
  10880. spaceMat.invertToRef(spaceMatInv);
  10881. var xzlen = null;
  10882. if (checkPitch) {
  10883. var localTarget = BoneLookController._tmpVecs[3];
  10884. target.subtractToRef(bonePos, localTarget);
  10885. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  10886. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  10887. var pitch = Math.atan2(localTarget.y, xzlen);
  10888. var newPitch = pitch;
  10889. if (pitch > this._maxPitch) {
  10890. localTarget.y = this._maxPitchTan * xzlen;
  10891. newPitch = this._maxPitch;
  10892. }
  10893. else if (pitch < this._minPitch) {
  10894. localTarget.y = this._minPitchTan * xzlen;
  10895. newPitch = this._minPitch;
  10896. }
  10897. if (pitch != newPitch) {
  10898. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  10899. localTarget.addInPlace(bonePos);
  10900. target = localTarget;
  10901. }
  10902. }
  10903. if (checkYaw) {
  10904. var localTarget = BoneLookController._tmpVecs[4];
  10905. target.subtractToRef(bonePos, localTarget);
  10906. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  10907. var yaw = Math.atan2(localTarget.x, localTarget.z);
  10908. var newYaw = yaw;
  10909. if (yaw > this._maxYaw || yaw < this._minYaw) {
  10910. if (xzlen == null) {
  10911. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  10912. }
  10913. if (this._yawRange > Math.PI) {
  10914. if (this._isAngleBetween(yaw, this._maxYaw, this._midYawConstraint)) {
  10915. localTarget.z = this._maxYawCos * xzlen;
  10916. localTarget.x = this._maxYawSin * xzlen;
  10917. newYaw = this._maxYaw;
  10918. }
  10919. else if (this._isAngleBetween(yaw, this._midYawConstraint, this._minYaw)) {
  10920. localTarget.z = this._minYawCos * xzlen;
  10921. localTarget.x = this._minYawSin * xzlen;
  10922. newYaw = this._minYaw;
  10923. }
  10924. }
  10925. else {
  10926. if (yaw > this._maxYaw) {
  10927. localTarget.z = this._maxYawCos * xzlen;
  10928. localTarget.x = this._maxYawSin * xzlen;
  10929. newYaw = this._maxYaw;
  10930. }
  10931. else if (yaw < this._minYaw) {
  10932. localTarget.z = this._minYawCos * xzlen;
  10933. localTarget.x = this._minYawSin * xzlen;
  10934. newYaw = this._minYaw;
  10935. }
  10936. }
  10937. }
  10938. if (this._slerping && this._yawRange > Math.PI) {
  10939. //are we going to be crossing into the min/max region?
  10940. var boneFwd = BoneLookController._tmpVecs[8];
  10941. boneFwd.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Z);
  10942. if (this._transformYawPitch) {
  10943. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, this._transformYawPitchInv, boneFwd);
  10944. }
  10945. var boneRotMat = BoneLookController._tmpMats[4];
  10946. this._boneQuat.toRotationMatrix(boneRotMat);
  10947. this.mesh.getWorldMatrix().multiplyToRef(boneRotMat, boneRotMat);
  10948. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, boneRotMat, boneFwd);
  10949. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, spaceMatInv, boneFwd);
  10950. var boneYaw = Math.atan2(boneFwd.x, boneFwd.z);
  10951. var angBtwTar = this._getAngleBetween(boneYaw, yaw);
  10952. var angBtwMidYaw = this._getAngleBetween(boneYaw, this._midYawConstraint);
  10953. if (angBtwTar > angBtwMidYaw) {
  10954. if (xzlen == null) {
  10955. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  10956. }
  10957. var angBtwMax = this._getAngleBetween(boneYaw, this._maxYaw);
  10958. var angBtwMin = this._getAngleBetween(boneYaw, this._minYaw);
  10959. if (angBtwMin < angBtwMax) {
  10960. newYaw = boneYaw + Math.PI * .75;
  10961. localTarget.z = Math.cos(newYaw) * xzlen;
  10962. localTarget.x = Math.sin(newYaw) * xzlen;
  10963. }
  10964. else {
  10965. newYaw = boneYaw - Math.PI * .75;
  10966. localTarget.z = Math.cos(newYaw) * xzlen;
  10967. localTarget.x = Math.sin(newYaw) * xzlen;
  10968. }
  10969. }
  10970. }
  10971. if (yaw != newYaw) {
  10972. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  10973. localTarget.addInPlace(bonePos);
  10974. target = localTarget;
  10975. }
  10976. }
  10977. }
  10978. var zaxis = BoneLookController._tmpVecs[5];
  10979. var xaxis = BoneLookController._tmpVecs[6];
  10980. var yaxis = BoneLookController._tmpVecs[7];
  10981. var _tmpQuat = BoneLookController._tmpQuat;
  10982. target.subtractToRef(bonePos, zaxis);
  10983. zaxis.normalize();
  10984. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(upAxis, zaxis, xaxis);
  10985. xaxis.normalize();
  10986. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(zaxis, xaxis, yaxis);
  10987. yaxis.normalize();
  10988. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, _tmpMat1);
  10989. if (xaxis.x === 0 && xaxis.y === 0 && xaxis.z === 0) {
  10990. return;
  10991. }
  10992. if (yaxis.x === 0 && yaxis.y === 0 && yaxis.z === 0) {
  10993. return;
  10994. }
  10995. if (zaxis.x === 0 && zaxis.y === 0 && zaxis.z === 0) {
  10996. return;
  10997. }
  10998. if (this.adjustYaw || this.adjustPitch || this.adjustRoll) {
  10999. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, _tmpMat2);
  11000. _tmpMat2.multiplyToRef(_tmpMat1, _tmpMat1);
  11001. }
  11002. if (this.slerpAmount < 1) {
  11003. if (!this._slerping) {
  11004. this.bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, this._boneQuat);
  11005. }
  11006. if (this._transformYawPitch) {
  11007. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11008. }
  11009. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(_tmpMat1, _tmpQuat);
  11010. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].SlerpToRef(this._boneQuat, _tmpQuat, this.slerpAmount, this._boneQuat);
  11011. this.bone.setRotationQuaternion(this._boneQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11012. this._slerping = true;
  11013. }
  11014. else {
  11015. if (this._transformYawPitch) {
  11016. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11017. }
  11018. this.bone.setRotationMatrix(_tmpMat1, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11019. this._slerping = false;
  11020. }
  11021. };
  11022. BoneLookController.prototype._getAngleDiff = function (ang1, ang2) {
  11023. var angDiff = ang2 - ang1;
  11024. angDiff %= Math.PI * 2;
  11025. if (angDiff > Math.PI) {
  11026. angDiff -= Math.PI * 2;
  11027. }
  11028. else if (angDiff < -Math.PI) {
  11029. angDiff += Math.PI * 2;
  11030. }
  11031. return angDiff;
  11032. };
  11033. BoneLookController.prototype._getAngleBetween = function (ang1, ang2) {
  11034. ang1 %= (2 * Math.PI);
  11035. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11036. ang2 %= (2 * Math.PI);
  11037. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11038. var ab = 0;
  11039. if (ang1 < ang2) {
  11040. ab = ang2 - ang1;
  11041. }
  11042. else {
  11043. ab = ang1 - ang2;
  11044. }
  11045. if (ab > Math.PI) {
  11046. ab = Math.PI * 2 - ab;
  11047. }
  11048. return ab;
  11049. };
  11050. BoneLookController.prototype._isAngleBetween = function (ang, ang1, ang2) {
  11051. ang %= (2 * Math.PI);
  11052. ang = (ang < 0) ? ang + (2 * Math.PI) : ang;
  11053. ang1 %= (2 * Math.PI);
  11054. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11055. ang2 %= (2 * Math.PI);
  11056. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11057. if (ang1 < ang2) {
  11058. if (ang > ang1 && ang < ang2) {
  11059. return true;
  11060. }
  11061. }
  11062. else {
  11063. if (ang > ang2 && ang < ang1) {
  11064. return true;
  11065. }
  11066. }
  11067. return false;
  11068. };
  11069. BoneLookController._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(10, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  11070. BoneLookController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11071. BoneLookController._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  11072. return BoneLookController;
  11073. }());
  11074. /***/ }),
  11075. /***/ "./Bones/index.ts":
  11076. /*!************************!*\
  11077. !*** ./Bones/index.ts ***!
  11078. \************************/
  11079. /*! exports provided: Bone, BoneIKController, BoneLookController, Skeleton */
  11080. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11081. "use strict";
  11082. __webpack_require__.r(__webpack_exports__);
  11083. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  11085. /* harmony import */ var _boneIKController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneIKController */ "./Bones/boneIKController.ts");
  11086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _boneIKController__WEBPACK_IMPORTED_MODULE_1__["BoneIKController"]; });
  11087. /* harmony import */ var _boneLookController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boneLookController */ "./Bones/boneLookController.ts");
  11088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _boneLookController__WEBPACK_IMPORTED_MODULE_2__["BoneLookController"]; });
  11089. /* harmony import */ var _skeleton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./skeleton */ "./Bones/skeleton.ts");
  11090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _skeleton__WEBPACK_IMPORTED_MODULE_3__["Skeleton"]; });
  11091. /***/ }),
  11092. /***/ "./Bones/skeleton.ts":
  11093. /*!***************************!*\
  11094. !*** ./Bones/skeleton.ts ***!
  11095. \***************************/
  11096. /*! exports provided: Skeleton */
  11097. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11098. "use strict";
  11099. __webpack_require__.r(__webpack_exports__);
  11100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return Skeleton; });
  11101. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11102. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  11103. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  11104. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  11105. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  11106. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  11107. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  11108. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  11109. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  11110. /**
  11111. * Class used to handle skinning animations
  11112. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  11113. */
  11114. var Skeleton = /** @class */ (function () {
  11115. /**
  11116. * Creates a new skeleton
  11117. * @param name defines the skeleton name
  11118. * @param id defines the skeleton Id
  11119. * @param scene defines the hosting scene
  11120. */
  11121. function Skeleton(
  11122. /** defines the skeleton name */
  11123. name,
  11124. /** defines the skeleton Id */
  11125. id, scene) {
  11126. this.name = name;
  11127. this.id = id;
  11128. /**
  11129. * Defines the list of child bones
  11130. */
  11131. this.bones = new Array();
  11132. /**
  11133. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  11134. */
  11135. this.needInitialSkinMatrix = false;
  11136. /**
  11137. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  11138. */
  11139. this.overrideMesh = null;
  11140. this._isDirty = true;
  11141. this._meshesWithPoseMatrix = new Array();
  11142. this._identity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  11143. this._ranges = {};
  11144. this._lastAbsoluteTransformsUpdateId = -1;
  11145. this._canUseTextureForBones = false;
  11146. /** @hidden */
  11147. this._numBonesWithLinkedTransformNode = 0;
  11148. /**
  11149. * Specifies if the skeleton should be serialized
  11150. */
  11151. this.doNotSerialize = false;
  11152. /**
  11153. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  11154. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  11155. */
  11156. this.useTextureToStoreBoneMatrices = true;
  11157. this._animationPropertiesOverride = null;
  11158. // Events
  11159. /**
  11160. * An observable triggered before computing the skeleton's matrices
  11161. */
  11162. this.onBeforeComputeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11163. this.bones = [];
  11164. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  11165. this._scene.skeletons.push(this);
  11166. //make sure it will recalculate the matrix next time prepare is called.
  11167. this._isDirty = true;
  11168. var engineCaps = this._scene.getEngine().getCaps();
  11169. this._canUseTextureForBones = engineCaps.textureFloat && engineCaps.maxVertexTextureImageUnits > 0;
  11170. }
  11171. Object.defineProperty(Skeleton.prototype, "animationPropertiesOverride", {
  11172. /**
  11173. * Gets or sets the animation properties override
  11174. */
  11175. get: function () {
  11176. if (!this._animationPropertiesOverride) {
  11177. return this._scene.animationPropertiesOverride;
  11178. }
  11179. return this._animationPropertiesOverride;
  11180. },
  11181. set: function (value) {
  11182. this._animationPropertiesOverride = value;
  11183. },
  11184. enumerable: true,
  11185. configurable: true
  11186. });
  11187. Object.defineProperty(Skeleton.prototype, "isUsingTextureForMatrices", {
  11188. /**
  11189. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  11190. */
  11191. get: function () {
  11192. return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones && !this.needInitialSkinMatrix;
  11193. },
  11194. enumerable: true,
  11195. configurable: true
  11196. });
  11197. // Members
  11198. /**
  11199. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  11200. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  11201. * @returns a Float32Array containing matrices data
  11202. */
  11203. Skeleton.prototype.getTransformMatrices = function (mesh) {
  11204. if (this.needInitialSkinMatrix && mesh._bonesTransformMatrices) {
  11205. return mesh._bonesTransformMatrices;
  11206. }
  11207. if (!this._transformMatrices) {
  11208. this.prepare();
  11209. }
  11210. return this._transformMatrices;
  11211. };
  11212. /**
  11213. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  11214. * @returns a raw texture containing the data
  11215. */
  11216. Skeleton.prototype.getTransformMatrixTexture = function () {
  11217. return this._transformMatrixTexture;
  11218. };
  11219. /**
  11220. * Gets the current hosting scene
  11221. * @returns a scene object
  11222. */
  11223. Skeleton.prototype.getScene = function () {
  11224. return this._scene;
  11225. };
  11226. // Methods
  11227. /**
  11228. * Gets a string representing the current skeleton data
  11229. * @param fullDetails defines a boolean indicating if we want a verbose version
  11230. * @returns a string representing the current skeleton data
  11231. */
  11232. Skeleton.prototype.toString = function (fullDetails) {
  11233. var ret = "Name: " + this.name + ", nBones: " + this.bones.length;
  11234. ret += ", nAnimationRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  11235. if (fullDetails) {
  11236. ret += ", Ranges: {";
  11237. var first = true;
  11238. for (var name_1 in this._ranges) {
  11239. if (first) {
  11240. ret += ", ";
  11241. first = false;
  11242. }
  11243. ret += name_1;
  11244. }
  11245. ret += "}";
  11246. }
  11247. return ret;
  11248. };
  11249. /**
  11250. * Get bone's index searching by name
  11251. * @param name defines bone's name to search for
  11252. * @return the indice of the bone. Returns -1 if not found
  11253. */
  11254. Skeleton.prototype.getBoneIndexByName = function (name) {
  11255. for (var boneIndex = 0, cache = this.bones.length; boneIndex < cache; boneIndex++) {
  11256. if (this.bones[boneIndex].name === name) {
  11257. return boneIndex;
  11258. }
  11259. }
  11260. return -1;
  11261. };
  11262. /**
  11263. * Creater a new animation range
  11264. * @param name defines the name of the range
  11265. * @param from defines the start key
  11266. * @param to defines the end key
  11267. */
  11268. Skeleton.prototype.createAnimationRange = function (name, from, to) {
  11269. // check name not already in use
  11270. if (!this._ranges[name]) {
  11271. this._ranges[name] = new _Animations_animation__WEBPACK_IMPORTED_MODULE_4__["AnimationRange"](name, from, to);
  11272. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11273. if (this.bones[i].animations[0]) {
  11274. this.bones[i].animations[0].createRange(name, from, to);
  11275. }
  11276. }
  11277. }
  11278. };
  11279. /**
  11280. * Delete a specific animation range
  11281. * @param name defines the name of the range
  11282. * @param deleteFrames defines if frames must be removed as well
  11283. */
  11284. Skeleton.prototype.deleteAnimationRange = function (name, deleteFrames) {
  11285. if (deleteFrames === void 0) { deleteFrames = true; }
  11286. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11287. if (this.bones[i].animations[0]) {
  11288. this.bones[i].animations[0].deleteRange(name, deleteFrames);
  11289. }
  11290. }
  11291. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  11292. };
  11293. /**
  11294. * Gets a specific animation range
  11295. * @param name defines the name of the range to look for
  11296. * @returns the requested animation range or null if not found
  11297. */
  11298. Skeleton.prototype.getAnimationRange = function (name) {
  11299. return this._ranges[name];
  11300. };
  11301. /**
  11302. * Gets the list of all animation ranges defined on this skeleton
  11303. * @returns an array
  11304. */
  11305. Skeleton.prototype.getAnimationRanges = function () {
  11306. var animationRanges = [];
  11307. var name;
  11308. var i = 0;
  11309. for (name in this._ranges) {
  11310. animationRanges[i] = this._ranges[name];
  11311. i++;
  11312. }
  11313. return animationRanges;
  11314. };
  11315. /**
  11316. * Copy animation range from a source skeleton.
  11317. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  11318. * @param source defines the source skeleton
  11319. * @param name defines the name of the range to copy
  11320. * @param rescaleAsRequired defines if rescaling must be applied if required
  11321. * @returns true if operation was successful
  11322. */
  11323. Skeleton.prototype.copyAnimationRange = function (source, name, rescaleAsRequired) {
  11324. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  11325. if (this._ranges[name] || !source.getAnimationRange(name)) {
  11326. return false;
  11327. }
  11328. var ret = true;
  11329. var frameOffset = this._getHighestAnimationFrame() + 1;
  11330. // make a dictionary of source skeleton's bones, so exact same order or doublely nested loop is not required
  11331. var boneDict = {};
  11332. var sourceBones = source.bones;
  11333. var nBones;
  11334. var i;
  11335. for (i = 0, nBones = sourceBones.length; i < nBones; i++) {
  11336. boneDict[sourceBones[i].name] = sourceBones[i];
  11337. }
  11338. if (this.bones.length !== sourceBones.length) {
  11339. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn("copyAnimationRange: this rig has " + this.bones.length + " bones, while source as " + sourceBones.length);
  11340. ret = false;
  11341. }
  11342. var skelDimensionsRatio = (rescaleAsRequired && this.dimensionsAtRest && source.dimensionsAtRest) ? this.dimensionsAtRest.divide(source.dimensionsAtRest) : null;
  11343. for (i = 0, nBones = this.bones.length; i < nBones; i++) {
  11344. var boneName = this.bones[i].name;
  11345. var sourceBone = boneDict[boneName];
  11346. if (sourceBone) {
  11347. ret = ret && this.bones[i].copyAnimationRange(sourceBone, name, frameOffset, rescaleAsRequired, skelDimensionsRatio);
  11348. }
  11349. else {
  11350. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn("copyAnimationRange: not same rig, missing source bone " + boneName);
  11351. ret = false;
  11352. }
  11353. }
  11354. // do not call createAnimationRange(), since it also is done to bones, which was already done
  11355. var range = source.getAnimationRange(name);
  11356. if (range) {
  11357. this._ranges[name] = new _Animations_animation__WEBPACK_IMPORTED_MODULE_4__["AnimationRange"](name, range.from + frameOffset, range.to + frameOffset);
  11358. }
  11359. return ret;
  11360. };
  11361. /**
  11362. * Forces the skeleton to go to rest pose
  11363. */
  11364. Skeleton.prototype.returnToRest = function () {
  11365. for (var index = 0; index < this.bones.length; index++) {
  11366. this.bones[index].returnToRest();
  11367. }
  11368. };
  11369. Skeleton.prototype._getHighestAnimationFrame = function () {
  11370. var ret = 0;
  11371. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11372. if (this.bones[i].animations[0]) {
  11373. var highest = this.bones[i].animations[0].getHighestFrame();
  11374. if (ret < highest) {
  11375. ret = highest;
  11376. }
  11377. }
  11378. }
  11379. return ret;
  11380. };
  11381. /**
  11382. * Begin a specific animation range
  11383. * @param name defines the name of the range to start
  11384. * @param loop defines if looping must be turned on (false by default)
  11385. * @param speedRatio defines the speed ratio to apply (1 by default)
  11386. * @param onAnimationEnd defines a callback which will be called when animation will end
  11387. * @returns a new animatable
  11388. */
  11389. Skeleton.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  11390. var range = this.getAnimationRange(name);
  11391. if (!range) {
  11392. return null;
  11393. }
  11394. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  11395. };
  11396. /** @hidden */
  11397. Skeleton.prototype._markAsDirty = function () {
  11398. this._isDirty = true;
  11399. };
  11400. /** @hidden */
  11401. Skeleton.prototype._registerMeshWithPoseMatrix = function (mesh) {
  11402. this._meshesWithPoseMatrix.push(mesh);
  11403. };
  11404. /** @hidden */
  11405. Skeleton.prototype._unregisterMeshWithPoseMatrix = function (mesh) {
  11406. var index = this._meshesWithPoseMatrix.indexOf(mesh);
  11407. if (index > -1) {
  11408. this._meshesWithPoseMatrix.splice(index, 1);
  11409. }
  11410. };
  11411. Skeleton.prototype._computeTransformMatrices = function (targetMatrix, initialSkinMatrix) {
  11412. this.onBeforeComputeObservable.notifyObservers(this);
  11413. for (var index = 0; index < this.bones.length; index++) {
  11414. var bone = this.bones[index];
  11415. var parentBone = bone.getParent();
  11416. if (parentBone) {
  11417. bone.getLocalMatrix().multiplyToRef(parentBone.getWorldMatrix(), bone.getWorldMatrix());
  11418. }
  11419. else {
  11420. if (initialSkinMatrix) {
  11421. bone.getLocalMatrix().multiplyToRef(initialSkinMatrix, bone.getWorldMatrix());
  11422. }
  11423. else {
  11424. bone.getWorldMatrix().copyFrom(bone.getLocalMatrix());
  11425. }
  11426. }
  11427. if (bone._index !== -1) {
  11428. var mappedIndex = bone._index === null ? index : bone._index;
  11429. bone.getInvertedAbsoluteTransform().multiplyToArray(bone.getWorldMatrix(), targetMatrix, mappedIndex * 16);
  11430. }
  11431. }
  11432. this._identity.copyToArray(targetMatrix, this.bones.length * 16);
  11433. };
  11434. /**
  11435. * Build all resources required to render a skeleton
  11436. */
  11437. Skeleton.prototype.prepare = function () {
  11438. // Update the local matrix of bones with linked transform nodes.
  11439. if (this._numBonesWithLinkedTransformNode > 0) {
  11440. for (var _i = 0, _a = this.bones; _i < _a.length; _i++) {
  11441. var bone_1 = _a[_i];
  11442. if (bone_1._linkedTransformNode) {
  11443. // Computing the world matrix also computes the local matrix.
  11444. bone_1._linkedTransformNode.computeWorldMatrix();
  11445. bone_1._matrix = bone_1._linkedTransformNode._localMatrix;
  11446. bone_1.markAsDirty();
  11447. }
  11448. }
  11449. }
  11450. if (!this._isDirty) {
  11451. return;
  11452. }
  11453. if (this.needInitialSkinMatrix) {
  11454. for (var index = 0; index < this._meshesWithPoseMatrix.length; index++) {
  11455. var mesh = this._meshesWithPoseMatrix[index];
  11456. var poseMatrix = mesh.getPoseMatrix();
  11457. if (!mesh._bonesTransformMatrices || mesh._bonesTransformMatrices.length !== 16 * (this.bones.length + 1)) {
  11458. mesh._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11459. }
  11460. if (this._synchronizedWithMesh !== mesh) {
  11461. this._synchronizedWithMesh = mesh;
  11462. // Prepare bones
  11463. for (var boneIndex = 0; boneIndex < this.bones.length; boneIndex++) {
  11464. var bone = this.bones[boneIndex];
  11465. if (!bone.getParent()) {
  11466. var matrix = bone.getBaseMatrix();
  11467. matrix.multiplyToRef(poseMatrix, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11468. bone._updateDifferenceMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11469. }
  11470. }
  11471. }
  11472. this._computeTransformMatrices(mesh._bonesTransformMatrices, poseMatrix);
  11473. }
  11474. }
  11475. else {
  11476. if (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) {
  11477. this._transformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11478. if (this.isUsingTextureForMatrices) {
  11479. if (this._transformMatrixTexture) {
  11480. this._transformMatrixTexture.dispose();
  11481. }
  11482. this._transformMatrixTexture = _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__["RawTexture"].CreateRGBATexture(this._transformMatrices, (this.bones.length + 1) * 4, 1, this._scene, false, false, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT);
  11483. }
  11484. }
  11485. this._computeTransformMatrices(this._transformMatrices, null);
  11486. if (this.isUsingTextureForMatrices && this._transformMatrixTexture) {
  11487. this._transformMatrixTexture.update(this._transformMatrices);
  11488. }
  11489. }
  11490. this._isDirty = false;
  11491. this._scene._activeBones.addCount(this.bones.length, false);
  11492. };
  11493. /**
  11494. * Gets the list of animatables currently running for this skeleton
  11495. * @returns an array of animatables
  11496. */
  11497. Skeleton.prototype.getAnimatables = function () {
  11498. if (!this._animatables || this._animatables.length !== this.bones.length) {
  11499. this._animatables = [];
  11500. for (var index = 0; index < this.bones.length; index++) {
  11501. this._animatables.push(this.bones[index]);
  11502. }
  11503. }
  11504. return this._animatables;
  11505. };
  11506. /**
  11507. * Clone the current skeleton
  11508. * @param name defines the name of the new skeleton
  11509. * @param id defines the id of the enw skeleton
  11510. * @returns the new skeleton
  11511. */
  11512. Skeleton.prototype.clone = function (name, id) {
  11513. var result = new Skeleton(name, id || name, this._scene);
  11514. result.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11515. for (var index = 0; index < this.bones.length; index++) {
  11516. var source = this.bones[index];
  11517. var parentBone = null;
  11518. var parent_1 = source.getParent();
  11519. if (parent_1) {
  11520. var parentIndex = this.bones.indexOf(parent_1);
  11521. parentBone = result.bones[parentIndex];
  11522. }
  11523. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](source.name, result, parentBone, source.getBaseMatrix().clone(), source.getRestPose().clone());
  11524. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_8__["DeepCopier"].DeepCopy(source.animations, bone.animations);
  11525. }
  11526. if (this._ranges) {
  11527. result._ranges = {};
  11528. for (var rangeName in this._ranges) {
  11529. var range = this._ranges[rangeName];
  11530. if (range) {
  11531. result._ranges[rangeName] = range.clone();
  11532. }
  11533. }
  11534. }
  11535. this._isDirty = true;
  11536. return result;
  11537. };
  11538. /**
  11539. * Enable animation blending for this skeleton
  11540. * @param blendingSpeed defines the blending speed to apply
  11541. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  11542. */
  11543. Skeleton.prototype.enableBlending = function (blendingSpeed) {
  11544. if (blendingSpeed === void 0) { blendingSpeed = 0.01; }
  11545. this.bones.forEach(function (bone) {
  11546. bone.animations.forEach(function (animation) {
  11547. animation.enableBlending = true;
  11548. animation.blendingSpeed = blendingSpeed;
  11549. });
  11550. });
  11551. };
  11552. /**
  11553. * Releases all resources associated with the current skeleton
  11554. */
  11555. Skeleton.prototype.dispose = function () {
  11556. this._meshesWithPoseMatrix = [];
  11557. // Animations
  11558. this.getScene().stopAnimation(this);
  11559. // Remove from scene
  11560. this.getScene().removeSkeleton(this);
  11561. if (this._transformMatrixTexture) {
  11562. this._transformMatrixTexture.dispose();
  11563. this._transformMatrixTexture = null;
  11564. }
  11565. };
  11566. /**
  11567. * Serialize the skeleton in a JSON object
  11568. * @returns a JSON object
  11569. */
  11570. Skeleton.prototype.serialize = function () {
  11571. var serializationObject = {};
  11572. serializationObject.name = this.name;
  11573. serializationObject.id = this.id;
  11574. if (this.dimensionsAtRest) {
  11575. serializationObject.dimensionsAtRest = this.dimensionsAtRest.asArray();
  11576. }
  11577. serializationObject.bones = [];
  11578. serializationObject.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11579. for (var index = 0; index < this.bones.length; index++) {
  11580. var bone = this.bones[index];
  11581. var parent_2 = bone.getParent();
  11582. var serializedBone = {
  11583. parentBoneIndex: parent_2 ? this.bones.indexOf(parent_2) : -1,
  11584. name: bone.name,
  11585. matrix: bone.getBaseMatrix().toArray(),
  11586. rest: bone.getRestPose().toArray()
  11587. };
  11588. serializationObject.bones.push(serializedBone);
  11589. if (bone.length) {
  11590. serializedBone.length = bone.length;
  11591. }
  11592. if (bone.metadata) {
  11593. serializedBone.metadata = bone.metadata;
  11594. }
  11595. if (bone.animations && bone.animations.length > 0) {
  11596. serializedBone.animation = bone.animations[0].serialize();
  11597. }
  11598. serializationObject.ranges = [];
  11599. for (var name in this._ranges) {
  11600. var source = this._ranges[name];
  11601. if (!source) {
  11602. continue;
  11603. }
  11604. var range = {};
  11605. range.name = name;
  11606. range.from = source.from;
  11607. range.to = source.to;
  11608. serializationObject.ranges.push(range);
  11609. }
  11610. }
  11611. return serializationObject;
  11612. };
  11613. /**
  11614. * Creates a new skeleton from serialized data
  11615. * @param parsedSkeleton defines the serialized data
  11616. * @param scene defines the hosting scene
  11617. * @returns a new skeleton
  11618. */
  11619. Skeleton.Parse = function (parsedSkeleton, scene) {
  11620. var skeleton = new Skeleton(parsedSkeleton.name, parsedSkeleton.id, scene);
  11621. if (parsedSkeleton.dimensionsAtRest) {
  11622. skeleton.dimensionsAtRest = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSkeleton.dimensionsAtRest);
  11623. }
  11624. skeleton.needInitialSkinMatrix = parsedSkeleton.needInitialSkinMatrix;
  11625. var index;
  11626. for (index = 0; index < parsedSkeleton.bones.length; index++) {
  11627. var parsedBone = parsedSkeleton.bones[index];
  11628. var parentBone = null;
  11629. if (parsedBone.parentBoneIndex > -1) {
  11630. parentBone = skeleton.bones[parsedBone.parentBoneIndex];
  11631. }
  11632. var rest = parsedBone.rest ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.rest) : null;
  11633. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](parsedBone.name, skeleton, parentBone, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.matrix), rest);
  11634. if (parsedBone.id !== undefined && parsedBone.id !== null) {
  11635. bone.id = parsedBone.id;
  11636. }
  11637. if (parsedBone.length) {
  11638. bone.length = parsedBone.length;
  11639. }
  11640. if (parsedBone.metadata) {
  11641. bone.metadata = parsedBone.metadata;
  11642. }
  11643. if (parsedBone.animation) {
  11644. bone.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].Parse(parsedBone.animation));
  11645. }
  11646. }
  11647. // placed after bones, so createAnimationRange can cascade down
  11648. if (parsedSkeleton.ranges) {
  11649. for (index = 0; index < parsedSkeleton.ranges.length; index++) {
  11650. var data = parsedSkeleton.ranges[index];
  11651. skeleton.createAnimationRange(data.name, data.from, data.to);
  11652. }
  11653. }
  11654. return skeleton;
  11655. };
  11656. /**
  11657. * Compute all node absolute transforms
  11658. * @param forceUpdate defines if computation must be done even if cache is up to date
  11659. */
  11660. Skeleton.prototype.computeAbsoluteTransforms = function (forceUpdate) {
  11661. if (forceUpdate === void 0) { forceUpdate = false; }
  11662. var renderId = this._scene.getRenderId();
  11663. if (this._lastAbsoluteTransformsUpdateId != renderId || forceUpdate) {
  11664. this.bones[0].computeAbsoluteTransforms();
  11665. this._lastAbsoluteTransformsUpdateId = renderId;
  11666. }
  11667. };
  11668. /**
  11669. * Gets the root pose matrix
  11670. * @returns a matrix
  11671. */
  11672. Skeleton.prototype.getPoseMatrix = function () {
  11673. var poseMatrix = null;
  11674. if (this._meshesWithPoseMatrix.length > 0) {
  11675. poseMatrix = this._meshesWithPoseMatrix[0].getPoseMatrix();
  11676. }
  11677. return poseMatrix;
  11678. };
  11679. /**
  11680. * Sorts bones per internal index
  11681. */
  11682. Skeleton.prototype.sortBones = function () {
  11683. var bones = new Array();
  11684. var visited = new Array(this.bones.length);
  11685. for (var index = 0; index < this.bones.length; index++) {
  11686. this._sortBones(index, bones, visited);
  11687. }
  11688. this.bones = bones;
  11689. };
  11690. Skeleton.prototype._sortBones = function (index, bones, visited) {
  11691. if (visited[index]) {
  11692. return;
  11693. }
  11694. visited[index] = true;
  11695. var bone = this.bones[index];
  11696. if (bone._index === undefined) {
  11697. bone._index = index;
  11698. }
  11699. var parentBone = bone.getParent();
  11700. if (parentBone) {
  11701. this._sortBones(this.bones.indexOf(parentBone), bones, visited);
  11702. }
  11703. bones.push(bone);
  11704. };
  11705. return Skeleton;
  11706. }());
  11707. /***/ }),
  11708. /***/ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts":
  11709. /*!*******************************************************!*\
  11710. !*** ./Cameras/Inputs/arcRotateCameraGamepadInput.ts ***!
  11711. \*******************************************************/
  11712. /*! exports provided: ArcRotateCameraGamepadInput */
  11713. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11714. "use strict";
  11715. __webpack_require__.r(__webpack_exports__);
  11716. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return ArcRotateCameraGamepadInput; });
  11717. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  11718. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  11719. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  11720. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  11721. /**
  11722. * Manage the gamepad inputs to control an arc rotate camera.
  11723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11724. */
  11725. var ArcRotateCameraGamepadInput = /** @class */ (function () {
  11726. function ArcRotateCameraGamepadInput() {
  11727. /**
  11728. * Defines the gamepad rotation sensiblity.
  11729. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  11730. */
  11731. this.gamepadRotationSensibility = 80;
  11732. /**
  11733. * Defines the gamepad move sensiblity.
  11734. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  11735. */
  11736. this.gamepadMoveSensibility = 40;
  11737. }
  11738. /**
  11739. * Attach the input controls to a specific dom element to get the input from.
  11740. * @param element Defines the element the controls should be listened from
  11741. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11742. */
  11743. ArcRotateCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  11744. var _this = this;
  11745. var manager = this.camera.getScene().gamepadManager;
  11746. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  11747. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].POSE_ENABLED) {
  11748. // prioritize XBOX gamepads.
  11749. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX) {
  11750. _this.gamepad = gamepad;
  11751. }
  11752. }
  11753. });
  11754. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  11755. if (_this.gamepad === gamepad) {
  11756. _this.gamepad = null;
  11757. }
  11758. });
  11759. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX);
  11760. };
  11761. /**
  11762. * Detach the current controls from the specified dom element.
  11763. * @param element Defines the element to stop listening the inputs from
  11764. */
  11765. ArcRotateCameraGamepadInput.prototype.detachControl = function (element) {
  11766. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  11767. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  11768. this.gamepad = null;
  11769. };
  11770. /**
  11771. * Update the current camera state depending on the inputs that have been used this frame.
  11772. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11773. */
  11774. ArcRotateCameraGamepadInput.prototype.checkInputs = function () {
  11775. if (this.gamepad) {
  11776. var camera = this.camera;
  11777. var RSValues = this.gamepad.rightStick;
  11778. if (RSValues) {
  11779. if (RSValues.x != 0) {
  11780. var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
  11781. if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
  11782. camera.inertialAlphaOffset += normalizedRX;
  11783. }
  11784. }
  11785. if (RSValues.y != 0) {
  11786. var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
  11787. if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
  11788. camera.inertialBetaOffset += normalizedRY;
  11789. }
  11790. }
  11791. }
  11792. var LSValues = this.gamepad.leftStick;
  11793. if (LSValues && LSValues.y != 0) {
  11794. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  11795. if (normalizedLY != 0 && Math.abs(normalizedLY) > 0.005) {
  11796. this.camera.inertialRadiusOffset -= normalizedLY;
  11797. }
  11798. }
  11799. }
  11800. };
  11801. /**
  11802. * Gets the class name of the current intput.
  11803. * @returns the class name
  11804. */
  11805. ArcRotateCameraGamepadInput.prototype.getClassName = function () {
  11806. return "ArcRotateCameraGamepadInput";
  11807. };
  11808. /**
  11809. * Get the friendly name associated with the input class.
  11810. * @returns the input friendly name
  11811. */
  11812. ArcRotateCameraGamepadInput.prototype.getSimpleName = function () {
  11813. return "gamepad";
  11814. };
  11815. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  11816. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11817. ], ArcRotateCameraGamepadInput.prototype, "gamepadRotationSensibility", void 0);
  11818. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  11819. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11820. ], ArcRotateCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  11821. return ArcRotateCameraGamepadInput;
  11822. }());
  11823. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraGamepadInput"] = ArcRotateCameraGamepadInput;
  11824. /***/ }),
  11825. /***/ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts":
  11826. /*!************************************************************!*\
  11827. !*** ./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts ***!
  11828. \************************************************************/
  11829. /*! exports provided: ArcRotateCameraKeyboardMoveInput */
  11830. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11831. "use strict";
  11832. __webpack_require__.r(__webpack_exports__);
  11833. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return ArcRotateCameraKeyboardMoveInput; });
  11834. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  11835. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  11836. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  11837. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  11838. /**
  11839. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  11840. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11841. */
  11842. var ArcRotateCameraKeyboardMoveInput = /** @class */ (function () {
  11843. function ArcRotateCameraKeyboardMoveInput() {
  11844. /**
  11845. * Defines the list of key codes associated with the up action (increase alpha)
  11846. */
  11847. this.keysUp = [38];
  11848. /**
  11849. * Defines the list of key codes associated with the down action (decrease alpha)
  11850. */
  11851. this.keysDown = [40];
  11852. /**
  11853. * Defines the list of key codes associated with the left action (increase beta)
  11854. */
  11855. this.keysLeft = [37];
  11856. /**
  11857. * Defines the list of key codes associated with the right action (decrease beta)
  11858. */
  11859. this.keysRight = [39];
  11860. /**
  11861. * Defines the list of key codes associated with the reset action.
  11862. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  11863. */
  11864. this.keysReset = [220];
  11865. /**
  11866. * Defines the panning sensibility of the inputs.
  11867. * (How fast is the camera paning)
  11868. */
  11869. this.panningSensibility = 50.0;
  11870. /**
  11871. * Defines the zooming sensibility of the inputs.
  11872. * (How fast is the camera zooming)
  11873. */
  11874. this.zoomingSensibility = 25.0;
  11875. /**
  11876. * Defines wether maintaining the alt key down switch the movement mode from
  11877. * orientation to zoom.
  11878. */
  11879. this.useAltToZoom = true;
  11880. /**
  11881. * Rotation speed of the camera
  11882. */
  11883. this.angularSpeed = 0.01;
  11884. this._keys = new Array();
  11885. }
  11886. /**
  11887. * Attach the input controls to a specific dom element to get the input from.
  11888. * @param element Defines the element the controls should be listened from
  11889. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11890. */
  11891. ArcRotateCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  11892. var _this = this;
  11893. if (this._onCanvasBlurObserver) {
  11894. return;
  11895. }
  11896. this._scene = this.camera.getScene();
  11897. this._engine = this._scene.getEngine();
  11898. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  11899. _this._keys = [];
  11900. });
  11901. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  11902. var evt = info.event;
  11903. if (!evt.metaKey) {
  11904. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  11905. _this._ctrlPressed = evt.ctrlKey;
  11906. _this._altPressed = evt.altKey;
  11907. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  11908. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  11909. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  11910. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  11911. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  11912. var index = _this._keys.indexOf(evt.keyCode);
  11913. if (index === -1) {
  11914. _this._keys.push(evt.keyCode);
  11915. }
  11916. if (evt.preventDefault) {
  11917. if (!noPreventDefault) {
  11918. evt.preventDefault();
  11919. }
  11920. }
  11921. }
  11922. }
  11923. else {
  11924. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  11925. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  11926. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  11927. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  11928. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  11929. var index = _this._keys.indexOf(evt.keyCode);
  11930. if (index >= 0) {
  11931. _this._keys.splice(index, 1);
  11932. }
  11933. if (evt.preventDefault) {
  11934. if (!noPreventDefault) {
  11935. evt.preventDefault();
  11936. }
  11937. }
  11938. }
  11939. }
  11940. }
  11941. });
  11942. };
  11943. /**
  11944. * Detach the current controls from the specified dom element.
  11945. * @param element Defines the element to stop listening the inputs from
  11946. */
  11947. ArcRotateCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  11948. if (this._scene) {
  11949. if (this._onKeyboardObserver) {
  11950. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  11951. }
  11952. if (this._onCanvasBlurObserver) {
  11953. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  11954. }
  11955. this._onKeyboardObserver = null;
  11956. this._onCanvasBlurObserver = null;
  11957. }
  11958. this._keys = [];
  11959. };
  11960. /**
  11961. * Update the current camera state depending on the inputs that have been used this frame.
  11962. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11963. */
  11964. ArcRotateCameraKeyboardMoveInput.prototype.checkInputs = function () {
  11965. if (this._onKeyboardObserver) {
  11966. var camera = this.camera;
  11967. for (var index = 0; index < this._keys.length; index++) {
  11968. var keyCode = this._keys[index];
  11969. if (this.keysLeft.indexOf(keyCode) !== -1) {
  11970. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  11971. camera.inertialPanningX -= 1 / this.panningSensibility;
  11972. }
  11973. else {
  11974. camera.inertialAlphaOffset -= this.angularSpeed;
  11975. }
  11976. }
  11977. else if (this.keysUp.indexOf(keyCode) !== -1) {
  11978. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  11979. camera.inertialPanningY += 1 / this.panningSensibility;
  11980. }
  11981. else if (this._altPressed && this.useAltToZoom) {
  11982. camera.inertialRadiusOffset += 1 / this.zoomingSensibility;
  11983. }
  11984. else {
  11985. camera.inertialBetaOffset -= this.angularSpeed;
  11986. }
  11987. }
  11988. else if (this.keysRight.indexOf(keyCode) !== -1) {
  11989. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  11990. camera.inertialPanningX += 1 / this.panningSensibility;
  11991. }
  11992. else {
  11993. camera.inertialAlphaOffset += this.angularSpeed;
  11994. }
  11995. }
  11996. else if (this.keysDown.indexOf(keyCode) !== -1) {
  11997. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  11998. camera.inertialPanningY -= 1 / this.panningSensibility;
  11999. }
  12000. else if (this._altPressed && this.useAltToZoom) {
  12001. camera.inertialRadiusOffset -= 1 / this.zoomingSensibility;
  12002. }
  12003. else {
  12004. camera.inertialBetaOffset += this.angularSpeed;
  12005. }
  12006. }
  12007. else if (this.keysReset.indexOf(keyCode) !== -1) {
  12008. if (camera.useInputToRestoreState) {
  12009. camera.restoreState();
  12010. }
  12011. }
  12012. }
  12013. }
  12014. };
  12015. /**
  12016. * Gets the class name of the current intput.
  12017. * @returns the class name
  12018. */
  12019. ArcRotateCameraKeyboardMoveInput.prototype.getClassName = function () {
  12020. return "ArcRotateCameraKeyboardMoveInput";
  12021. };
  12022. /**
  12023. * Get the friendly name associated with the input class.
  12024. * @returns the input friendly name
  12025. */
  12026. ArcRotateCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  12027. return "keyboard";
  12028. };
  12029. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12030. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12031. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  12032. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12033. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12034. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  12035. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12036. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12037. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  12038. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12039. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12040. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  12041. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12042. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12043. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysReset", void 0);
  12044. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12045. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12046. ], ArcRotateCameraKeyboardMoveInput.prototype, "panningSensibility", void 0);
  12047. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12048. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12049. ], ArcRotateCameraKeyboardMoveInput.prototype, "zoomingSensibility", void 0);
  12050. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12051. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12052. ], ArcRotateCameraKeyboardMoveInput.prototype, "useAltToZoom", void 0);
  12053. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12054. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12055. ], ArcRotateCameraKeyboardMoveInput.prototype, "angularSpeed", void 0);
  12056. return ArcRotateCameraKeyboardMoveInput;
  12057. }());
  12058. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraKeyboardMoveInput"] = ArcRotateCameraKeyboardMoveInput;
  12059. /***/ }),
  12060. /***/ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts":
  12061. /*!**********************************************************!*\
  12062. !*** ./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts ***!
  12063. \**********************************************************/
  12064. /*! exports provided: ArcRotateCameraMouseWheelInput */
  12065. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12066. "use strict";
  12067. __webpack_require__.r(__webpack_exports__);
  12068. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return ArcRotateCameraMouseWheelInput; });
  12069. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12070. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12071. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12072. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12073. /**
  12074. * Manage the mouse wheel inputs to control an arc rotate camera.
  12075. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12076. */
  12077. var ArcRotateCameraMouseWheelInput = /** @class */ (function () {
  12078. function ArcRotateCameraMouseWheelInput() {
  12079. /**
  12080. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  12081. */
  12082. this.wheelPrecision = 3.0;
  12083. /**
  12084. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  12085. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  12086. */
  12087. this.wheelDeltaPercentage = 0;
  12088. }
  12089. /**
  12090. * Attach the input controls to a specific dom element to get the input from.
  12091. * @param element Defines the element the controls should be listened from
  12092. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12093. */
  12094. ArcRotateCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  12095. var _this = this;
  12096. this._wheel = function (p, s) {
  12097. //sanity check - this should be a PointerWheel event.
  12098. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  12099. return;
  12100. }
  12101. var event = p.event;
  12102. var delta = 0;
  12103. var mouseWheelLegacyEvent = event;
  12104. if (mouseWheelLegacyEvent.wheelDelta) {
  12105. if (_this.wheelDeltaPercentage) {
  12106. var wheelDelta = (mouseWheelLegacyEvent.wheelDelta * 0.01 * _this.wheelDeltaPercentage) * _this.camera.radius;
  12107. if (mouseWheelLegacyEvent.wheelDelta > 0) {
  12108. delta = wheelDelta / (1.0 + _this.wheelDeltaPercentage);
  12109. }
  12110. else {
  12111. delta = wheelDelta * (1.0 + _this.wheelDeltaPercentage);
  12112. }
  12113. }
  12114. else {
  12115. delta = mouseWheelLegacyEvent.wheelDelta / (_this.wheelPrecision * 40);
  12116. }
  12117. }
  12118. else {
  12119. var deltaValue = event.deltaY || event.detail;
  12120. delta = -deltaValue / _this.wheelPrecision;
  12121. }
  12122. if (delta) {
  12123. _this.camera.inertialRadiusOffset += delta;
  12124. }
  12125. if (event.preventDefault) {
  12126. if (!noPreventDefault) {
  12127. event.preventDefault();
  12128. }
  12129. }
  12130. };
  12131. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  12132. };
  12133. /**
  12134. * Detach the current controls from the specified dom element.
  12135. * @param element Defines the element to stop listening the inputs from
  12136. */
  12137. ArcRotateCameraMouseWheelInput.prototype.detachControl = function (element) {
  12138. if (this._observer && element) {
  12139. this.camera.getScene().onPointerObservable.remove(this._observer);
  12140. this._observer = null;
  12141. this._wheel = null;
  12142. }
  12143. };
  12144. /**
  12145. * Gets the class name of the current intput.
  12146. * @returns the class name
  12147. */
  12148. ArcRotateCameraMouseWheelInput.prototype.getClassName = function () {
  12149. return "ArcRotateCameraMouseWheelInput";
  12150. };
  12151. /**
  12152. * Get the friendly name associated with the input class.
  12153. * @returns the input friendly name
  12154. */
  12155. ArcRotateCameraMouseWheelInput.prototype.getSimpleName = function () {
  12156. return "mousewheel";
  12157. };
  12158. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12159. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12160. ], ArcRotateCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  12161. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12162. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12163. ], ArcRotateCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  12164. return ArcRotateCameraMouseWheelInput;
  12165. }());
  12166. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraMouseWheelInput"] = ArcRotateCameraMouseWheelInput;
  12167. /***/ }),
  12168. /***/ "./Cameras/Inputs/arcRotateCameraPointersInput.ts":
  12169. /*!********************************************************!*\
  12170. !*** ./Cameras/Inputs/arcRotateCameraPointersInput.ts ***!
  12171. \********************************************************/
  12172. /*! exports provided: ArcRotateCameraPointersInput */
  12173. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12174. "use strict";
  12175. __webpack_require__.r(__webpack_exports__);
  12176. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return ArcRotateCameraPointersInput; });
  12177. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12178. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12179. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  12180. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12181. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12182. /**
  12183. * Manage the pointers inputs to control an arc rotate camera.
  12184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12185. */
  12186. var ArcRotateCameraPointersInput = /** @class */ (function () {
  12187. function ArcRotateCameraPointersInput() {
  12188. /**
  12189. * Defines the buttons associated with the input to handle camera move.
  12190. */
  12191. this.buttons = [0, 1, 2];
  12192. /**
  12193. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  12194. */
  12195. this.angularSensibilityX = 1000.0;
  12196. /**
  12197. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  12198. */
  12199. this.angularSensibilityY = 1000.0;
  12200. /**
  12201. * Defines the pointer pinch precision or how fast is the camera zooming.
  12202. */
  12203. this.pinchPrecision = 12.0;
  12204. /**
  12205. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  12206. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  12207. */
  12208. this.pinchDeltaPercentage = 0;
  12209. /**
  12210. * Defines the pointer panning sensibility or how fast is the camera moving.
  12211. */
  12212. this.panningSensibility = 1000.0;
  12213. /**
  12214. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  12215. */
  12216. this.multiTouchPanning = true;
  12217. /**
  12218. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  12219. */
  12220. this.multiTouchPanAndZoom = true;
  12221. /**
  12222. * Revers pinch action direction.
  12223. */
  12224. this.pinchInwards = true;
  12225. this._isPanClick = false;
  12226. }
  12227. /**
  12228. * Attach the input controls to a specific dom element to get the input from.
  12229. * @param element Defines the element the controls should be listened from
  12230. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12231. */
  12232. ArcRotateCameraPointersInput.prototype.attachControl = function (element, noPreventDefault) {
  12233. var _this = this;
  12234. var engine = this.camera.getEngine();
  12235. var cacheSoloPointer; // cache pointer object for better perf on camera rotation
  12236. var pointA = null;
  12237. var pointB = null;
  12238. var previousPinchSquaredDistance = 0;
  12239. var initialDistance = 0;
  12240. var twoFingerActivityCount = 0;
  12241. var previousMultiTouchPanPosition = { x: 0, y: 0, isPaning: false, isPinching: false };
  12242. this._pointerInput = function (p, s) {
  12243. var evt = p.event;
  12244. var isTouch = p.event.pointerType === "touch";
  12245. if (engine.isInVRExclusivePointerMode) {
  12246. return;
  12247. }
  12248. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  12249. return;
  12250. }
  12251. var srcElement = (evt.srcElement || evt.target);
  12252. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN && srcElement) {
  12253. try {
  12254. srcElement.setPointerCapture(evt.pointerId);
  12255. }
  12256. catch (e) {
  12257. //Nothing to do with the error. Execution will continue.
  12258. }
  12259. // Manage panning with pan button click
  12260. _this._isPanClick = evt.button === _this.camera._panningMouseButton;
  12261. // manage pointers
  12262. cacheSoloPointer = { x: evt.clientX, y: evt.clientY, pointerId: evt.pointerId, type: evt.pointerType };
  12263. if (pointA === null) {
  12264. pointA = cacheSoloPointer;
  12265. }
  12266. else if (pointB === null) {
  12267. pointB = cacheSoloPointer;
  12268. }
  12269. if (!noPreventDefault) {
  12270. evt.preventDefault();
  12271. element.focus();
  12272. }
  12273. }
  12274. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOUBLETAP) {
  12275. if (_this.camera.useInputToRestoreState) {
  12276. _this.camera.restoreState();
  12277. }
  12278. }
  12279. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP && srcElement) {
  12280. try {
  12281. srcElement.releasePointerCapture(evt.pointerId);
  12282. }
  12283. catch (e) {
  12284. //Nothing to do with the error.
  12285. }
  12286. cacheSoloPointer = null;
  12287. previousPinchSquaredDistance = 0;
  12288. previousMultiTouchPanPosition.isPaning = false;
  12289. previousMultiTouchPanPosition.isPinching = false;
  12290. twoFingerActivityCount = 0;
  12291. initialDistance = 0;
  12292. if (!isTouch) {
  12293. pointB = null; // Mouse and pen are mono pointer
  12294. }
  12295. //would be better to use pointers.remove(evt.pointerId) for multitouch gestures,
  12296. //but emptying completly pointers collection is required to fix a bug on iPhone :
  12297. //when changing orientation while pinching camera, one pointer stay pressed forever if we don't release all pointers
  12298. //will be ok to put back pointers.remove(evt.pointerId); when iPhone bug corrected
  12299. if (engine._badOS) {
  12300. pointA = pointB = null;
  12301. }
  12302. else {
  12303. //only remove the impacted pointer in case of multitouch allowing on most
  12304. //platforms switching from rotate to zoom and pan seamlessly.
  12305. if (pointB && pointA && pointA.pointerId == evt.pointerId) {
  12306. pointA = pointB;
  12307. pointB = null;
  12308. cacheSoloPointer = { x: pointA.x, y: pointA.y, pointerId: pointA.pointerId, type: evt.pointerType };
  12309. }
  12310. else if (pointA && pointB && pointB.pointerId == evt.pointerId) {
  12311. pointB = null;
  12312. cacheSoloPointer = { x: pointA.x, y: pointA.y, pointerId: pointA.pointerId, type: evt.pointerType };
  12313. }
  12314. else {
  12315. pointA = pointB = null;
  12316. }
  12317. }
  12318. if (!noPreventDefault) {
  12319. evt.preventDefault();
  12320. }
  12321. }
  12322. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  12323. if (!noPreventDefault) {
  12324. evt.preventDefault();
  12325. }
  12326. // One button down
  12327. if (pointA && pointB === null && cacheSoloPointer) {
  12328. if (_this.panningSensibility !== 0 &&
  12329. ((evt.ctrlKey && _this.camera._useCtrlForPanning) || _this._isPanClick)) {
  12330. _this.camera.inertialPanningX += -(evt.clientX - cacheSoloPointer.x) / _this.panningSensibility;
  12331. _this.camera.inertialPanningY += (evt.clientY - cacheSoloPointer.y) / _this.panningSensibility;
  12332. }
  12333. else {
  12334. var offsetX = evt.clientX - cacheSoloPointer.x;
  12335. var offsetY = evt.clientY - cacheSoloPointer.y;
  12336. _this.camera.inertialAlphaOffset -= offsetX / _this.angularSensibilityX;
  12337. _this.camera.inertialBetaOffset -= offsetY / _this.angularSensibilityY;
  12338. }
  12339. cacheSoloPointer.x = evt.clientX;
  12340. cacheSoloPointer.y = evt.clientY;
  12341. }
  12342. // Two buttons down: pinch/pan
  12343. else if (pointA && pointB) {
  12344. //if (noPreventDefault) { evt.preventDefault(); } //if pinch gesture, could be useful to force preventDefault to avoid html page scroll/zoom in some mobile browsers
  12345. var ed = (pointA.pointerId === evt.pointerId) ? pointA : pointB;
  12346. ed.x = evt.clientX;
  12347. ed.y = evt.clientY;
  12348. var direction = _this.pinchInwards ? 1 : -1;
  12349. var distX = pointA.x - pointB.x;
  12350. var distY = pointA.y - pointB.y;
  12351. var pinchSquaredDistance = (distX * distX) + (distY * distY);
  12352. var pinchDistance = Math.sqrt(pinchSquaredDistance);
  12353. if (previousPinchSquaredDistance === 0) {
  12354. initialDistance = pinchDistance;
  12355. previousPinchSquaredDistance = pinchSquaredDistance;
  12356. previousMultiTouchPanPosition.x = (pointA.x + pointB.x) / 2;
  12357. previousMultiTouchPanPosition.y = (pointA.y + pointB.y) / 2;
  12358. return;
  12359. }
  12360. if (_this.multiTouchPanAndZoom) {
  12361. if (_this.pinchDeltaPercentage) {
  12362. _this.camera.inertialRadiusOffset += ((pinchSquaredDistance - previousPinchSquaredDistance) * 0.001) * _this.camera.radius * _this.pinchDeltaPercentage;
  12363. }
  12364. else {
  12365. _this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
  12366. (_this.pinchPrecision *
  12367. ((_this.angularSensibilityX + _this.angularSensibilityY) / 2) *
  12368. direction);
  12369. }
  12370. if (_this.panningSensibility !== 0) {
  12371. var pointersCenterX = (pointA.x + pointB.x) / 2;
  12372. var pointersCenterY = (pointA.y + pointB.y) / 2;
  12373. var pointersCenterDistX = pointersCenterX - previousMultiTouchPanPosition.x;
  12374. var pointersCenterDistY = pointersCenterY - previousMultiTouchPanPosition.y;
  12375. previousMultiTouchPanPosition.x = pointersCenterX;
  12376. previousMultiTouchPanPosition.y = pointersCenterY;
  12377. _this.camera.inertialPanningX += -(pointersCenterDistX) / (_this.panningSensibility);
  12378. _this.camera.inertialPanningY += (pointersCenterDistY) / (_this.panningSensibility);
  12379. }
  12380. }
  12381. else {
  12382. twoFingerActivityCount++;
  12383. if (previousMultiTouchPanPosition.isPinching || (twoFingerActivityCount < 20 && Math.abs(pinchDistance - initialDistance) > _this.camera.pinchToPanMaxDistance)) {
  12384. if (_this.pinchDeltaPercentage) {
  12385. _this.camera.inertialRadiusOffset += ((pinchSquaredDistance - previousPinchSquaredDistance) * 0.001) * _this.camera.radius * _this.pinchDeltaPercentage;
  12386. }
  12387. else {
  12388. _this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
  12389. (_this.pinchPrecision *
  12390. ((_this.angularSensibilityX + _this.angularSensibilityY) / 2) *
  12391. direction);
  12392. }
  12393. previousMultiTouchPanPosition.isPaning = false;
  12394. previousMultiTouchPanPosition.isPinching = true;
  12395. }
  12396. else {
  12397. if (cacheSoloPointer && cacheSoloPointer.pointerId === ed.pointerId && _this.panningSensibility !== 0 && _this.multiTouchPanning) {
  12398. if (!previousMultiTouchPanPosition.isPaning) {
  12399. previousMultiTouchPanPosition.isPaning = true;
  12400. previousMultiTouchPanPosition.isPinching = false;
  12401. previousMultiTouchPanPosition.x = ed.x;
  12402. previousMultiTouchPanPosition.y = ed.y;
  12403. return;
  12404. }
  12405. _this.camera.inertialPanningX += -(ed.x - previousMultiTouchPanPosition.x) / (_this.panningSensibility);
  12406. _this.camera.inertialPanningY += (ed.y - previousMultiTouchPanPosition.y) / (_this.panningSensibility);
  12407. }
  12408. }
  12409. if (cacheSoloPointer && cacheSoloPointer.pointerId === evt.pointerId) {
  12410. previousMultiTouchPanPosition.x = ed.x;
  12411. previousMultiTouchPanPosition.y = ed.y;
  12412. }
  12413. }
  12414. previousPinchSquaredDistance = pinchSquaredDistance;
  12415. }
  12416. }
  12417. };
  12418. this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOUBLETAP);
  12419. this._onContextMenu = function (evt) {
  12420. evt.preventDefault();
  12421. };
  12422. if (!this.camera._useCtrlForPanning) {
  12423. element.addEventListener("contextmenu", this._onContextMenu, false);
  12424. }
  12425. this._onLostFocus = function () {
  12426. //this._keys = [];
  12427. pointA = pointB = null;
  12428. previousPinchSquaredDistance = 0;
  12429. previousMultiTouchPanPosition.isPaning = false;
  12430. previousMultiTouchPanPosition.isPinching = false;
  12431. twoFingerActivityCount = 0;
  12432. cacheSoloPointer = null;
  12433. initialDistance = 0;
  12434. };
  12435. this._onMouseMove = function (evt) {
  12436. if (!engine.isPointerLock) {
  12437. return;
  12438. }
  12439. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  12440. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  12441. _this.camera.inertialAlphaOffset -= offsetX / _this.angularSensibilityX;
  12442. _this.camera.inertialBetaOffset -= offsetY / _this.angularSensibilityY;
  12443. if (!noPreventDefault) {
  12444. evt.preventDefault();
  12445. }
  12446. };
  12447. this._onGestureStart = function (e) {
  12448. if (window.MSGesture === undefined) {
  12449. return;
  12450. }
  12451. if (!_this._MSGestureHandler) {
  12452. _this._MSGestureHandler = new MSGesture();
  12453. _this._MSGestureHandler.target = element;
  12454. }
  12455. _this._MSGestureHandler.addPointer(e.pointerId);
  12456. };
  12457. this._onGesture = function (e) {
  12458. _this.camera.radius *= e.scale;
  12459. if (e.preventDefault) {
  12460. if (!noPreventDefault) {
  12461. e.stopPropagation();
  12462. e.preventDefault();
  12463. }
  12464. }
  12465. };
  12466. element.addEventListener("mousemove", this._onMouseMove, false);
  12467. element.addEventListener("MSPointerDown", this._onGestureStart, false);
  12468. element.addEventListener("MSGestureChange", this._onGesture, false);
  12469. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RegisterTopRootEvents([
  12470. { name: "blur", handler: this._onLostFocus }
  12471. ]);
  12472. };
  12473. /**
  12474. * Detach the current controls from the specified dom element.
  12475. * @param element Defines the element to stop listening the inputs from
  12476. */
  12477. ArcRotateCameraPointersInput.prototype.detachControl = function (element) {
  12478. if (this._onLostFocus) {
  12479. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].UnregisterTopRootEvents([
  12480. { name: "blur", handler: this._onLostFocus }
  12481. ]);
  12482. }
  12483. if (element && this._observer) {
  12484. this.camera.getScene().onPointerObservable.remove(this._observer);
  12485. this._observer = null;
  12486. if (this._onContextMenu) {
  12487. element.removeEventListener("contextmenu", this._onContextMenu);
  12488. }
  12489. if (this._onMouseMove) {
  12490. element.removeEventListener("mousemove", this._onMouseMove);
  12491. }
  12492. if (this._onGestureStart) {
  12493. element.removeEventListener("MSPointerDown", this._onGestureStart);
  12494. }
  12495. if (this._onGesture) {
  12496. element.removeEventListener("MSGestureChange", this._onGesture);
  12497. }
  12498. this._isPanClick = false;
  12499. this.pinchInwards = true;
  12500. this._onMouseMove = null;
  12501. this._onGestureStart = null;
  12502. this._onGesture = null;
  12503. this._MSGestureHandler = null;
  12504. this._onLostFocus = null;
  12505. this._onContextMenu = null;
  12506. }
  12507. };
  12508. /**
  12509. * Gets the class name of the current intput.
  12510. * @returns the class name
  12511. */
  12512. ArcRotateCameraPointersInput.prototype.getClassName = function () {
  12513. return "ArcRotateCameraPointersInput";
  12514. };
  12515. /**
  12516. * Get the friendly name associated with the input class.
  12517. * @returns the input friendly name
  12518. */
  12519. ArcRotateCameraPointersInput.prototype.getSimpleName = function () {
  12520. return "pointers";
  12521. };
  12522. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12523. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12524. ], ArcRotateCameraPointersInput.prototype, "buttons", void 0);
  12525. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12526. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12527. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityX", void 0);
  12528. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12529. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12530. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityY", void 0);
  12531. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12532. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12533. ], ArcRotateCameraPointersInput.prototype, "pinchPrecision", void 0);
  12534. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12535. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12536. ], ArcRotateCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  12537. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12538. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12539. ], ArcRotateCameraPointersInput.prototype, "panningSensibility", void 0);
  12540. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12541. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12542. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanning", void 0);
  12543. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12544. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12545. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
  12546. return ArcRotateCameraPointersInput;
  12547. }());
  12548. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["CameraInputTypes"]["ArcRotateCameraPointersInput"] = ArcRotateCameraPointersInput;
  12549. /***/ }),
  12550. /***/ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts":
  12551. /*!*******************************************************************!*\
  12552. !*** ./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts ***!
  12553. \*******************************************************************/
  12554. /*! exports provided: ArcRotateCameraVRDeviceOrientationInput */
  12555. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12556. "use strict";
  12557. __webpack_require__.r(__webpack_exports__);
  12558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return ArcRotateCameraVRDeviceOrientationInput; });
  12559. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12560. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  12561. /**
  12562. * Add orientation input support to the input manager.
  12563. * @returns the current input manager
  12564. */
  12565. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraInputsManager"].prototype.addVRDeviceOrientation = function () {
  12566. this.add(new ArcRotateCameraVRDeviceOrientationInput());
  12567. return this;
  12568. };
  12569. /**
  12570. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  12571. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12572. */
  12573. var ArcRotateCameraVRDeviceOrientationInput = /** @class */ (function () {
  12574. /**
  12575. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  12576. */
  12577. function ArcRotateCameraVRDeviceOrientationInput() {
  12578. /**
  12579. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  12580. */
  12581. this.alphaCorrection = 1;
  12582. /**
  12583. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  12584. */
  12585. this.gammaCorrection = 1;
  12586. this._alpha = 0;
  12587. this._gamma = 0;
  12588. this._dirty = false;
  12589. this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
  12590. }
  12591. /**
  12592. * Attach the input controls to a specific dom element to get the input from.
  12593. * @param element Defines the element the controls should be listened from
  12594. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12595. */
  12596. ArcRotateCameraVRDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  12597. this.camera.attachControl(element, noPreventDefault);
  12598. window.addEventListener("deviceorientation", this._deviceOrientationHandler);
  12599. };
  12600. /** @hidden */
  12601. ArcRotateCameraVRDeviceOrientationInput.prototype._onOrientationEvent = function (evt) {
  12602. if (evt.alpha !== null) {
  12603. this._alpha = (+evt.alpha | 0) * this.alphaCorrection;
  12604. }
  12605. if (evt.gamma !== null) {
  12606. this._gamma = (+evt.gamma | 0) * this.gammaCorrection;
  12607. }
  12608. this._dirty = true;
  12609. };
  12610. /**
  12611. * Update the current camera state depending on the inputs that have been used this frame.
  12612. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12613. */
  12614. ArcRotateCameraVRDeviceOrientationInput.prototype.checkInputs = function () {
  12615. if (this._dirty) {
  12616. this._dirty = false;
  12617. if (this._gamma < 0) {
  12618. this._gamma = 180 + this._gamma;
  12619. }
  12620. this.camera.alpha = (-this._alpha / 180.0 * Math.PI) % Math.PI * 2;
  12621. this.camera.beta = (this._gamma / 180.0 * Math.PI);
  12622. }
  12623. };
  12624. /**
  12625. * Detach the current controls from the specified dom element.
  12626. * @param element Defines the element to stop listening the inputs from
  12627. */
  12628. ArcRotateCameraVRDeviceOrientationInput.prototype.detachControl = function (element) {
  12629. window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
  12630. };
  12631. /**
  12632. * Gets the class name of the current intput.
  12633. * @returns the class name
  12634. */
  12635. ArcRotateCameraVRDeviceOrientationInput.prototype.getClassName = function () {
  12636. return "ArcRotateCameraVRDeviceOrientationInput";
  12637. };
  12638. /**
  12639. * Get the friendly name associated with the input class.
  12640. * @returns the input friendly name
  12641. */
  12642. ArcRotateCameraVRDeviceOrientationInput.prototype.getSimpleName = function () {
  12643. return "VRDeviceOrientation";
  12644. };
  12645. return ArcRotateCameraVRDeviceOrientationInput;
  12646. }());
  12647. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["ArcRotateCameraVRDeviceOrientationInput"] = ArcRotateCameraVRDeviceOrientationInput;
  12648. /***/ }),
  12649. /***/ "./Cameras/Inputs/flyCameraKeyboardInput.ts":
  12650. /*!**************************************************!*\
  12651. !*** ./Cameras/Inputs/flyCameraKeyboardInput.ts ***!
  12652. \**************************************************/
  12653. /*! exports provided: FlyCameraKeyboardInput */
  12654. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12655. "use strict";
  12656. __webpack_require__.r(__webpack_exports__);
  12657. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return FlyCameraKeyboardInput; });
  12658. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12659. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12660. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12661. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12662. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  12663. /**
  12664. * Listen to keyboard events to control the camera.
  12665. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12666. */
  12667. var FlyCameraKeyboardInput = /** @class */ (function () {
  12668. function FlyCameraKeyboardInput() {
  12669. /**
  12670. * The list of keyboard keys used to control the forward move of the camera.
  12671. */
  12672. this.keysForward = [87];
  12673. /**
  12674. * The list of keyboard keys used to control the backward move of the camera.
  12675. */
  12676. this.keysBackward = [83];
  12677. /**
  12678. * The list of keyboard keys used to control the forward move of the camera.
  12679. */
  12680. this.keysUp = [69];
  12681. /**
  12682. * The list of keyboard keys used to control the backward move of the camera.
  12683. */
  12684. this.keysDown = [81];
  12685. /**
  12686. * The list of keyboard keys used to control the right strafe move of the camera.
  12687. */
  12688. this.keysRight = [68];
  12689. /**
  12690. * The list of keyboard keys used to control the left strafe move of the camera.
  12691. */
  12692. this.keysLeft = [65];
  12693. this._keys = new Array();
  12694. }
  12695. /**
  12696. * Attach the input controls to a specific dom element to get the input from.
  12697. * @param element Defines the element the controls should be listened from
  12698. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12699. */
  12700. FlyCameraKeyboardInput.prototype.attachControl = function (element, noPreventDefault) {
  12701. var _this = this;
  12702. if (this._onCanvasBlurObserver) {
  12703. return;
  12704. }
  12705. this._scene = this.camera.getScene();
  12706. this._engine = this._scene.getEngine();
  12707. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  12708. _this._keys = [];
  12709. });
  12710. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  12711. var evt = info.event;
  12712. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  12713. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  12714. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  12715. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12716. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12717. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12718. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  12719. var index = _this._keys.indexOf(evt.keyCode);
  12720. if (index === -1) {
  12721. _this._keys.push(evt.keyCode);
  12722. }
  12723. if (!noPreventDefault) {
  12724. evt.preventDefault();
  12725. }
  12726. }
  12727. }
  12728. else {
  12729. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  12730. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  12731. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12732. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12733. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12734. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  12735. var index = _this._keys.indexOf(evt.keyCode);
  12736. if (index >= 0) {
  12737. _this._keys.splice(index, 1);
  12738. }
  12739. if (!noPreventDefault) {
  12740. evt.preventDefault();
  12741. }
  12742. }
  12743. }
  12744. });
  12745. };
  12746. /**
  12747. * Detach the current controls from the specified dom element.
  12748. * @param element Defines the element to stop listening the inputs from
  12749. */
  12750. FlyCameraKeyboardInput.prototype.detachControl = function (element) {
  12751. if (this._scene) {
  12752. if (this._onKeyboardObserver) {
  12753. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  12754. }
  12755. if (this._onCanvasBlurObserver) {
  12756. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  12757. }
  12758. this._onKeyboardObserver = null;
  12759. this._onCanvasBlurObserver = null;
  12760. }
  12761. this._keys = [];
  12762. };
  12763. /**
  12764. * Gets the class name of the current intput.
  12765. * @returns the class name
  12766. */
  12767. FlyCameraKeyboardInput.prototype.getClassName = function () {
  12768. return "FlyCameraKeyboardInput";
  12769. };
  12770. /** @hidden */
  12771. FlyCameraKeyboardInput.prototype._onLostFocus = function (e) {
  12772. this._keys = [];
  12773. };
  12774. /**
  12775. * Get the friendly name associated with the input class.
  12776. * @returns the input friendly name
  12777. */
  12778. FlyCameraKeyboardInput.prototype.getSimpleName = function () {
  12779. return "keyboard";
  12780. };
  12781. /**
  12782. * Update the current camera state depending on the inputs that have been used this frame.
  12783. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12784. */
  12785. FlyCameraKeyboardInput.prototype.checkInputs = function () {
  12786. if (this._onKeyboardObserver) {
  12787. var camera = this.camera;
  12788. // Keyboard
  12789. for (var index = 0; index < this._keys.length; index++) {
  12790. var keyCode = this._keys[index];
  12791. var speed = camera._computeLocalCameraSpeed();
  12792. if (this.keysForward.indexOf(keyCode) !== -1) {
  12793. camera._localDirection.copyFromFloats(0, 0, speed);
  12794. }
  12795. else if (this.keysBackward.indexOf(keyCode) !== -1) {
  12796. camera._localDirection.copyFromFloats(0, 0, -speed);
  12797. }
  12798. else if (this.keysUp.indexOf(keyCode) !== -1) {
  12799. camera._localDirection.copyFromFloats(0, speed, 0);
  12800. }
  12801. else if (this.keysDown.indexOf(keyCode) !== -1) {
  12802. camera._localDirection.copyFromFloats(0, -speed, 0);
  12803. }
  12804. else if (this.keysRight.indexOf(keyCode) !== -1) {
  12805. camera._localDirection.copyFromFloats(speed, 0, 0);
  12806. }
  12807. else if (this.keysLeft.indexOf(keyCode) !== -1) {
  12808. camera._localDirection.copyFromFloats(-speed, 0, 0);
  12809. }
  12810. if (camera.getScene().useRightHandedSystem) {
  12811. camera._localDirection.z *= -1;
  12812. }
  12813. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  12814. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  12815. camera.cameraDirection.addInPlace(camera._transformedDirection);
  12816. }
  12817. }
  12818. };
  12819. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12820. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12821. ], FlyCameraKeyboardInput.prototype, "keysForward", void 0);
  12822. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12823. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12824. ], FlyCameraKeyboardInput.prototype, "keysBackward", void 0);
  12825. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12826. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12827. ], FlyCameraKeyboardInput.prototype, "keysUp", void 0);
  12828. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12830. ], FlyCameraKeyboardInput.prototype, "keysDown", void 0);
  12831. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12832. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12833. ], FlyCameraKeyboardInput.prototype, "keysRight", void 0);
  12834. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12835. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12836. ], FlyCameraKeyboardInput.prototype, "keysLeft", void 0);
  12837. return FlyCameraKeyboardInput;
  12838. }());
  12839. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraKeyboardInput"] = FlyCameraKeyboardInput;
  12840. /***/ }),
  12841. /***/ "./Cameras/Inputs/flyCameraMouseInput.ts":
  12842. /*!***********************************************!*\
  12843. !*** ./Cameras/Inputs/flyCameraMouseInput.ts ***!
  12844. \***********************************************/
  12845. /*! exports provided: FlyCameraMouseInput */
  12846. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12847. "use strict";
  12848. __webpack_require__.r(__webpack_exports__);
  12849. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return FlyCameraMouseInput; });
  12850. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12851. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12852. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12853. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12854. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  12855. /**
  12856. * Listen to mouse events to control the camera.
  12857. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12858. */
  12859. var FlyCameraMouseInput = /** @class */ (function () {
  12860. /**
  12861. * Listen to mouse events to control the camera.
  12862. * @param touchEnabled Define if touch is enabled. (Default is true.)
  12863. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12864. */
  12865. function FlyCameraMouseInput(touchEnabled) {
  12866. if (touchEnabled === void 0) { touchEnabled = true; }
  12867. /**
  12868. * Defines the buttons associated with the input to handle camera rotation.
  12869. */
  12870. this.buttons = [0, 1, 2];
  12871. /**
  12872. * Assign buttons for Yaw control.
  12873. */
  12874. this.buttonsYaw = [-1, 0, 1];
  12875. /**
  12876. * Assign buttons for Pitch control.
  12877. */
  12878. this.buttonsPitch = [-1, 0, 1];
  12879. /**
  12880. * Assign buttons for Roll control.
  12881. */
  12882. this.buttonsRoll = [2];
  12883. /**
  12884. * Detect if any button is being pressed while mouse is moved.
  12885. * -1 = Mouse locked.
  12886. * 0 = Left button.
  12887. * 1 = Middle Button.
  12888. * 2 = Right Button.
  12889. */
  12890. this.activeButton = -1;
  12891. /**
  12892. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  12893. * Higher values reduce its sensitivity.
  12894. */
  12895. this.angularSensibility = 1000.0;
  12896. this.previousPosition = null;
  12897. }
  12898. /**
  12899. * Attach the mouse control to the HTML DOM element.
  12900. * @param element Defines the element that listens to the input events.
  12901. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  12902. */
  12903. FlyCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  12904. var _this = this;
  12905. this.element = element;
  12906. this.noPreventDefault = noPreventDefault;
  12907. this._observer = this.camera.getScene().onPointerObservable.add(function (p, s) {
  12908. _this._pointerInput(p, s);
  12909. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  12910. // Correct Roll by rate, if enabled.
  12911. this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add(function () {
  12912. if (_this.camera.rollCorrect) {
  12913. _this.camera.restoreRoll(_this.camera.rollCorrect);
  12914. }
  12915. });
  12916. // Helper function to keep 'this'.
  12917. this._mousemoveCallback = function (e) {
  12918. _this._onMouseMove(e);
  12919. };
  12920. element.addEventListener("mousemove", this._mousemoveCallback, false);
  12921. };
  12922. /**
  12923. * Detach the current controls from the specified dom element.
  12924. * @param element Defines the element to stop listening the inputs from
  12925. */
  12926. FlyCameraMouseInput.prototype.detachControl = function (element) {
  12927. if (this._observer && element) {
  12928. this.camera.getScene().onPointerObservable.remove(this._observer);
  12929. this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver);
  12930. if (this._mousemoveCallback) {
  12931. element.removeEventListener("mousemove", this._mousemoveCallback);
  12932. }
  12933. this._observer = null;
  12934. this._rollObserver = null;
  12935. this.previousPosition = null;
  12936. this.noPreventDefault = undefined;
  12937. }
  12938. };
  12939. /**
  12940. * Gets the class name of the current input.
  12941. * @returns the class name.
  12942. */
  12943. FlyCameraMouseInput.prototype.getClassName = function () {
  12944. return "FlyCameraMouseInput";
  12945. };
  12946. /**
  12947. * Get the friendly name associated with the input class.
  12948. * @returns the input's friendly name.
  12949. */
  12950. FlyCameraMouseInput.prototype.getSimpleName = function () {
  12951. return "mouse";
  12952. };
  12953. // Track mouse movement, when the pointer is not locked.
  12954. FlyCameraMouseInput.prototype._pointerInput = function (p, s) {
  12955. var e = p.event;
  12956. var camera = this.camera;
  12957. var engine = camera.getEngine();
  12958. if (engine.isInVRExclusivePointerMode) {
  12959. return;
  12960. }
  12961. if (!this.touchEnabled && e.pointerType === "touch") {
  12962. return;
  12963. }
  12964. // Mouse is moved but an unknown mouse button is pressed.
  12965. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && this.buttons.indexOf(e.button) === -1) {
  12966. return;
  12967. }
  12968. var srcElement = (e.srcElement || e.target);
  12969. // Mouse down.
  12970. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  12971. try {
  12972. srcElement.setPointerCapture(e.pointerId);
  12973. }
  12974. catch (e) {
  12975. // Nothing to do with the error. Execution continues.
  12976. }
  12977. this.previousPosition = {
  12978. x: e.clientX,
  12979. y: e.clientY
  12980. };
  12981. this.activeButton = e.button;
  12982. if (!this.noPreventDefault) {
  12983. e.preventDefault();
  12984. this.element.focus();
  12985. }
  12986. }
  12987. else
  12988. // Mouse up.
  12989. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  12990. try {
  12991. srcElement.releasePointerCapture(e.pointerId);
  12992. }
  12993. catch (e) {
  12994. // Nothing to do with the error. Execution continues.
  12995. }
  12996. this.activeButton = -1;
  12997. this.previousPosition = null;
  12998. if (!this.noPreventDefault) {
  12999. e.preventDefault();
  13000. }
  13001. }
  13002. else
  13003. // Mouse move.
  13004. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  13005. if (!this.previousPosition || engine.isPointerLock) {
  13006. return;
  13007. }
  13008. var offsetX = e.clientX - this.previousPosition.x;
  13009. var offsetY = e.clientY - this.previousPosition.y;
  13010. this.rotateCamera(offsetX, offsetY);
  13011. this.previousPosition = {
  13012. x: e.clientX,
  13013. y: e.clientY
  13014. };
  13015. if (!this.noPreventDefault) {
  13016. e.preventDefault();
  13017. }
  13018. }
  13019. };
  13020. // Track mouse movement, when pointer is locked.
  13021. FlyCameraMouseInput.prototype._onMouseMove = function (e) {
  13022. var camera = this.camera;
  13023. var engine = camera.getEngine();
  13024. if (!engine.isPointerLock || engine.isInVRExclusivePointerMode) {
  13025. return;
  13026. }
  13027. var offsetX = e.movementX || e.mozMovementX || e.webkitMovementX || e.msMovementX || 0;
  13028. var offsetY = e.movementY || e.mozMovementY || e.webkitMovementY || e.msMovementY || 0;
  13029. this.rotateCamera(offsetX, offsetY);
  13030. this.previousPosition = null;
  13031. if (!this.noPreventDefault) {
  13032. e.preventDefault();
  13033. }
  13034. };
  13035. /**
  13036. * Rotate camera by mouse offset.
  13037. */
  13038. FlyCameraMouseInput.prototype.rotateCamera = function (offsetX, offsetY) {
  13039. var _this = this;
  13040. var camera = this.camera;
  13041. var scene = this.camera.getScene();
  13042. if (scene.useRightHandedSystem) {
  13043. offsetX *= -1;
  13044. }
  13045. if (camera.parent && camera.parent._getWorldMatrixDeterminant() < 0) {
  13046. offsetX *= -1;
  13047. }
  13048. var x = offsetX / this.angularSensibility;
  13049. var y = offsetY / this.angularSensibility;
  13050. // Initialize to current rotation.
  13051. var currentRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, camera.rotation.z);
  13052. var rotationChange;
  13053. // Pitch.
  13054. if (this.buttonsPitch.some(function (v) { return v === _this.activeButton; })) {
  13055. // Apply change in Radians to vector Angle.
  13056. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].X, y);
  13057. // Apply Pitch to quaternion.
  13058. currentRotation.multiplyInPlace(rotationChange);
  13059. }
  13060. // Yaw.
  13061. if (this.buttonsYaw.some(function (v) { return v === _this.activeButton; })) {
  13062. // Apply change in Radians to vector Angle.
  13063. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Y, x);
  13064. // Apply Yaw to quaternion.
  13065. currentRotation.multiplyInPlace(rotationChange);
  13066. // Add Roll, if banked turning is enabled, within Roll limit.
  13067. var limit = (camera.bankedTurnLimit) + camera._trackRoll; // Defaults to 90° plus manual roll.
  13068. if (camera.bankedTurn && -limit < camera.rotation.z && camera.rotation.z < limit) {
  13069. var bankingDelta = camera.bankedTurnMultiplier * -x;
  13070. // Apply change in Radians to vector Angle.
  13071. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, bankingDelta);
  13072. // Apply Yaw to quaternion.
  13073. currentRotation.multiplyInPlace(rotationChange);
  13074. }
  13075. }
  13076. // Roll.
  13077. if (this.buttonsRoll.some(function (v) { return v === _this.activeButton; })) {
  13078. // Apply change in Radians to vector Angle.
  13079. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, -x);
  13080. // Track Rolling.
  13081. camera._trackRoll -= x;
  13082. // Apply Pitch to quaternion.
  13083. currentRotation.multiplyInPlace(rotationChange);
  13084. }
  13085. // Apply rotationQuaternion to Euler camera.rotation.
  13086. currentRotation.toEulerAnglesToRef(camera.rotation);
  13087. };
  13088. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13089. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13090. ], FlyCameraMouseInput.prototype, "buttons", void 0);
  13091. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13092. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13093. ], FlyCameraMouseInput.prototype, "angularSensibility", void 0);
  13094. return FlyCameraMouseInput;
  13095. }());
  13096. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraMouseInput"] = FlyCameraMouseInput;
  13097. /***/ }),
  13098. /***/ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts":
  13099. /*!*********************************************************!*\
  13100. !*** ./Cameras/Inputs/followCameraKeyboardMoveInput.ts ***!
  13101. \*********************************************************/
  13102. /*! exports provided: FollowCameraKeyboardMoveInput */
  13103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13104. "use strict";
  13105. __webpack_require__.r(__webpack_exports__);
  13106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return FollowCameraKeyboardMoveInput; });
  13107. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13108. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13109. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13110. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13111. /**
  13112. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  13113. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13114. */
  13115. var FollowCameraKeyboardMoveInput = /** @class */ (function () {
  13116. function FollowCameraKeyboardMoveInput() {
  13117. /**
  13118. * Defines the list of key codes associated with the up action (increase heightOffset)
  13119. */
  13120. this.keysUp = [38];
  13121. /**
  13122. * Defines the list of key codes associated with the down action (decrease heightOffset)
  13123. */
  13124. this.keysDown = [40];
  13125. /**
  13126. * Defines the list of key codes associated with the left action (increase rotation)
  13127. */
  13128. this.keysLeft = [37];
  13129. /**
  13130. * Defines the list of key codes associated with the right action (decrease rotation)
  13131. */
  13132. this.keysRight = [39];
  13133. /**
  13134. * Defines the rate of change of heightOffset.
  13135. */
  13136. this.heightSensibility = 1;
  13137. /**
  13138. * Defines the rate of change of rotationOffset.
  13139. */
  13140. this.rotationSensibility = 1;
  13141. /**
  13142. * Defines the rate of change of radius.
  13143. */
  13144. this.radiusSensibility = 1;
  13145. /**
  13146. * Defines the minimum heightOffset value.
  13147. */
  13148. this.minHeightOffset = 0;
  13149. /**
  13150. * Defines the minimum radius value.
  13151. */
  13152. this.minRadius = 0;
  13153. this._keys = new Array();
  13154. }
  13155. /**
  13156. * Attach the input controls to a specific dom element to get the input from.
  13157. * @param element Defines the element the controls should be listened from
  13158. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13159. */
  13160. FollowCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  13161. var _this = this;
  13162. if (this._onCanvasBlurObserver) {
  13163. return;
  13164. }
  13165. this._scene = this.camera.getScene();
  13166. this._engine = this._scene.getEngine();
  13167. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13168. _this._keys = [];
  13169. });
  13170. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13171. var evt = info.event;
  13172. if (!evt.metaKey) {
  13173. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13174. // this._ctrlPressed = evt.ctrlKey;
  13175. _this._altPressed = evt.altKey;
  13176. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13177. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13178. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13179. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13180. var index = _this._keys.indexOf(evt.keyCode);
  13181. if (index === -1) {
  13182. _this._keys.push(evt.keyCode);
  13183. }
  13184. if (evt.preventDefault) {
  13185. if (!noPreventDefault) {
  13186. evt.preventDefault();
  13187. }
  13188. }
  13189. }
  13190. }
  13191. else {
  13192. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13193. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13194. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13195. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13196. var index = _this._keys.indexOf(evt.keyCode);
  13197. if (index >= 0) {
  13198. _this._keys.splice(index, 1);
  13199. }
  13200. if (evt.preventDefault) {
  13201. if (!noPreventDefault) {
  13202. evt.preventDefault();
  13203. }
  13204. }
  13205. }
  13206. }
  13207. }
  13208. });
  13209. };
  13210. /**
  13211. * Detach the current controls from the specified dom element.
  13212. * @param element Defines the element to stop listening the inputs from
  13213. */
  13214. FollowCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  13215. if (this._scene) {
  13216. if (this._onKeyboardObserver) {
  13217. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13218. }
  13219. if (this._onCanvasBlurObserver) {
  13220. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13221. }
  13222. this._onKeyboardObserver = null;
  13223. this._onCanvasBlurObserver = null;
  13224. }
  13225. this._keys = [];
  13226. };
  13227. /**
  13228. * Update the current camera state depending on the inputs that have been used this frame.
  13229. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13230. */
  13231. FollowCameraKeyboardMoveInput.prototype.checkInputs = function () {
  13232. if (this._onKeyboardObserver) {
  13233. for (var index = 0; index < this._keys.length; index++) {
  13234. var keyCode = this._keys[index];
  13235. if (this.keysLeft.indexOf(keyCode) !== -1) {
  13236. this.camera.rotationOffset += this.rotationSensibility;
  13237. this.camera.rotationOffset %= 360;
  13238. }
  13239. else if (this.keysUp.indexOf(keyCode) !== -1) {
  13240. if (this._altPressed) {
  13241. this.camera.radius += this.radiusSensibility;
  13242. }
  13243. else {
  13244. this.camera.heightOffset += this.heightSensibility;
  13245. }
  13246. }
  13247. else if (this.keysRight.indexOf(keyCode) !== -1) {
  13248. this.camera.rotationOffset -= this.rotationSensibility;
  13249. this.camera.rotationOffset %= 360;
  13250. }
  13251. else if (this.keysDown.indexOf(keyCode) !== -1) {
  13252. if (this._altPressed) {
  13253. this.camera.radius -= this.radiusSensibility;
  13254. this.camera.radius =
  13255. Math.max(this.minRadius, this.camera.radius);
  13256. }
  13257. else {
  13258. this.camera.heightOffset -= this.heightSensibility;
  13259. this.camera.heightOffset =
  13260. Math.max(this.minHeightOffset, this.camera.heightOffset);
  13261. }
  13262. }
  13263. }
  13264. }
  13265. };
  13266. /**
  13267. * Gets the class name of the current intput.
  13268. * @returns the class name
  13269. */
  13270. FollowCameraKeyboardMoveInput.prototype.getClassName = function () {
  13271. return "FollowCameraKeyboardMoveInput";
  13272. };
  13273. /**
  13274. * Get the friendly name associated with the input class.
  13275. * @returns the input friendly name
  13276. */
  13277. FollowCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  13278. return "keyboard";
  13279. };
  13280. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13281. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13282. ], FollowCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  13283. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13284. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13285. ], FollowCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  13286. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13287. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13288. ], FollowCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  13289. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13290. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13291. ], FollowCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  13292. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13293. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13294. ], FollowCameraKeyboardMoveInput.prototype, "heightSensibility", void 0);
  13295. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13296. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13297. ], FollowCameraKeyboardMoveInput.prototype, "rotationSensibility", void 0);
  13298. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13299. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13300. ], FollowCameraKeyboardMoveInput.prototype, "radiusSensibility", void 0);
  13301. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13302. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13303. ], FollowCameraKeyboardMoveInput.prototype, "minHeightOffset", void 0);
  13304. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13305. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13306. ], FollowCameraKeyboardMoveInput.prototype, "minRadius", void 0);
  13307. return FollowCameraKeyboardMoveInput;
  13308. }());
  13309. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FollowCameraKeyboardMoveInput"] = FollowCameraKeyboardMoveInput;
  13310. /***/ }),
  13311. /***/ "./Cameras/Inputs/followCameraMouseWheelInput.ts":
  13312. /*!*******************************************************!*\
  13313. !*** ./Cameras/Inputs/followCameraMouseWheelInput.ts ***!
  13314. \*******************************************************/
  13315. /*! exports provided: FollowCameraMouseWheelInput */
  13316. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13317. "use strict";
  13318. __webpack_require__.r(__webpack_exports__);
  13319. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return FollowCameraMouseWheelInput; });
  13320. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13321. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13322. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13323. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13324. /**
  13325. * Manage the mouse wheel inputs to control a follow camera.
  13326. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13327. */
  13328. var FollowCameraMouseWheelInput = /** @class */ (function () {
  13329. function FollowCameraMouseWheelInput() {
  13330. /**
  13331. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  13332. */
  13333. this.axisControlRadius = true;
  13334. /**
  13335. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  13336. */
  13337. this.axisControlHeight = false;
  13338. /**
  13339. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  13340. */
  13341. this.axisControlRotation = false;
  13342. /**
  13343. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  13344. * relation to mouseWheel events.
  13345. */
  13346. this.wheelPrecision = 3.0;
  13347. /**
  13348. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  13349. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  13350. */
  13351. this.wheelDeltaPercentage = 0;
  13352. }
  13353. /**
  13354. * Attach the input controls to a specific dom element to get the input from.
  13355. * @param element Defines the element the controls should be listened from
  13356. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13357. */
  13358. FollowCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  13359. var _this = this;
  13360. this._wheel = function (p, s) {
  13361. // sanity check - this should be a PointerWheel event.
  13362. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  13363. return;
  13364. }
  13365. var event = p.event;
  13366. var delta = 0;
  13367. // Chrome, Safari: event.deltaY
  13368. // IE: event.wheelDelta
  13369. // Firefox: event.detail (inverted)
  13370. var wheelDelta = Math.max(-1, Math.min(1, (event.deltaY || event.wheelDelta || -event.detail)));
  13371. if (_this.wheelDeltaPercentage) {
  13372. console.assert((_this.axisControlRadius +
  13373. _this.axisControlHeight +
  13374. _this.axisControlRotation) <= 1, "wheelDeltaPercentage only usable when mouse wheel " +
  13375. "controlls ONE axis. " +
  13376. "Currently enabled: " +
  13377. "axisControlRadius: " + _this.axisControlRadius +
  13378. ", axisControlHeightOffset: " + _this.axisControlHeight +
  13379. ", axisControlRotationOffset: " + _this.axisControlRotation);
  13380. if (_this.axisControlRadius) {
  13381. delta =
  13382. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13383. _this.camera.radius;
  13384. }
  13385. else if (_this.axisControlHeight) {
  13386. delta =
  13387. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13388. _this.camera.heightOffset;
  13389. }
  13390. else if (_this.axisControlRotation) {
  13391. delta =
  13392. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13393. _this.camera.rotationOffset;
  13394. }
  13395. }
  13396. else {
  13397. delta = wheelDelta * _this.wheelPrecision;
  13398. }
  13399. if (delta) {
  13400. if (_this.axisControlRadius) {
  13401. _this.camera.radius += delta;
  13402. }
  13403. else if (_this.axisControlHeight) {
  13404. _this.camera.heightOffset += delta;
  13405. }
  13406. else if (_this.axisControlRotation) {
  13407. _this.camera.rotationOffset += delta;
  13408. }
  13409. }
  13410. if (event.preventDefault) {
  13411. if (!noPreventDefault) {
  13412. event.preventDefault();
  13413. }
  13414. }
  13415. };
  13416. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  13417. };
  13418. /**
  13419. * Detach the current controls from the specified dom element.
  13420. * @param element Defines the element to stop listening the inputs from
  13421. */
  13422. FollowCameraMouseWheelInput.prototype.detachControl = function (element) {
  13423. if (this._observer && element) {
  13424. this.camera.getScene().onPointerObservable.remove(this._observer);
  13425. this._observer = null;
  13426. this._wheel = null;
  13427. }
  13428. };
  13429. /**
  13430. * Gets the class name of the current intput.
  13431. * @returns the class name
  13432. */
  13433. FollowCameraMouseWheelInput.prototype.getClassName = function () {
  13434. return "ArcRotateCameraMouseWheelInput";
  13435. };
  13436. /**
  13437. * Get the friendly name associated with the input class.
  13438. * @returns the input friendly name
  13439. */
  13440. FollowCameraMouseWheelInput.prototype.getSimpleName = function () {
  13441. return "mousewheel";
  13442. };
  13443. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13444. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13445. ], FollowCameraMouseWheelInput.prototype, "axisControlRadius", void 0);
  13446. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13447. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13448. ], FollowCameraMouseWheelInput.prototype, "axisControlHeight", void 0);
  13449. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13450. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13451. ], FollowCameraMouseWheelInput.prototype, "axisControlRotation", void 0);
  13452. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13453. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13454. ], FollowCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  13455. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13456. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13457. ], FollowCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  13458. return FollowCameraMouseWheelInput;
  13459. }());
  13460. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraMouseWheelInput"] = FollowCameraMouseWheelInput;
  13461. /***/ }),
  13462. /***/ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts":
  13463. /*!************************************************************!*\
  13464. !*** ./Cameras/Inputs/freeCameraDeviceOrientationInput.ts ***!
  13465. \************************************************************/
  13466. /*! exports provided: FreeCameraDeviceOrientationInput */
  13467. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13468. "use strict";
  13469. __webpack_require__.r(__webpack_exports__);
  13470. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return FreeCameraDeviceOrientationInput; });
  13471. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13472. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13473. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  13474. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  13475. /**
  13476. * Add orientation input support to the input manager.
  13477. * @returns the current input manager
  13478. */
  13479. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addDeviceOrientation = function () {
  13480. this.add(new FreeCameraDeviceOrientationInput());
  13481. return this;
  13482. };
  13483. /**
  13484. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  13485. * Screen rotation is taken into account.
  13486. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13487. */
  13488. var FreeCameraDeviceOrientationInput = /** @class */ (function () {
  13489. /**
  13490. * Instantiates a new input
  13491. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13492. */
  13493. function FreeCameraDeviceOrientationInput() {
  13494. var _this = this;
  13495. this._screenOrientationAngle = 0;
  13496. this._screenQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  13497. this._alpha = 0;
  13498. this._beta = 0;
  13499. this._gamma = 0;
  13500. this._orientationChanged = function () {
  13501. _this._screenOrientationAngle = (window.orientation !== undefined ? +window.orientation : (window.screen.orientation && (window.screen.orientation)['angle'] ? (window.screen.orientation).angle : 0));
  13502. _this._screenOrientationAngle = -_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(_this._screenOrientationAngle / 2);
  13503. _this._screenQuaternion.copyFromFloats(0, Math.sin(_this._screenOrientationAngle), 0, Math.cos(_this._screenOrientationAngle));
  13504. };
  13505. this._deviceOrientation = function (evt) {
  13506. _this._alpha = evt.alpha !== null ? evt.alpha : 0;
  13507. _this._beta = evt.beta !== null ? evt.beta : 0;
  13508. _this._gamma = evt.gamma !== null ? evt.gamma : 0;
  13509. };
  13510. this._constantTranform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5));
  13511. this._orientationChanged();
  13512. }
  13513. Object.defineProperty(FreeCameraDeviceOrientationInput.prototype, "camera", {
  13514. /**
  13515. * Define the camera controlled by the input.
  13516. */
  13517. get: function () {
  13518. return this._camera;
  13519. },
  13520. set: function (camera) {
  13521. this._camera = camera;
  13522. if (this._camera != null && !this._camera.rotationQuaternion) {
  13523. this._camera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  13524. }
  13525. },
  13526. enumerable: true,
  13527. configurable: true
  13528. });
  13529. /**
  13530. * Attach the input controls to a specific dom element to get the input from.
  13531. * @param element Defines the element the controls should be listened from
  13532. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13533. */
  13534. FreeCameraDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  13535. window.addEventListener("orientationchange", this._orientationChanged);
  13536. window.addEventListener("deviceorientation", this._deviceOrientation);
  13537. //In certain cases, the attach control is called AFTER orientation was changed,
  13538. //So this is needed.
  13539. this._orientationChanged();
  13540. };
  13541. /**
  13542. * Detach the current controls from the specified dom element.
  13543. * @param element Defines the element to stop listening the inputs from
  13544. */
  13545. FreeCameraDeviceOrientationInput.prototype.detachControl = function (element) {
  13546. window.removeEventListener("orientationchange", this._orientationChanged);
  13547. window.removeEventListener("deviceorientation", this._deviceOrientation);
  13548. };
  13549. /**
  13550. * Update the current camera state depending on the inputs that have been used this frame.
  13551. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13552. */
  13553. FreeCameraDeviceOrientationInput.prototype.checkInputs = function () {
  13554. //if no device orientation provided, don't update the rotation.
  13555. //Only testing against alpha under the assumption thatnorientation will never be so exact when set.
  13556. if (!this._alpha) {
  13557. return;
  13558. }
  13559. _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);
  13560. this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion);
  13561. this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform);
  13562. //Mirror on XY Plane
  13563. this._camera.rotationQuaternion.z *= -1;
  13564. this._camera.rotationQuaternion.w *= -1;
  13565. };
  13566. /**
  13567. * Gets the class name of the current intput.
  13568. * @returns the class name
  13569. */
  13570. FreeCameraDeviceOrientationInput.prototype.getClassName = function () {
  13571. return "FreeCameraDeviceOrientationInput";
  13572. };
  13573. /**
  13574. * Get the friendly name associated with the input class.
  13575. * @returns the input friendly name
  13576. */
  13577. FreeCameraDeviceOrientationInput.prototype.getSimpleName = function () {
  13578. return "deviceOrientation";
  13579. };
  13580. return FreeCameraDeviceOrientationInput;
  13581. }());
  13582. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["FreeCameraDeviceOrientationInput"] = FreeCameraDeviceOrientationInput;
  13583. /***/ }),
  13584. /***/ "./Cameras/Inputs/freeCameraGamepadInput.ts":
  13585. /*!**************************************************!*\
  13586. !*** ./Cameras/Inputs/freeCameraGamepadInput.ts ***!
  13587. \**************************************************/
  13588. /*! exports provided: FreeCameraGamepadInput */
  13589. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13590. "use strict";
  13591. __webpack_require__.r(__webpack_exports__);
  13592. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return FreeCameraGamepadInput; });
  13593. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13594. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13595. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13596. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13597. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  13598. /**
  13599. * Manage the gamepad inputs to control a free camera.
  13600. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13601. */
  13602. var FreeCameraGamepadInput = /** @class */ (function () {
  13603. function FreeCameraGamepadInput() {
  13604. /**
  13605. * Defines the gamepad rotation sensiblity.
  13606. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  13607. */
  13608. this.gamepadAngularSensibility = 200;
  13609. /**
  13610. * Defines the gamepad move sensiblity.
  13611. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  13612. */
  13613. this.gamepadMoveSensibility = 40;
  13614. this._cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  13615. this._deltaTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  13616. this._vector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  13617. this._vector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  13618. }
  13619. /**
  13620. * Attach the input controls to a specific dom element to get the input from.
  13621. * @param element Defines the element the controls should be listened from
  13622. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13623. */
  13624. FreeCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  13625. var _this = this;
  13626. var manager = this.camera.getScene().gamepadManager;
  13627. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  13628. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].POSE_ENABLED) {
  13629. // prioritize XBOX gamepads.
  13630. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX) {
  13631. _this.gamepad = gamepad;
  13632. }
  13633. }
  13634. });
  13635. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  13636. if (_this.gamepad === gamepad) {
  13637. _this.gamepad = null;
  13638. }
  13639. });
  13640. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX);
  13641. };
  13642. /**
  13643. * Detach the current controls from the specified dom element.
  13644. * @param element Defines the element to stop listening the inputs from
  13645. */
  13646. FreeCameraGamepadInput.prototype.detachControl = function (element) {
  13647. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  13648. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  13649. this.gamepad = null;
  13650. };
  13651. /**
  13652. * Update the current camera state depending on the inputs that have been used this frame.
  13653. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13654. */
  13655. FreeCameraGamepadInput.prototype.checkInputs = function () {
  13656. if (this.gamepad && this.gamepad.leftStick) {
  13657. var camera = this.camera;
  13658. var LSValues = this.gamepad.leftStick;
  13659. var normalizedLX = LSValues.x / this.gamepadMoveSensibility;
  13660. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  13661. LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
  13662. LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
  13663. var RSValues = this.gamepad.rightStick;
  13664. if (RSValues) {
  13665. var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
  13666. var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
  13667. RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
  13668. RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
  13669. }
  13670. else {
  13671. RSValues = { x: 0, y: 0 };
  13672. }
  13673. if (!camera.rotationQuaternion) {
  13674. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, this._cameraTransform);
  13675. }
  13676. else {
  13677. camera.rotationQuaternion.toRotationMatrix(this._cameraTransform);
  13678. }
  13679. var speed = camera._computeLocalCameraSpeed() * 50.0;
  13680. this._vector3.copyFromFloats(LSValues.x * speed, 0, -LSValues.y * speed);
  13681. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform);
  13682. camera.cameraDirection.addInPlace(this._deltaTransform);
  13683. this._vector2.copyFromFloats(RSValues.y, RSValues.x);
  13684. camera.cameraRotation.addInPlace(this._vector2);
  13685. }
  13686. };
  13687. /**
  13688. * Gets the class name of the current intput.
  13689. * @returns the class name
  13690. */
  13691. FreeCameraGamepadInput.prototype.getClassName = function () {
  13692. return "FreeCameraGamepadInput";
  13693. };
  13694. /**
  13695. * Get the friendly name associated with the input class.
  13696. * @returns the input friendly name
  13697. */
  13698. FreeCameraGamepadInput.prototype.getSimpleName = function () {
  13699. return "gamepad";
  13700. };
  13701. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13702. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13703. ], FreeCameraGamepadInput.prototype, "gamepadAngularSensibility", void 0);
  13704. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13705. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13706. ], FreeCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  13707. return FreeCameraGamepadInput;
  13708. }());
  13709. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraGamepadInput"] = FreeCameraGamepadInput;
  13710. /***/ }),
  13711. /***/ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts":
  13712. /*!*******************************************************!*\
  13713. !*** ./Cameras/Inputs/freeCameraKeyboardMoveInput.ts ***!
  13714. \*******************************************************/
  13715. /*! exports provided: FreeCameraKeyboardMoveInput */
  13716. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13717. "use strict";
  13718. __webpack_require__.r(__webpack_exports__);
  13719. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return FreeCameraKeyboardMoveInput; });
  13720. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13721. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13722. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13723. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13724. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13725. /**
  13726. * Manage the keyboard inputs to control the movement of a free camera.
  13727. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13728. */
  13729. var FreeCameraKeyboardMoveInput = /** @class */ (function () {
  13730. function FreeCameraKeyboardMoveInput() {
  13731. /**
  13732. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  13733. */
  13734. this.keysUp = [38];
  13735. /**
  13736. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  13737. */
  13738. this.keysDown = [40];
  13739. /**
  13740. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  13741. */
  13742. this.keysLeft = [37];
  13743. /**
  13744. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  13745. */
  13746. this.keysRight = [39];
  13747. this._keys = new Array();
  13748. }
  13749. /**
  13750. * Attach the input controls to a specific dom element to get the input from.
  13751. * @param element Defines the element the controls should be listened from
  13752. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13753. */
  13754. FreeCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  13755. var _this = this;
  13756. if (this._onCanvasBlurObserver) {
  13757. return;
  13758. }
  13759. this._scene = this.camera.getScene();
  13760. this._engine = this._scene.getEngine();
  13761. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13762. _this._keys = [];
  13763. });
  13764. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13765. var evt = info.event;
  13766. if (!evt.metaKey) {
  13767. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13768. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13769. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13770. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13771. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13772. var index = _this._keys.indexOf(evt.keyCode);
  13773. if (index === -1) {
  13774. _this._keys.push(evt.keyCode);
  13775. }
  13776. if (!noPreventDefault) {
  13777. evt.preventDefault();
  13778. }
  13779. }
  13780. }
  13781. else {
  13782. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13783. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13784. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13785. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13786. var index = _this._keys.indexOf(evt.keyCode);
  13787. if (index >= 0) {
  13788. _this._keys.splice(index, 1);
  13789. }
  13790. if (!noPreventDefault) {
  13791. evt.preventDefault();
  13792. }
  13793. }
  13794. }
  13795. }
  13796. });
  13797. };
  13798. /**
  13799. * Detach the current controls from the specified dom element.
  13800. * @param element Defines the element to stop listening the inputs from
  13801. */
  13802. FreeCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  13803. if (this._scene) {
  13804. if (this._onKeyboardObserver) {
  13805. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13806. }
  13807. if (this._onCanvasBlurObserver) {
  13808. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13809. }
  13810. this._onKeyboardObserver = null;
  13811. this._onCanvasBlurObserver = null;
  13812. }
  13813. this._keys = [];
  13814. };
  13815. /**
  13816. * Update the current camera state depending on the inputs that have been used this frame.
  13817. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13818. */
  13819. FreeCameraKeyboardMoveInput.prototype.checkInputs = function () {
  13820. if (this._onKeyboardObserver) {
  13821. var camera = this.camera;
  13822. // Keyboard
  13823. for (var index = 0; index < this._keys.length; index++) {
  13824. var keyCode = this._keys[index];
  13825. var speed = camera._computeLocalCameraSpeed();
  13826. if (this.keysLeft.indexOf(keyCode) !== -1) {
  13827. camera._localDirection.copyFromFloats(-speed, 0, 0);
  13828. }
  13829. else if (this.keysUp.indexOf(keyCode) !== -1) {
  13830. camera._localDirection.copyFromFloats(0, 0, speed);
  13831. }
  13832. else if (this.keysRight.indexOf(keyCode) !== -1) {
  13833. camera._localDirection.copyFromFloats(speed, 0, 0);
  13834. }
  13835. else if (this.keysDown.indexOf(keyCode) !== -1) {
  13836. camera._localDirection.copyFromFloats(0, 0, -speed);
  13837. }
  13838. if (camera.getScene().useRightHandedSystem) {
  13839. camera._localDirection.z *= -1;
  13840. }
  13841. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  13842. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  13843. camera.cameraDirection.addInPlace(camera._transformedDirection);
  13844. }
  13845. }
  13846. };
  13847. /**
  13848. * Gets the class name of the current intput.
  13849. * @returns the class name
  13850. */
  13851. FreeCameraKeyboardMoveInput.prototype.getClassName = function () {
  13852. return "FreeCameraKeyboardMoveInput";
  13853. };
  13854. /** @hidden */
  13855. FreeCameraKeyboardMoveInput.prototype._onLostFocus = function () {
  13856. this._keys = [];
  13857. };
  13858. /**
  13859. * Get the friendly name associated with the input class.
  13860. * @returns the input friendly name
  13861. */
  13862. FreeCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  13863. return "keyboard";
  13864. };
  13865. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13866. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13867. ], FreeCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  13868. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13869. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13870. ], FreeCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  13871. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13872. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13873. ], FreeCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  13874. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13875. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13876. ], FreeCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  13877. return FreeCameraKeyboardMoveInput;
  13878. }());
  13879. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraKeyboardMoveInput"] = FreeCameraKeyboardMoveInput;
  13880. /***/ }),
  13881. /***/ "./Cameras/Inputs/freeCameraMouseInput.ts":
  13882. /*!************************************************!*\
  13883. !*** ./Cameras/Inputs/freeCameraMouseInput.ts ***!
  13884. \************************************************/
  13885. /*! exports provided: FreeCameraMouseInput */
  13886. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13887. "use strict";
  13888. __webpack_require__.r(__webpack_exports__);
  13889. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return FreeCameraMouseInput; });
  13890. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13891. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13892. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13893. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13894. /**
  13895. * Manage the mouse inputs to control the movement of a free camera.
  13896. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13897. */
  13898. var FreeCameraMouseInput = /** @class */ (function () {
  13899. /**
  13900. * Manage the mouse inputs to control the movement of a free camera.
  13901. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13902. * @param touchEnabled Defines if touch is enabled or not
  13903. */
  13904. function FreeCameraMouseInput(
  13905. /**
  13906. * Define if touch is enabled in the mouse input
  13907. */
  13908. touchEnabled) {
  13909. if (touchEnabled === void 0) { touchEnabled = true; }
  13910. this.touchEnabled = touchEnabled;
  13911. /**
  13912. * Defines the buttons associated with the input to handle camera move.
  13913. */
  13914. this.buttons = [0, 1, 2];
  13915. /**
  13916. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  13917. */
  13918. this.angularSensibility = 2000.0;
  13919. this.previousPosition = null;
  13920. }
  13921. /**
  13922. * Attach the input controls to a specific dom element to get the input from.
  13923. * @param element Defines the element the controls should be listened from
  13924. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13925. */
  13926. FreeCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  13927. var _this = this;
  13928. var engine = this.camera.getEngine();
  13929. if (!this._pointerInput) {
  13930. this._pointerInput = function (p) {
  13931. var evt = p.event;
  13932. if (engine.isInVRExclusivePointerMode) {
  13933. return;
  13934. }
  13935. if (!_this.touchEnabled && evt.pointerType === "touch") {
  13936. return;
  13937. }
  13938. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  13939. return;
  13940. }
  13941. var srcElement = (evt.srcElement || evt.target);
  13942. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  13943. try {
  13944. srcElement.setPointerCapture(evt.pointerId);
  13945. }
  13946. catch (e) {
  13947. //Nothing to do with the error. Execution will continue.
  13948. }
  13949. _this.previousPosition = {
  13950. x: evt.clientX,
  13951. y: evt.clientY
  13952. };
  13953. if (!noPreventDefault) {
  13954. evt.preventDefault();
  13955. element.focus();
  13956. }
  13957. }
  13958. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  13959. try {
  13960. srcElement.releasePointerCapture(evt.pointerId);
  13961. }
  13962. catch (e) {
  13963. //Nothing to do with the error.
  13964. }
  13965. _this.previousPosition = null;
  13966. if (!noPreventDefault) {
  13967. evt.preventDefault();
  13968. }
  13969. }
  13970. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  13971. if (!_this.previousPosition || engine.isPointerLock) {
  13972. return;
  13973. }
  13974. var offsetX = evt.clientX - _this.previousPosition.x;
  13975. if (_this.camera.getScene().useRightHandedSystem) {
  13976. offsetX *= -1;
  13977. }
  13978. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  13979. offsetX *= -1;
  13980. }
  13981. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  13982. var offsetY = evt.clientY - _this.previousPosition.y;
  13983. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  13984. _this.previousPosition = {
  13985. x: evt.clientX,
  13986. y: evt.clientY
  13987. };
  13988. if (!noPreventDefault) {
  13989. evt.preventDefault();
  13990. }
  13991. }
  13992. };
  13993. }
  13994. this._onMouseMove = function (evt) {
  13995. if (!engine.isPointerLock) {
  13996. return;
  13997. }
  13998. if (engine.isInVRExclusivePointerMode) {
  13999. return;
  14000. }
  14001. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  14002. if (_this.camera.getScene().useRightHandedSystem) {
  14003. offsetX *= -1;
  14004. }
  14005. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14006. offsetX *= -1;
  14007. }
  14008. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14009. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  14010. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14011. _this.previousPosition = null;
  14012. if (!noPreventDefault) {
  14013. evt.preventDefault();
  14014. }
  14015. };
  14016. 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);
  14017. element.addEventListener("mousemove", this._onMouseMove, false);
  14018. };
  14019. /**
  14020. * Detach the current controls from the specified dom element.
  14021. * @param element Defines the element to stop listening the inputs from
  14022. */
  14023. FreeCameraMouseInput.prototype.detachControl = function (element) {
  14024. if (this._observer && element) {
  14025. this.camera.getScene().onPointerObservable.remove(this._observer);
  14026. if (this._onMouseMove) {
  14027. element.removeEventListener("mousemove", this._onMouseMove);
  14028. }
  14029. this._observer = null;
  14030. this._onMouseMove = null;
  14031. this.previousPosition = null;
  14032. }
  14033. };
  14034. /**
  14035. * Gets the class name of the current intput.
  14036. * @returns the class name
  14037. */
  14038. FreeCameraMouseInput.prototype.getClassName = function () {
  14039. return "FreeCameraMouseInput";
  14040. };
  14041. /**
  14042. * Get the friendly name associated with the input class.
  14043. * @returns the input friendly name
  14044. */
  14045. FreeCameraMouseInput.prototype.getSimpleName = function () {
  14046. return "mouse";
  14047. };
  14048. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14049. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14050. ], FreeCameraMouseInput.prototype, "buttons", void 0);
  14051. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14052. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14053. ], FreeCameraMouseInput.prototype, "angularSensibility", void 0);
  14054. return FreeCameraMouseInput;
  14055. }());
  14056. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraMouseInput"] = FreeCameraMouseInput;
  14057. /***/ }),
  14058. /***/ "./Cameras/Inputs/freeCameraTouchInput.ts":
  14059. /*!************************************************!*\
  14060. !*** ./Cameras/Inputs/freeCameraTouchInput.ts ***!
  14061. \************************************************/
  14062. /*! exports provided: FreeCameraTouchInput */
  14063. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14064. "use strict";
  14065. __webpack_require__.r(__webpack_exports__);
  14066. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return FreeCameraTouchInput; });
  14067. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14068. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14069. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14070. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14071. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14072. /**
  14073. * Manage the touch inputs to control the movement of a free camera.
  14074. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14075. */
  14076. var FreeCameraTouchInput = /** @class */ (function () {
  14077. function FreeCameraTouchInput() {
  14078. /**
  14079. * Defines the touch sensibility for rotation.
  14080. * The higher the faster.
  14081. */
  14082. this.touchAngularSensibility = 200000.0;
  14083. /**
  14084. * Defines the touch sensibility for move.
  14085. * The higher the faster.
  14086. */
  14087. this.touchMoveSensibility = 250.0;
  14088. this._offsetX = null;
  14089. this._offsetY = null;
  14090. this._pointerPressed = new Array();
  14091. }
  14092. /**
  14093. * Attach the input controls to a specific dom element to get the input from.
  14094. * @param element Defines the element the controls should be listened from
  14095. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14096. */
  14097. FreeCameraTouchInput.prototype.attachControl = function (element, noPreventDefault) {
  14098. var _this = this;
  14099. var previousPosition = null;
  14100. if (this._pointerInput === undefined) {
  14101. this._onLostFocus = function () {
  14102. _this._offsetX = null;
  14103. _this._offsetY = null;
  14104. };
  14105. this._pointerInput = function (p) {
  14106. var evt = p.event;
  14107. if (evt.pointerType === "mouse") {
  14108. return;
  14109. }
  14110. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN) {
  14111. if (!noPreventDefault) {
  14112. evt.preventDefault();
  14113. }
  14114. _this._pointerPressed.push(evt.pointerId);
  14115. if (_this._pointerPressed.length !== 1) {
  14116. return;
  14117. }
  14118. previousPosition = {
  14119. x: evt.clientX,
  14120. y: evt.clientY
  14121. };
  14122. }
  14123. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP) {
  14124. if (!noPreventDefault) {
  14125. evt.preventDefault();
  14126. }
  14127. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14128. if (index === -1) {
  14129. return;
  14130. }
  14131. _this._pointerPressed.splice(index, 1);
  14132. if (index != 0) {
  14133. return;
  14134. }
  14135. previousPosition = null;
  14136. _this._offsetX = null;
  14137. _this._offsetY = null;
  14138. }
  14139. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  14140. if (!noPreventDefault) {
  14141. evt.preventDefault();
  14142. }
  14143. if (!previousPosition) {
  14144. return;
  14145. }
  14146. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14147. if (index != 0) {
  14148. return;
  14149. }
  14150. _this._offsetX = evt.clientX - previousPosition.x;
  14151. _this._offsetY = -(evt.clientY - previousPosition.y);
  14152. }
  14153. };
  14154. }
  14155. 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);
  14156. if (this._onLostFocus) {
  14157. element.addEventListener("blur", this._onLostFocus);
  14158. }
  14159. };
  14160. /**
  14161. * Detach the current controls from the specified dom element.
  14162. * @param element Defines the element to stop listening the inputs from
  14163. */
  14164. FreeCameraTouchInput.prototype.detachControl = function (element) {
  14165. if (this._pointerInput && element) {
  14166. if (this._observer) {
  14167. this.camera.getScene().onPointerObservable.remove(this._observer);
  14168. this._observer = null;
  14169. }
  14170. if (this._onLostFocus) {
  14171. element.removeEventListener("blur", this._onLostFocus);
  14172. this._onLostFocus = null;
  14173. }
  14174. this._pointerPressed = [];
  14175. this._offsetX = null;
  14176. this._offsetY = null;
  14177. }
  14178. };
  14179. /**
  14180. * Update the current camera state depending on the inputs that have been used this frame.
  14181. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14182. */
  14183. FreeCameraTouchInput.prototype.checkInputs = function () {
  14184. if (this._offsetX && this._offsetY) {
  14185. var camera = this.camera;
  14186. camera.cameraRotation.y += this._offsetX / this.touchAngularSensibility;
  14187. if (this._pointerPressed.length > 1) {
  14188. camera.cameraRotation.x += -this._offsetY / this.touchAngularSensibility;
  14189. }
  14190. else {
  14191. var speed = camera._computeLocalCameraSpeed();
  14192. var direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, speed * this._offsetY / this.touchMoveSensibility);
  14193. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
  14194. camera.cameraDirection.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(direction, camera._cameraRotationMatrix));
  14195. }
  14196. }
  14197. };
  14198. /**
  14199. * Gets the class name of the current intput.
  14200. * @returns the class name
  14201. */
  14202. FreeCameraTouchInput.prototype.getClassName = function () {
  14203. return "FreeCameraTouchInput";
  14204. };
  14205. /**
  14206. * Get the friendly name associated with the input class.
  14207. * @returns the input friendly name
  14208. */
  14209. FreeCameraTouchInput.prototype.getSimpleName = function () {
  14210. return "touch";
  14211. };
  14212. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14213. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14214. ], FreeCameraTouchInput.prototype, "touchAngularSensibility", void 0);
  14215. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14216. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14217. ], FreeCameraTouchInput.prototype, "touchMoveSensibility", void 0);
  14218. return FreeCameraTouchInput;
  14219. }());
  14220. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraTouchInput"] = FreeCameraTouchInput;
  14221. /***/ }),
  14222. /***/ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts":
  14223. /*!**********************************************************!*\
  14224. !*** ./Cameras/Inputs/freeCameraVirtualJoystickInput.ts ***!
  14225. \**********************************************************/
  14226. /*! exports provided: FreeCameraVirtualJoystickInput */
  14227. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14228. "use strict";
  14229. __webpack_require__.r(__webpack_exports__);
  14230. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return FreeCameraVirtualJoystickInput; });
  14231. /* harmony import */ var _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/virtualJoystick */ "./Misc/virtualJoystick.ts");
  14232. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14233. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14234. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  14235. /**
  14236. * Add virtual joystick input support to the input manager.
  14237. * @returns the current input manager
  14238. */
  14239. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addVirtualJoystick = function () {
  14240. this.add(new FreeCameraVirtualJoystickInput());
  14241. return this;
  14242. };
  14243. /**
  14244. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  14245. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14246. */
  14247. var FreeCameraVirtualJoystickInput = /** @class */ (function () {
  14248. function FreeCameraVirtualJoystickInput() {
  14249. }
  14250. /**
  14251. * Gets the left stick of the virtual joystick.
  14252. * @returns The virtual Joystick
  14253. */
  14254. FreeCameraVirtualJoystickInput.prototype.getLeftJoystick = function () {
  14255. return this._leftjoystick;
  14256. };
  14257. /**
  14258. * Gets the right stick of the virtual joystick.
  14259. * @returns The virtual Joystick
  14260. */
  14261. FreeCameraVirtualJoystickInput.prototype.getRightJoystick = function () {
  14262. return this._rightjoystick;
  14263. };
  14264. /**
  14265. * Update the current camera state depending on the inputs that have been used this frame.
  14266. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14267. */
  14268. FreeCameraVirtualJoystickInput.prototype.checkInputs = function () {
  14269. if (this._leftjoystick) {
  14270. var camera = this.camera;
  14271. var speed = camera._computeLocalCameraSpeed() * 50;
  14272. var cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0);
  14273. 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);
  14274. camera.cameraDirection = camera.cameraDirection.add(deltaTransform);
  14275. camera.cameraRotation = camera.cameraRotation.addVector3(this._rightjoystick.deltaPosition);
  14276. if (!this._leftjoystick.pressed) {
  14277. this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9);
  14278. }
  14279. if (!this._rightjoystick.pressed) {
  14280. this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(0.9);
  14281. }
  14282. }
  14283. };
  14284. /**
  14285. * Attach the input controls to a specific dom element to get the input from.
  14286. * @param element Defines the element the controls should be listened from
  14287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14288. */
  14289. FreeCameraVirtualJoystickInput.prototype.attachControl = function (element, noPreventDefault) {
  14290. this._leftjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](true);
  14291. this._leftjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Z);
  14292. this._leftjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  14293. this._leftjoystick.setJoystickSensibility(0.15);
  14294. this._rightjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](false);
  14295. this._rightjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  14296. this._rightjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Y);
  14297. this._rightjoystick.reverseUpDown = true;
  14298. this._rightjoystick.setJoystickSensibility(0.05);
  14299. this._rightjoystick.setJoystickColor("yellow");
  14300. };
  14301. /**
  14302. * Detach the current controls from the specified dom element.
  14303. * @param element Defines the element to stop listening the inputs from
  14304. */
  14305. FreeCameraVirtualJoystickInput.prototype.detachControl = function (element) {
  14306. this._leftjoystick.releaseCanvas();
  14307. this._rightjoystick.releaseCanvas();
  14308. };
  14309. /**
  14310. * Gets the class name of the current intput.
  14311. * @returns the class name
  14312. */
  14313. FreeCameraVirtualJoystickInput.prototype.getClassName = function () {
  14314. return "FreeCameraVirtualJoystickInput";
  14315. };
  14316. /**
  14317. * Get the friendly name associated with the input class.
  14318. * @returns the input friendly name
  14319. */
  14320. FreeCameraVirtualJoystickInput.prototype.getSimpleName = function () {
  14321. return "virtualJoystick";
  14322. };
  14323. return FreeCameraVirtualJoystickInput;
  14324. }());
  14325. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FreeCameraVirtualJoystickInput"] = FreeCameraVirtualJoystickInput;
  14326. /***/ }),
  14327. /***/ "./Cameras/Inputs/index.ts":
  14328. /*!*********************************!*\
  14329. !*** ./Cameras/Inputs/index.ts ***!
  14330. \*********************************/
  14331. /*! exports provided: ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput */
  14332. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14333. "use strict";
  14334. __webpack_require__.r(__webpack_exports__);
  14335. /* harmony import */ var _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  14336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  14337. /* harmony import */ var _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  14338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraKeyboardMoveInput"]; });
  14339. /* harmony import */ var _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  14340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraMouseWheelInput"]; });
  14341. /* harmony import */ var _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  14342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraPointersInput"]; });
  14343. /* harmony import */ var _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  14344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__["ArcRotateCameraVRDeviceOrientationInput"]; });
  14345. /* harmony import */ var _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  14346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__["FlyCameraKeyboardInput"]; });
  14347. /* harmony import */ var _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  14348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__["FlyCameraMouseInput"]; });
  14349. /* harmony import */ var _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  14350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  14351. /* harmony import */ var _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  14352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_8__["FreeCameraGamepadInput"]; });
  14353. /* harmony import */ var _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  14354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_9__["FreeCameraKeyboardMoveInput"]; });
  14355. /* harmony import */ var _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  14356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_10__["FreeCameraMouseInput"]; });
  14357. /* harmony import */ var _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  14358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_11__["FreeCameraTouchInput"]; });
  14359. /* harmony import */ var _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  14360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_12__["FreeCameraVirtualJoystickInput"]; });
  14361. /***/ }),
  14362. /***/ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts":
  14363. /*!*********************************************************!*\
  14364. !*** ./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts ***!
  14365. \*********************************************************/
  14366. /*! no exports provided */
  14367. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14368. "use strict";
  14369. __webpack_require__.r(__webpack_exports__);
  14370. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14371. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  14372. /* harmony import */ var _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  14373. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicAnaglyphRigMode = function (camera) {
  14374. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  14375. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__["AnaglyphPostProcess"](camera.name + "_anaglyph", 1.0, camera._rigCameras);
  14376. };
  14377. /***/ }),
  14378. /***/ "./Cameras/RigModes/stereoscopicRigMode.ts":
  14379. /*!*************************************************!*\
  14380. !*** ./Cameras/RigModes/stereoscopicRigMode.ts ***!
  14381. \*************************************************/
  14382. /*! no exports provided */
  14383. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14384. "use strict";
  14385. __webpack_require__.r(__webpack_exports__);
  14386. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14387. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  14388. /* harmony import */ var _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  14389. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicRigMode = function (camera) {
  14390. var isStereoscopicHoriz = camera.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL || camera.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  14391. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  14392. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__["StereoscopicInterlacePostProcess"](camera.name + "_stereoInterlace", camera._rigCameras, isStereoscopicHoriz);
  14393. };
  14394. /***/ }),
  14395. /***/ "./Cameras/RigModes/vrRigMode.ts":
  14396. /*!***************************************!*\
  14397. !*** ./Cameras/RigModes/vrRigMode.ts ***!
  14398. \***************************************/
  14399. /*! no exports provided */
  14400. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14401. "use strict";
  14402. __webpack_require__.r(__webpack_exports__);
  14403. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14404. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14405. /* harmony import */ var _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  14406. /* harmony import */ var _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  14407. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setVRRigMode = function (camera, rigParams) {
  14408. var metrics = rigParams.vrCameraMetrics || _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault();
  14409. camera._rigCameras[0]._cameraRigParams.vrMetrics = metrics;
  14410. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  14411. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14412. camera._rigCameras[0]._cameraRigParams.vrHMatrix = metrics.leftHMatrix;
  14413. camera._rigCameras[0]._cameraRigParams.vrPreViewMatrix = metrics.leftPreViewMatrix;
  14414. camera._rigCameras[0].getProjectionMatrix = camera._rigCameras[0]._getVRProjectionMatrix;
  14415. camera._rigCameras[1]._cameraRigParams.vrMetrics = metrics;
  14416. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  14417. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14418. camera._rigCameras[1]._cameraRigParams.vrHMatrix = metrics.rightHMatrix;
  14419. camera._rigCameras[1]._cameraRigParams.vrPreViewMatrix = metrics.rightPreViewMatrix;
  14420. camera._rigCameras[1].getProjectionMatrix = camera._rigCameras[1]._getVRProjectionMatrix;
  14421. if (metrics.compensateDistortion) {
  14422. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Left", camera._rigCameras[0], false, metrics);
  14423. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Right", camera._rigCameras[1], true, metrics);
  14424. }
  14425. };
  14426. /***/ }),
  14427. /***/ "./Cameras/RigModes/webVRRigMode.ts":
  14428. /*!******************************************!*\
  14429. !*** ./Cameras/RigModes/webVRRigMode.ts ***!
  14430. \******************************************/
  14431. /*! no exports provided */
  14432. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14433. "use strict";
  14434. __webpack_require__.r(__webpack_exports__);
  14435. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14436. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14437. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setWebVRRigMode = function (camera, rigParams) {
  14438. if (rigParams.vrDisplay) {
  14439. var leftEye = rigParams.vrDisplay.getEyeParameters('left');
  14440. var rightEye = rigParams.vrDisplay.getEyeParameters('right');
  14441. //Left eye
  14442. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  14443. camera._rigCameras[0].setCameraRigParameter("left", true);
  14444. //leaving this for future reference
  14445. camera._rigCameras[0].setCameraRigParameter("specs", rigParams.specs);
  14446. camera._rigCameras[0].setCameraRigParameter("eyeParameters", leftEye);
  14447. camera._rigCameras[0].setCameraRigParameter("frameData", rigParams.frameData);
  14448. camera._rigCameras[0].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  14449. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14450. camera._rigCameras[0].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  14451. camera._rigCameras[0].parent = camera;
  14452. camera._rigCameras[0]._getViewMatrix = camera._getWebVRViewMatrix;
  14453. //Right eye
  14454. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  14455. camera._rigCameras[1].setCameraRigParameter('eyeParameters', rightEye);
  14456. camera._rigCameras[1].setCameraRigParameter("specs", rigParams.specs);
  14457. camera._rigCameras[1].setCameraRigParameter("frameData", rigParams.frameData);
  14458. camera._rigCameras[1].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  14459. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14460. camera._rigCameras[1].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  14461. camera._rigCameras[1].parent = camera;
  14462. camera._rigCameras[1]._getViewMatrix = camera._getWebVRViewMatrix;
  14463. if (_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].UseAlternateWebVRRendering) {
  14464. camera._rigCameras[1]._skipRendering = true;
  14465. camera._rigCameras[0]._alternateCamera = camera._rigCameras[1];
  14466. }
  14467. }
  14468. };
  14469. /***/ }),
  14470. /***/ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts":
  14471. /*!*********************************************************!*\
  14472. !*** ./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts ***!
  14473. \*********************************************************/
  14474. /*! exports provided: AnaglyphArcRotateCamera */
  14475. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14476. "use strict";
  14477. __webpack_require__.r(__webpack_exports__);
  14478. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return AnaglyphArcRotateCamera; });
  14479. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14480. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14481. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  14482. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14483. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14484. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14485. // Side effect import to define the stereoscopic mode.
  14486. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphArcRotateCamera", function (name, scene, options) {
  14487. return function () { return new AnaglyphArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14488. });
  14489. /**
  14490. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  14491. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14492. */
  14493. var AnaglyphArcRotateCamera = /** @class */ (function (_super) {
  14494. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphArcRotateCamera, _super);
  14495. /**
  14496. * Creates a new AnaglyphArcRotateCamera
  14497. * @param name defines camera name
  14498. * @param alpha defines alpha angle (in radians)
  14499. * @param beta defines beta angle (in radians)
  14500. * @param radius defines radius
  14501. * @param target defines camera target
  14502. * @param interaxialDistance defines distance between each color axis
  14503. * @param scene defines the hosting scene
  14504. */
  14505. function AnaglyphArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, scene) {
  14506. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  14507. _this.interaxialDistance = interaxialDistance;
  14508. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14509. return _this;
  14510. }
  14511. /**
  14512. * Gets camera class name
  14513. * @returns AnaglyphArcRotateCamera
  14514. */
  14515. AnaglyphArcRotateCamera.prototype.getClassName = function () {
  14516. return "AnaglyphArcRotateCamera";
  14517. };
  14518. return AnaglyphArcRotateCamera;
  14519. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  14520. /***/ }),
  14521. /***/ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts":
  14522. /*!****************************************************!*\
  14523. !*** ./Cameras/Stereoscopic/anaglyphFreeCamera.ts ***!
  14524. \****************************************************/
  14525. /*! exports provided: AnaglyphFreeCamera */
  14526. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14527. "use strict";
  14528. __webpack_require__.r(__webpack_exports__);
  14529. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return AnaglyphFreeCamera; });
  14530. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14531. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14532. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  14533. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14534. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14535. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14536. // Side effect import to define the stereoscopic mode.
  14537. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphFreeCamera", function (name, scene, options) {
  14538. return function () { return new AnaglyphFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14539. });
  14540. /**
  14541. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  14542. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14543. */
  14544. var AnaglyphFreeCamera = /** @class */ (function (_super) {
  14545. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphFreeCamera, _super);
  14546. /**
  14547. * Creates a new AnaglyphFreeCamera
  14548. * @param name defines camera name
  14549. * @param position defines initial position
  14550. * @param interaxialDistance defines distance between each color axis
  14551. * @param scene defines the hosting scene
  14552. */
  14553. function AnaglyphFreeCamera(name, position, interaxialDistance, scene) {
  14554. var _this = _super.call(this, name, position, scene) || this;
  14555. _this.interaxialDistance = interaxialDistance;
  14556. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14557. return _this;
  14558. }
  14559. /**
  14560. * Gets camera class name
  14561. * @returns AnaglyphFreeCamera
  14562. */
  14563. AnaglyphFreeCamera.prototype.getClassName = function () {
  14564. return "AnaglyphFreeCamera";
  14565. };
  14566. return AnaglyphFreeCamera;
  14567. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  14568. /***/ }),
  14569. /***/ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts":
  14570. /*!*******************************************************!*\
  14571. !*** ./Cameras/Stereoscopic/anaglyphGamepadCamera.ts ***!
  14572. \*******************************************************/
  14573. /*! exports provided: AnaglyphGamepadCamera */
  14574. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14575. "use strict";
  14576. __webpack_require__.r(__webpack_exports__);
  14577. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return AnaglyphGamepadCamera; });
  14578. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14579. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14580. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  14581. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14582. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14583. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14584. // Side effect import to define the stereoscopic mode.
  14585. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphGamepadCamera", function (name, scene, options) {
  14586. return function () { return new AnaglyphGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14587. });
  14588. /**
  14589. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  14590. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14591. */
  14592. var AnaglyphGamepadCamera = /** @class */ (function (_super) {
  14593. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphGamepadCamera, _super);
  14594. /**
  14595. * Creates a new AnaglyphGamepadCamera
  14596. * @param name defines camera name
  14597. * @param position defines initial position
  14598. * @param interaxialDistance defines distance between each color axis
  14599. * @param scene defines the hosting scene
  14600. */
  14601. function AnaglyphGamepadCamera(name, position, interaxialDistance, scene) {
  14602. var _this = _super.call(this, name, position, scene) || this;
  14603. _this.interaxialDistance = interaxialDistance;
  14604. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14605. return _this;
  14606. }
  14607. /**
  14608. * Gets camera class name
  14609. * @returns AnaglyphGamepadCamera
  14610. */
  14611. AnaglyphGamepadCamera.prototype.getClassName = function () {
  14612. return "AnaglyphGamepadCamera";
  14613. };
  14614. return AnaglyphGamepadCamera;
  14615. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  14616. /***/ }),
  14617. /***/ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts":
  14618. /*!*********************************************************!*\
  14619. !*** ./Cameras/Stereoscopic/anaglyphUniversalCamera.ts ***!
  14620. \*********************************************************/
  14621. /*! exports provided: AnaglyphUniversalCamera */
  14622. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14623. "use strict";
  14624. __webpack_require__.r(__webpack_exports__);
  14625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return AnaglyphUniversalCamera; });
  14626. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14627. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14628. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  14629. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14630. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14631. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14632. // Side effect import to define the stereoscopic mode.
  14633. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphUniversalCamera", function (name, scene, options) {
  14634. return function () { return new AnaglyphUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14635. });
  14636. /**
  14637. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  14638. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14639. */
  14640. var AnaglyphUniversalCamera = /** @class */ (function (_super) {
  14641. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphUniversalCamera, _super);
  14642. /**
  14643. * Creates a new AnaglyphUniversalCamera
  14644. * @param name defines camera name
  14645. * @param position defines initial position
  14646. * @param interaxialDistance defines distance between each color axis
  14647. * @param scene defines the hosting scene
  14648. */
  14649. function AnaglyphUniversalCamera(name, position, interaxialDistance, scene) {
  14650. var _this = _super.call(this, name, position, scene) || this;
  14651. _this.interaxialDistance = interaxialDistance;
  14652. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14653. return _this;
  14654. }
  14655. /**
  14656. * Gets camera class name
  14657. * @returns AnaglyphUniversalCamera
  14658. */
  14659. AnaglyphUniversalCamera.prototype.getClassName = function () {
  14660. return "AnaglyphUniversalCamera";
  14661. };
  14662. return AnaglyphUniversalCamera;
  14663. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  14664. /***/ }),
  14665. /***/ "./Cameras/Stereoscopic/index.ts":
  14666. /*!***************************************!*\
  14667. !*** ./Cameras/Stereoscopic/index.ts ***!
  14668. \***************************************/
  14669. /*! exports provided: AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera */
  14670. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14671. "use strict";
  14672. __webpack_require__.r(__webpack_exports__);
  14673. /* harmony import */ var _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphArcRotateCamera */ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts");
  14674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  14675. /* harmony import */ var _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./anaglyphFreeCamera */ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts");
  14676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__["AnaglyphFreeCamera"]; });
  14677. /* harmony import */ var _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./anaglyphGamepadCamera */ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts");
  14678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__["AnaglyphGamepadCamera"]; });
  14679. /* harmony import */ var _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./anaglyphUniversalCamera */ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts");
  14680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__["AnaglyphUniversalCamera"]; });
  14681. /* harmony import */ var _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./stereoscopicArcRotateCamera */ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts");
  14682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__["StereoscopicArcRotateCamera"]; });
  14683. /* harmony import */ var _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stereoscopicFreeCamera */ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts");
  14684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__["StereoscopicFreeCamera"]; });
  14685. /* harmony import */ var _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./stereoscopicGamepadCamera */ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts");
  14686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__["StereoscopicGamepadCamera"]; });
  14687. /* harmony import */ var _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stereoscopicUniversalCamera */ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts");
  14688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  14689. /***/ }),
  14690. /***/ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts":
  14691. /*!*************************************************************!*\
  14692. !*** ./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts ***!
  14693. \*************************************************************/
  14694. /*! exports provided: StereoscopicArcRotateCamera */
  14695. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14696. "use strict";
  14697. __webpack_require__.r(__webpack_exports__);
  14698. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return StereoscopicArcRotateCamera; });
  14699. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14700. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14701. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  14702. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14703. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14704. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  14705. // Side effect import to define the stereoscopic mode.
  14706. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicArcRotateCamera", function (name, scene, options) {
  14707. return function () { return new StereoscopicArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  14708. });
  14709. /**
  14710. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  14711. * @see http://doc.babylonjs.com/features/cameras
  14712. */
  14713. var StereoscopicArcRotateCamera = /** @class */ (function (_super) {
  14714. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicArcRotateCamera, _super);
  14715. /**
  14716. * Creates a new StereoscopicArcRotateCamera
  14717. * @param name defines camera name
  14718. * @param alpha defines alpha angle (in radians)
  14719. * @param beta defines beta angle (in radians)
  14720. * @param radius defines radius
  14721. * @param target defines camera target
  14722. * @param interaxialDistance defines distance between each color axis
  14723. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  14724. * @param scene defines the hosting scene
  14725. */
  14726. function StereoscopicArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, isStereoscopicSideBySide, scene) {
  14727. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  14728. _this.interaxialDistance = interaxialDistance;
  14729. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  14730. _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 });
  14731. return _this;
  14732. }
  14733. /**
  14734. * Gets camera class name
  14735. * @returns StereoscopicArcRotateCamera
  14736. */
  14737. StereoscopicArcRotateCamera.prototype.getClassName = function () {
  14738. return "StereoscopicArcRotateCamera";
  14739. };
  14740. return StereoscopicArcRotateCamera;
  14741. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  14742. /***/ }),
  14743. /***/ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts":
  14744. /*!********************************************************!*\
  14745. !*** ./Cameras/Stereoscopic/stereoscopicFreeCamera.ts ***!
  14746. \********************************************************/
  14747. /*! exports provided: StereoscopicFreeCamera */
  14748. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14749. "use strict";
  14750. __webpack_require__.r(__webpack_exports__);
  14751. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return StereoscopicFreeCamera; });
  14752. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14753. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14754. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  14755. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14756. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14757. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  14758. // Side effect import to define the stereoscopic mode.
  14759. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  14760. return function () { return new StereoscopicFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  14761. });
  14762. /**
  14763. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  14764. * @see http://doc.babylonjs.com/features/cameras
  14765. */
  14766. var StereoscopicFreeCamera = /** @class */ (function (_super) {
  14767. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicFreeCamera, _super);
  14768. /**
  14769. * Creates a new StereoscopicFreeCamera
  14770. * @param name defines camera name
  14771. * @param position defines initial position
  14772. * @param interaxialDistance defines distance between each color axis
  14773. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  14774. * @param scene defines the hosting scene
  14775. */
  14776. function StereoscopicFreeCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  14777. var _this = _super.call(this, name, position, scene) || this;
  14778. _this.interaxialDistance = interaxialDistance;
  14779. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  14780. _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 });
  14781. return _this;
  14782. }
  14783. /**
  14784. * Gets camera class name
  14785. * @returns StereoscopicFreeCamera
  14786. */
  14787. StereoscopicFreeCamera.prototype.getClassName = function () {
  14788. return "StereoscopicFreeCamera";
  14789. };
  14790. return StereoscopicFreeCamera;
  14791. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  14792. /***/ }),
  14793. /***/ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts":
  14794. /*!***********************************************************!*\
  14795. !*** ./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts ***!
  14796. \***********************************************************/
  14797. /*! exports provided: StereoscopicGamepadCamera */
  14798. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14799. "use strict";
  14800. __webpack_require__.r(__webpack_exports__);
  14801. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return StereoscopicGamepadCamera; });
  14802. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14803. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14804. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  14805. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14806. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14807. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  14808. // Side effect import to define the stereoscopic mode.
  14809. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicGamepadCamera", function (name, scene, options) {
  14810. return function () { return new StereoscopicGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  14811. });
  14812. /**
  14813. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  14814. * @see http://doc.babylonjs.com/features/cameras
  14815. */
  14816. var StereoscopicGamepadCamera = /** @class */ (function (_super) {
  14817. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicGamepadCamera, _super);
  14818. /**
  14819. * Creates a new StereoscopicGamepadCamera
  14820. * @param name defines camera name
  14821. * @param position defines initial position
  14822. * @param interaxialDistance defines distance between each color axis
  14823. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  14824. * @param scene defines the hosting scene
  14825. */
  14826. function StereoscopicGamepadCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  14827. var _this = _super.call(this, name, position, scene) || this;
  14828. _this.interaxialDistance = interaxialDistance;
  14829. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  14830. _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 });
  14831. return _this;
  14832. }
  14833. /**
  14834. * Gets camera class name
  14835. * @returns StereoscopicGamepadCamera
  14836. */
  14837. StereoscopicGamepadCamera.prototype.getClassName = function () {
  14838. return "StereoscopicGamepadCamera";
  14839. };
  14840. return StereoscopicGamepadCamera;
  14841. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  14842. /***/ }),
  14843. /***/ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts":
  14844. /*!*************************************************************!*\
  14845. !*** ./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts ***!
  14846. \*************************************************************/
  14847. /*! exports provided: StereoscopicUniversalCamera */
  14848. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14849. "use strict";
  14850. __webpack_require__.r(__webpack_exports__);
  14851. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return StereoscopicUniversalCamera; });
  14852. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14853. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14854. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  14855. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14856. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14857. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  14858. // Side effect import to define the stereoscopic mode.
  14859. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  14860. return function () { return new StereoscopicUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  14861. });
  14862. /**
  14863. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  14864. * @see http://doc.babylonjs.com/features/cameras
  14865. */
  14866. var StereoscopicUniversalCamera = /** @class */ (function (_super) {
  14867. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicUniversalCamera, _super);
  14868. /**
  14869. * Creates a new StereoscopicUniversalCamera
  14870. * @param name defines camera name
  14871. * @param position defines initial position
  14872. * @param interaxialDistance defines distance between each color axis
  14873. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  14874. * @param scene defines the hosting scene
  14875. */
  14876. function StereoscopicUniversalCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  14877. var _this = _super.call(this, name, position, scene) || this;
  14878. _this.interaxialDistance = interaxialDistance;
  14879. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  14880. _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 });
  14881. return _this;
  14882. }
  14883. /**
  14884. * Gets camera class name
  14885. * @returns StereoscopicUniversalCamera
  14886. */
  14887. StereoscopicUniversalCamera.prototype.getClassName = function () {
  14888. return "StereoscopicUniversalCamera";
  14889. };
  14890. return StereoscopicUniversalCamera;
  14891. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  14892. /***/ }),
  14893. /***/ "./Cameras/VR/index.ts":
  14894. /*!*****************************!*\
  14895. !*** ./Cameras/VR/index.ts ***!
  14896. \*****************************/
  14897. /*! exports provided: VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera */
  14898. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14899. "use strict";
  14900. __webpack_require__.r(__webpack_exports__);
  14901. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  14902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  14903. /* harmony import */ var _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationArcRotateCamera */ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts");
  14904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationArcRotateCamera"]; });
  14905. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  14906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__["VRDeviceOrientationFreeCamera"]; });
  14907. /* harmony import */ var _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrDeviceOrientationGamepadCamera */ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts");
  14908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__["VRDeviceOrientationGamepadCamera"]; });
  14909. /* harmony import */ var _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  14910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["VRExperienceHelper"]; });
  14911. /* harmony import */ var _webVRCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  14912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _webVRCamera__WEBPACK_IMPORTED_MODULE_5__["WebVRFreeCamera"]; });
  14913. /***/ }),
  14914. /***/ "./Cameras/VR/vrCameraMetrics.ts":
  14915. /*!***************************************!*\
  14916. !*** ./Cameras/VR/vrCameraMetrics.ts ***!
  14917. \***************************************/
  14918. /*! exports provided: VRCameraMetrics */
  14919. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14920. "use strict";
  14921. __webpack_require__.r(__webpack_exports__);
  14922. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return VRCameraMetrics; });
  14923. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14924. /**
  14925. * This represents all the required metrics to create a VR camera.
  14926. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  14927. */
  14928. var VRCameraMetrics = /** @class */ (function () {
  14929. function VRCameraMetrics() {
  14930. /**
  14931. * Define if the current vr camera should compensate the distortion of the lense or not.
  14932. */
  14933. this.compensateDistortion = true;
  14934. }
  14935. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatio", {
  14936. /**
  14937. * Gets the rendering aspect ratio based on the provided resolutions.
  14938. */
  14939. get: function () {
  14940. return this.hResolution / (2 * this.vResolution);
  14941. },
  14942. enumerable: true,
  14943. configurable: true
  14944. });
  14945. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatioFov", {
  14946. /**
  14947. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  14948. */
  14949. get: function () {
  14950. return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));
  14951. },
  14952. enumerable: true,
  14953. configurable: true
  14954. });
  14955. Object.defineProperty(VRCameraMetrics.prototype, "leftHMatrix", {
  14956. /**
  14957. * @hidden
  14958. */
  14959. get: function () {
  14960. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  14961. var h = (4 * meters) / this.hScreenSize;
  14962. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(h, 0, 0);
  14963. },
  14964. enumerable: true,
  14965. configurable: true
  14966. });
  14967. Object.defineProperty(VRCameraMetrics.prototype, "rightHMatrix", {
  14968. /**
  14969. * @hidden
  14970. */
  14971. get: function () {
  14972. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  14973. var h = (4 * meters) / this.hScreenSize;
  14974. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-h, 0, 0);
  14975. },
  14976. enumerable: true,
  14977. configurable: true
  14978. });
  14979. Object.defineProperty(VRCameraMetrics.prototype, "leftPreViewMatrix", {
  14980. /**
  14981. * @hidden
  14982. */
  14983. get: function () {
  14984. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(0.5 * this.interpupillaryDistance, 0, 0);
  14985. },
  14986. enumerable: true,
  14987. configurable: true
  14988. });
  14989. Object.defineProperty(VRCameraMetrics.prototype, "rightPreViewMatrix", {
  14990. /**
  14991. * @hidden
  14992. */
  14993. get: function () {
  14994. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-0.5 * this.interpupillaryDistance, 0, 0);
  14995. },
  14996. enumerable: true,
  14997. configurable: true
  14998. });
  14999. /**
  15000. * Get the default VRMetrics based on the most generic setup.
  15001. * @returns the default vr metrics
  15002. */
  15003. VRCameraMetrics.GetDefault = function () {
  15004. var result = new VRCameraMetrics();
  15005. result.hResolution = 1280;
  15006. result.vResolution = 800;
  15007. result.hScreenSize = 0.149759993;
  15008. result.vScreenSize = 0.0935999975;
  15009. result.vScreenCenter = 0.0467999987;
  15010. result.eyeToScreenDistance = 0.0410000011;
  15011. result.lensSeparationDistance = 0.0635000020;
  15012. result.interpupillaryDistance = 0.0640000030;
  15013. result.distortionK = [1.0, 0.219999999, 0.239999995, 0.0];
  15014. result.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0.0];
  15015. result.postProcessScaleFactor = 1.714605507808412;
  15016. result.lensCenterOffset = 0.151976421;
  15017. return result;
  15018. };
  15019. return VRCameraMetrics;
  15020. }());
  15021. /***/ }),
  15022. /***/ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts":
  15023. /*!**********************************************************!*\
  15024. !*** ./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts ***!
  15025. \**********************************************************/
  15026. /*! exports provided: VRDeviceOrientationArcRotateCamera */
  15027. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15028. "use strict";
  15029. __webpack_require__.r(__webpack_exports__);
  15030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return VRDeviceOrientationArcRotateCamera; });
  15031. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15032. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15033. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15034. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15035. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15036. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15037. /* harmony import */ var _Inputs_arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Inputs/arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15038. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15039. // Side effect import to define the stereoscopic mode.
  15040. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15041. return function () { return new VRDeviceOrientationArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15042. });
  15043. /**
  15044. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  15045. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15046. */
  15047. var VRDeviceOrientationArcRotateCamera = /** @class */ (function (_super) {
  15048. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationArcRotateCamera, _super);
  15049. /**
  15050. * Creates a new VRDeviceOrientationArcRotateCamera
  15051. * @param name defines camera name
  15052. * @param alpha defines the camera rotation along the logitudinal axis
  15053. * @param beta defines the camera rotation along the latitudinal axis
  15054. * @param radius defines the camera distance from its target
  15055. * @param target defines the camera target
  15056. * @param scene defines the scene the camera belongs to
  15057. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15058. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15059. */
  15060. function VRDeviceOrientationArcRotateCamera(name, alpha, beta, radius, target, scene, compensateDistortion, vrCameraMetrics) {
  15061. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15062. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15063. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15064. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15065. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15066. _this.inputs.addVRDeviceOrientation();
  15067. return _this;
  15068. }
  15069. /**
  15070. * Gets camera class name
  15071. * @returns VRDeviceOrientationArcRotateCamera
  15072. */
  15073. VRDeviceOrientationArcRotateCamera.prototype.getClassName = function () {
  15074. return "VRDeviceOrientationArcRotateCamera";
  15075. };
  15076. return VRDeviceOrientationArcRotateCamera;
  15077. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15078. /***/ }),
  15079. /***/ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts":
  15080. /*!*****************************************************!*\
  15081. !*** ./Cameras/VR/vrDeviceOrientationFreeCamera.ts ***!
  15082. \*****************************************************/
  15083. /*! exports provided: VRDeviceOrientationFreeCamera */
  15084. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15085. "use strict";
  15086. __webpack_require__.r(__webpack_exports__);
  15087. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return VRDeviceOrientationFreeCamera; });
  15088. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15089. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15090. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15091. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15092. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15093. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15094. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15095. // Side effect import to define the stereoscopic mode.
  15096. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15097. return function () { return new VRDeviceOrientationFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15098. });
  15099. /**
  15100. * Camera used to simulate VR rendering (based on FreeCamera)
  15101. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15102. */
  15103. var VRDeviceOrientationFreeCamera = /** @class */ (function (_super) {
  15104. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationFreeCamera, _super);
  15105. /**
  15106. * Creates a new VRDeviceOrientationFreeCamera
  15107. * @param name defines camera name
  15108. * @param position defines the start position of the camera
  15109. * @param scene defines the scene the camera belongs to
  15110. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15111. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15112. */
  15113. function VRDeviceOrientationFreeCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15114. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15115. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15116. var _this = _super.call(this, name, position, scene) || this;
  15117. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15118. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15119. return _this;
  15120. }
  15121. /**
  15122. * Gets camera class name
  15123. * @returns VRDeviceOrientationFreeCamera
  15124. */
  15125. VRDeviceOrientationFreeCamera.prototype.getClassName = function () {
  15126. return "VRDeviceOrientationFreeCamera";
  15127. };
  15128. return VRDeviceOrientationFreeCamera;
  15129. }(_Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__["DeviceOrientationCamera"]));
  15130. /***/ }),
  15131. /***/ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts":
  15132. /*!********************************************************!*\
  15133. !*** ./Cameras/VR/vrDeviceOrientationGamepadCamera.ts ***!
  15134. \********************************************************/
  15135. /*! exports provided: VRDeviceOrientationGamepadCamera */
  15136. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15137. "use strict";
  15138. __webpack_require__.r(__webpack_exports__);
  15139. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return VRDeviceOrientationGamepadCamera; });
  15140. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15141. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15142. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15143. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15144. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15145. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("VRDeviceOrientationGamepadCamera", function (name, scene) {
  15146. return function () { return new VRDeviceOrientationGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  15147. });
  15148. /**
  15149. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  15150. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15151. */
  15152. var VRDeviceOrientationGamepadCamera = /** @class */ (function (_super) {
  15153. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationGamepadCamera, _super);
  15154. /**
  15155. * Creates a new VRDeviceOrientationGamepadCamera
  15156. * @param name defines camera name
  15157. * @param position defines the start position of the camera
  15158. * @param scene defines the scene the camera belongs to
  15159. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15160. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15161. */
  15162. function VRDeviceOrientationGamepadCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15163. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15164. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__["VRCameraMetrics"].GetDefault(); }
  15165. var _this = _super.call(this, name, position, scene, compensateDistortion, vrCameraMetrics) || this;
  15166. _this.inputs.addGamepad();
  15167. return _this;
  15168. }
  15169. /**
  15170. * Gets camera class name
  15171. * @returns VRDeviceOrientationGamepadCamera
  15172. */
  15173. VRDeviceOrientationGamepadCamera.prototype.getClassName = function () {
  15174. return "VRDeviceOrientationGamepadCamera";
  15175. };
  15176. return VRDeviceOrientationGamepadCamera;
  15177. }(_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationFreeCamera"]));
  15178. /***/ }),
  15179. /***/ "./Cameras/VR/vrExperienceHelper.ts":
  15180. /*!******************************************!*\
  15181. !*** ./Cameras/VR/vrExperienceHelper.ts ***!
  15182. \******************************************/
  15183. /*! exports provided: VRExperienceHelper */
  15184. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15185. "use strict";
  15186. __webpack_require__.r(__webpack_exports__);
  15187. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return VRExperienceHelper; });
  15188. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15189. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  15190. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  15191. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15192. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  15193. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15194. /* harmony import */ var _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Cameras/VR/vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15195. /* harmony import */ var _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Cameras/VR/webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15196. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  15197. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15198. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  15199. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  15200. /* harmony import */ var _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Gamepads/Controllers/webVRController */ "./Gamepads/Controllers/webVRController.ts");
  15201. /* harmony import */ var _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Gamepads/xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  15202. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  15203. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  15204. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  15205. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  15206. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  15207. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  15208. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  15209. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  15210. var VRExperienceHelperGazer = /** @class */ (function () {
  15211. function VRExperienceHelperGazer(scene, gazeTrackerToClone) {
  15212. if (gazeTrackerToClone === void 0) { gazeTrackerToClone = null; }
  15213. this.scene = scene;
  15214. /** @hidden */
  15215. this._pointerDownOnMeshAsked = false;
  15216. /** @hidden */
  15217. this._isActionableMesh = false;
  15218. /** @hidden */
  15219. this._teleportationRequestInitiated = false;
  15220. /** @hidden */
  15221. this._teleportationBackRequestInitiated = false;
  15222. /** @hidden */
  15223. this._rotationRightAsked = false;
  15224. /** @hidden */
  15225. this._rotationLeftAsked = false;
  15226. /** @hidden */
  15227. this._dpadPressed = true;
  15228. /** @hidden */
  15229. this._activePointer = false;
  15230. this._id = VRExperienceHelperGazer._idCounter++;
  15231. // Gaze tracker
  15232. if (!gazeTrackerToClone) {
  15233. this._gazeTracker = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("gazeTracker", 0.0035, 0.0025, 20, scene, false);
  15234. this._gazeTracker.bakeCurrentTransformIntoVertices();
  15235. this._gazeTracker.isPickable = false;
  15236. this._gazeTracker.isVisible = false;
  15237. var targetMat = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("targetMat", scene);
  15238. targetMat.specularColor = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"].Black();
  15239. targetMat.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  15240. targetMat.backFaceCulling = false;
  15241. this._gazeTracker.material = targetMat;
  15242. }
  15243. else {
  15244. this._gazeTracker = gazeTrackerToClone.clone("gazeTracker");
  15245. }
  15246. }
  15247. /** @hidden */
  15248. VRExperienceHelperGazer.prototype._getForwardRay = function (length) {
  15249. 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));
  15250. };
  15251. /** @hidden */
  15252. VRExperienceHelperGazer.prototype._selectionPointerDown = function () {
  15253. this._pointerDownOnMeshAsked = true;
  15254. if (this._currentHit) {
  15255. this.scene.simulatePointerDown(this._currentHit, { pointerId: this._id });
  15256. }
  15257. };
  15258. /** @hidden */
  15259. VRExperienceHelperGazer.prototype._selectionPointerUp = function () {
  15260. if (this._currentHit) {
  15261. this.scene.simulatePointerUp(this._currentHit, { pointerId: this._id });
  15262. }
  15263. this._pointerDownOnMeshAsked = false;
  15264. };
  15265. /** @hidden */
  15266. VRExperienceHelperGazer.prototype._activatePointer = function () {
  15267. this._activePointer = true;
  15268. };
  15269. /** @hidden */
  15270. VRExperienceHelperGazer.prototype._deactivatePointer = function () {
  15271. this._activePointer = false;
  15272. };
  15273. /** @hidden */
  15274. VRExperienceHelperGazer.prototype._updatePointerDistance = function (distance) {
  15275. if (distance === void 0) { distance = 100; }
  15276. };
  15277. VRExperienceHelperGazer.prototype.dispose = function () {
  15278. this._interactionsEnabled = false;
  15279. this._teleportationEnabled = false;
  15280. if (this._gazeTracker) {
  15281. this._gazeTracker.dispose();
  15282. }
  15283. };
  15284. VRExperienceHelperGazer._idCounter = 0;
  15285. return VRExperienceHelperGazer;
  15286. }());
  15287. var VRExperienceHelperControllerGazer = /** @class */ (function (_super) {
  15288. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperControllerGazer, _super);
  15289. function VRExperienceHelperControllerGazer(webVRController, scene, gazeTrackerToClone) {
  15290. var _this = _super.call(this, scene, gazeTrackerToClone) || this;
  15291. _this.webVRController = webVRController;
  15292. // Laser pointer
  15293. _this._laserPointer = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateCylinder("laserPointer", 1, 0.004, 0.0002, 20, 1, scene, false);
  15294. var laserPointerMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("laserPointerMat", scene);
  15295. laserPointerMaterial.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  15296. laserPointerMaterial.alpha = 0.6;
  15297. _this._laserPointer.material = laserPointerMaterial;
  15298. _this._laserPointer.rotation.x = Math.PI / 2;
  15299. _this._laserPointer.position.z = -0.5;
  15300. _this._laserPointer.isVisible = false;
  15301. _this._laserPointer.isPickable = false;
  15302. if (!webVRController.mesh) {
  15303. // Create an empty mesh that is used prior to loading the high quality model
  15304. var preloadMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"]("preloadControllerMesh", scene);
  15305. var preloadPointerPose = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"](_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE, scene);
  15306. preloadPointerPose.rotation.x = -0.7;
  15307. preloadMesh.addChild(preloadPointerPose);
  15308. webVRController.attachToMesh(preloadMesh);
  15309. }
  15310. _this._setLaserPointerParent(webVRController.mesh);
  15311. _this._meshAttachedObserver = webVRController._meshAttachedObservable.add(function (mesh) {
  15312. _this._setLaserPointerParent(mesh);
  15313. });
  15314. return _this;
  15315. }
  15316. VRExperienceHelperControllerGazer.prototype._getForwardRay = function (length) {
  15317. return this.webVRController.getForwardRay(length);
  15318. };
  15319. /** @hidden */
  15320. VRExperienceHelperControllerGazer.prototype._activatePointer = function () {
  15321. _super.prototype._activatePointer.call(this);
  15322. this._laserPointer.isVisible = true;
  15323. };
  15324. /** @hidden */
  15325. VRExperienceHelperControllerGazer.prototype._deactivatePointer = function () {
  15326. _super.prototype._deactivatePointer.call(this);
  15327. this._laserPointer.isVisible = false;
  15328. };
  15329. /** @hidden */
  15330. VRExperienceHelperControllerGazer.prototype._setLaserPointerColor = function (color) {
  15331. this._laserPointer.material.emissiveColor = color;
  15332. };
  15333. /** @hidden */
  15334. VRExperienceHelperControllerGazer.prototype._setLaserPointerParent = function (mesh) {
  15335. var makeNotPick = function (root) {
  15336. root.isPickable = false;
  15337. root.getChildMeshes().forEach(function (c) {
  15338. makeNotPick(c);
  15339. });
  15340. };
  15341. makeNotPick(mesh);
  15342. var meshChildren = mesh.getChildren(undefined, false);
  15343. var laserParent = mesh;
  15344. this.webVRController._pointingPoseNode = null;
  15345. for (var i = 0; i < meshChildren.length; i++) {
  15346. if (meshChildren[i].name && meshChildren[i].name.indexOf(_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE) >= 0) {
  15347. laserParent = meshChildren[i];
  15348. this.webVRController._pointingPoseNode = laserParent;
  15349. break;
  15350. }
  15351. }
  15352. this._laserPointer.parent = laserParent;
  15353. };
  15354. VRExperienceHelperControllerGazer.prototype._updatePointerDistance = function (distance) {
  15355. if (distance === void 0) { distance = 100; }
  15356. this._laserPointer.scaling.y = distance;
  15357. this._laserPointer.position.z = -distance / 2;
  15358. };
  15359. VRExperienceHelperControllerGazer.prototype.dispose = function () {
  15360. _super.prototype.dispose.call(this);
  15361. this._laserPointer.dispose();
  15362. if (this._meshAttachedObserver) {
  15363. this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver);
  15364. }
  15365. };
  15366. return VRExperienceHelperControllerGazer;
  15367. }(VRExperienceHelperGazer));
  15368. var VRExperienceHelperCameraGazer = /** @class */ (function (_super) {
  15369. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperCameraGazer, _super);
  15370. function VRExperienceHelperCameraGazer(getCamera, scene) {
  15371. var _this = _super.call(this, scene) || this;
  15372. _this.getCamera = getCamera;
  15373. return _this;
  15374. }
  15375. VRExperienceHelperCameraGazer.prototype._getForwardRay = function (length) {
  15376. var camera = this.getCamera();
  15377. if (camera) {
  15378. return camera.getForwardRay(length);
  15379. }
  15380. else {
  15381. 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());
  15382. }
  15383. };
  15384. return VRExperienceHelperCameraGazer;
  15385. }(VRExperienceHelperGazer));
  15386. /**
  15387. * Helps to quickly add VR support to an existing scene.
  15388. * See http://doc.babylonjs.com/how_to/webvr_helper
  15389. */
  15390. var VRExperienceHelper = /** @class */ (function () {
  15391. /**
  15392. * Instantiates a VRExperienceHelper.
  15393. * Helps to quickly add VR support to an existing scene.
  15394. * @param scene The scene the VRExperienceHelper belongs to.
  15395. * @param webVROptions Options to modify the vr experience helper's behavior.
  15396. */
  15397. function VRExperienceHelper(scene,
  15398. /** Options to modify the vr experience helper's behavior. */
  15399. webVROptions) {
  15400. if (webVROptions === void 0) { webVROptions = {}; }
  15401. var _this = this;
  15402. this.webVROptions = webVROptions;
  15403. // Can the system support WebVR, even if a headset isn't plugged in?
  15404. this._webVRsupported = false;
  15405. // If WebVR is supported, is a headset plugged in and are we ready to present?
  15406. this._webVRready = false;
  15407. // Are we waiting for the requestPresent callback to complete?
  15408. this._webVRrequesting = false;
  15409. // Are we presenting to the headset right now? (this is the vrDevice state)
  15410. this._webVRpresenting = false;
  15411. // Are we presenting in the fullscreen fallback?
  15412. this._fullscreenVRpresenting = false;
  15413. /**
  15414. * Observable raised when entering VR.
  15415. */
  15416. this.onEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15417. /**
  15418. * Observable raised when exiting VR.
  15419. */
  15420. this.onExitingVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15421. /**
  15422. * Observable raised when controller mesh is loaded.
  15423. */
  15424. this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15425. this._useCustomVRButton = false;
  15426. this._teleportationRequested = false;
  15427. this._teleportActive = false;
  15428. this._floorMeshesCollection = [];
  15429. this._rotationAllowed = true;
  15430. this._teleportBackwardsVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, -1, -1);
  15431. this._isDefaultTeleportationTarget = true;
  15432. this._teleportationFillColor = "#444444";
  15433. this._teleportationBorderColor = "#FFFFFF";
  15434. this._rotationAngle = 0;
  15435. this._haloCenter = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, 0, 0);
  15436. this._padSensibilityUp = 0.65;
  15437. this._padSensibilityDown = 0.35;
  15438. this._leftController = null;
  15439. this._rightController = null;
  15440. /**
  15441. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  15442. */
  15443. this.onNewMeshSelected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15444. /**
  15445. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  15446. */
  15447. this.onNewMeshPicked = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15448. /**
  15449. * Observable raised before camera teleportation
  15450. */
  15451. this.onBeforeCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15452. /**
  15453. * Observable raised after camera teleportation
  15454. */
  15455. this.onAfterCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15456. /**
  15457. * Observable raised when current selected mesh gets unselected
  15458. */
  15459. this.onSelectedMeshUnselected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15460. /**
  15461. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  15462. */
  15463. this.teleportationEnabled = true;
  15464. this._teleportationInitialized = false;
  15465. this._interactionsEnabled = false;
  15466. this._interactionsRequested = false;
  15467. this._displayGaze = true;
  15468. this._displayLaserPointer = true;
  15469. /**
  15470. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  15471. */
  15472. this.updateGazeTrackerScale = true;
  15473. /**
  15474. * If the gaze trackers color should be updated when selecting meshes
  15475. */
  15476. this.updateGazeTrackerColor = true;
  15477. this._onResize = function () {
  15478. _this.moveButtonToBottomRight();
  15479. if (_this._fullscreenVRpresenting && _this._webVRready) {
  15480. _this.exitVR();
  15481. }
  15482. };
  15483. this._onFullscreenChange = function () {
  15484. if (document.fullscreen !== undefined) {
  15485. _this._fullscreenVRpresenting = document.fullscreen;
  15486. }
  15487. else if (document.mozFullScreen !== undefined) {
  15488. _this._fullscreenVRpresenting = document.mozFullScreen;
  15489. }
  15490. else if (document.webkitIsFullScreen !== undefined) {
  15491. _this._fullscreenVRpresenting = document.webkitIsFullScreen;
  15492. }
  15493. else if (document.msIsFullScreen !== undefined) {
  15494. _this._fullscreenVRpresenting = document.msIsFullScreen;
  15495. }
  15496. else if (document.msFullscreenElement !== undefined) {
  15497. _this._fullscreenVRpresenting = document.msFullscreenElement;
  15498. }
  15499. if (!_this._fullscreenVRpresenting && _this._canvas) {
  15500. _this.exitVR();
  15501. if (!_this._useCustomVRButton) {
  15502. _this._btnVR.style.top = _this._canvas.offsetTop + _this._canvas.offsetHeight - 70 + "px";
  15503. _this._btnVR.style.left = _this._canvas.offsetLeft + _this._canvas.offsetWidth - 100 + "px";
  15504. }
  15505. }
  15506. };
  15507. this._cachedAngularSensibility = { angularSensibilityX: null, angularSensibilityY: null, angularSensibility: null };
  15508. this.beforeRender = function () {
  15509. if (_this._leftController && _this._leftController._activePointer) {
  15510. _this._castRayAndSelectObject(_this._leftController);
  15511. }
  15512. if (_this._rightController && _this._rightController._activePointer) {
  15513. _this._castRayAndSelectObject(_this._rightController);
  15514. }
  15515. if (_this._noControllerIsActive) {
  15516. _this._castRayAndSelectObject(_this._cameraGazer);
  15517. }
  15518. else {
  15519. _this._cameraGazer._gazeTracker.isVisible = false;
  15520. }
  15521. };
  15522. this._onNewGamepadConnected = function (gamepad) {
  15523. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].POSE_ENABLED) {
  15524. if (gamepad.leftStick) {
  15525. gamepad.onleftstickchanged(function (stickValues) {
  15526. if (_this._teleportationInitialized && _this.teleportationEnabled) {
  15527. // Listening to classic/xbox gamepad only if no VR controller is active
  15528. if ((!_this._leftController && !_this._rightController) ||
  15529. ((_this._leftController && !_this._leftController._activePointer) &&
  15530. (_this._rightController && !_this._rightController._activePointer))) {
  15531. _this._checkTeleportWithRay(stickValues, _this._cameraGazer);
  15532. _this._checkTeleportBackwards(stickValues, _this._cameraGazer);
  15533. }
  15534. }
  15535. });
  15536. }
  15537. if (gamepad.rightStick) {
  15538. gamepad.onrightstickchanged(function (stickValues) {
  15539. if (_this._teleportationInitialized) {
  15540. _this._checkRotate(stickValues, _this._cameraGazer);
  15541. }
  15542. });
  15543. }
  15544. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].XBOX) {
  15545. gamepad.onbuttondown(function (buttonPressed) {
  15546. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  15547. _this._cameraGazer._selectionPointerDown();
  15548. }
  15549. });
  15550. gamepad.onbuttonup(function (buttonPressed) {
  15551. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  15552. _this._cameraGazer._selectionPointerUp();
  15553. }
  15554. });
  15555. }
  15556. }
  15557. else {
  15558. var webVRController = gamepad;
  15559. var controller = new VRExperienceHelperControllerGazer(webVRController, _this._scene, _this._cameraGazer._gazeTracker);
  15560. if (webVRController.hand === "right" || (_this._leftController && _this._leftController.webVRController != webVRController)) {
  15561. _this._rightController = controller;
  15562. }
  15563. else {
  15564. _this._leftController = controller;
  15565. }
  15566. _this._tryEnableInteractionOnController(controller);
  15567. }
  15568. };
  15569. // 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
  15570. this._tryEnableInteractionOnController = function (controller) {
  15571. if (_this._interactionsRequested && !controller._interactionsEnabled) {
  15572. _this._enableInteractionOnController(controller);
  15573. }
  15574. if (_this._teleportationRequested && !controller._teleportationEnabled) {
  15575. _this._enableTeleportationOnController(controller);
  15576. }
  15577. };
  15578. this._onNewGamepadDisconnected = function (gamepad) {
  15579. if (gamepad instanceof _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__["WebVRController"]) {
  15580. if (gamepad.hand === "left" && _this._leftController != null) {
  15581. _this._leftController.dispose();
  15582. _this._leftController = null;
  15583. }
  15584. if (gamepad.hand === "right" && _this._rightController != null) {
  15585. _this._rightController.dispose();
  15586. _this._rightController = null;
  15587. }
  15588. }
  15589. };
  15590. this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero();
  15591. this._workingQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].Identity();
  15592. this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].Identity();
  15593. this._scene = scene;
  15594. this._canvas = scene.getEngine().getRenderingCanvas();
  15595. // Parse options
  15596. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera === undefined) {
  15597. webVROptions.createFallbackVRDeviceOrientationFreeCamera = true;
  15598. }
  15599. if (webVROptions.createDeviceOrientationCamera === undefined) {
  15600. webVROptions.createDeviceOrientationCamera = true;
  15601. }
  15602. if (webVROptions.laserToggle === undefined) {
  15603. webVROptions.laserToggle = true;
  15604. }
  15605. if (webVROptions.defaultHeight === undefined) {
  15606. webVROptions.defaultHeight = 1.7;
  15607. }
  15608. if (webVROptions.useCustomVRButton) {
  15609. this._useCustomVRButton = true;
  15610. if (webVROptions.customVRButton) {
  15611. this._btnVR = webVROptions.customVRButton;
  15612. }
  15613. }
  15614. if (webVROptions.rayLength) {
  15615. this._rayLength = webVROptions.rayLength;
  15616. }
  15617. this._defaultHeight = webVROptions.defaultHeight;
  15618. if (webVROptions.positionScale) {
  15619. this._rayLength *= webVROptions.positionScale;
  15620. this._defaultHeight *= webVROptions.positionScale;
  15621. }
  15622. this._hasEnteredVR = false;
  15623. // Set position
  15624. if (this._scene.activeCamera) {
  15625. this._position = this._scene.activeCamera.position.clone();
  15626. }
  15627. else {
  15628. this._position = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, this._defaultHeight, 0);
  15629. }
  15630. // Set non-vr camera
  15631. if (webVROptions.createDeviceOrientationCamera || !this._scene.activeCamera) {
  15632. this._deviceOrientationCamera = new _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__["DeviceOrientationCamera"]("deviceOrientationVRHelper", this._position.clone(), scene);
  15633. // Copy data from existing camera
  15634. if (this._scene.activeCamera) {
  15635. this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  15636. this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
  15637. // Set rotation from previous camera
  15638. if (this._scene.activeCamera instanceof _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"] && this._scene.activeCamera.rotation) {
  15639. var targetCamera = this._scene.activeCamera;
  15640. if (targetCamera.rotationQuaternion) {
  15641. this._deviceOrientationCamera.rotationQuaternion.copyFrom(targetCamera.rotationQuaternion);
  15642. }
  15643. else {
  15644. this._deviceOrientationCamera.rotationQuaternion.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRoll(targetCamera.rotation.y, targetCamera.rotation.x, targetCamera.rotation.z));
  15645. }
  15646. this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
  15647. }
  15648. }
  15649. this._scene.activeCamera = this._deviceOrientationCamera;
  15650. if (this._canvas) {
  15651. this._scene.activeCamera.attachControl(this._canvas);
  15652. }
  15653. }
  15654. else {
  15655. this._existingCamera = this._scene.activeCamera;
  15656. }
  15657. // Create VR cameras
  15658. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  15659. this._vrDeviceOrientationCamera = new _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__["VRDeviceOrientationFreeCamera"]("VRDeviceOrientationVRHelper", this._position, this._scene);
  15660. this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  15661. }
  15662. this._webVRCamera = new _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]("WebVRHelper", this._position, this._scene, webVROptions);
  15663. this._webVRCamera.useStandingMatrix();
  15664. this._cameraGazer = new VRExperienceHelperCameraGazer(function () { return _this.currentVRCamera; }, scene);
  15665. // Create default button
  15666. if (!this._useCustomVRButton) {
  15667. this._btnVR = document.createElement("BUTTON");
  15668. this._btnVR.className = "babylonVRicon";
  15669. this._btnVR.id = "babylonVRiconbtn";
  15670. this._btnVR.title = "Click to switch to VR";
  15671. 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) }";
  15672. css += ".babylonVRicon.vrdisplaypresenting { display: none; }";
  15673. // TODO: Add user feedback so that they know what state the VRDisplay is in (disconnected, connected, entering-VR)
  15674. // css += ".babylonVRicon.vrdisplaysupported { }";
  15675. // css += ".babylonVRicon.vrdisplayready { }";
  15676. // css += ".babylonVRicon.vrdisplayrequesting { }";
  15677. var style = document.createElement('style');
  15678. style.appendChild(document.createTextNode(css));
  15679. document.getElementsByTagName('head')[0].appendChild(style);
  15680. this.moveButtonToBottomRight();
  15681. }
  15682. // VR button click event
  15683. if (this._btnVR) {
  15684. this._btnVR.addEventListener("click", function () {
  15685. if (!_this.isInVRMode) {
  15686. _this.enterVR();
  15687. }
  15688. else {
  15689. _this.exitVR();
  15690. }
  15691. });
  15692. }
  15693. // Window events
  15694. window.addEventListener("resize", this._onResize);
  15695. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  15696. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  15697. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  15698. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  15699. document.onmsfullscreenchange = this._onFullscreenChange;
  15700. // Display vr button when headset is connected
  15701. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  15702. this.displayVRButton();
  15703. }
  15704. else {
  15705. this._scene.getEngine().onVRDisplayChangedObservable.add(function (e) {
  15706. if (e.vrDisplay) {
  15707. _this.displayVRButton();
  15708. }
  15709. });
  15710. }
  15711. // Exiting VR mode using 'ESC' key on desktop
  15712. this._onKeyDown = function (event) {
  15713. if (event.keyCode === 27 && _this.isInVRMode) {
  15714. _this.exitVR();
  15715. }
  15716. };
  15717. document.addEventListener("keydown", this._onKeyDown);
  15718. // Exiting VR mode double tapping the touch screen
  15719. this._scene.onPrePointerObservable.add(function () {
  15720. if (_this.isInVRMode) {
  15721. _this.exitVR();
  15722. if (_this._fullscreenVRpresenting) {
  15723. _this._scene.getEngine().switchFullscreen(true);
  15724. }
  15725. }
  15726. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__["PointerEventTypes"].POINTERDOUBLETAP, false);
  15727. // Listen for WebVR display changes
  15728. this._onVRDisplayChanged = function (eventArgs) { return _this.onVRDisplayChanged(eventArgs); };
  15729. this._onVrDisplayPresentChange = function () { return _this.onVrDisplayPresentChange(); };
  15730. this._onVRRequestPresentStart = function () {
  15731. _this._webVRrequesting = true;
  15732. _this.updateButtonVisibility();
  15733. };
  15734. this._onVRRequestPresentComplete = function () {
  15735. _this._webVRrequesting = false;
  15736. _this.updateButtonVisibility();
  15737. };
  15738. scene.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged);
  15739. scene.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart);
  15740. scene.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete);
  15741. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  15742. scene.onDisposeObservable.add(function () {
  15743. _this.dispose();
  15744. });
  15745. // Gamepad connection events
  15746. this._webVRCamera.onControllerMeshLoadedObservable.add(function (webVRController) { return _this._onDefaultMeshLoaded(webVRController); });
  15747. this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected);
  15748. this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected);
  15749. this.updateButtonVisibility();
  15750. //create easing functions
  15751. this._circleEase = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["CircleEase"]();
  15752. this._circleEase.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  15753. if (this.webVROptions.floorMeshes) {
  15754. this.enableTeleportation({ floorMeshes: this.webVROptions.floorMeshes });
  15755. }
  15756. }
  15757. Object.defineProperty(VRExperienceHelper.prototype, "onEnteringVR", {
  15758. /** Return this.onEnteringVRObservable
  15759. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  15760. */
  15761. get: function () {
  15762. return this.onEnteringVRObservable;
  15763. },
  15764. enumerable: true,
  15765. configurable: true
  15766. });
  15767. Object.defineProperty(VRExperienceHelper.prototype, "onExitingVR", {
  15768. /** Return this.onExitingVRObservable
  15769. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  15770. */
  15771. get: function () {
  15772. return this.onExitingVRObservable;
  15773. },
  15774. enumerable: true,
  15775. configurable: true
  15776. });
  15777. Object.defineProperty(VRExperienceHelper.prototype, "onControllerMeshLoaded", {
  15778. /** Return this.onControllerMeshLoadedObservable
  15779. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  15780. */
  15781. get: function () {
  15782. return this.onControllerMeshLoadedObservable;
  15783. },
  15784. enumerable: true,
  15785. configurable: true
  15786. });
  15787. Object.defineProperty(VRExperienceHelper.prototype, "teleportationTarget", {
  15788. /**
  15789. * The mesh used to display where the user is going to teleport.
  15790. */
  15791. get: function () {
  15792. return this._teleportationTarget;
  15793. },
  15794. /**
  15795. * Sets the mesh to be used to display where the user is going to teleport.
  15796. */
  15797. set: function (value) {
  15798. if (value) {
  15799. value.name = "teleportationTarget";
  15800. this._isDefaultTeleportationTarget = false;
  15801. this._teleportationTarget = value;
  15802. }
  15803. },
  15804. enumerable: true,
  15805. configurable: true
  15806. });
  15807. Object.defineProperty(VRExperienceHelper.prototype, "gazeTrackerMesh", {
  15808. /**
  15809. * 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
  15810. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  15811. * See http://doc.babylonjs.com/resources/baking_transformations
  15812. */
  15813. get: function () {
  15814. return this._cameraGazer._gazeTracker;
  15815. },
  15816. set: function (value) {
  15817. if (value) {
  15818. // Dispose of existing meshes
  15819. if (this._cameraGazer._gazeTracker) {
  15820. this._cameraGazer._gazeTracker.dispose();
  15821. }
  15822. if (this._leftController && this._leftController._gazeTracker) {
  15823. this._leftController._gazeTracker.dispose();
  15824. }
  15825. if (this._rightController && this._rightController._gazeTracker) {
  15826. this._rightController._gazeTracker.dispose();
  15827. }
  15828. // Set and create gaze trackers on head and controllers
  15829. this._cameraGazer._gazeTracker = value;
  15830. this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices();
  15831. this._cameraGazer._gazeTracker.isPickable = false;
  15832. this._cameraGazer._gazeTracker.isVisible = false;
  15833. this._cameraGazer._gazeTracker.name = "gazeTracker";
  15834. if (this._leftController) {
  15835. this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  15836. }
  15837. if (this._rightController) {
  15838. this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  15839. }
  15840. }
  15841. },
  15842. enumerable: true,
  15843. configurable: true
  15844. });
  15845. Object.defineProperty(VRExperienceHelper.prototype, "leftControllerGazeTrackerMesh", {
  15846. /**
  15847. * The gaze tracking mesh corresponding to the left controller
  15848. */
  15849. get: function () {
  15850. if (this._leftController) {
  15851. return this._leftController._gazeTracker;
  15852. }
  15853. return null;
  15854. },
  15855. enumerable: true,
  15856. configurable: true
  15857. });
  15858. Object.defineProperty(VRExperienceHelper.prototype, "rightControllerGazeTrackerMesh", {
  15859. /**
  15860. * The gaze tracking mesh corresponding to the right controller
  15861. */
  15862. get: function () {
  15863. if (this._rightController) {
  15864. return this._rightController._gazeTracker;
  15865. }
  15866. return null;
  15867. },
  15868. enumerable: true,
  15869. configurable: true
  15870. });
  15871. Object.defineProperty(VRExperienceHelper.prototype, "displayGaze", {
  15872. /**
  15873. * If the ray of the gaze should be displayed.
  15874. */
  15875. get: function () {
  15876. return this._displayGaze;
  15877. },
  15878. /**
  15879. * Sets if the ray of the gaze should be displayed.
  15880. */
  15881. set: function (value) {
  15882. this._displayGaze = value;
  15883. if (!value) {
  15884. this._cameraGazer._gazeTracker.isVisible = false;
  15885. if (this._leftController) {
  15886. this._leftController._gazeTracker.isVisible = false;
  15887. }
  15888. if (this._rightController) {
  15889. this._rightController._gazeTracker.isVisible = false;
  15890. }
  15891. }
  15892. },
  15893. enumerable: true,
  15894. configurable: true
  15895. });
  15896. Object.defineProperty(VRExperienceHelper.prototype, "displayLaserPointer", {
  15897. /**
  15898. * If the ray of the LaserPointer should be displayed.
  15899. */
  15900. get: function () {
  15901. return this._displayLaserPointer;
  15902. },
  15903. /**
  15904. * Sets if the ray of the LaserPointer should be displayed.
  15905. */
  15906. set: function (value) {
  15907. this._displayLaserPointer = value;
  15908. if (!value) {
  15909. if (this._rightController) {
  15910. this._rightController._deactivatePointer();
  15911. this._rightController._gazeTracker.isVisible = false;
  15912. }
  15913. if (this._leftController) {
  15914. this._leftController._deactivatePointer();
  15915. this._leftController._gazeTracker.isVisible = false;
  15916. }
  15917. }
  15918. else {
  15919. if (this._rightController) {
  15920. this._rightController._activatePointer();
  15921. }
  15922. if (this._leftController) {
  15923. this._leftController._activatePointer();
  15924. }
  15925. }
  15926. },
  15927. enumerable: true,
  15928. configurable: true
  15929. });
  15930. Object.defineProperty(VRExperienceHelper.prototype, "deviceOrientationCamera", {
  15931. /**
  15932. * The deviceOrientationCamera used as the camera when not in VR.
  15933. */
  15934. get: function () {
  15935. return this._deviceOrientationCamera;
  15936. },
  15937. enumerable: true,
  15938. configurable: true
  15939. });
  15940. Object.defineProperty(VRExperienceHelper.prototype, "currentVRCamera", {
  15941. /**
  15942. * Based on the current WebVR support, returns the current VR camera used.
  15943. */
  15944. get: function () {
  15945. if (this._webVRready) {
  15946. return this._webVRCamera;
  15947. }
  15948. else {
  15949. return this._scene.activeCamera;
  15950. }
  15951. },
  15952. enumerable: true,
  15953. configurable: true
  15954. });
  15955. Object.defineProperty(VRExperienceHelper.prototype, "webVRCamera", {
  15956. /**
  15957. * The webVRCamera which is used when in VR.
  15958. */
  15959. get: function () {
  15960. return this._webVRCamera;
  15961. },
  15962. enumerable: true,
  15963. configurable: true
  15964. });
  15965. Object.defineProperty(VRExperienceHelper.prototype, "vrDeviceOrientationCamera", {
  15966. /**
  15967. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  15968. */
  15969. get: function () {
  15970. return this._vrDeviceOrientationCamera;
  15971. },
  15972. enumerable: true,
  15973. configurable: true
  15974. });
  15975. Object.defineProperty(VRExperienceHelper.prototype, "_teleportationRequestInitiated", {
  15976. get: function () {
  15977. var result = this._cameraGazer._teleportationRequestInitiated
  15978. || (this._leftController !== null && this._leftController._teleportationRequestInitiated)
  15979. || (this._rightController !== null && this._rightController._teleportationRequestInitiated);
  15980. return result;
  15981. },
  15982. enumerable: true,
  15983. configurable: true
  15984. });
  15985. // Raised when one of the controller has loaded successfully its associated default mesh
  15986. VRExperienceHelper.prototype._onDefaultMeshLoaded = function (webVRController) {
  15987. if (this._leftController && this._leftController.webVRController == webVRController) {
  15988. if (webVRController.mesh) {
  15989. this._leftController._setLaserPointerParent(webVRController.mesh);
  15990. }
  15991. }
  15992. if (this._rightController && this._rightController.webVRController == webVRController) {
  15993. if (webVRController.mesh) {
  15994. this._rightController._setLaserPointerParent(webVRController.mesh);
  15995. }
  15996. }
  15997. try {
  15998. this.onControllerMeshLoadedObservable.notifyObservers(webVRController);
  15999. }
  16000. catch (err) {
  16001. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onControllerMeshLoaded: " + err);
  16002. }
  16003. };
  16004. Object.defineProperty(VRExperienceHelper.prototype, "isInVRMode", {
  16005. /**
  16006. * Gets a value indicating if we are currently in VR mode.
  16007. */
  16008. get: function () {
  16009. return this._webVRpresenting || this._fullscreenVRpresenting;
  16010. },
  16011. enumerable: true,
  16012. configurable: true
  16013. });
  16014. VRExperienceHelper.prototype.onVrDisplayPresentChange = function () {
  16015. var vrDisplay = this._scene.getEngine().getVRDevice();
  16016. if (vrDisplay) {
  16017. var wasPresenting = this._webVRpresenting;
  16018. this._webVRpresenting = vrDisplay.isPresenting;
  16019. if (wasPresenting && !this._webVRpresenting) {
  16020. this.exitVR();
  16021. }
  16022. }
  16023. else {
  16024. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?');
  16025. }
  16026. this.updateButtonVisibility();
  16027. };
  16028. VRExperienceHelper.prototype.onVRDisplayChanged = function (eventArgs) {
  16029. this._webVRsupported = eventArgs.vrSupported;
  16030. this._webVRready = !!eventArgs.vrDisplay;
  16031. this._webVRpresenting = eventArgs.vrDisplay && eventArgs.vrDisplay.isPresenting;
  16032. this.updateButtonVisibility();
  16033. };
  16034. VRExperienceHelper.prototype.moveButtonToBottomRight = function () {
  16035. if (this._canvas && !this._useCustomVRButton) {
  16036. this._btnVR.style.top = this._canvas.offsetTop + this._canvas.offsetHeight - 70 + "px";
  16037. this._btnVR.style.left = this._canvas.offsetLeft + this._canvas.offsetWidth - 100 + "px";
  16038. }
  16039. };
  16040. VRExperienceHelper.prototype.displayVRButton = function () {
  16041. if (!this._useCustomVRButton && !this._btnVRDisplayed) {
  16042. document.body.appendChild(this._btnVR);
  16043. this._btnVRDisplayed = true;
  16044. }
  16045. };
  16046. VRExperienceHelper.prototype.updateButtonVisibility = function () {
  16047. if (!this._btnVR || this._useCustomVRButton) {
  16048. return;
  16049. }
  16050. this._btnVR.className = "babylonVRicon";
  16051. if (this.isInVRMode) {
  16052. this._btnVR.className += " vrdisplaypresenting";
  16053. }
  16054. else {
  16055. if (this._webVRready) {
  16056. this._btnVR.className += " vrdisplayready";
  16057. }
  16058. if (this._webVRsupported) {
  16059. this._btnVR.className += " vrdisplaysupported";
  16060. }
  16061. if (this._webVRrequesting) {
  16062. this._btnVR.className += " vrdisplayrequesting";
  16063. }
  16064. }
  16065. };
  16066. /**
  16067. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  16068. * Otherwise, will use the fullscreen API.
  16069. */
  16070. VRExperienceHelper.prototype.enterVR = function () {
  16071. if (this.onEnteringVRObservable) {
  16072. try {
  16073. this.onEnteringVRObservable.notifyObservers(this);
  16074. }
  16075. catch (err) {
  16076. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onEnteringVR: " + err);
  16077. }
  16078. }
  16079. if (this._scene.activeCamera) {
  16080. this._position = this._scene.activeCamera.position.clone();
  16081. if (this.vrDeviceOrientationCamera) {
  16082. this.vrDeviceOrientationCamera.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles();
  16083. this.vrDeviceOrientationCamera.angularSensibility = 2000;
  16084. }
  16085. if (this.webVRCamera) {
  16086. var currentYRotation = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y;
  16087. var desiredYRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y;
  16088. var delta = desiredYRotation - currentYRotation;
  16089. var currentGlobalRotation = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
  16090. this.webVRCamera.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromEulerAngles(0, currentGlobalRotation + delta, 0);
  16091. }
  16092. // make sure that we return to the last active camera
  16093. this._existingCamera = this._scene.activeCamera;
  16094. // Remove and cache angular sensability to avoid camera rotation when in VR
  16095. if (this._existingCamera.angularSensibilityX) {
  16096. this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX;
  16097. this._existingCamera.angularSensibilityX = Number.MAX_VALUE;
  16098. }
  16099. if (this._existingCamera.angularSensibilityY) {
  16100. this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY;
  16101. this._existingCamera.angularSensibilityY = Number.MAX_VALUE;
  16102. }
  16103. if (this._existingCamera.angularSensibility) {
  16104. this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility;
  16105. this._existingCamera.angularSensibility = Number.MAX_VALUE;
  16106. }
  16107. }
  16108. if (this._webVRrequesting) {
  16109. return;
  16110. }
  16111. // If WebVR is supported and a headset is connected
  16112. if (this._webVRready) {
  16113. if (!this._webVRpresenting) {
  16114. this._webVRCamera.position = this._position;
  16115. this._scene.activeCamera = this._webVRCamera;
  16116. }
  16117. }
  16118. else if (this._vrDeviceOrientationCamera) {
  16119. this._vrDeviceOrientationCamera.position = this._position;
  16120. if (this._scene.activeCamera) {
  16121. this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16122. }
  16123. this._scene.activeCamera = this._vrDeviceOrientationCamera;
  16124. this._scene.getEngine().switchFullscreen(true);
  16125. this.updateButtonVisibility();
  16126. }
  16127. if (this._scene.activeCamera && this._canvas) {
  16128. this._scene.activeCamera.attachControl(this._canvas);
  16129. }
  16130. if (this._interactionsEnabled) {
  16131. this._scene.registerBeforeRender(this.beforeRender);
  16132. }
  16133. if (this._displayLaserPointer) {
  16134. [this._leftController, this._rightController].forEach(function (controller) {
  16135. if (controller) {
  16136. controller._activatePointer();
  16137. }
  16138. });
  16139. }
  16140. this._hasEnteredVR = true;
  16141. };
  16142. /**
  16143. * Attempt to exit VR, or fullscreen.
  16144. */
  16145. VRExperienceHelper.prototype.exitVR = function () {
  16146. if (this._hasEnteredVR) {
  16147. if (this.onExitingVRObservable) {
  16148. try {
  16149. this.onExitingVRObservable.notifyObservers(this);
  16150. }
  16151. catch (err) {
  16152. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onExitingVR: " + err);
  16153. }
  16154. }
  16155. if (this._webVRpresenting) {
  16156. this._scene.getEngine().disableVR();
  16157. }
  16158. if (this._scene.activeCamera) {
  16159. this._position = this._scene.activeCamera.position.clone();
  16160. }
  16161. if (this.vrDeviceOrientationCamera) {
  16162. this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16163. }
  16164. if (this._deviceOrientationCamera) {
  16165. this._deviceOrientationCamera.position = this._position;
  16166. this._scene.activeCamera = this._deviceOrientationCamera;
  16167. if (this._canvas) {
  16168. this._scene.activeCamera.attachControl(this._canvas);
  16169. }
  16170. // Restore angular sensibility
  16171. if (this._cachedAngularSensibility.angularSensibilityX) {
  16172. this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  16173. this._cachedAngularSensibility.angularSensibilityX = null;
  16174. }
  16175. if (this._cachedAngularSensibility.angularSensibilityY) {
  16176. this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  16177. this._cachedAngularSensibility.angularSensibilityY = null;
  16178. }
  16179. if (this._cachedAngularSensibility.angularSensibility) {
  16180. this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  16181. this._cachedAngularSensibility.angularSensibility = null;
  16182. }
  16183. }
  16184. else if (this._existingCamera) {
  16185. this._existingCamera.position = this._position;
  16186. this._scene.activeCamera = this._existingCamera;
  16187. // Restore angular sensibility
  16188. if (this._cachedAngularSensibility.angularSensibilityX) {
  16189. this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  16190. this._cachedAngularSensibility.angularSensibilityX = null;
  16191. }
  16192. if (this._cachedAngularSensibility.angularSensibilityY) {
  16193. this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  16194. this._cachedAngularSensibility.angularSensibilityY = null;
  16195. }
  16196. if (this._cachedAngularSensibility.angularSensibility) {
  16197. this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  16198. this._cachedAngularSensibility.angularSensibility = null;
  16199. }
  16200. }
  16201. this.updateButtonVisibility();
  16202. if (this._interactionsEnabled) {
  16203. this._scene.unregisterBeforeRender(this.beforeRender);
  16204. this._cameraGazer._gazeTracker.isVisible = false;
  16205. if (this._leftController) {
  16206. this._leftController._gazeTracker.isVisible = false;
  16207. }
  16208. if (this._rightController) {
  16209. this._rightController._gazeTracker.isVisible = false;
  16210. }
  16211. }
  16212. // resize to update width and height when exiting vr exits fullscreen
  16213. this._scene.getEngine().resize();
  16214. [this._leftController, this._rightController].forEach(function (controller) {
  16215. if (controller) {
  16216. controller._deactivatePointer();
  16217. }
  16218. });
  16219. this._hasEnteredVR = false;
  16220. }
  16221. };
  16222. Object.defineProperty(VRExperienceHelper.prototype, "position", {
  16223. /**
  16224. * The position of the vr experience helper.
  16225. */
  16226. get: function () {
  16227. return this._position;
  16228. },
  16229. /**
  16230. * Sets the position of the vr experience helper.
  16231. */
  16232. set: function (value) {
  16233. this._position = value;
  16234. if (this._scene.activeCamera) {
  16235. this._scene.activeCamera.position = value;
  16236. }
  16237. },
  16238. enumerable: true,
  16239. configurable: true
  16240. });
  16241. /**
  16242. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  16243. */
  16244. VRExperienceHelper.prototype.enableInteractions = function () {
  16245. var _this = this;
  16246. if (!this._interactionsEnabled) {
  16247. this._interactionsRequested = true;
  16248. if (this._leftController) {
  16249. this._enableInteractionOnController(this._leftController);
  16250. }
  16251. if (this._rightController) {
  16252. this._enableInteractionOnController(this._rightController);
  16253. }
  16254. this.raySelectionPredicate = function (mesh) {
  16255. return mesh.isVisible && (mesh.isPickable || mesh.name === _this._floorMeshName);
  16256. };
  16257. this.meshSelectionPredicate = function () {
  16258. return true;
  16259. };
  16260. this._raySelectionPredicate = function (mesh) {
  16261. if (_this._isTeleportationFloor(mesh) || (mesh.name.indexOf("gazeTracker") === -1
  16262. && mesh.name.indexOf("teleportationTarget") === -1
  16263. && mesh.name.indexOf("torusTeleportation") === -1)) {
  16264. return _this.raySelectionPredicate(mesh);
  16265. }
  16266. return false;
  16267. };
  16268. this._interactionsEnabled = true;
  16269. }
  16270. };
  16271. Object.defineProperty(VRExperienceHelper.prototype, "_noControllerIsActive", {
  16272. get: function () {
  16273. return !(this._leftController && this._leftController._activePointer) && !(this._rightController && this._rightController._activePointer);
  16274. },
  16275. enumerable: true,
  16276. configurable: true
  16277. });
  16278. VRExperienceHelper.prototype._isTeleportationFloor = function (mesh) {
  16279. for (var i = 0; i < this._floorMeshesCollection.length; i++) {
  16280. if (this._floorMeshesCollection[i].id === mesh.id) {
  16281. return true;
  16282. }
  16283. }
  16284. if (this._floorMeshName && mesh.name === this._floorMeshName) {
  16285. return true;
  16286. }
  16287. return false;
  16288. };
  16289. /**
  16290. * Adds a floor mesh to be used for teleportation.
  16291. * @param floorMesh the mesh to be used for teleportation.
  16292. */
  16293. VRExperienceHelper.prototype.addFloorMesh = function (floorMesh) {
  16294. if (!this._floorMeshesCollection) {
  16295. return;
  16296. }
  16297. if (this._floorMeshesCollection.indexOf(floorMesh) > -1) {
  16298. return;
  16299. }
  16300. this._floorMeshesCollection.push(floorMesh);
  16301. };
  16302. /**
  16303. * Removes a floor mesh from being used for teleportation.
  16304. * @param floorMesh the mesh to be removed.
  16305. */
  16306. VRExperienceHelper.prototype.removeFloorMesh = function (floorMesh) {
  16307. if (!this._floorMeshesCollection) {
  16308. return;
  16309. }
  16310. var meshIndex = this._floorMeshesCollection.indexOf(floorMesh);
  16311. if (meshIndex !== -1) {
  16312. this._floorMeshesCollection.splice(meshIndex, 1);
  16313. }
  16314. };
  16315. /**
  16316. * Enables interactions and teleportation using the VR controllers and gaze.
  16317. * @param vrTeleportationOptions options to modify teleportation behavior.
  16318. */
  16319. VRExperienceHelper.prototype.enableTeleportation = function (vrTeleportationOptions) {
  16320. if (vrTeleportationOptions === void 0) { vrTeleportationOptions = {}; }
  16321. if (!this._teleportationInitialized) {
  16322. this._teleportationRequested = true;
  16323. this.enableInteractions();
  16324. if (vrTeleportationOptions.floorMeshName) {
  16325. this._floorMeshName = vrTeleportationOptions.floorMeshName;
  16326. }
  16327. if (vrTeleportationOptions.floorMeshes) {
  16328. this._floorMeshesCollection = vrTeleportationOptions.floorMeshes;
  16329. }
  16330. if (this._leftController != null) {
  16331. this._enableTeleportationOnController(this._leftController);
  16332. }
  16333. if (this._rightController != null) {
  16334. this._enableTeleportationOnController(this._rightController);
  16335. }
  16336. // Creates an image processing post process for the vignette not relying
  16337. // on the main scene configuration for image processing to reduce setup and spaces
  16338. // (gamma/linear) conflicts.
  16339. var imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__["ImageProcessingConfiguration"]();
  16340. imageProcessingConfiguration.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color4"](0, 0, 0, 0);
  16341. imageProcessingConfiguration.vignetteEnabled = true;
  16342. this._postProcessMove = new _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__["ImageProcessingPostProcess"]("postProcessMove", 1.0, this._webVRCamera, undefined, undefined, undefined, undefined, imageProcessingConfiguration);
  16343. this._webVRCamera.detachPostProcess(this._postProcessMove);
  16344. this._teleportationInitialized = true;
  16345. if (this._isDefaultTeleportationTarget) {
  16346. this._createTeleportationCircles();
  16347. this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor);
  16348. }
  16349. }
  16350. };
  16351. VRExperienceHelper.prototype._enableInteractionOnController = function (controller) {
  16352. var _this = this;
  16353. var controllerMesh = controller.webVRController.mesh;
  16354. if (controllerMesh) {
  16355. controller._interactionsEnabled = true;
  16356. if (this.isInVRMode && this._displayLaserPointer) {
  16357. controller._activatePointer();
  16358. }
  16359. if (this.webVROptions.laserToggle) {
  16360. controller.webVRController.onMainButtonStateChangedObservable.add(function (stateObject) {
  16361. // Enabling / disabling laserPointer
  16362. if (_this._displayLaserPointer && stateObject.value === 1) {
  16363. if (controller._activePointer) {
  16364. controller._deactivatePointer();
  16365. }
  16366. else {
  16367. controller._activatePointer();
  16368. }
  16369. if (_this.displayGaze) {
  16370. controller._gazeTracker.isVisible = controller._activePointer;
  16371. }
  16372. }
  16373. });
  16374. }
  16375. controller.webVRController.onTriggerStateChangedObservable.add(function (stateObject) {
  16376. var gazer = controller;
  16377. if (_this._noControllerIsActive) {
  16378. gazer = _this._cameraGazer;
  16379. }
  16380. if (!gazer._pointerDownOnMeshAsked) {
  16381. if (stateObject.value > _this._padSensibilityUp) {
  16382. gazer._selectionPointerDown();
  16383. }
  16384. }
  16385. else if (stateObject.value < _this._padSensibilityDown) {
  16386. gazer._selectionPointerUp();
  16387. }
  16388. });
  16389. }
  16390. };
  16391. VRExperienceHelper.prototype._checkTeleportWithRay = function (stateObject, gazer) {
  16392. // Dont teleport if another gaze already requested teleportation
  16393. if (this._teleportationRequestInitiated && !gazer._teleportationRequestInitiated) {
  16394. return;
  16395. }
  16396. if (!gazer._teleportationRequestInitiated) {
  16397. if (stateObject.y < -this._padSensibilityUp && gazer._dpadPressed) {
  16398. gazer._activatePointer();
  16399. gazer._teleportationRequestInitiated = true;
  16400. }
  16401. }
  16402. else {
  16403. // Listening to the proper controller values changes to confirm teleportation
  16404. if (Math.sqrt(stateObject.y * stateObject.y + stateObject.x * stateObject.x) < this._padSensibilityDown) {
  16405. if (this._teleportActive) {
  16406. this.teleportCamera(this._haloCenter);
  16407. }
  16408. gazer._teleportationRequestInitiated = false;
  16409. }
  16410. }
  16411. };
  16412. VRExperienceHelper.prototype._checkRotate = function (stateObject, gazer) {
  16413. // Only rotate when user is not currently selecting a teleportation location
  16414. if (gazer._teleportationRequestInitiated) {
  16415. return;
  16416. }
  16417. if (!gazer._rotationLeftAsked) {
  16418. if (stateObject.x < -this._padSensibilityUp && gazer._dpadPressed) {
  16419. gazer._rotationLeftAsked = true;
  16420. if (this._rotationAllowed) {
  16421. this._rotateCamera(false);
  16422. }
  16423. }
  16424. }
  16425. else {
  16426. if (stateObject.x > -this._padSensibilityDown) {
  16427. gazer._rotationLeftAsked = false;
  16428. }
  16429. }
  16430. if (!gazer._rotationRightAsked) {
  16431. if (stateObject.x > this._padSensibilityUp && gazer._dpadPressed) {
  16432. gazer._rotationRightAsked = true;
  16433. if (this._rotationAllowed) {
  16434. this._rotateCamera(true);
  16435. }
  16436. }
  16437. }
  16438. else {
  16439. if (stateObject.x < this._padSensibilityDown) {
  16440. gazer._rotationRightAsked = false;
  16441. }
  16442. }
  16443. };
  16444. VRExperienceHelper.prototype._checkTeleportBackwards = function (stateObject, gazer) {
  16445. // Only teleport backwards when user is not currently selecting a teleportation location
  16446. if (gazer._teleportationRequestInitiated) {
  16447. return;
  16448. }
  16449. // Teleport backwards
  16450. if (stateObject.y > this._padSensibilityUp && gazer._dpadPressed) {
  16451. if (!gazer._teleportationBackRequestInitiated) {
  16452. if (!this.currentVRCamera) {
  16453. return;
  16454. }
  16455. // Get rotation and position of the current camera
  16456. var rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix());
  16457. var position = this.currentVRCamera.position;
  16458. // If the camera has device position, use that instead
  16459. if (this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion) {
  16460. rotation = this.currentVRCamera.deviceRotationQuaternion;
  16461. position = this.currentVRCamera.devicePosition;
  16462. }
  16463. // Get matrix with only the y rotation of the device rotation
  16464. rotation.toEulerAnglesToRef(this._workingVector);
  16465. this._workingVector.z = 0;
  16466. this._workingVector.x = 0;
  16467. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion);
  16468. this._workingQuaternion.toRotationMatrix(this._workingMatrix);
  16469. // Rotate backwards ray by device rotation to cast at the ground behind the user
  16470. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
  16471. // Teleport if ray hit the ground and is not to far away eg. backwards off a cliff
  16472. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_15__["Ray"](position, this._workingVector);
  16473. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  16474. if (hit && hit.pickedPoint && hit.pickedMesh && this._isTeleportationFloor(hit.pickedMesh) && hit.distance < 5) {
  16475. this.teleportCamera(hit.pickedPoint);
  16476. }
  16477. gazer._teleportationBackRequestInitiated = true;
  16478. }
  16479. }
  16480. else {
  16481. gazer._teleportationBackRequestInitiated = false;
  16482. }
  16483. };
  16484. VRExperienceHelper.prototype._enableTeleportationOnController = function (controller) {
  16485. var _this = this;
  16486. var controllerMesh = controller.webVRController.mesh;
  16487. if (controllerMesh) {
  16488. if (!controller._interactionsEnabled) {
  16489. this._enableInteractionOnController(controller);
  16490. }
  16491. controller._interactionsEnabled = true;
  16492. controller._teleportationEnabled = true;
  16493. if (controller.webVRController.controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledControllerType"].VIVE) {
  16494. controller._dpadPressed = false;
  16495. controller.webVRController.onPadStateChangedObservable.add(function (stateObject) {
  16496. controller._dpadPressed = stateObject.pressed;
  16497. if (!controller._dpadPressed) {
  16498. controller._rotationLeftAsked = false;
  16499. controller._rotationRightAsked = false;
  16500. controller._teleportationBackRequestInitiated = false;
  16501. }
  16502. });
  16503. }
  16504. controller.webVRController.onPadValuesChangedObservable.add(function (stateObject) {
  16505. if (_this.teleportationEnabled) {
  16506. _this._checkTeleportBackwards(stateObject, controller);
  16507. _this._checkTeleportWithRay(stateObject, controller);
  16508. }
  16509. _this._checkRotate(stateObject, controller);
  16510. });
  16511. }
  16512. };
  16513. VRExperienceHelper.prototype._createTeleportationCircles = function () {
  16514. this._teleportationTarget = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateGround("teleportationTarget", 2, 2, 2, this._scene);
  16515. this._teleportationTarget.isPickable = false;
  16516. var length = 512;
  16517. var dynamicTexture = new _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__["DynamicTexture"]("DynamicTexture", length, this._scene, true);
  16518. dynamicTexture.hasAlpha = true;
  16519. var context = dynamicTexture.getContext();
  16520. var centerX = length / 2;
  16521. var centerY = length / 2;
  16522. var radius = 200;
  16523. context.beginPath();
  16524. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  16525. context.fillStyle = this._teleportationFillColor;
  16526. context.fill();
  16527. context.lineWidth = 10;
  16528. context.strokeStyle = this._teleportationBorderColor;
  16529. context.stroke();
  16530. context.closePath();
  16531. dynamicTexture.update();
  16532. var teleportationCircleMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("TextPlaneMaterial", this._scene);
  16533. teleportationCircleMaterial.diffuseTexture = dynamicTexture;
  16534. this._teleportationTarget.material = teleportationCircleMaterial;
  16535. var torus = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("torusTeleportation", 0.75, 0.1, 25, this._scene, false);
  16536. torus.isPickable = false;
  16537. torus.parent = this._teleportationTarget;
  16538. 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);
  16539. var keys = [];
  16540. keys.push({
  16541. frame: 0,
  16542. value: 0
  16543. });
  16544. keys.push({
  16545. frame: 30,
  16546. value: 0.4
  16547. });
  16548. keys.push({
  16549. frame: 60,
  16550. value: 0
  16551. });
  16552. animationInnerCircle.setKeys(keys);
  16553. var easingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["SineEase"]();
  16554. easingFunction.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16555. animationInnerCircle.setEasingFunction(easingFunction);
  16556. torus.animations = [];
  16557. torus.animations.push(animationInnerCircle);
  16558. this._scene.beginAnimation(torus, 0, 60, true);
  16559. this._hideTeleportationTarget();
  16560. };
  16561. VRExperienceHelper.prototype._displayTeleportationTarget = function () {
  16562. this._teleportActive = true;
  16563. if (this._teleportationInitialized) {
  16564. this._teleportationTarget.isVisible = true;
  16565. if (this._isDefaultTeleportationTarget) {
  16566. this._teleportationTarget.getChildren()[0].isVisible = true;
  16567. }
  16568. }
  16569. };
  16570. VRExperienceHelper.prototype._hideTeleportationTarget = function () {
  16571. this._teleportActive = false;
  16572. if (this._teleportationInitialized) {
  16573. this._teleportationTarget.isVisible = false;
  16574. if (this._isDefaultTeleportationTarget) {
  16575. this._teleportationTarget.getChildren()[0].isVisible = false;
  16576. }
  16577. }
  16578. };
  16579. VRExperienceHelper.prototype._rotateCamera = function (right) {
  16580. var _this = this;
  16581. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  16582. return;
  16583. }
  16584. if (right) {
  16585. this._rotationAngle++;
  16586. }
  16587. else {
  16588. this._rotationAngle--;
  16589. }
  16590. this.currentVRCamera.animations = [];
  16591. var target = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].RotationY(Math.PI / 4 * this._rotationAngle));
  16592. 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);
  16593. var animationRotationKeys = [];
  16594. animationRotationKeys.push({
  16595. frame: 0,
  16596. value: this.currentVRCamera.rotationQuaternion
  16597. });
  16598. animationRotationKeys.push({
  16599. frame: 6,
  16600. value: target
  16601. });
  16602. animationRotation.setKeys(animationRotationKeys);
  16603. animationRotation.setEasingFunction(this._circleEase);
  16604. this.currentVRCamera.animations.push(animationRotation);
  16605. this._postProcessMove.animations = [];
  16606. 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);
  16607. var vignetteWeightKeys = [];
  16608. vignetteWeightKeys.push({
  16609. frame: 0,
  16610. value: 0
  16611. });
  16612. vignetteWeightKeys.push({
  16613. frame: 3,
  16614. value: 4
  16615. });
  16616. vignetteWeightKeys.push({
  16617. frame: 6,
  16618. value: 0
  16619. });
  16620. animationPP.setKeys(vignetteWeightKeys);
  16621. animationPP.setEasingFunction(this._circleEase);
  16622. this._postProcessMove.animations.push(animationPP);
  16623. 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);
  16624. var vignetteStretchKeys = [];
  16625. vignetteStretchKeys.push({
  16626. frame: 0,
  16627. value: 0
  16628. });
  16629. vignetteStretchKeys.push({
  16630. frame: 3,
  16631. value: 10
  16632. });
  16633. vignetteStretchKeys.push({
  16634. frame: 6,
  16635. value: 0
  16636. });
  16637. animationPP2.setKeys(vignetteStretchKeys);
  16638. animationPP2.setEasingFunction(this._circleEase);
  16639. this._postProcessMove.animations.push(animationPP2);
  16640. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  16641. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  16642. this._postProcessMove.samples = 4;
  16643. this._webVRCamera.attachPostProcess(this._postProcessMove);
  16644. this._scene.beginAnimation(this._postProcessMove, 0, 6, false, 1, function () {
  16645. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  16646. });
  16647. this._scene.beginAnimation(this.currentVRCamera, 0, 6, false, 1);
  16648. };
  16649. VRExperienceHelper.prototype._moveTeleportationSelectorTo = function (hit, gazer, ray) {
  16650. if (hit.pickedPoint) {
  16651. if (gazer._teleportationRequestInitiated) {
  16652. this._displayTeleportationTarget();
  16653. this._haloCenter.copyFrom(hit.pickedPoint);
  16654. this._teleportationTarget.position.copyFrom(hit.pickedPoint);
  16655. }
  16656. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(true, false), ray);
  16657. if (pickNormal) {
  16658. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  16659. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  16660. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, this._teleportationTarget.rotation);
  16661. }
  16662. this._teleportationTarget.position.y += 0.1;
  16663. }
  16664. };
  16665. /**
  16666. * Teleports the users feet to the desired location
  16667. * @param location The location where the user's feet should be placed
  16668. */
  16669. VRExperienceHelper.prototype.teleportCamera = function (location) {
  16670. var _this = this;
  16671. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  16672. return;
  16673. }
  16674. // Teleport the hmd to where the user is looking by moving the anchor to where they are looking minus the
  16675. // offset of the headset from the anchor.
  16676. if (this.webVRCamera.leftCamera) {
  16677. this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition);
  16678. this._workingVector.subtractInPlace(this.webVRCamera.position);
  16679. location.subtractToRef(this._workingVector, this._workingVector);
  16680. }
  16681. else {
  16682. this._workingVector.copyFrom(location);
  16683. }
  16684. // Add height to account for user's height offset
  16685. if (this.isInVRMode) {
  16686. this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor;
  16687. }
  16688. else {
  16689. this._workingVector.y += this._defaultHeight;
  16690. }
  16691. this.onBeforeCameraTeleport.notifyObservers(this._workingVector);
  16692. // Create animation from the camera's position to the new location
  16693. this.currentVRCamera.animations = [];
  16694. 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);
  16695. var animationCameraTeleportationKeys = [{
  16696. frame: 0,
  16697. value: this.currentVRCamera.position
  16698. },
  16699. {
  16700. frame: 11,
  16701. value: this._workingVector
  16702. }
  16703. ];
  16704. animationCameraTeleportation.setKeys(animationCameraTeleportationKeys);
  16705. animationCameraTeleportation.setEasingFunction(this._circleEase);
  16706. this.currentVRCamera.animations.push(animationCameraTeleportation);
  16707. this._postProcessMove.animations = [];
  16708. 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);
  16709. var vignetteWeightKeys = [];
  16710. vignetteWeightKeys.push({
  16711. frame: 0,
  16712. value: 0
  16713. });
  16714. vignetteWeightKeys.push({
  16715. frame: 5,
  16716. value: 8
  16717. });
  16718. vignetteWeightKeys.push({
  16719. frame: 11,
  16720. value: 0
  16721. });
  16722. animationPP.setKeys(vignetteWeightKeys);
  16723. this._postProcessMove.animations.push(animationPP);
  16724. 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);
  16725. var vignetteStretchKeys = [];
  16726. vignetteStretchKeys.push({
  16727. frame: 0,
  16728. value: 0
  16729. });
  16730. vignetteStretchKeys.push({
  16731. frame: 5,
  16732. value: 10
  16733. });
  16734. vignetteStretchKeys.push({
  16735. frame: 11,
  16736. value: 0
  16737. });
  16738. animationPP2.setKeys(vignetteStretchKeys);
  16739. this._postProcessMove.animations.push(animationPP2);
  16740. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  16741. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  16742. this._webVRCamera.attachPostProcess(this._postProcessMove);
  16743. this._scene.beginAnimation(this._postProcessMove, 0, 11, false, 1, function () {
  16744. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  16745. });
  16746. this._scene.beginAnimation(this.currentVRCamera, 0, 11, false, 1, function () {
  16747. _this.onAfterCameraTeleport.notifyObservers(_this._workingVector);
  16748. });
  16749. this._hideTeleportationTarget();
  16750. };
  16751. VRExperienceHelper.prototype._convertNormalToDirectionOfRay = function (normal, ray) {
  16752. if (normal) {
  16753. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Dot(normal, ray.direction));
  16754. if (angle < Math.PI / 2) {
  16755. normal.scaleInPlace(-1);
  16756. }
  16757. }
  16758. return normal;
  16759. };
  16760. VRExperienceHelper.prototype._castRayAndSelectObject = function (gazer) {
  16761. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  16762. return;
  16763. }
  16764. var ray = gazer._getForwardRay(this._rayLength);
  16765. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  16766. if (hit) {
  16767. // Populate the contrllers mesh that can be used for drag/drop
  16768. if (gazer._laserPointer) {
  16769. hit.originMesh = gazer._laserPointer.parent;
  16770. }
  16771. this._scene.simulatePointerMove(hit, { pointerId: gazer._id });
  16772. }
  16773. gazer._currentHit = hit;
  16774. // Moving the gazeTracker on the mesh face targetted
  16775. if (hit && hit.pickedPoint) {
  16776. if (this._displayGaze) {
  16777. var multiplier = 1;
  16778. gazer._gazeTracker.isVisible = true;
  16779. if (gazer._isActionableMesh) {
  16780. multiplier = 3;
  16781. }
  16782. if (this.updateGazeTrackerScale) {
  16783. gazer._gazeTracker.scaling.x = hit.distance * multiplier;
  16784. gazer._gazeTracker.scaling.y = hit.distance * multiplier;
  16785. gazer._gazeTracker.scaling.z = hit.distance * multiplier;
  16786. }
  16787. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(), ray);
  16788. // To avoid z-fighting
  16789. var deltaFighting = 0.002;
  16790. if (pickNormal) {
  16791. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  16792. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  16793. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, gazer._gazeTracker.rotation);
  16794. }
  16795. gazer._gazeTracker.position.copyFrom(hit.pickedPoint);
  16796. if (gazer._gazeTracker.position.x < 0) {
  16797. gazer._gazeTracker.position.x += deltaFighting;
  16798. }
  16799. else {
  16800. gazer._gazeTracker.position.x -= deltaFighting;
  16801. }
  16802. if (gazer._gazeTracker.position.y < 0) {
  16803. gazer._gazeTracker.position.y += deltaFighting;
  16804. }
  16805. else {
  16806. gazer._gazeTracker.position.y -= deltaFighting;
  16807. }
  16808. if (gazer._gazeTracker.position.z < 0) {
  16809. gazer._gazeTracker.position.z += deltaFighting;
  16810. }
  16811. else {
  16812. gazer._gazeTracker.position.z -= deltaFighting;
  16813. }
  16814. }
  16815. // Changing the size of the laser pointer based on the distance from the targetted point
  16816. gazer._updatePointerDistance(hit.distance);
  16817. }
  16818. else {
  16819. gazer._updatePointerDistance();
  16820. gazer._gazeTracker.isVisible = false;
  16821. }
  16822. if (hit && hit.pickedMesh) {
  16823. // The object selected is the floor, we're in a teleportation scenario
  16824. if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
  16825. // Moving the teleportation area to this targetted point
  16826. //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
  16827. if (gazer._currentMeshSelected && !this._isTeleportationFloor(gazer._currentMeshSelected)) {
  16828. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  16829. }
  16830. gazer._currentMeshSelected = null;
  16831. if (gazer._teleportationRequestInitiated) {
  16832. this._moveTeleportationSelectorTo(hit, gazer, ray);
  16833. }
  16834. return;
  16835. }
  16836. // If not, we're in a selection scenario
  16837. //this._teleportationAllowed = false;
  16838. if (hit.pickedMesh !== gazer._currentMeshSelected) {
  16839. if (this.meshSelectionPredicate(hit.pickedMesh)) {
  16840. this.onNewMeshPicked.notifyObservers(hit);
  16841. gazer._currentMeshSelected = hit.pickedMesh;
  16842. if (hit.pickedMesh.isPickable && hit.pickedMesh.actionManager) {
  16843. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0, 0, 1));
  16844. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.2, 0.2, 1));
  16845. gazer._isActionableMesh = true;
  16846. }
  16847. else {
  16848. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  16849. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  16850. gazer._isActionableMesh = false;
  16851. }
  16852. try {
  16853. this.onNewMeshSelected.notifyObservers(hit.pickedMesh);
  16854. }
  16855. catch (err) {
  16856. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onNewMeshSelected: " + err);
  16857. }
  16858. }
  16859. else {
  16860. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  16861. gazer._currentMeshSelected = null;
  16862. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  16863. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  16864. }
  16865. }
  16866. }
  16867. else {
  16868. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  16869. gazer._currentMeshSelected = null;
  16870. //this._teleportationAllowed = false;
  16871. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  16872. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  16873. }
  16874. };
  16875. VRExperienceHelper.prototype._notifySelectedMeshUnselected = function (mesh) {
  16876. if (mesh) {
  16877. this.onSelectedMeshUnselected.notifyObservers(mesh);
  16878. }
  16879. };
  16880. /**
  16881. * Sets the color of the laser ray from the vr controllers.
  16882. * @param color new color for the ray.
  16883. */
  16884. VRExperienceHelper.prototype.changeLaserColor = function (color) {
  16885. if (this._leftController) {
  16886. this._leftController._setLaserPointerColor(color);
  16887. }
  16888. if (this._rightController) {
  16889. this._rightController._setLaserPointerColor(color);
  16890. }
  16891. };
  16892. /**
  16893. * Sets the color of the ray from the vr headsets gaze.
  16894. * @param color new color for the ray.
  16895. */
  16896. VRExperienceHelper.prototype.changeGazeColor = function (color) {
  16897. if (!this.updateGazeTrackerColor) {
  16898. return;
  16899. }
  16900. if (!this._cameraGazer._gazeTracker.material) {
  16901. return;
  16902. }
  16903. this._cameraGazer._gazeTracker.material.emissiveColor = color;
  16904. if (this._leftController) {
  16905. this._leftController._gazeTracker.material.emissiveColor = color;
  16906. }
  16907. if (this._rightController) {
  16908. this._rightController._gazeTracker.material.emissiveColor = color;
  16909. }
  16910. };
  16911. /**
  16912. * Exits VR and disposes of the vr experience helper
  16913. */
  16914. VRExperienceHelper.prototype.dispose = function () {
  16915. if (this.isInVRMode) {
  16916. this.exitVR();
  16917. }
  16918. if (this._postProcessMove) {
  16919. this._postProcessMove.dispose();
  16920. }
  16921. if (this._webVRCamera) {
  16922. this._webVRCamera.dispose();
  16923. }
  16924. if (this._vrDeviceOrientationCamera) {
  16925. this._vrDeviceOrientationCamera.dispose();
  16926. }
  16927. if (!this._useCustomVRButton && this._btnVR.parentNode) {
  16928. document.body.removeChild(this._btnVR);
  16929. }
  16930. if (this._deviceOrientationCamera && (this._scene.activeCamera != this._deviceOrientationCamera)) {
  16931. this._deviceOrientationCamera.dispose();
  16932. }
  16933. if (this._cameraGazer) {
  16934. this._cameraGazer.dispose();
  16935. }
  16936. if (this._leftController) {
  16937. this._leftController.dispose();
  16938. }
  16939. if (this._rightController) {
  16940. this._rightController.dispose();
  16941. }
  16942. if (this._teleportationTarget) {
  16943. this._teleportationTarget.dispose();
  16944. }
  16945. this._floorMeshesCollection = [];
  16946. document.removeEventListener("keydown", this._onKeyDown);
  16947. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  16948. window.removeEventListener("resize", this._onResize);
  16949. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  16950. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  16951. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  16952. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  16953. document.onmsfullscreenchange = null;
  16954. this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged);
  16955. this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart);
  16956. this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete);
  16957. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  16958. this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected);
  16959. this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected);
  16960. this._scene.unregisterBeforeRender(this.beforeRender);
  16961. };
  16962. /**
  16963. * Gets the name of the VRExperienceHelper class
  16964. * @returns "VRExperienceHelper"
  16965. */
  16966. VRExperienceHelper.prototype.getClassName = function () {
  16967. return "VRExperienceHelper";
  16968. };
  16969. return VRExperienceHelper;
  16970. }());
  16971. /***/ }),
  16972. /***/ "./Cameras/VR/webVRCamera.ts":
  16973. /*!***********************************!*\
  16974. !*** ./Cameras/VR/webVRCamera.ts ***!
  16975. \***********************************/
  16976. /*! exports provided: WebVRFreeCamera */
  16977. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16978. "use strict";
  16979. __webpack_require__.r(__webpack_exports__);
  16980. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return WebVRFreeCamera; });
  16981. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  16982. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  16983. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  16984. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  16985. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  16986. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  16987. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  16988. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../node */ "./node.ts");
  16989. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  16990. /* harmony import */ var _RigModes_webVRRigMode__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../RigModes/webVRRigMode */ "./Cameras/RigModes/webVRRigMode.ts");
  16991. // Side effect import to define the stereoscopic mode.
  16992. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRFreeCamera", function (name, scene) {
  16993. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  16994. });
  16995. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRGamepadCamera", function (name, scene) {
  16996. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  16997. });
  16998. /**
  16999. * This represents a WebVR camera.
  17000. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17001. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17002. */
  17003. var WebVRFreeCamera = /** @class */ (function (_super) {
  17004. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRFreeCamera, _super);
  17005. /**
  17006. * Instantiates a WebVRFreeCamera.
  17007. * @param name The name of the WebVRFreeCamera
  17008. * @param position The starting anchor position for the camera
  17009. * @param scene The scene the camera belongs to
  17010. * @param webVROptions a set of customizable options for the webVRCamera
  17011. */
  17012. function WebVRFreeCamera(name, position, scene, webVROptions) {
  17013. if (webVROptions === void 0) { webVROptions = {}; }
  17014. var _this = _super.call(this, name, position, scene) || this;
  17015. _this.webVROptions = webVROptions;
  17016. /**
  17017. * @hidden
  17018. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17019. */
  17020. _this._vrDevice = null;
  17021. /**
  17022. * The rawPose of the vrDevice.
  17023. */
  17024. _this.rawPose = null;
  17025. _this._specsVersion = "1.1";
  17026. _this._attached = false;
  17027. _this._descendants = [];
  17028. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  17029. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17030. /** @hidden */
  17031. _this._deviceRoomRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17032. _this._standingMatrix = null;
  17033. /**
  17034. * Represents device position in babylon space.
  17035. */
  17036. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17037. /**
  17038. * Represents device rotation in babylon space.
  17039. */
  17040. _this.deviceRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17041. /**
  17042. * The scale of the device to be used when translating from device space to babylon space.
  17043. */
  17044. _this.deviceScaleFactor = 1;
  17045. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17046. _this._worldToDevice = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17047. /**
  17048. * References to the webVR controllers for the vrDevice.
  17049. */
  17050. _this.controllers = [];
  17051. /**
  17052. * Emits an event when a controller is attached.
  17053. */
  17054. _this.onControllersAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17055. /**
  17056. * Emits an event when a controller's mesh has been loaded;
  17057. */
  17058. _this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17059. /**
  17060. * Emits an event when the HMD's pose has been updated.
  17061. */
  17062. _this.onPoseUpdatedFromDeviceObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17063. _this._poseSet = false;
  17064. /**
  17065. * If the rig cameras be used as parent instead of this camera.
  17066. */
  17067. _this.rigParenting = true;
  17068. _this._defaultHeight = undefined;
  17069. _this._htmlElementAttached = null;
  17070. _this._detachIfAttached = function () {
  17071. var vrDisplay = _this.getEngine().getVRDevice();
  17072. if (vrDisplay && !vrDisplay.isPresenting && _this._htmlElementAttached) {
  17073. _this.detachControl(_this._htmlElementAttached);
  17074. }
  17075. };
  17076. _this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17077. _this._oneVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].One();
  17078. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17079. _this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  17080. _this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17081. if (webVROptions.defaultHeight) {
  17082. _this._defaultHeight = webVROptions.defaultHeight;
  17083. _this.position.y = _this._defaultHeight;
  17084. }
  17085. _this.minZ = 0.1;
  17086. //legacy support - the compensation boolean was removed.
  17087. if (arguments.length === 5) {
  17088. _this.webVROptions = arguments[4];
  17089. }
  17090. // default webVR options
  17091. if (_this.webVROptions.trackPosition == undefined) {
  17092. _this.webVROptions.trackPosition = true;
  17093. }
  17094. if (_this.webVROptions.controllerMeshes == undefined) {
  17095. _this.webVROptions.controllerMeshes = true;
  17096. }
  17097. if (_this.webVROptions.defaultLightingOnControllers == undefined) {
  17098. _this.webVROptions.defaultLightingOnControllers = true;
  17099. }
  17100. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]();
  17101. if (_this.webVROptions && _this.webVROptions.positionScale) {
  17102. _this.deviceScaleFactor = _this.webVROptions.positionScale;
  17103. }
  17104. //enable VR
  17105. var engine = _this.getEngine();
  17106. _this._onVREnabled = function (success) { if (success) {
  17107. _this.initControllers();
  17108. } };
  17109. engine.onVRRequestPresentComplete.add(_this._onVREnabled);
  17110. engine.initWebVR().add(function (event) {
  17111. if (!event.vrDisplay || _this._vrDevice === event.vrDisplay) {
  17112. return;
  17113. }
  17114. _this._vrDevice = event.vrDisplay;
  17115. //reset the rig parameters.
  17116. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].RIG_MODE_WEBVR, { parentCamera: _this, vrDisplay: _this._vrDevice, frameData: _this._frameData, specs: _this._specsVersion });
  17117. if (_this._attached) {
  17118. _this.getEngine().enableVR();
  17119. }
  17120. });
  17121. if (typeof (VRFrameData) !== "undefined") {
  17122. _this._frameData = new VRFrameData();
  17123. }
  17124. /**
  17125. * The idea behind the following lines:
  17126. * objects that have the camera as parent should actually have the rig cameras as a parent.
  17127. * BUT, each of those cameras has a different view matrix, which means that if we set the parent to the first rig camera,
  17128. * the second will not show it correctly.
  17129. *
  17130. * To solve this - each object that has the camera as parent will be added to a protected array.
  17131. * When the rig camera renders, it will take this array and set all of those to be its children.
  17132. * This way, the right camera will be used as a parent, and the mesh will be rendered correctly.
  17133. * Amazing!
  17134. */
  17135. scene.onBeforeCameraRenderObservable.add(function (camera) {
  17136. if (camera.parent === _this && _this.rigParenting) {
  17137. _this._descendants = _this.getDescendants(true, function (n) {
  17138. // don't take the cameras or the controllers!
  17139. var isController = _this.controllers.some(function (controller) { return controller._mesh === n; });
  17140. var isRigCamera = _this._rigCameras.indexOf(n) !== -1;
  17141. return !isController && !isRigCamera;
  17142. });
  17143. _this._descendants.forEach(function (node) {
  17144. node.parent = camera;
  17145. });
  17146. }
  17147. });
  17148. scene.onAfterCameraRenderObservable.add(function (camera) {
  17149. if (camera.parent === _this && _this.rigParenting) {
  17150. _this._descendants.forEach(function (node) {
  17151. node.parent = _this;
  17152. });
  17153. }
  17154. });
  17155. return _this;
  17156. }
  17157. /**
  17158. * Gets the device distance from the ground in meters.
  17159. * @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.
  17160. */
  17161. WebVRFreeCamera.prototype.deviceDistanceToRoomGround = function () {
  17162. if (this._standingMatrix) {
  17163. // Add standing matrix offset to get real offset from ground in room
  17164. this._standingMatrix.getTranslationToRef(this._workingVector);
  17165. return this._deviceRoomPosition.y + this._workingVector.y;
  17166. }
  17167. //If VRDisplay does not inform stage parameters and no default height is set we fallback to zero.
  17168. return this._defaultHeight || 0;
  17169. };
  17170. /**
  17171. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17172. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  17173. */
  17174. WebVRFreeCamera.prototype.useStandingMatrix = function (callback) {
  17175. var _this = this;
  17176. if (callback === void 0) { callback = function (bool) { }; }
  17177. // Use standing matrix if available
  17178. this.getEngine().initWebVRAsync().then(function (result) {
  17179. if (!result.vrDisplay || !result.vrDisplay.stageParameters || !result.vrDisplay.stageParameters.sittingToStandingTransform || !_this.webVROptions.trackPosition) {
  17180. callback(false);
  17181. }
  17182. else {
  17183. _this._standingMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  17184. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromFloat32ArrayToRefScaled(result.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, _this._standingMatrix);
  17185. if (!_this.getScene().useRightHandedSystem) {
  17186. if (_this._standingMatrix) {
  17187. _this._standingMatrix.toggleModelMatrixHandInPlace();
  17188. }
  17189. }
  17190. callback(true);
  17191. }
  17192. });
  17193. };
  17194. /**
  17195. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17196. * @returns A promise with a boolean set to if the standing matrix is supported.
  17197. */
  17198. WebVRFreeCamera.prototype.useStandingMatrixAsync = function () {
  17199. var _this = this;
  17200. return new Promise(function (res) {
  17201. _this.useStandingMatrix(function (supported) {
  17202. res(supported);
  17203. });
  17204. });
  17205. };
  17206. /**
  17207. * Disposes the camera
  17208. */
  17209. WebVRFreeCamera.prototype.dispose = function () {
  17210. this._detachIfAttached();
  17211. this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled);
  17212. if (this._updateCacheWhenTrackingDisabledObserver) {
  17213. this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver);
  17214. }
  17215. _super.prototype.dispose.call(this);
  17216. };
  17217. /**
  17218. * Gets a vrController by name.
  17219. * @param name The name of the controller to retreive
  17220. * @returns the controller matching the name specified or null if not found
  17221. */
  17222. WebVRFreeCamera.prototype.getControllerByName = function (name) {
  17223. for (var _i = 0, _a = this.controllers; _i < _a.length; _i++) {
  17224. var gp = _a[_i];
  17225. if (gp.hand === name) {
  17226. return gp;
  17227. }
  17228. }
  17229. return null;
  17230. };
  17231. Object.defineProperty(WebVRFreeCamera.prototype, "leftController", {
  17232. /**
  17233. * The controller corrisponding to the users left hand.
  17234. */
  17235. get: function () {
  17236. if (!this._leftController) {
  17237. this._leftController = this.getControllerByName("left");
  17238. }
  17239. return this._leftController;
  17240. },
  17241. enumerable: true,
  17242. configurable: true
  17243. });
  17244. Object.defineProperty(WebVRFreeCamera.prototype, "rightController", {
  17245. /**
  17246. * The controller corrisponding to the users right hand.
  17247. */
  17248. get: function () {
  17249. if (!this._rightController) {
  17250. this._rightController = this.getControllerByName("right");
  17251. }
  17252. return this._rightController;
  17253. },
  17254. enumerable: true,
  17255. configurable: true
  17256. });
  17257. /**
  17258. * Casts a ray forward from the vrCamera's gaze.
  17259. * @param length Length of the ray (default: 100)
  17260. * @returns the ray corrisponding to the gaze
  17261. */
  17262. WebVRFreeCamera.prototype.getForwardRay = function (length) {
  17263. if (length === void 0) { length = 100; }
  17264. if (this.leftCamera) {
  17265. // Use left eye to avoid computation to compute center on every call
  17266. return _super.prototype.getForwardRay.call(this, length, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition); // Need the actual rendered camera
  17267. }
  17268. else {
  17269. return _super.prototype.getForwardRay.call(this, length);
  17270. }
  17271. };
  17272. /**
  17273. * @hidden
  17274. * Updates the camera based on device's frame data
  17275. */
  17276. WebVRFreeCamera.prototype._checkInputs = function () {
  17277. if (this._vrDevice && this._vrDevice.isPresenting) {
  17278. this._vrDevice.getFrameData(this._frameData);
  17279. this.updateFromDevice(this._frameData.pose);
  17280. }
  17281. _super.prototype._checkInputs.call(this);
  17282. };
  17283. /**
  17284. * Updates the poseControlled values based on the input device pose.
  17285. * @param poseData Pose coming from the device
  17286. */
  17287. WebVRFreeCamera.prototype.updateFromDevice = function (poseData) {
  17288. if (poseData && poseData.orientation) {
  17289. this.rawPose = poseData;
  17290. this._deviceRoomRotationQuaternion.copyFromFloats(poseData.orientation[0], poseData.orientation[1], -poseData.orientation[2], -poseData.orientation[3]);
  17291. if (this.getScene().useRightHandedSystem) {
  17292. this._deviceRoomRotationQuaternion.z *= -1;
  17293. this._deviceRoomRotationQuaternion.w *= -1;
  17294. }
  17295. if (this.webVROptions.trackPosition && this.rawPose.position) {
  17296. this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]);
  17297. if (this.getScene().useRightHandedSystem) {
  17298. this._deviceRoomPosition.z *= -1;
  17299. }
  17300. }
  17301. this._poseSet = true;
  17302. }
  17303. };
  17304. /**
  17305. * WebVR's attach control will start broadcasting frames to the device.
  17306. * Note that in certain browsers (chrome for example) this function must be called
  17307. * within a user-interaction callback. Example:
  17308. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  17309. *
  17310. * @param element html element to attach the vrDevice to
  17311. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  17312. */
  17313. WebVRFreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  17314. _super.prototype.attachControl.call(this, element, noPreventDefault);
  17315. this._attached = true;
  17316. this._htmlElementAttached = element;
  17317. noPreventDefault = _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  17318. if (this._vrDevice) {
  17319. this.getEngine().enableVR();
  17320. }
  17321. window.addEventListener('vrdisplaypresentchange', this._detachIfAttached);
  17322. };
  17323. /**
  17324. * Detaches the camera from the html element and disables VR
  17325. *
  17326. * @param element html element to detach from
  17327. */
  17328. WebVRFreeCamera.prototype.detachControl = function (element) {
  17329. this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  17330. this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  17331. _super.prototype.detachControl.call(this, element);
  17332. this._attached = false;
  17333. this.getEngine().disableVR();
  17334. window.removeEventListener('vrdisplaypresentchange', this._detachIfAttached);
  17335. };
  17336. /**
  17337. * @returns the name of this class
  17338. */
  17339. WebVRFreeCamera.prototype.getClassName = function () {
  17340. return "WebVRFreeCamera";
  17341. };
  17342. /**
  17343. * Calls resetPose on the vrDisplay
  17344. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  17345. */
  17346. WebVRFreeCamera.prototype.resetToCurrentRotation = function () {
  17347. //uses the vrDisplay's "resetPose()".
  17348. //pitch and roll won't be affected.
  17349. this._vrDevice.resetPose();
  17350. };
  17351. /**
  17352. * @hidden
  17353. * Updates the rig cameras (left and right eye)
  17354. */
  17355. WebVRFreeCamera.prototype._updateRigCameras = function () {
  17356. var camLeft = this._rigCameras[0];
  17357. var camRight = this._rigCameras[1];
  17358. camLeft.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  17359. camRight.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  17360. camLeft.position.copyFrom(this._deviceRoomPosition);
  17361. camRight.position.copyFrom(this._deviceRoomPosition);
  17362. };
  17363. // Remove translation from 6dof headset if trackposition is set to false
  17364. WebVRFreeCamera.prototype._correctPositionIfNotTrackPosition = function (matrix, isViewMatrix) {
  17365. if (isViewMatrix === void 0) { isViewMatrix = false; }
  17366. if (this.rawPose && this.rawPose.position && !this.webVROptions.trackPosition) {
  17367. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix);
  17368. if (!isViewMatrix) {
  17369. this._tmpMatrix.invert();
  17370. }
  17371. this._tmpMatrix.multiplyToRef(matrix, matrix);
  17372. }
  17373. };
  17374. /**
  17375. * @hidden
  17376. * Updates the cached values of the camera
  17377. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  17378. */
  17379. WebVRFreeCamera.prototype._updateCache = function (ignoreParentClass) {
  17380. var _this = this;
  17381. if (!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)) {
  17382. // Update to ensure devicePosition is up to date with most recent _deviceRoomPosition
  17383. if (!this.updateCacheCalled) {
  17384. // make sure it is only called once per loop. this.update() might cause an infinite loop.
  17385. this.updateCacheCalled = true;
  17386. this.update();
  17387. }
  17388. // Set working vector to the device position in room space rotated by the new rotation
  17389. this.rotationQuaternion.toRotationMatrix(this._workingMatrix);
  17390. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector);
  17391. // Subtract this vector from the current device position in world to get the translation for the device world matrix
  17392. this.devicePosition.subtractToRef(this._workingVector, this._workingVector);
  17393. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld);
  17394. // Add translation from anchor position
  17395. this._deviceToWorld.getTranslationToRef(this._workingVector);
  17396. this._workingVector.addInPlace(this.position);
  17397. this._workingVector.subtractInPlace(this._cache.position);
  17398. this._deviceToWorld.setTranslation(this._workingVector);
  17399. // Set an inverted matrix to be used when updating the camera
  17400. this._deviceToWorld.invertToRef(this._worldToDevice);
  17401. // Update the gamepad to ensure the mesh is updated on the same frame as camera
  17402. this.controllers.forEach(function (controller) {
  17403. controller._deviceToWorld.copyFrom(_this._deviceToWorld);
  17404. _this._correctPositionIfNotTrackPosition(controller._deviceToWorld);
  17405. controller.update();
  17406. });
  17407. }
  17408. if (!ignoreParentClass) {
  17409. _super.prototype._updateCache.call(this);
  17410. }
  17411. this.updateCacheCalled = false;
  17412. };
  17413. /**
  17414. * @hidden
  17415. * Get current device position in babylon world
  17416. */
  17417. WebVRFreeCamera.prototype._computeDevicePosition = function () {
  17418. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition);
  17419. };
  17420. /**
  17421. * Updates the current device position and rotation in the babylon world
  17422. */
  17423. WebVRFreeCamera.prototype.update = function () {
  17424. this._computeDevicePosition();
  17425. // Get current device rotation in babylon world
  17426. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix);
  17427. this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix);
  17428. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  17429. if (this._poseSet) {
  17430. this.onPoseUpdatedFromDeviceObservable.notifyObservers(null);
  17431. }
  17432. _super.prototype.update.call(this);
  17433. };
  17434. /**
  17435. * @hidden
  17436. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  17437. * @returns an identity matrix
  17438. */
  17439. WebVRFreeCamera.prototype._getViewMatrix = function () {
  17440. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17441. };
  17442. /**
  17443. * This function is called by the two RIG cameras.
  17444. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  17445. * @hidden
  17446. */
  17447. WebVRFreeCamera.prototype._getWebVRViewMatrix = function () {
  17448. // Update the parent camera prior to using a child camera to avoid desynchronization
  17449. var parentCamera = this._cameraRigParams["parentCamera"];
  17450. parentCamera._updateCache();
  17451. //WebVR 1.1
  17452. var viewArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftViewMatrix : this._cameraRigParams["frameData"].rightViewMatrix;
  17453. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(viewArray, 0, this._webvrViewMatrix);
  17454. if (!this.getScene().useRightHandedSystem) {
  17455. this._webvrViewMatrix.toggleModelMatrixHandInPlace();
  17456. }
  17457. // update the camera rotation matrix
  17458. this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix);
  17459. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  17460. // Computing target and final matrix
  17461. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  17462. // should the view matrix be updated with scale and position offset?
  17463. if (parentCamera.deviceScaleFactor !== 1) {
  17464. this._webvrViewMatrix.invert();
  17465. // scale the position, if set
  17466. if (parentCamera.deviceScaleFactor) {
  17467. this._webvrViewMatrix.multiplyAtIndex(12, parentCamera.deviceScaleFactor);
  17468. this._webvrViewMatrix.multiplyAtIndex(13, parentCamera.deviceScaleFactor);
  17469. this._webvrViewMatrix.multiplyAtIndex(14, parentCamera.deviceScaleFactor);
  17470. }
  17471. this._webvrViewMatrix.invert();
  17472. }
  17473. // Remove translation from 6dof headset if trackposition is set to false
  17474. parentCamera._correctPositionIfNotTrackPosition(this._webvrViewMatrix, true);
  17475. parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
  17476. // Compute global position
  17477. this._workingMatrix = this._workingMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17478. this._webvrViewMatrix.invertToRef(this._workingMatrix);
  17479. this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
  17480. this._workingMatrix.getTranslationToRef(this._globalPosition);
  17481. this._markSyncedWithParent();
  17482. return this._webvrViewMatrix;
  17483. };
  17484. /** @hidden */
  17485. WebVRFreeCamera.prototype._getWebVRProjectionMatrix = function () {
  17486. var parentCamera = this.parent;
  17487. parentCamera._vrDevice.depthNear = parentCamera.minZ;
  17488. parentCamera._vrDevice.depthFar = parentCamera.maxZ;
  17489. var projectionArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftProjectionMatrix : this._cameraRigParams["frameData"].rightProjectionMatrix;
  17490. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(projectionArray, 0, this._projectionMatrix);
  17491. //babylon compatible matrix
  17492. if (!this.getScene().useRightHandedSystem) {
  17493. this._projectionMatrix.toggleProjectionMatrixHandInPlace();
  17494. }
  17495. return this._projectionMatrix;
  17496. };
  17497. /**
  17498. * Initializes the controllers and their meshes
  17499. */
  17500. WebVRFreeCamera.prototype.initControllers = function () {
  17501. var _this = this;
  17502. this.controllers = [];
  17503. var manager = this.getScene().gamepadManager;
  17504. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  17505. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  17506. var webVrController = gamepad;
  17507. if (webVrController.defaultModel) {
  17508. webVrController.defaultModel.setEnabled(false);
  17509. }
  17510. if (webVrController.hand === "right") {
  17511. _this._rightController = null;
  17512. }
  17513. if (webVrController.hand === "left") {
  17514. _this._leftController = null;
  17515. }
  17516. var controllerIndex = _this.controllers.indexOf(webVrController);
  17517. if (controllerIndex !== -1) {
  17518. _this.controllers.splice(controllerIndex, 1);
  17519. }
  17520. }
  17521. });
  17522. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  17523. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  17524. var webVrController_1 = gamepad;
  17525. if (!_this.webVROptions.trackPosition) {
  17526. webVrController_1._disableTrackPosition(new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](webVrController_1.hand == "left" ? -0.15 : 0.15, -0.5, 0.25));
  17527. // Cache must be updated before rendering controllers to avoid them being one frame behind
  17528. if (!_this._updateCacheWhenTrackingDisabledObserver) {
  17529. _this._updateCacheWhenTrackingDisabledObserver = _this._scene.onBeforeRenderObservable.add(function () {
  17530. _this._updateCache();
  17531. });
  17532. }
  17533. }
  17534. webVrController_1.deviceScaleFactor = _this.deviceScaleFactor;
  17535. webVrController_1._deviceToWorld.copyFrom(_this._deviceToWorld);
  17536. _this._correctPositionIfNotTrackPosition(webVrController_1._deviceToWorld);
  17537. if (_this.webVROptions.controllerMeshes) {
  17538. if (webVrController_1.defaultModel) {
  17539. webVrController_1.defaultModel.setEnabled(true);
  17540. }
  17541. else {
  17542. // Load the meshes
  17543. webVrController_1.initControllerMesh(_this.getScene(), function (loadedMesh) {
  17544. loadedMesh.scaling.scaleInPlace(_this.deviceScaleFactor);
  17545. _this.onControllerMeshLoadedObservable.notifyObservers(webVrController_1);
  17546. if (_this.webVROptions.defaultLightingOnControllers) {
  17547. if (!_this._lightOnControllers) {
  17548. _this._lightOnControllers = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__["HemisphericLight"]("vrControllersLight", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 1, 0), _this.getScene());
  17549. }
  17550. var activateLightOnSubMeshes_1 = function (mesh, light) {
  17551. var children = mesh.getChildren();
  17552. if (children && children.length !== 0) {
  17553. children.forEach(function (mesh) {
  17554. light.includedOnlyMeshes.push(mesh);
  17555. activateLightOnSubMeshes_1(mesh, light);
  17556. });
  17557. }
  17558. };
  17559. _this._lightOnControllers.includedOnlyMeshes.push(loadedMesh);
  17560. activateLightOnSubMeshes_1(loadedMesh, _this._lightOnControllers);
  17561. }
  17562. });
  17563. }
  17564. }
  17565. webVrController_1.attachToPoseControlledCamera(_this);
  17566. // since this is async - sanity check. Is the controller already stored?
  17567. if (_this.controllers.indexOf(webVrController_1) === -1) {
  17568. //add to the controllers array
  17569. _this.controllers.push(webVrController_1);
  17570. // Forced to add some control code for Vive as it doesn't always fill properly the "hand" property
  17571. // Sometimes, both controllers are set correctly (left and right), sometimes none, sometimes only one of them...
  17572. // So we're overriding setting left & right manually to be sure
  17573. var firstViveWandDetected = false;
  17574. for (var i = 0; i < _this.controllers.length; i++) {
  17575. if (_this.controllers[i].controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__["PoseEnabledControllerType"].VIVE) {
  17576. if (!firstViveWandDetected) {
  17577. firstViveWandDetected = true;
  17578. _this.controllers[i].hand = "left";
  17579. }
  17580. else {
  17581. _this.controllers[i].hand = "right";
  17582. }
  17583. }
  17584. }
  17585. //did we find enough controllers? Great! let the developer know.
  17586. if (_this.controllers.length >= 2) {
  17587. _this.onControllersAttachedObservable.notifyObservers(_this.controllers);
  17588. }
  17589. }
  17590. }
  17591. });
  17592. };
  17593. return WebVRFreeCamera;
  17594. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  17595. /***/ }),
  17596. /***/ "./Cameras/XR/index.ts":
  17597. /*!*****************************!*\
  17598. !*** ./Cameras/XR/index.ts ***!
  17599. \*****************************/
  17600. /*! exports provided: WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  17601. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17602. "use strict";
  17603. __webpack_require__.r(__webpack_exports__);
  17604. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  17605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _webXRCamera__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  17606. /* harmony import */ var _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  17607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIButton"]; });
  17608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIOptions"]; });
  17609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUI"]; });
  17610. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  17611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"]; });
  17612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRExperienceHelper"]; });
  17613. /* harmony import */ var _webXRInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRInput */ "./Cameras/XR/webXRInput.ts");
  17614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRController"]; });
  17615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRInput"]; });
  17616. /* harmony import */ var _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  17617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__["WebXRManagedOutputCanvas"]; });
  17618. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  17619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__["WebXRSessionManager"]; });
  17620. /***/ }),
  17621. /***/ "./Cameras/XR/webXRCamera.ts":
  17622. /*!***********************************!*\
  17623. !*** ./Cameras/XR/webXRCamera.ts ***!
  17624. \***********************************/
  17625. /*! exports provided: WebXRCamera */
  17626. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17627. "use strict";
  17628. __webpack_require__.r(__webpack_exports__);
  17629. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return WebXRCamera; });
  17630. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  17631. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17632. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  17633. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  17634. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  17635. /**
  17636. * WebXR Camera which holds the views for the xrSession
  17637. * @see https://doc.babylonjs.com/how_to/webxr
  17638. */
  17639. var WebXRCamera = /** @class */ (function (_super) {
  17640. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebXRCamera, _super);
  17641. /**
  17642. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  17643. * @param name the name of the camera
  17644. * @param scene the scene to add the camera to
  17645. */
  17646. function WebXRCamera(name, scene) {
  17647. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), scene) || this;
  17648. // Initial camera configuration
  17649. _this.minZ = 0;
  17650. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  17651. _this.cameraRigMode = _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_CUSTOM;
  17652. _this.updateUpVectorFromRotation = true;
  17653. _this._updateNumberOfRigCameras(1);
  17654. return _this;
  17655. }
  17656. WebXRCamera.prototype._updateNumberOfRigCameras = function (viewCount) {
  17657. if (viewCount === void 0) { viewCount = 1; }
  17658. while (this.rigCameras.length < viewCount) {
  17659. var newCamera = new _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]("view: " + this.rigCameras.length, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), this.getScene());
  17660. newCamera.minZ = 0;
  17661. newCamera.parent = this;
  17662. newCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  17663. newCamera.updateUpVectorFromRotation = true;
  17664. this.rigCameras.push(newCamera);
  17665. }
  17666. while (this.rigCameras.length > viewCount) {
  17667. var removedCamera = this.rigCameras.pop();
  17668. if (removedCamera) {
  17669. removedCamera.dispose();
  17670. }
  17671. }
  17672. };
  17673. /** @hidden */
  17674. WebXRCamera.prototype._updateForDualEyeDebugging = function (pupilDistance) {
  17675. if (pupilDistance === void 0) { pupilDistance = 0.01; }
  17676. // Create initial camera rigs
  17677. this._updateNumberOfRigCameras(2);
  17678. this.rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  17679. this.rigCameras[0].position.x = -pupilDistance / 2;
  17680. this.rigCameras[0].outputRenderTarget = null;
  17681. this.rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  17682. this.rigCameras[1].position.x = pupilDistance / 2;
  17683. this.rigCameras[1].outputRenderTarget = null;
  17684. };
  17685. /**
  17686. * Updates the cameras position from the current pose information of the XR session
  17687. * @param xrSessionManager the session containing pose information
  17688. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  17689. */
  17690. WebXRCamera.prototype.updateFromXRSessionManager = function (xrSessionManager) {
  17691. var _this = this;
  17692. // Ensure all frame data is available
  17693. if (!xrSessionManager._currentXRFrame || !xrSessionManager._currentXRFrame.getDevicePose) {
  17694. return false;
  17695. }
  17696. var pose = xrSessionManager._currentXRFrame.getDevicePose(xrSessionManager._frameOfReference);
  17697. if (!pose || !pose.poseModelMatrix) {
  17698. return false;
  17699. }
  17700. // Update the parent cameras matrix
  17701. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.poseModelMatrix, 0, 1, WebXRCamera._TmpMatrix);
  17702. if (!this._scene.useRightHandedSystem) {
  17703. WebXRCamera._TmpMatrix.toggleModelMatrixHandInPlace();
  17704. }
  17705. WebXRCamera._TmpMatrix.getTranslationToRef(this.position);
  17706. WebXRCamera._TmpMatrix.getRotationMatrixToRef(WebXRCamera._TmpMatrix);
  17707. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(WebXRCamera._TmpMatrix, this.rotationQuaternion);
  17708. this.computeWorldMatrix();
  17709. // Update camera rigs
  17710. this._updateNumberOfRigCameras(xrSessionManager._currentXRFrame.views.length);
  17711. xrSessionManager._currentXRFrame.views.forEach(function (view, i) {
  17712. // Update view/projection matrix
  17713. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.getViewMatrix(view), 0, 1, _this.rigCameras[i]._computedViewMatrix);
  17714. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, _this.rigCameras[i]._projectionMatrix);
  17715. if (!_this._scene.useRightHandedSystem) {
  17716. _this.rigCameras[i]._computedViewMatrix.toggleModelMatrixHandInPlace();
  17717. _this.rigCameras[i]._projectionMatrix.toggleProjectionMatrixHandInPlace();
  17718. }
  17719. // Update viewport
  17720. var viewport = xrSessionManager._xrSession.baseLayer.getViewport(view);
  17721. var width = xrSessionManager._xrSession.baseLayer.framebufferWidth;
  17722. var height = xrSessionManager._xrSession.baseLayer.framebufferHeight;
  17723. _this.rigCameras[i].viewport.width = viewport.width / width;
  17724. _this.rigCameras[i].viewport.height = viewport.height / height;
  17725. _this.rigCameras[i].viewport.x = viewport.x / width;
  17726. _this.rigCameras[i].viewport.y = viewport.y / height;
  17727. // Set cameras to render to the session's render target
  17728. _this.rigCameras[i].outputRenderTarget = xrSessionManager._sessionRenderTargetTexture;
  17729. });
  17730. return true;
  17731. };
  17732. WebXRCamera._TmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  17733. return WebXRCamera;
  17734. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"]));
  17735. /***/ }),
  17736. /***/ "./Cameras/XR/webXREnterExitUI.ts":
  17737. /*!****************************************!*\
  17738. !*** ./Cameras/XR/webXREnterExitUI.ts ***!
  17739. \****************************************/
  17740. /*! exports provided: WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI */
  17741. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17742. "use strict";
  17743. __webpack_require__.r(__webpack_exports__);
  17744. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return WebXREnterExitUIButton; });
  17745. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return WebXREnterExitUIOptions; });
  17746. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return WebXREnterExitUI; });
  17747. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  17748. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  17749. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  17750. /**
  17751. * Button which can be used to enter a different mode of XR
  17752. */
  17753. var WebXREnterExitUIButton = /** @class */ (function () {
  17754. /**
  17755. * Creates a WebXREnterExitUIButton
  17756. * @param element button element
  17757. * @param initializationOptions XR initialization options for the button
  17758. */
  17759. function WebXREnterExitUIButton(
  17760. /** button element */
  17761. element,
  17762. /** XR initialization options for the button */
  17763. initializationOptions) {
  17764. this.element = element;
  17765. this.initializationOptions = initializationOptions;
  17766. }
  17767. /**
  17768. * Overwritable function which can be used to update the button's visuals when the state changes
  17769. * @param activeButton the current active button in the UI
  17770. */
  17771. WebXREnterExitUIButton.prototype.update = function (activeButton) {
  17772. };
  17773. return WebXREnterExitUIButton;
  17774. }());
  17775. /**
  17776. * Options to create the webXR UI
  17777. */
  17778. var WebXREnterExitUIOptions = /** @class */ (function () {
  17779. function WebXREnterExitUIOptions() {
  17780. }
  17781. return WebXREnterExitUIOptions;
  17782. }());
  17783. /**
  17784. * UI to allow the user to enter/exit XR mode
  17785. */
  17786. var WebXREnterExitUI = /** @class */ (function () {
  17787. function WebXREnterExitUI(scene, options) {
  17788. var _this = this;
  17789. this.scene = scene;
  17790. this._buttons = [];
  17791. this._activeButton = null;
  17792. /**
  17793. * Fired every time the active button is changed.
  17794. *
  17795. * When xr is entered via a button that launches xr that button will be the callback parameter
  17796. *
  17797. * When exiting xr the callback parameter will be null)
  17798. */
  17799. this.activeButtonChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17800. this._overlay = document.createElement("div");
  17801. this._overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;";
  17802. if (options.customButtons) {
  17803. this._buttons = options.customButtons;
  17804. }
  17805. else {
  17806. var hmdBtn = document.createElement("button");
  17807. 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;";
  17808. hmdBtn.innerText = "HMD";
  17809. this._buttons.push(new WebXREnterExitUIButton(hmdBtn, { immersive: true, outputContext: options.outputCanvasContext }));
  17810. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  17811. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  17812. this.element.innerText = activeButton === this ? "EXIT" : "HMD";
  17813. };
  17814. var windowBtn = document.createElement("button");
  17815. windowBtn.style.cssText = hmdBtn.style.cssText;
  17816. windowBtn.innerText = "Window";
  17817. this._buttons.push(new WebXREnterExitUIButton(windowBtn, { immersive: false, environmentIntegration: true, outputContext: options.outputCanvasContext }));
  17818. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  17819. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  17820. this.element.innerText = activeButton === this ? "EXIT" : "Window";
  17821. };
  17822. this._updateButtons(null);
  17823. }
  17824. var renderCanvas = scene.getEngine().getRenderingCanvas();
  17825. if (renderCanvas && renderCanvas.parentNode) {
  17826. renderCanvas.parentNode.appendChild(this._overlay);
  17827. scene.onDisposeObservable.addOnce(function () {
  17828. _this.dispose();
  17829. });
  17830. }
  17831. }
  17832. /**
  17833. * Creates UI to allow the user to enter/exit XR mode
  17834. * @param scene the scene to add the ui to
  17835. * @param helper the xr experience helper to enter/exit xr with
  17836. * @param options options to configure the UI
  17837. * @returns the created ui
  17838. */
  17839. WebXREnterExitUI.CreateAsync = function (scene, helper, options) {
  17840. var _this = this;
  17841. var ui = new WebXREnterExitUI(scene, options);
  17842. var supportedPromises = ui._buttons.map(function (btn) {
  17843. return helper.supportsSessionAsync(btn.initializationOptions);
  17844. });
  17845. helper.onStateChangedObservable.add(function (state) {
  17846. if (state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR) {
  17847. ui._updateButtons(null);
  17848. }
  17849. });
  17850. return Promise.all(supportedPromises).then(function (results) {
  17851. results.forEach(function (supported, i) {
  17852. if (supported) {
  17853. ui._overlay.appendChild(ui._buttons[i].element);
  17854. ui._buttons[i].element.onclick = function () { return tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"](_this, void 0, void 0, function () {
  17855. return tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"](this, function (_a) {
  17856. switch (_a.label) {
  17857. case 0:
  17858. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].IN_XR)) return [3 /*break*/, 2];
  17859. ui._updateButtons(null);
  17860. return [4 /*yield*/, helper.exitXRAsync()];
  17861. case 1:
  17862. _a.sent();
  17863. return [2 /*return*/];
  17864. case 2:
  17865. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR)) return [3 /*break*/, 4];
  17866. ui._updateButtons(ui._buttons[i]);
  17867. return [4 /*yield*/, helper.enterXRAsync(ui._buttons[i].initializationOptions, "eye-level")];
  17868. case 3:
  17869. _a.sent();
  17870. _a.label = 4;
  17871. case 4: return [2 /*return*/];
  17872. }
  17873. });
  17874. }); };
  17875. }
  17876. });
  17877. return ui;
  17878. });
  17879. };
  17880. WebXREnterExitUI.prototype._updateButtons = function (activeButton) {
  17881. var _this = this;
  17882. this._activeButton = activeButton;
  17883. this._buttons.forEach(function (b) {
  17884. b.update(_this._activeButton);
  17885. });
  17886. this.activeButtonChangedObservable.notifyObservers(this._activeButton);
  17887. };
  17888. /**
  17889. * Disposes of the object
  17890. */
  17891. WebXREnterExitUI.prototype.dispose = function () {
  17892. var renderCanvas = this.scene.getEngine().getRenderingCanvas();
  17893. if (renderCanvas && renderCanvas.parentNode && renderCanvas.parentNode.contains(this._overlay)) {
  17894. renderCanvas.parentNode.removeChild(this._overlay);
  17895. }
  17896. this.activeButtonChangedObservable.clear();
  17897. };
  17898. return WebXREnterExitUI;
  17899. }());
  17900. /***/ }),
  17901. /***/ "./Cameras/XR/webXRExperienceHelper.ts":
  17902. /*!*********************************************!*\
  17903. !*** ./Cameras/XR/webXRExperienceHelper.ts ***!
  17904. \*********************************************/
  17905. /*! exports provided: WebXRState, WebXRExperienceHelper */
  17906. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17907. "use strict";
  17908. __webpack_require__.r(__webpack_exports__);
  17909. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return WebXRState; });
  17910. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return WebXRExperienceHelper; });
  17911. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  17912. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17913. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  17914. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  17915. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  17916. /**
  17917. * States of the webXR experience
  17918. */
  17919. var WebXRState;
  17920. (function (WebXRState) {
  17921. /**
  17922. * Transitioning to being in XR mode
  17923. */
  17924. WebXRState[WebXRState["ENTERING_XR"] = 0] = "ENTERING_XR";
  17925. /**
  17926. * Transitioning to non XR mode
  17927. */
  17928. WebXRState[WebXRState["EXITING_XR"] = 1] = "EXITING_XR";
  17929. /**
  17930. * In XR mode and presenting
  17931. */
  17932. WebXRState[WebXRState["IN_XR"] = 2] = "IN_XR";
  17933. /**
  17934. * Not entered XR mode
  17935. */
  17936. WebXRState[WebXRState["NOT_IN_XR"] = 3] = "NOT_IN_XR";
  17937. })(WebXRState || (WebXRState = {}));
  17938. /**
  17939. * Helper class used to enable XR
  17940. * @see https://doc.babylonjs.com/how_to/webxr
  17941. */
  17942. var WebXRExperienceHelper = /** @class */ (function () {
  17943. /**
  17944. * Creates a WebXRExperienceHelper
  17945. * @param scene The scene the helper should be created in
  17946. */
  17947. function WebXRExperienceHelper(scene) {
  17948. this.scene = scene;
  17949. /**
  17950. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  17951. */
  17952. this.state = WebXRState.NOT_IN_XR;
  17953. /**
  17954. * Fires when the state of the experience helper has changed
  17955. */
  17956. this.onStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  17957. this._nonVRCamera = null;
  17958. this._originalSceneAutoClear = true;
  17959. this._supported = false;
  17960. this.camera = new _webXRCamera__WEBPACK_IMPORTED_MODULE_4__["WebXRCamera"]("", scene);
  17961. this._sessionManager = new _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__["WebXRSessionManager"](scene);
  17962. this.container = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", scene);
  17963. this.camera.parent = this.container;
  17964. }
  17965. WebXRExperienceHelper.prototype._setState = function (val) {
  17966. this.state = val;
  17967. this.onStateChangedObservable.notifyObservers(this.state);
  17968. };
  17969. /**
  17970. * Creates the experience helper
  17971. * @param scene the scene to attach the experience helper to
  17972. * @returns a promise for the experience helper
  17973. */
  17974. WebXRExperienceHelper.CreateAsync = function (scene) {
  17975. var helper = new WebXRExperienceHelper(scene);
  17976. return helper._sessionManager.initializeAsync().then(function () {
  17977. helper._supported = true;
  17978. return helper;
  17979. }).catch(function () {
  17980. return helper;
  17981. });
  17982. };
  17983. /**
  17984. * Exits XR mode and returns the scene to its original state
  17985. * @returns promise that resolves after xr mode has exited
  17986. */
  17987. WebXRExperienceHelper.prototype.exitXRAsync = function () {
  17988. this._setState(WebXRState.EXITING_XR);
  17989. return this._sessionManager.exitXRAsync();
  17990. };
  17991. /**
  17992. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  17993. * @param sessionCreationOptions options for the XR session
  17994. * @param frameOfReference frame of reference of the XR session
  17995. * @returns promise that resolves after xr mode has entered
  17996. */
  17997. WebXRExperienceHelper.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReference) {
  17998. var _this = this;
  17999. if (!this._supported) {
  18000. throw "XR session not supported by this browser";
  18001. }
  18002. this._setState(WebXRState.ENTERING_XR);
  18003. return this._sessionManager.enterXRAsync(sessionCreationOptions, frameOfReference).then(function () {
  18004. // Cache pre xr scene settings
  18005. _this._originalSceneAutoClear = _this.scene.autoClear;
  18006. _this._nonVRCamera = _this.scene.activeCamera;
  18007. // Overwrite current scene settings
  18008. _this.scene.autoClear = false;
  18009. _this.scene.activeCamera = _this.camera;
  18010. _this._sessionManager.onXRFrameObservable.add(function () {
  18011. _this.camera.updateFromXRSessionManager(_this._sessionManager);
  18012. });
  18013. _this._sessionManager.onXRSessionEnded.addOnce(function () {
  18014. // Reset camera rigs output render target to ensure sessions render target is not drawn after it ends
  18015. _this.camera.rigCameras.forEach(function (c) {
  18016. c.outputRenderTarget = null;
  18017. });
  18018. // Restore scene settings
  18019. _this.scene.autoClear = _this._originalSceneAutoClear;
  18020. _this.scene.activeCamera = _this._nonVRCamera;
  18021. _this._sessionManager.onXRFrameObservable.clear();
  18022. _this._setState(WebXRState.NOT_IN_XR);
  18023. });
  18024. _this._setState(WebXRState.IN_XR);
  18025. });
  18026. };
  18027. /**
  18028. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18029. * @param ray ray to cast into the environment
  18030. * @returns Promise which resolves with a collision point in the environment if it exists
  18031. */
  18032. WebXRExperienceHelper.prototype.environmentPointHitTestAsync = function (ray) {
  18033. return this._sessionManager.environmentPointHitTestAsync(ray);
  18034. };
  18035. /**
  18036. * Updates the global position of the camera by moving the camera's container
  18037. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  18038. * @param position The desired global position of the camera
  18039. */
  18040. WebXRExperienceHelper.prototype.setPositionOfCameraUsingContainer = function (position) {
  18041. this.camera.globalPosition.subtractToRef(position, WebXRExperienceHelper._TmpVector);
  18042. this.container.position.subtractInPlace(WebXRExperienceHelper._TmpVector);
  18043. };
  18044. /**
  18045. * Rotates the xr camera by rotating the camera's container around the camera's position
  18046. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  18047. * @param rotation the desired quaternion rotation to apply to the camera
  18048. */
  18049. WebXRExperienceHelper.prototype.rotateCameraByQuaternionUsingContainer = function (rotation) {
  18050. if (!this.container.rotationQuaternion) {
  18051. this.container.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromEulerVector(this.container.rotation);
  18052. }
  18053. this.container.rotationQuaternion.multiplyInPlace(rotation);
  18054. this.container.position.rotateByQuaternionAroundPointToRef(rotation, this.camera.globalPosition, this.container.position);
  18055. };
  18056. /**
  18057. * Checks if the creation options are supported by the xr session
  18058. * @param options creation options
  18059. * @returns true if supported
  18060. */
  18061. WebXRExperienceHelper.prototype.supportsSessionAsync = function (options) {
  18062. if (!this._supported) {
  18063. return Promise.resolve(false);
  18064. }
  18065. return this._sessionManager.supportsSessionAsync(options);
  18066. };
  18067. /**
  18068. * Disposes of the experience helper
  18069. */
  18070. WebXRExperienceHelper.prototype.dispose = function () {
  18071. this.camera.dispose();
  18072. this.container.dispose();
  18073. this.onStateChangedObservable.clear();
  18074. this._sessionManager.dispose();
  18075. };
  18076. WebXRExperienceHelper._TmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]();
  18077. return WebXRExperienceHelper;
  18078. }());
  18079. /***/ }),
  18080. /***/ "./Cameras/XR/webXRInput.ts":
  18081. /*!**********************************!*\
  18082. !*** ./Cameras/XR/webXRInput.ts ***!
  18083. \**********************************/
  18084. /*! exports provided: WebXRController, WebXRInput */
  18085. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18086. "use strict";
  18087. __webpack_require__.r(__webpack_exports__);
  18088. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return WebXRController; });
  18089. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return WebXRInput; });
  18090. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18091. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18092. /**
  18093. * Represents an XR input
  18094. */
  18095. var WebXRController = /** @class */ (function () {
  18096. /**
  18097. * Creates the controller
  18098. * @see https://doc.babylonjs.com/how_to/webxr
  18099. * @param scene the scene which the controller should be associated to
  18100. */
  18101. function WebXRController(scene) {
  18102. this.pointer = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerPointer", scene);
  18103. }
  18104. /**
  18105. * Disposes of the object
  18106. */
  18107. WebXRController.prototype.dispose = function () {
  18108. if (this.grip) {
  18109. this.grip.dispose();
  18110. }
  18111. this.pointer.dispose();
  18112. };
  18113. return WebXRController;
  18114. }());
  18115. /**
  18116. * XR input used to track XR inputs such as controllers/rays
  18117. */
  18118. var WebXRInput = /** @class */ (function () {
  18119. /**
  18120. * Initializes the WebXRInput
  18121. * @param helper experience helper which the input should be created for
  18122. */
  18123. function WebXRInput(helper) {
  18124. var _this = this;
  18125. this.helper = helper;
  18126. /**
  18127. * XR controllers being tracked
  18128. */
  18129. this.controllers = [];
  18130. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  18131. this._frameObserver = helper._sessionManager.onXRFrameObservable.add(function () {
  18132. if (!helper._sessionManager._currentXRFrame || !helper._sessionManager._currentXRFrame.getDevicePose) {
  18133. return;
  18134. }
  18135. var xrFrame = helper._sessionManager._currentXRFrame;
  18136. var inputSources = helper._sessionManager._xrSession.getInputSources();
  18137. inputSources.forEach(function (input, i) {
  18138. var inputPose = xrFrame.getInputPose(input, helper._sessionManager._frameOfReference);
  18139. if (inputPose) {
  18140. if (_this.controllers.length <= i) {
  18141. _this.controllers.push(new WebXRController(helper.container.getScene()));
  18142. }
  18143. var controller = _this.controllers[i];
  18144. // Manage the grip if it exists
  18145. if (inputPose.gripMatrix) {
  18146. if (!controller.grip) {
  18147. controller.grip = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerGrip", helper.container.getScene());
  18148. }
  18149. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.gripMatrix, 0, 1, _this._tmpMatrix);
  18150. if (!controller.grip.getScene().useRightHandedSystem) {
  18151. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  18152. }
  18153. if (!controller.grip.rotationQuaternion) {
  18154. controller.grip.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  18155. }
  18156. _this._tmpMatrix.decompose(controller.grip.scaling, controller.grip.rotationQuaternion, controller.grip.position);
  18157. }
  18158. // Manager pointer of controller
  18159. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.targetRay.transformMatrix, 0, 1, _this._tmpMatrix);
  18160. if (!controller.pointer.getScene().useRightHandedSystem) {
  18161. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  18162. }
  18163. if (!controller.pointer.rotationQuaternion) {
  18164. controller.pointer.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  18165. }
  18166. _this._tmpMatrix.decompose(controller.pointer.scaling, controller.pointer.rotationQuaternion, controller.pointer.position);
  18167. }
  18168. });
  18169. });
  18170. }
  18171. /**
  18172. * Disposes of the object
  18173. */
  18174. WebXRInput.prototype.dispose = function () {
  18175. this.controllers.forEach(function (c) {
  18176. c.dispose();
  18177. });
  18178. this.helper._sessionManager.onXRFrameObservable.remove(this._frameObserver);
  18179. };
  18180. return WebXRInput;
  18181. }());
  18182. /***/ }),
  18183. /***/ "./Cameras/XR/webXRManagedOutputCanvas.ts":
  18184. /*!************************************************!*\
  18185. !*** ./Cameras/XR/webXRManagedOutputCanvas.ts ***!
  18186. \************************************************/
  18187. /*! exports provided: WebXRManagedOutputCanvas */
  18188. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18189. "use strict";
  18190. __webpack_require__.r(__webpack_exports__);
  18191. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return WebXRManagedOutputCanvas; });
  18192. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18193. /**
  18194. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  18195. */
  18196. var WebXRManagedOutputCanvas = /** @class */ (function () {
  18197. /**
  18198. * Initializes the canvas to be added/removed upon entering/exiting xr
  18199. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  18200. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  18201. */
  18202. function WebXRManagedOutputCanvas(helper, canvas) {
  18203. var _this = this;
  18204. this._canvas = null;
  18205. /**
  18206. * xrpresent context of the canvas which can be used to display/mirror xr content
  18207. */
  18208. this.canvasContext = null;
  18209. if (!canvas) {
  18210. canvas = document.createElement('canvas');
  18211. canvas.style.cssText = "position:absolute; bottom:0px;right:0px;z-index:10;width:100%;height:100%;background-color: #000000;";
  18212. }
  18213. this._setManagedOutputCanvas(canvas);
  18214. helper.onStateChangedObservable.add(function (stateInfo) {
  18215. if (stateInfo == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].ENTERING_XR) {
  18216. // 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
  18217. _this._addCanvas();
  18218. }
  18219. else if (helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].NOT_IN_XR) {
  18220. _this._removeCanvas();
  18221. }
  18222. });
  18223. }
  18224. /**
  18225. * Disposes of the object
  18226. */
  18227. WebXRManagedOutputCanvas.prototype.dispose = function () {
  18228. this._removeCanvas();
  18229. this._setManagedOutputCanvas(null);
  18230. };
  18231. WebXRManagedOutputCanvas.prototype._setManagedOutputCanvas = function (canvas) {
  18232. this._removeCanvas();
  18233. if (!canvas) {
  18234. this._canvas = null;
  18235. this.canvasContext = null;
  18236. }
  18237. else {
  18238. this._canvas = canvas;
  18239. this.canvasContext = this._canvas.getContext('xrpresent');
  18240. }
  18241. };
  18242. WebXRManagedOutputCanvas.prototype._addCanvas = function () {
  18243. if (this._canvas) {
  18244. document.body.appendChild(this._canvas);
  18245. }
  18246. };
  18247. WebXRManagedOutputCanvas.prototype._removeCanvas = function () {
  18248. if (this._canvas && document.body.contains(this._canvas)) {
  18249. document.body.removeChild(this._canvas);
  18250. }
  18251. };
  18252. return WebXRManagedOutputCanvas;
  18253. }());
  18254. /***/ }),
  18255. /***/ "./Cameras/XR/webXRSessionManager.ts":
  18256. /*!*******************************************!*\
  18257. !*** ./Cameras/XR/webXRSessionManager.ts ***!
  18258. \*******************************************/
  18259. /*! exports provided: WebXRSessionManager */
  18260. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18261. "use strict";
  18262. __webpack_require__.r(__webpack_exports__);
  18263. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return WebXRSessionManager; });
  18264. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  18265. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18266. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18267. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  18268. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  18269. /**
  18270. * Manages an XRSession
  18271. * @see https://doc.babylonjs.com/how_to/webxr
  18272. */
  18273. var WebXRSessionManager = /** @class */ (function () {
  18274. /**
  18275. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  18276. * @param scene The scene which the session should be created for
  18277. */
  18278. function WebXRSessionManager(scene) {
  18279. this.scene = scene;
  18280. /**
  18281. * Fires every time a new xrFrame arrives which can be used to update the camera
  18282. */
  18283. this.onXRFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18284. /**
  18285. * Fires when the xr session is ended either by the device or manually done
  18286. */
  18287. this.onXRSessionEnded = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18288. /** @hidden */
  18289. this._sessionRenderTargetTexture = null;
  18290. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  18291. }
  18292. /**
  18293. * Initializes the manager
  18294. * After initialization enterXR can be called to start an XR session
  18295. * @returns Promise which resolves after it is initialized
  18296. */
  18297. WebXRSessionManager.prototype.initializeAsync = function () {
  18298. var _this = this;
  18299. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("The WebXR APIs are still under development and are subject to change in the future.");
  18300. // Check if the browser supports webXR
  18301. this._xrNavigator = navigator;
  18302. if (!this._xrNavigator.xr) {
  18303. return Promise.reject("webXR not supported by this browser");
  18304. }
  18305. // Request the webXR device
  18306. return this._xrNavigator.xr.requestDevice().then(function (device) {
  18307. _this._xrDevice = device;
  18308. return _this.scene.getEngine()._gl.setCompatibleXRDevice(_this._xrDevice);
  18309. });
  18310. };
  18311. /**
  18312. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  18313. * @param sessionCreationOptions xr options to create the session with
  18314. * @param frameOfReferenceType option to configure how the xr pose is expressed
  18315. * @returns Promise which resolves after it enters XR
  18316. */
  18317. WebXRSessionManager.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReferenceType) {
  18318. var _this = this;
  18319. // initialize session
  18320. return this._xrDevice.requestSession(sessionCreationOptions).then(function (session) {
  18321. _this._xrSession = session;
  18322. // handle when the session is ended (By calling session.end or device ends its own session eg. pressing home button on phone)
  18323. _this._xrSession.addEventListener("end", function () {
  18324. // Remove render target texture and notify frame obervers
  18325. _this._sessionRenderTargetTexture = null;
  18326. // Restore frame buffer to avoid clear on xr framebuffer after session end
  18327. _this.scene.getEngine().restoreDefaultFramebuffer();
  18328. // Need to restart render loop as after the session is ended the last request for new frame will never call callback
  18329. _this.scene.getEngine().customAnimationFrameRequester = null;
  18330. _this.onXRSessionEnded.notifyObservers(null);
  18331. _this.scene.getEngine()._renderLoop();
  18332. }, { once: true });
  18333. _this._xrSession.baseLayer = new XRWebGLLayer(_this._xrSession, _this.scene.getEngine()._gl);
  18334. return _this._xrSession.requestFrameOfReference(frameOfReferenceType);
  18335. }).then(function (frameOfRef) {
  18336. _this._frameOfReference = frameOfRef;
  18337. // Tell the engine's render loop to be driven by the xr session's refresh rate and provide xr pose information
  18338. _this.scene.getEngine().customAnimationFrameRequester = {
  18339. requestAnimationFrame: _this._xrSession.requestAnimationFrame.bind(_this._xrSession),
  18340. renderFunction: function (timestamp, xrFrame) {
  18341. // Store the XR frame in the manager to be consumed by the XR camera to update pose
  18342. _this._currentXRFrame = xrFrame;
  18343. _this.onXRFrameObservable.notifyObservers(null);
  18344. _this.scene.getEngine()._renderLoop();
  18345. }
  18346. };
  18347. // Create render target texture from xr's webgl render target
  18348. _this._sessionRenderTargetTexture = WebXRSessionManager._CreateRenderTargetTextureFromSession(_this._xrSession, _this.scene);
  18349. // Stop window's animation frame and trigger sessions animation frame
  18350. window.cancelAnimationFrame(_this.scene.getEngine()._frameHandler);
  18351. _this.scene.getEngine()._renderLoop();
  18352. });
  18353. };
  18354. /**
  18355. * Stops the xrSession and restores the renderloop
  18356. * @returns Promise which resolves after it exits XR
  18357. */
  18358. WebXRSessionManager.prototype.exitXRAsync = function () {
  18359. return this._xrSession.end();
  18360. };
  18361. /**
  18362. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18363. * @param ray ray to cast into the environment
  18364. * @returns Promise which resolves with a collision point in the environment if it exists
  18365. */
  18366. WebXRSessionManager.prototype.environmentPointHitTestAsync = function (ray) {
  18367. var _this = this;
  18368. return new Promise(function (res) {
  18369. // Compute left handed inputs to request hit test
  18370. var origin = new Float32Array([ray.origin.x, ray.origin.y, ray.origin.z]);
  18371. var direction = new Float32Array([ray.direction.x, ray.direction.y, ray.direction.z]);
  18372. if (!_this.scene.useRightHandedSystem) {
  18373. origin[2] *= -1;
  18374. direction[2] *= -1;
  18375. }
  18376. // Fire hittest
  18377. _this._xrSession.requestHitTest(origin, direction, _this._frameOfReference)
  18378. .then(function (hits) {
  18379. if (hits.length > 0) {
  18380. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromFloat32ArrayToRefScaled(hits[0].hitMatrix, 0, 1.0, _this._tmpMatrix);
  18381. var hitPoint = _this._tmpMatrix.getTranslation();
  18382. if (!_this.scene.useRightHandedSystem) {
  18383. hitPoint.z *= -1;
  18384. }
  18385. res(hitPoint);
  18386. }
  18387. else {
  18388. res(null);
  18389. }
  18390. }).catch(function () {
  18391. res(null);
  18392. });
  18393. });
  18394. };
  18395. /**
  18396. * Checks if a session would be supported for the creation options specified
  18397. * @param options creation options to check if they are supported
  18398. * @returns true if supported
  18399. */
  18400. WebXRSessionManager.prototype.supportsSessionAsync = function (options) {
  18401. return this._xrDevice.supportsSession(options).then(function () {
  18402. return true;
  18403. }).catch(function () {
  18404. return false;
  18405. });
  18406. };
  18407. /**
  18408. * @hidden
  18409. * Converts the render layer of xrSession to a render target
  18410. * @param session session to create render target for
  18411. * @param scene scene the new render target should be created for
  18412. */
  18413. WebXRSessionManager._CreateRenderTargetTextureFromSession = function (session, scene) {
  18414. // Create internal texture
  18415. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](scene.getEngine(), _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  18416. internalTexture.width = session.baseLayer.framebufferWidth;
  18417. internalTexture.height = session.baseLayer.framebufferHeight;
  18418. internalTexture._framebuffer = session.baseLayer.framebuffer;
  18419. // Create render target texture from the internal texture
  18420. 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);
  18421. renderTargetTexture._texture = internalTexture;
  18422. return renderTargetTexture;
  18423. };
  18424. /**
  18425. * Disposes of the session manager
  18426. */
  18427. WebXRSessionManager.prototype.dispose = function () {
  18428. this.onXRFrameObservable.clear();
  18429. this.onXRSessionEnded.clear();
  18430. };
  18431. return WebXRSessionManager;
  18432. }());
  18433. /***/ }),
  18434. /***/ "./Cameras/arcRotateCamera.ts":
  18435. /*!************************************!*\
  18436. !*** ./Cameras/arcRotateCamera.ts ***!
  18437. \************************************/
  18438. /*! exports provided: ArcRotateCamera */
  18439. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18440. "use strict";
  18441. __webpack_require__.r(__webpack_exports__);
  18442. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return ArcRotateCamera; });
  18443. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18444. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  18445. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  18446. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  18447. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  18448. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  18449. /* harmony import */ var _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Cameras/autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  18450. /* harmony import */ var _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Cameras/bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  18451. /* harmony import */ var _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Behaviors/Cameras/framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  18452. /* harmony import */ var _Collisions_collider__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Collisions/collider */ "./Collisions/collider.ts");
  18453. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  18454. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  18455. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  18456. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("ArcRotateCamera", function (name, scene) {
  18457. return function () { return new ArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  18458. });
  18459. /**
  18460. * This represents an orbital type of camera.
  18461. *
  18462. * 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.
  18463. * 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.
  18464. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  18465. */
  18466. var ArcRotateCamera = /** @class */ (function (_super) {
  18467. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCamera, _super);
  18468. /**
  18469. * Instantiates a new ArcRotateCamera in a given scene
  18470. * @param name Defines the name of the camera
  18471. * @param alpha Defines the camera rotation along the logitudinal axis
  18472. * @param beta Defines the camera rotation along the latitudinal axis
  18473. * @param radius Defines the camera distance from its target
  18474. * @param target Defines the camera target
  18475. * @param scene Defines the scene the camera belongs to
  18476. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18477. */
  18478. function ArcRotateCamera(name, alpha, beta, radius, target, scene, setActiveOnSceneIfNoneActive) {
  18479. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  18480. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene, setActiveOnSceneIfNoneActive) || this;
  18481. /**
  18482. * Current inertia value on the longitudinal axis.
  18483. * The bigger this number the longer it will take for the camera to stop.
  18484. */
  18485. _this.inertialAlphaOffset = 0;
  18486. /**
  18487. * Current inertia value on the latitudinal axis.
  18488. * The bigger this number the longer it will take for the camera to stop.
  18489. */
  18490. _this.inertialBetaOffset = 0;
  18491. /**
  18492. * Current inertia value on the radius axis.
  18493. * The bigger this number the longer it will take for the camera to stop.
  18494. */
  18495. _this.inertialRadiusOffset = 0;
  18496. /**
  18497. * Minimum allowed angle on the longitudinal axis.
  18498. * This can help limiting how the Camera is able to move in the scene.
  18499. */
  18500. _this.lowerAlphaLimit = null;
  18501. /**
  18502. * Maximum allowed angle on the longitudinal axis.
  18503. * This can help limiting how the Camera is able to move in the scene.
  18504. */
  18505. _this.upperAlphaLimit = null;
  18506. /**
  18507. * Minimum allowed angle on the latitudinal axis.
  18508. * This can help limiting how the Camera is able to move in the scene.
  18509. */
  18510. _this.lowerBetaLimit = 0.01;
  18511. /**
  18512. * Maximum allowed angle on the latitudinal axis.
  18513. * This can help limiting how the Camera is able to move in the scene.
  18514. */
  18515. _this.upperBetaLimit = Math.PI - 0.01;
  18516. /**
  18517. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  18518. * This can help limiting how the Camera is able to move in the scene.
  18519. */
  18520. _this.lowerRadiusLimit = null;
  18521. /**
  18522. * Maximum allowed distance of the camera to the target (The camera can not get further).
  18523. * This can help limiting how the Camera is able to move in the scene.
  18524. */
  18525. _this.upperRadiusLimit = null;
  18526. /**
  18527. * Defines the current inertia value used during panning of the camera along the X axis.
  18528. */
  18529. _this.inertialPanningX = 0;
  18530. /**
  18531. * Defines the current inertia value used during panning of the camera along the Y axis.
  18532. */
  18533. _this.inertialPanningY = 0;
  18534. /**
  18535. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  18536. * Basically if your fingers moves away from more than this distance you will be considered
  18537. * in pinch mode.
  18538. */
  18539. _this.pinchToPanMaxDistance = 20;
  18540. /**
  18541. * Defines the maximum distance the camera can pan.
  18542. * This could help keeping the cammera always in your scene.
  18543. */
  18544. _this.panningDistanceLimit = null;
  18545. /**
  18546. * Defines the target of the camera before paning.
  18547. */
  18548. _this.panningOriginTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18549. /**
  18550. * Defines the value of the inertia used during panning.
  18551. * 0 would mean stop inertia and one would mean no decelleration at all.
  18552. */
  18553. _this.panningInertia = 0.9;
  18554. //-- end properties for backward compatibility for inputs
  18555. /**
  18556. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  18557. */
  18558. _this.zoomOnFactor = 1;
  18559. /**
  18560. * Defines a screen offset for the camera position.
  18561. */
  18562. _this.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  18563. /**
  18564. * Allows the camera to be completely reversed.
  18565. * If false the camera can not arrive upside down.
  18566. */
  18567. _this.allowUpsideDown = true;
  18568. /**
  18569. * Define if double tap/click is used to restore the previously saved state of the camera.
  18570. */
  18571. _this.useInputToRestoreState = true;
  18572. /** @hidden */
  18573. _this._viewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  18574. /**
  18575. * Defines the allowed panning axis.
  18576. */
  18577. _this.panningAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 0);
  18578. /**
  18579. * Observable triggered when the mesh target has been changed on the camera.
  18580. */
  18581. _this.onMeshTargetChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  18582. /**
  18583. * Defines whether the camera should check collision with the objects oh the scene.
  18584. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  18585. */
  18586. _this.checkCollisions = false;
  18587. /**
  18588. * Defines the collision radius of the camera.
  18589. * This simulates a sphere around the camera.
  18590. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18591. */
  18592. _this.collisionRadius = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 0.5, 0.5);
  18593. _this._previousPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18594. _this._collisionVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18595. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18596. _this._computationVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18597. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  18598. if (collidedMesh === void 0) { collidedMesh = null; }
  18599. if (!collidedMesh) {
  18600. _this._previousPosition.copyFrom(_this.position);
  18601. }
  18602. else {
  18603. _this.setPosition(newPosition);
  18604. if (_this.onCollide) {
  18605. _this.onCollide(collidedMesh);
  18606. }
  18607. }
  18608. // Recompute because of constraints
  18609. var cosa = Math.cos(_this.alpha);
  18610. var sina = Math.sin(_this.alpha);
  18611. var cosb = Math.cos(_this.beta);
  18612. var sinb = Math.sin(_this.beta);
  18613. if (sinb === 0) {
  18614. sinb = 0.0001;
  18615. }
  18616. var target = _this._getTargetPosition();
  18617. _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
  18618. target.addToRef(_this._computationVector, _this._newPosition);
  18619. _this.position.copyFrom(_this._newPosition);
  18620. var up = _this.upVector;
  18621. if (_this.allowUpsideDown && _this.beta < 0) {
  18622. up = up.clone();
  18623. up = up.negate();
  18624. }
  18625. _this._computeViewMatrix(_this.position, target, up);
  18626. _this._viewMatrix.addAtIndex(12, _this.targetScreenOffset.x);
  18627. _this._viewMatrix.addAtIndex(13, _this.targetScreenOffset.y);
  18628. _this._collisionTriggered = false;
  18629. };
  18630. _this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18631. if (target) {
  18632. _this.setTarget(target);
  18633. }
  18634. _this.alpha = alpha;
  18635. _this.beta = beta;
  18636. _this.radius = radius;
  18637. _this.getViewMatrix();
  18638. _this.inputs = new _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_12__["ArcRotateCameraInputsManager"](_this);
  18639. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  18640. return _this;
  18641. }
  18642. Object.defineProperty(ArcRotateCamera.prototype, "target", {
  18643. /**
  18644. * Defines the target point of the camera.
  18645. * The camera looks towards it form the radius distance.
  18646. */
  18647. get: function () {
  18648. return this._target;
  18649. },
  18650. set: function (value) {
  18651. this.setTarget(value);
  18652. },
  18653. enumerable: true,
  18654. configurable: true
  18655. });
  18656. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityX", {
  18657. //-- begin properties for backward compatibility for inputs
  18658. /**
  18659. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  18660. */
  18661. get: function () {
  18662. var pointers = this.inputs.attached["pointers"];
  18663. if (pointers) {
  18664. return pointers.angularSensibilityX;
  18665. }
  18666. return 0;
  18667. },
  18668. set: function (value) {
  18669. var pointers = this.inputs.attached["pointers"];
  18670. if (pointers) {
  18671. pointers.angularSensibilityX = value;
  18672. }
  18673. },
  18674. enumerable: true,
  18675. configurable: true
  18676. });
  18677. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityY", {
  18678. /**
  18679. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  18680. */
  18681. get: function () {
  18682. var pointers = this.inputs.attached["pointers"];
  18683. if (pointers) {
  18684. return pointers.angularSensibilityY;
  18685. }
  18686. return 0;
  18687. },
  18688. set: function (value) {
  18689. var pointers = this.inputs.attached["pointers"];
  18690. if (pointers) {
  18691. pointers.angularSensibilityY = value;
  18692. }
  18693. },
  18694. enumerable: true,
  18695. configurable: true
  18696. });
  18697. Object.defineProperty(ArcRotateCamera.prototype, "pinchPrecision", {
  18698. /**
  18699. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  18700. */
  18701. get: function () {
  18702. var pointers = this.inputs.attached["pointers"];
  18703. if (pointers) {
  18704. return pointers.pinchPrecision;
  18705. }
  18706. return 0;
  18707. },
  18708. set: function (value) {
  18709. var pointers = this.inputs.attached["pointers"];
  18710. if (pointers) {
  18711. pointers.pinchPrecision = value;
  18712. }
  18713. },
  18714. enumerable: true,
  18715. configurable: true
  18716. });
  18717. Object.defineProperty(ArcRotateCamera.prototype, "pinchDeltaPercentage", {
  18718. /**
  18719. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  18720. * It will be used instead of pinchDeltaPrecision if different from 0.
  18721. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  18722. */
  18723. get: function () {
  18724. var pointers = this.inputs.attached["pointers"];
  18725. if (pointers) {
  18726. return pointers.pinchDeltaPercentage;
  18727. }
  18728. return 0;
  18729. },
  18730. set: function (value) {
  18731. var pointers = this.inputs.attached["pointers"];
  18732. if (pointers) {
  18733. pointers.pinchDeltaPercentage = value;
  18734. }
  18735. },
  18736. enumerable: true,
  18737. configurable: true
  18738. });
  18739. Object.defineProperty(ArcRotateCamera.prototype, "panningSensibility", {
  18740. /**
  18741. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  18742. */
  18743. get: function () {
  18744. var pointers = this.inputs.attached["pointers"];
  18745. if (pointers) {
  18746. return pointers.panningSensibility;
  18747. }
  18748. return 0;
  18749. },
  18750. set: function (value) {
  18751. var pointers = this.inputs.attached["pointers"];
  18752. if (pointers) {
  18753. pointers.panningSensibility = value;
  18754. }
  18755. },
  18756. enumerable: true,
  18757. configurable: true
  18758. });
  18759. Object.defineProperty(ArcRotateCamera.prototype, "keysUp", {
  18760. /**
  18761. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  18762. */
  18763. get: function () {
  18764. var keyboard = this.inputs.attached["keyboard"];
  18765. if (keyboard) {
  18766. return keyboard.keysUp;
  18767. }
  18768. return [];
  18769. },
  18770. set: function (value) {
  18771. var keyboard = this.inputs.attached["keyboard"];
  18772. if (keyboard) {
  18773. keyboard.keysUp = value;
  18774. }
  18775. },
  18776. enumerable: true,
  18777. configurable: true
  18778. });
  18779. Object.defineProperty(ArcRotateCamera.prototype, "keysDown", {
  18780. /**
  18781. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  18782. */
  18783. get: function () {
  18784. var keyboard = this.inputs.attached["keyboard"];
  18785. if (keyboard) {
  18786. return keyboard.keysDown;
  18787. }
  18788. return [];
  18789. },
  18790. set: function (value) {
  18791. var keyboard = this.inputs.attached["keyboard"];
  18792. if (keyboard) {
  18793. keyboard.keysDown = value;
  18794. }
  18795. },
  18796. enumerable: true,
  18797. configurable: true
  18798. });
  18799. Object.defineProperty(ArcRotateCamera.prototype, "keysLeft", {
  18800. /**
  18801. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  18802. */
  18803. get: function () {
  18804. var keyboard = this.inputs.attached["keyboard"];
  18805. if (keyboard) {
  18806. return keyboard.keysLeft;
  18807. }
  18808. return [];
  18809. },
  18810. set: function (value) {
  18811. var keyboard = this.inputs.attached["keyboard"];
  18812. if (keyboard) {
  18813. keyboard.keysLeft = value;
  18814. }
  18815. },
  18816. enumerable: true,
  18817. configurable: true
  18818. });
  18819. Object.defineProperty(ArcRotateCamera.prototype, "keysRight", {
  18820. /**
  18821. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  18822. */
  18823. get: function () {
  18824. var keyboard = this.inputs.attached["keyboard"];
  18825. if (keyboard) {
  18826. return keyboard.keysRight;
  18827. }
  18828. return [];
  18829. },
  18830. set: function (value) {
  18831. var keyboard = this.inputs.attached["keyboard"];
  18832. if (keyboard) {
  18833. keyboard.keysRight = value;
  18834. }
  18835. },
  18836. enumerable: true,
  18837. configurable: true
  18838. });
  18839. Object.defineProperty(ArcRotateCamera.prototype, "wheelPrecision", {
  18840. /**
  18841. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  18842. */
  18843. get: function () {
  18844. var mousewheel = this.inputs.attached["mousewheel"];
  18845. if (mousewheel) {
  18846. return mousewheel.wheelPrecision;
  18847. }
  18848. return 0;
  18849. },
  18850. set: function (value) {
  18851. var mousewheel = this.inputs.attached["mousewheel"];
  18852. if (mousewheel) {
  18853. mousewheel.wheelPrecision = value;
  18854. }
  18855. },
  18856. enumerable: true,
  18857. configurable: true
  18858. });
  18859. Object.defineProperty(ArcRotateCamera.prototype, "wheelDeltaPercentage", {
  18860. /**
  18861. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  18862. * It will be used instead of pinchDeltaPrecision if different from 0.
  18863. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  18864. */
  18865. get: function () {
  18866. var mousewheel = this.inputs.attached["mousewheel"];
  18867. if (mousewheel) {
  18868. return mousewheel.wheelDeltaPercentage;
  18869. }
  18870. return 0;
  18871. },
  18872. set: function (value) {
  18873. var mousewheel = this.inputs.attached["mousewheel"];
  18874. if (mousewheel) {
  18875. mousewheel.wheelDeltaPercentage = value;
  18876. }
  18877. },
  18878. enumerable: true,
  18879. configurable: true
  18880. });
  18881. Object.defineProperty(ArcRotateCamera.prototype, "bouncingBehavior", {
  18882. /**
  18883. * Gets the bouncing behavior of the camera if it has been enabled.
  18884. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  18885. */
  18886. get: function () {
  18887. return this._bouncingBehavior;
  18888. },
  18889. enumerable: true,
  18890. configurable: true
  18891. });
  18892. Object.defineProperty(ArcRotateCamera.prototype, "useBouncingBehavior", {
  18893. /**
  18894. * Defines if the bouncing behavior of the camera is enabled on the camera.
  18895. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  18896. */
  18897. get: function () {
  18898. return this._bouncingBehavior != null;
  18899. },
  18900. set: function (value) {
  18901. if (value === this.useBouncingBehavior) {
  18902. return;
  18903. }
  18904. if (value) {
  18905. this._bouncingBehavior = new _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__["BouncingBehavior"]();
  18906. this.addBehavior(this._bouncingBehavior);
  18907. }
  18908. else if (this._bouncingBehavior) {
  18909. this.removeBehavior(this._bouncingBehavior);
  18910. this._bouncingBehavior = null;
  18911. }
  18912. },
  18913. enumerable: true,
  18914. configurable: true
  18915. });
  18916. Object.defineProperty(ArcRotateCamera.prototype, "framingBehavior", {
  18917. /**
  18918. * Gets the framing behavior of the camera if it has been enabled.
  18919. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  18920. */
  18921. get: function () {
  18922. return this._framingBehavior;
  18923. },
  18924. enumerable: true,
  18925. configurable: true
  18926. });
  18927. Object.defineProperty(ArcRotateCamera.prototype, "useFramingBehavior", {
  18928. /**
  18929. * Defines if the framing behavior of the camera is enabled on the camera.
  18930. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  18931. */
  18932. get: function () {
  18933. return this._framingBehavior != null;
  18934. },
  18935. set: function (value) {
  18936. if (value === this.useFramingBehavior) {
  18937. return;
  18938. }
  18939. if (value) {
  18940. this._framingBehavior = new _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__["FramingBehavior"]();
  18941. this.addBehavior(this._framingBehavior);
  18942. }
  18943. else if (this._framingBehavior) {
  18944. this.removeBehavior(this._framingBehavior);
  18945. this._framingBehavior = null;
  18946. }
  18947. },
  18948. enumerable: true,
  18949. configurable: true
  18950. });
  18951. Object.defineProperty(ArcRotateCamera.prototype, "autoRotationBehavior", {
  18952. /**
  18953. * Gets the auto rotation behavior of the camera if it has been enabled.
  18954. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  18955. */
  18956. get: function () {
  18957. return this._autoRotationBehavior;
  18958. },
  18959. enumerable: true,
  18960. configurable: true
  18961. });
  18962. Object.defineProperty(ArcRotateCamera.prototype, "useAutoRotationBehavior", {
  18963. /**
  18964. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  18965. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  18966. */
  18967. get: function () {
  18968. return this._autoRotationBehavior != null;
  18969. },
  18970. set: function (value) {
  18971. if (value === this.useAutoRotationBehavior) {
  18972. return;
  18973. }
  18974. if (value) {
  18975. this._autoRotationBehavior = new _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__["AutoRotationBehavior"]();
  18976. this.addBehavior(this._autoRotationBehavior);
  18977. }
  18978. else if (this._autoRotationBehavior) {
  18979. this.removeBehavior(this._autoRotationBehavior);
  18980. this._autoRotationBehavior = null;
  18981. }
  18982. },
  18983. enumerable: true,
  18984. configurable: true
  18985. });
  18986. // Cache
  18987. /** @hidden */
  18988. ArcRotateCamera.prototype._initCache = function () {
  18989. _super.prototype._initCache.call(this);
  18990. this._cache._target = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  18991. this._cache.alpha = undefined;
  18992. this._cache.beta = undefined;
  18993. this._cache.radius = undefined;
  18994. this._cache.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  18995. };
  18996. /** @hidden */
  18997. ArcRotateCamera.prototype._updateCache = function (ignoreParentClass) {
  18998. if (!ignoreParentClass) {
  18999. _super.prototype._updateCache.call(this);
  19000. }
  19001. this._cache._target.copyFrom(this._getTargetPosition());
  19002. this._cache.alpha = this.alpha;
  19003. this._cache.beta = this.beta;
  19004. this._cache.radius = this.radius;
  19005. this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset);
  19006. };
  19007. ArcRotateCamera.prototype._getTargetPosition = function () {
  19008. if (this._targetHost && this._targetHost.getAbsolutePosition) {
  19009. var pos = this._targetHost.absolutePosition;
  19010. if (this._targetBoundingCenter) {
  19011. pos.addToRef(this._targetBoundingCenter, this._target);
  19012. }
  19013. else {
  19014. this._target.copyFrom(pos);
  19015. }
  19016. }
  19017. var lockedTargetPosition = this._getLockedTargetPosition();
  19018. if (lockedTargetPosition) {
  19019. return lockedTargetPosition;
  19020. }
  19021. return this._target;
  19022. };
  19023. /**
  19024. * Stores the current state of the camera (alpha, beta, radius and target)
  19025. * @returns the camera itself
  19026. */
  19027. ArcRotateCamera.prototype.storeState = function () {
  19028. this._storedAlpha = this.alpha;
  19029. this._storedBeta = this.beta;
  19030. this._storedRadius = this.radius;
  19031. this._storedTarget = this._getTargetPosition().clone();
  19032. return _super.prototype.storeState.call(this);
  19033. };
  19034. /**
  19035. * @hidden
  19036. * Restored camera state. You must call storeState() first
  19037. */
  19038. ArcRotateCamera.prototype._restoreStateValues = function () {
  19039. if (!_super.prototype._restoreStateValues.call(this)) {
  19040. return false;
  19041. }
  19042. this.alpha = this._storedAlpha;
  19043. this.beta = this._storedBeta;
  19044. this.radius = this._storedRadius;
  19045. this.setTarget(this._storedTarget.clone());
  19046. this.inertialAlphaOffset = 0;
  19047. this.inertialBetaOffset = 0;
  19048. this.inertialRadiusOffset = 0;
  19049. this.inertialPanningX = 0;
  19050. this.inertialPanningY = 0;
  19051. return true;
  19052. };
  19053. // Synchronized
  19054. /** @hidden */
  19055. ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
  19056. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  19057. return false;
  19058. }
  19059. return this._cache._target.equals(this._getTargetPosition())
  19060. && this._cache.alpha === this.alpha
  19061. && this._cache.beta === this.beta
  19062. && this._cache.radius === this.radius
  19063. && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
  19064. };
  19065. /**
  19066. * Attached controls to the current camera.
  19067. * @param element Defines the element the controls should be listened from
  19068. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19069. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  19070. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  19071. */
  19072. ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault, useCtrlForPanning, panningMouseButton) {
  19073. var _this = this;
  19074. if (useCtrlForPanning === void 0) { useCtrlForPanning = true; }
  19075. if (panningMouseButton === void 0) { panningMouseButton = 2; }
  19076. this._useCtrlForPanning = useCtrlForPanning;
  19077. this._panningMouseButton = panningMouseButton;
  19078. this.inputs.attachElement(element, noPreventDefault);
  19079. this._reset = function () {
  19080. _this.inertialAlphaOffset = 0;
  19081. _this.inertialBetaOffset = 0;
  19082. _this.inertialRadiusOffset = 0;
  19083. _this.inertialPanningX = 0;
  19084. _this.inertialPanningY = 0;
  19085. };
  19086. };
  19087. /**
  19088. * Detach the current controls from the camera.
  19089. * The camera will stop reacting to inputs.
  19090. * @param element Defines the element to stop listening the inputs from
  19091. */
  19092. ArcRotateCamera.prototype.detachControl = function (element) {
  19093. this.inputs.detachElement(element);
  19094. if (this._reset) {
  19095. this._reset();
  19096. }
  19097. };
  19098. /** @hidden */
  19099. ArcRotateCamera.prototype._checkInputs = function () {
  19100. //if (async) collision inspection was triggered, don't update the camera's position - until the collision callback was called.
  19101. if (this._collisionTriggered) {
  19102. return;
  19103. }
  19104. this.inputs.checkInputs();
  19105. // Inertia
  19106. if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
  19107. var inertialAlphaOffset = this.inertialAlphaOffset;
  19108. if (this.beta <= 0) {
  19109. inertialAlphaOffset *= -1;
  19110. }
  19111. if (this.getScene().useRightHandedSystem) {
  19112. inertialAlphaOffset *= -1;
  19113. }
  19114. if (this.parent && this.parent._getWorldMatrixDeterminant() < 0) {
  19115. inertialAlphaOffset *= -1;
  19116. }
  19117. this.alpha += inertialAlphaOffset;
  19118. this.beta += this.inertialBetaOffset;
  19119. this.radius -= this.inertialRadiusOffset;
  19120. this.inertialAlphaOffset *= this.inertia;
  19121. this.inertialBetaOffset *= this.inertia;
  19122. this.inertialRadiusOffset *= this.inertia;
  19123. if (Math.abs(this.inertialAlphaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19124. this.inertialAlphaOffset = 0;
  19125. }
  19126. if (Math.abs(this.inertialBetaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19127. this.inertialBetaOffset = 0;
  19128. }
  19129. if (Math.abs(this.inertialRadiusOffset) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19130. this.inertialRadiusOffset = 0;
  19131. }
  19132. }
  19133. // Panning inertia
  19134. if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
  19135. if (!this._localDirection) {
  19136. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19137. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19138. }
  19139. this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
  19140. this._localDirection.multiplyInPlace(this.panningAxis);
  19141. this._viewMatrix.invertToRef(this._cameraTransformMatrix);
  19142. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
  19143. //Eliminate y if map panning is enabled (panningAxis == 1,0,1)
  19144. if (!this.panningAxis.y) {
  19145. this._transformedDirection.y = 0;
  19146. }
  19147. if (!this._targetHost) {
  19148. if (this.panningDistanceLimit) {
  19149. this._transformedDirection.addInPlace(this._target);
  19150. var distanceSquared = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].DistanceSquared(this._transformedDirection, this.panningOriginTarget);
  19151. if (distanceSquared <= (this.panningDistanceLimit * this.panningDistanceLimit)) {
  19152. this._target.copyFrom(this._transformedDirection);
  19153. }
  19154. }
  19155. else {
  19156. this._target.addInPlace(this._transformedDirection);
  19157. }
  19158. }
  19159. this.inertialPanningX *= this.panningInertia;
  19160. this.inertialPanningY *= this.panningInertia;
  19161. if (Math.abs(this.inertialPanningX) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19162. this.inertialPanningX = 0;
  19163. }
  19164. if (Math.abs(this.inertialPanningY) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19165. this.inertialPanningY = 0;
  19166. }
  19167. }
  19168. // Limits
  19169. this._checkLimits();
  19170. _super.prototype._checkInputs.call(this);
  19171. };
  19172. ArcRotateCamera.prototype._checkLimits = function () {
  19173. if (this.lowerBetaLimit === null || this.lowerBetaLimit === undefined) {
  19174. if (this.allowUpsideDown && this.beta > Math.PI) {
  19175. this.beta = this.beta - (2 * Math.PI);
  19176. }
  19177. }
  19178. else {
  19179. if (this.beta < this.lowerBetaLimit) {
  19180. this.beta = this.lowerBetaLimit;
  19181. }
  19182. }
  19183. if (this.upperBetaLimit === null || this.upperBetaLimit === undefined) {
  19184. if (this.allowUpsideDown && this.beta < -Math.PI) {
  19185. this.beta = this.beta + (2 * Math.PI);
  19186. }
  19187. }
  19188. else {
  19189. if (this.beta > this.upperBetaLimit) {
  19190. this.beta = this.upperBetaLimit;
  19191. }
  19192. }
  19193. if (this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit) {
  19194. this.alpha = this.lowerAlphaLimit;
  19195. }
  19196. if (this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit) {
  19197. this.alpha = this.upperAlphaLimit;
  19198. }
  19199. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  19200. this.radius = this.lowerRadiusLimit;
  19201. this.inertialRadiusOffset = 0;
  19202. }
  19203. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  19204. this.radius = this.upperRadiusLimit;
  19205. this.inertialRadiusOffset = 0;
  19206. }
  19207. };
  19208. /**
  19209. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  19210. */
  19211. ArcRotateCamera.prototype.rebuildAnglesAndRadius = function () {
  19212. this.position.subtractToRef(this._getTargetPosition(), this._computationVector);
  19213. this.radius = this._computationVector.length();
  19214. if (this.radius === 0) {
  19215. this.radius = 0.0001; // Just to avoid division by zero
  19216. }
  19217. // Alpha
  19218. this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
  19219. if (this._computationVector.z < 0) {
  19220. this.alpha = 2 * Math.PI - this.alpha;
  19221. }
  19222. // Beta
  19223. this.beta = Math.acos(this._computationVector.y / this.radius);
  19224. this._checkLimits();
  19225. };
  19226. /**
  19227. * Use a position to define the current camera related information like aplha, beta and radius
  19228. * @param position Defines the position to set the camera at
  19229. */
  19230. ArcRotateCamera.prototype.setPosition = function (position) {
  19231. if (this.position.equals(position)) {
  19232. return;
  19233. }
  19234. this.position.copyFrom(position);
  19235. this.rebuildAnglesAndRadius();
  19236. };
  19237. /**
  19238. * Defines the target the camera should look at.
  19239. * This will automatically adapt alpha beta and radius to fit within the new target.
  19240. * @param target Defines the new target as a Vector or a mesh
  19241. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  19242. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  19243. */
  19244. ArcRotateCamera.prototype.setTarget = function (target, toBoundingCenter, allowSamePosition) {
  19245. if (toBoundingCenter === void 0) { toBoundingCenter = false; }
  19246. if (allowSamePosition === void 0) { allowSamePosition = false; }
  19247. if (target.getBoundingInfo) {
  19248. if (toBoundingCenter) {
  19249. this._targetBoundingCenter = target.getBoundingInfo().boundingBox.centerWorld.clone();
  19250. }
  19251. else {
  19252. this._targetBoundingCenter = null;
  19253. }
  19254. this._targetHost = target;
  19255. this._target = this._getTargetPosition();
  19256. this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
  19257. }
  19258. else {
  19259. var newTarget = target;
  19260. var currentTarget = this._getTargetPosition();
  19261. if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
  19262. return;
  19263. }
  19264. this._targetHost = null;
  19265. this._target = newTarget;
  19266. this._targetBoundingCenter = null;
  19267. this.onMeshTargetChangedObservable.notifyObservers(null);
  19268. }
  19269. this.rebuildAnglesAndRadius();
  19270. };
  19271. /** @hidden */
  19272. ArcRotateCamera.prototype._getViewMatrix = function () {
  19273. // Compute
  19274. var cosa = Math.cos(this.alpha);
  19275. var sina = Math.sin(this.alpha);
  19276. var cosb = Math.cos(this.beta);
  19277. var sinb = Math.sin(this.beta);
  19278. if (sinb === 0) {
  19279. sinb = 0.0001;
  19280. }
  19281. var target = this._getTargetPosition();
  19282. this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
  19283. // Rotate according to up vector
  19284. if (this.upVector.x !== 0 || this.upVector.y !== 1.0 || this.upVector.z !== 0) {
  19285. if (!this._tempAxisVector) {
  19286. this._tempAxisVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  19287. this._tempAxisRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19288. }
  19289. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), this.upVector, this._tempAxisVector);
  19290. this._tempAxisVector.normalize();
  19291. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this.upVector));
  19292. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(this._tempAxisVector, angle, this._tempAxisRotationMatrix);
  19293. this._tempAxisVector.copyFrom(this._computationVector);
  19294. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._tempAxisVector, this._tempAxisRotationMatrix, this._computationVector);
  19295. }
  19296. target.addToRef(this._computationVector, this._newPosition);
  19297. if (this.getScene().collisionsEnabled && this.checkCollisions) {
  19298. if (!this._collider) {
  19299. this._collider = new _Collisions_collider__WEBPACK_IMPORTED_MODULE_9__["Collider"]();
  19300. }
  19301. this._collider._radius = this.collisionRadius;
  19302. this._newPosition.subtractToRef(this.position, this._collisionVelocity);
  19303. this._collisionTriggered = true;
  19304. this.getScene().collisionCoordinator.getNewPosition(this.position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  19305. }
  19306. else {
  19307. this.position.copyFrom(this._newPosition);
  19308. var up = this.upVector;
  19309. if (this.allowUpsideDown && sinb < 0) {
  19310. up = up.clone();
  19311. up = up.negate();
  19312. }
  19313. this._computeViewMatrix(this.position, target, up);
  19314. this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x);
  19315. this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y);
  19316. }
  19317. this._currentTarget = target;
  19318. return this._viewMatrix;
  19319. };
  19320. /**
  19321. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  19322. * @param meshes Defines the mesh to zoom on
  19323. * @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)
  19324. */
  19325. ArcRotateCamera.prototype.zoomOn = function (meshes, doNotUpdateMaxZ) {
  19326. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  19327. meshes = meshes || this.getScene().meshes;
  19328. var minMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  19329. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(minMaxVector.min, minMaxVector.max);
  19330. this.radius = distance * this.zoomOnFactor;
  19331. this.focusOn({ min: minMaxVector.min, max: minMaxVector.max, distance: distance }, doNotUpdateMaxZ);
  19332. };
  19333. /**
  19334. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  19335. * The target will be changed but the radius
  19336. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  19337. * @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)
  19338. */
  19339. ArcRotateCamera.prototype.focusOn = function (meshesOrMinMaxVectorAndDistance, doNotUpdateMaxZ) {
  19340. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  19341. var meshesOrMinMaxVector;
  19342. var distance;
  19343. if (meshesOrMinMaxVectorAndDistance.min === undefined) { // meshes
  19344. var meshes = meshesOrMinMaxVectorAndDistance || this.getScene().meshes;
  19345. meshesOrMinMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  19346. distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(meshesOrMinMaxVector.min, meshesOrMinMaxVector.max);
  19347. }
  19348. else { //minMaxVector and distance
  19349. var minMaxVectorAndDistance = meshesOrMinMaxVectorAndDistance;
  19350. meshesOrMinMaxVector = minMaxVectorAndDistance;
  19351. distance = minMaxVectorAndDistance.distance;
  19352. }
  19353. this._target = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].Center(meshesOrMinMaxVector);
  19354. if (!doNotUpdateMaxZ) {
  19355. this.maxZ = distance * 2;
  19356. }
  19357. };
  19358. /**
  19359. * @override
  19360. * Override Camera.createRigCamera
  19361. */
  19362. ArcRotateCamera.prototype.createRigCamera = function (name, cameraIndex) {
  19363. var alphaShift = 0;
  19364. switch (this.cameraRigMode) {
  19365. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  19366. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  19367. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  19368. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_VR:
  19369. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? 1 : -1);
  19370. break;
  19371. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  19372. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? -1 : 1);
  19373. break;
  19374. }
  19375. var rigCam = new ArcRotateCamera(name, this.alpha + alphaShift, this.beta, this.radius, this._target, this.getScene());
  19376. rigCam._cameraRigParams = {};
  19377. return rigCam;
  19378. };
  19379. /**
  19380. * @hidden
  19381. * @override
  19382. * Override Camera._updateRigCameras
  19383. */
  19384. ArcRotateCamera.prototype._updateRigCameras = function () {
  19385. var camLeft = this._rigCameras[0];
  19386. var camRight = this._rigCameras[1];
  19387. camLeft.beta = camRight.beta = this.beta;
  19388. switch (this.cameraRigMode) {
  19389. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  19390. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  19391. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  19392. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_VR:
  19393. camLeft.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  19394. camRight.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  19395. break;
  19396. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  19397. camLeft.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  19398. camRight.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  19399. break;
  19400. }
  19401. _super.prototype._updateRigCameras.call(this);
  19402. };
  19403. /**
  19404. * Destroy the camera and release the current resources hold by it.
  19405. */
  19406. ArcRotateCamera.prototype.dispose = function () {
  19407. this.inputs.clear();
  19408. _super.prototype.dispose.call(this);
  19409. };
  19410. /**
  19411. * Gets the current object class name.
  19412. * @return the class name
  19413. */
  19414. ArcRotateCamera.prototype.getClassName = function () {
  19415. return "ArcRotateCamera";
  19416. };
  19417. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19418. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19419. ], ArcRotateCamera.prototype, "alpha", void 0);
  19420. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19421. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19422. ], ArcRotateCamera.prototype, "beta", void 0);
  19423. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19424. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19425. ], ArcRotateCamera.prototype, "radius", void 0);
  19426. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19427. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("target")
  19428. ], ArcRotateCamera.prototype, "_target", void 0);
  19429. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19430. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19431. ], ArcRotateCamera.prototype, "inertialAlphaOffset", void 0);
  19432. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19433. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19434. ], ArcRotateCamera.prototype, "inertialBetaOffset", void 0);
  19435. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19436. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19437. ], ArcRotateCamera.prototype, "inertialRadiusOffset", void 0);
  19438. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19439. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19440. ], ArcRotateCamera.prototype, "lowerAlphaLimit", void 0);
  19441. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19442. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19443. ], ArcRotateCamera.prototype, "upperAlphaLimit", void 0);
  19444. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19445. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19446. ], ArcRotateCamera.prototype, "lowerBetaLimit", void 0);
  19447. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19448. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19449. ], ArcRotateCamera.prototype, "upperBetaLimit", void 0);
  19450. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19451. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19452. ], ArcRotateCamera.prototype, "lowerRadiusLimit", void 0);
  19453. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19454. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19455. ], ArcRotateCamera.prototype, "upperRadiusLimit", void 0);
  19456. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19457. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19458. ], ArcRotateCamera.prototype, "inertialPanningX", void 0);
  19459. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19460. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19461. ], ArcRotateCamera.prototype, "inertialPanningY", void 0);
  19462. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19463. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19464. ], ArcRotateCamera.prototype, "pinchToPanMaxDistance", void 0);
  19465. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19466. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19467. ], ArcRotateCamera.prototype, "panningDistanceLimit", void 0);
  19468. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19469. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  19470. ], ArcRotateCamera.prototype, "panningOriginTarget", void 0);
  19471. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19472. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19473. ], ArcRotateCamera.prototype, "panningInertia", void 0);
  19474. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19475. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19476. ], ArcRotateCamera.prototype, "zoomOnFactor", void 0);
  19477. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19478. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19479. ], ArcRotateCamera.prototype, "targetScreenOffset", void 0);
  19480. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19481. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19482. ], ArcRotateCamera.prototype, "allowUpsideDown", void 0);
  19483. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19484. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19485. ], ArcRotateCamera.prototype, "useInputToRestoreState", void 0);
  19486. return ArcRotateCamera;
  19487. }(_targetCamera__WEBPACK_IMPORTED_MODULE_11__["TargetCamera"]));
  19488. /***/ }),
  19489. /***/ "./Cameras/arcRotateCameraInputsManager.ts":
  19490. /*!*************************************************!*\
  19491. !*** ./Cameras/arcRotateCameraInputsManager.ts ***!
  19492. \*************************************************/
  19493. /*! exports provided: ArcRotateCameraInputsManager */
  19494. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19495. "use strict";
  19496. __webpack_require__.r(__webpack_exports__);
  19497. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return ArcRotateCameraInputsManager; });
  19498. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19499. /* harmony import */ var _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  19500. /* harmony import */ var _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  19501. /* harmony import */ var _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  19502. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  19503. /**
  19504. * Default Inputs manager for the ArcRotateCamera.
  19505. * It groups all the default supported inputs for ease of use.
  19506. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19507. */
  19508. var ArcRotateCameraInputsManager = /** @class */ (function (_super) {
  19509. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraInputsManager, _super);
  19510. /**
  19511. * Instantiates a new ArcRotateCameraInputsManager.
  19512. * @param camera Defines the camera the inputs belong to
  19513. */
  19514. function ArcRotateCameraInputsManager(camera) {
  19515. return _super.call(this, camera) || this;
  19516. }
  19517. /**
  19518. * Add mouse wheel input support to the input manager.
  19519. * @returns the current input manager
  19520. */
  19521. ArcRotateCameraInputsManager.prototype.addMouseWheel = function () {
  19522. this.add(new _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraMouseWheelInput"]());
  19523. return this;
  19524. };
  19525. /**
  19526. * Add pointers input support to the input manager.
  19527. * @returns the current input manager
  19528. */
  19529. ArcRotateCameraInputsManager.prototype.addPointers = function () {
  19530. this.add(new _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraPointersInput"]());
  19531. return this;
  19532. };
  19533. /**
  19534. * Add keyboard input support to the input manager.
  19535. * @returns the current input manager
  19536. */
  19537. ArcRotateCameraInputsManager.prototype.addKeyboard = function () {
  19538. this.add(new _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraKeyboardMoveInput"]());
  19539. return this;
  19540. };
  19541. return ArcRotateCameraInputsManager;
  19542. }(_Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__["CameraInputsManager"]));
  19543. /***/ }),
  19544. /***/ "./Cameras/camera.ts":
  19545. /*!***************************!*\
  19546. !*** ./Cameras/camera.ts ***!
  19547. \***************************/
  19548. /*! exports provided: Camera */
  19549. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19550. "use strict";
  19551. __webpack_require__.r(__webpack_exports__);
  19552. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return Camera; });
  19553. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19554. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  19555. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  19556. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  19557. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  19558. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  19559. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  19560. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  19561. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  19562. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  19563. /**
  19564. * This is the base class of all the camera used in the application.
  19565. * @see http://doc.babylonjs.com/features/cameras
  19566. */
  19567. var Camera = /** @class */ (function (_super) {
  19568. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Camera, _super);
  19569. /**
  19570. * Instantiates a new camera object.
  19571. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  19572. * @see http://doc.babylonjs.com/features/cameras
  19573. * @param name Defines the name of the camera in the scene
  19574. * @param position Defines the position of the camera
  19575. * @param scene Defines the scene the camera belongs too
  19576. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  19577. */
  19578. function Camera(name, position, scene, setActiveOnSceneIfNoneActive) {
  19579. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  19580. var _this = _super.call(this, name, scene) || this;
  19581. /**
  19582. * The vector the camera should consider as up.
  19583. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  19584. */
  19585. _this.upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Up();
  19586. /**
  19587. * Define the current limit on the left side for an orthographic camera
  19588. * In scene unit
  19589. */
  19590. _this.orthoLeft = null;
  19591. /**
  19592. * Define the current limit on the right side for an orthographic camera
  19593. * In scene unit
  19594. */
  19595. _this.orthoRight = null;
  19596. /**
  19597. * Define the current limit on the bottom side for an orthographic camera
  19598. * In scene unit
  19599. */
  19600. _this.orthoBottom = null;
  19601. /**
  19602. * Define the current limit on the top side for an orthographic camera
  19603. * In scene unit
  19604. */
  19605. _this.orthoTop = null;
  19606. /**
  19607. * Field Of View is set in Radians. (default is 0.8)
  19608. */
  19609. _this.fov = 0.8;
  19610. /**
  19611. * Define the minimum distance the camera can see from.
  19612. * This is important to note that the depth buffer are not infinite and the closer it starts
  19613. * the more your scene might encounter depth fighting issue.
  19614. */
  19615. _this.minZ = 1;
  19616. /**
  19617. * Define the maximum distance the camera can see to.
  19618. * This is important to note that the depth buffer are not infinite and the further it end
  19619. * the more your scene might encounter depth fighting issue.
  19620. */
  19621. _this.maxZ = 10000.0;
  19622. /**
  19623. * Define the default inertia of the camera.
  19624. * This helps giving a smooth feeling to the camera movement.
  19625. */
  19626. _this.inertia = 0.9;
  19627. /**
  19628. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  19629. */
  19630. _this.mode = Camera.PERSPECTIVE_CAMERA;
  19631. /**
  19632. * Define wether the camera is intermediate.
  19633. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  19634. */
  19635. _this.isIntermediate = false;
  19636. /**
  19637. * Define the viewport of the camera.
  19638. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  19639. */
  19640. _this.viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0, 0, 1.0, 1.0);
  19641. /**
  19642. * Restricts the camera to viewing objects with the same layerMask.
  19643. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  19644. */
  19645. _this.layerMask = 0x0FFFFFFF;
  19646. /**
  19647. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  19648. */
  19649. _this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
  19650. /**
  19651. * Rig mode of the camera.
  19652. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  19653. * This is normally controlled byt the camera themselves as internal use.
  19654. */
  19655. _this.cameraRigMode = Camera.RIG_MODE_NONE;
  19656. /**
  19657. * 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
  19658. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  19659. * else in the scene.
  19660. */
  19661. _this.customRenderTargets = new Array();
  19662. /**
  19663. * When set, the camera will render to this render target instead of the default canvas
  19664. */
  19665. _this.outputRenderTarget = null;
  19666. /**
  19667. * Observable triggered when the camera view matrix has changed.
  19668. */
  19669. _this.onViewMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  19670. /**
  19671. * Observable triggered when the camera Projection matrix has changed.
  19672. */
  19673. _this.onProjectionMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  19674. /**
  19675. * Observable triggered when the inputs have been processed.
  19676. */
  19677. _this.onAfterCheckInputsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  19678. /**
  19679. * Observable triggered when reset has been called and applied to the camera.
  19680. */
  19681. _this.onRestoreStateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  19682. /** @hidden */
  19683. _this._rigCameras = new Array();
  19684. _this._webvrViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  19685. /** @hidden */
  19686. _this._skipRendering = false;
  19687. /** @hidden */
  19688. _this._projectionMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  19689. /** @hidden */
  19690. _this._postProcesses = new Array();
  19691. /** @hidden */
  19692. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](256);
  19693. _this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  19694. /** hidden */
  19695. _this._computedViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  19696. _this._doNotComputeProjectionMatrix = false;
  19697. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Zero();
  19698. _this._refreshFrustumPlanes = true;
  19699. /** @hidden */
  19700. _this._isCamera = true;
  19701. _this.getScene().addCamera(_this);
  19702. if (setActiveOnSceneIfNoneActive && !_this.getScene().activeCamera) {
  19703. _this.getScene().activeCamera = _this;
  19704. }
  19705. _this.position = position;
  19706. return _this;
  19707. }
  19708. /**
  19709. * Store current camera state (fov, position, etc..)
  19710. * @returns the camera
  19711. */
  19712. Camera.prototype.storeState = function () {
  19713. this._stateStored = true;
  19714. this._storedFov = this.fov;
  19715. return this;
  19716. };
  19717. /**
  19718. * Restores the camera state values if it has been stored. You must call storeState() first
  19719. */
  19720. Camera.prototype._restoreStateValues = function () {
  19721. if (!this._stateStored) {
  19722. return false;
  19723. }
  19724. this.fov = this._storedFov;
  19725. return true;
  19726. };
  19727. /**
  19728. * Restored camera state. You must call storeState() first.
  19729. * @returns true if restored and false otherwise
  19730. */
  19731. Camera.prototype.restoreState = function () {
  19732. if (this._restoreStateValues()) {
  19733. this.onRestoreStateObservable.notifyObservers(this);
  19734. return true;
  19735. }
  19736. return false;
  19737. };
  19738. /**
  19739. * Gets the class name of the camera.
  19740. * @returns the class name
  19741. */
  19742. Camera.prototype.getClassName = function () {
  19743. return "Camera";
  19744. };
  19745. /**
  19746. * Gets a string representation of the camera useful for debug purpose.
  19747. * @param fullDetails Defines that a more verboe level of logging is required
  19748. * @returns the string representation
  19749. */
  19750. Camera.prototype.toString = function (fullDetails) {
  19751. var ret = "Name: " + this.name;
  19752. ret += ", type: " + this.getClassName();
  19753. if (this.animations) {
  19754. for (var i = 0; i < this.animations.length; i++) {
  19755. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  19756. }
  19757. }
  19758. if (fullDetails) {
  19759. }
  19760. return ret;
  19761. };
  19762. Object.defineProperty(Camera.prototype, "globalPosition", {
  19763. /**
  19764. * Gets the current world space position of the camera.
  19765. */
  19766. get: function () {
  19767. return this._globalPosition;
  19768. },
  19769. enumerable: true,
  19770. configurable: true
  19771. });
  19772. /**
  19773. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  19774. * @returns the active meshe list
  19775. */
  19776. Camera.prototype.getActiveMeshes = function () {
  19777. return this._activeMeshes;
  19778. };
  19779. /**
  19780. * Check wether a mesh is part of the current active mesh list of the camera
  19781. * @param mesh Defines the mesh to check
  19782. * @returns true if active, false otherwise
  19783. */
  19784. Camera.prototype.isActiveMesh = function (mesh) {
  19785. return (this._activeMeshes.indexOf(mesh) !== -1);
  19786. };
  19787. /**
  19788. * Is this camera ready to be used/rendered
  19789. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  19790. * @return true if the camera is ready
  19791. */
  19792. Camera.prototype.isReady = function (completeCheck) {
  19793. if (completeCheck === void 0) { completeCheck = false; }
  19794. if (completeCheck) {
  19795. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  19796. var pp = _a[_i];
  19797. if (pp && !pp.isReady()) {
  19798. return false;
  19799. }
  19800. }
  19801. }
  19802. return _super.prototype.isReady.call(this, completeCheck);
  19803. };
  19804. /** @hidden */
  19805. Camera.prototype._initCache = function () {
  19806. _super.prototype._initCache.call(this);
  19807. this._cache.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  19808. this._cache.upVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  19809. this._cache.mode = undefined;
  19810. this._cache.minZ = undefined;
  19811. this._cache.maxZ = undefined;
  19812. this._cache.fov = undefined;
  19813. this._cache.fovMode = undefined;
  19814. this._cache.aspectRatio = undefined;
  19815. this._cache.orthoLeft = undefined;
  19816. this._cache.orthoRight = undefined;
  19817. this._cache.orthoBottom = undefined;
  19818. this._cache.orthoTop = undefined;
  19819. this._cache.renderWidth = undefined;
  19820. this._cache.renderHeight = undefined;
  19821. };
  19822. /** @hidden */
  19823. Camera.prototype._updateCache = function (ignoreParentClass) {
  19824. if (!ignoreParentClass) {
  19825. _super.prototype._updateCache.call(this);
  19826. }
  19827. this._cache.position.copyFrom(this.position);
  19828. this._cache.upVector.copyFrom(this.upVector);
  19829. };
  19830. /** @hidden */
  19831. Camera.prototype._isSynchronized = function () {
  19832. return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
  19833. };
  19834. /** @hidden */
  19835. Camera.prototype._isSynchronizedViewMatrix = function () {
  19836. if (!_super.prototype._isSynchronized.call(this)) {
  19837. return false;
  19838. }
  19839. return this._cache.position.equals(this.position)
  19840. && this._cache.upVector.equals(this.upVector)
  19841. && this.isSynchronizedWithParent();
  19842. };
  19843. /** @hidden */
  19844. Camera.prototype._isSynchronizedProjectionMatrix = function () {
  19845. var check = this._cache.mode === this.mode
  19846. && this._cache.minZ === this.minZ
  19847. && this._cache.maxZ === this.maxZ;
  19848. if (!check) {
  19849. return false;
  19850. }
  19851. var engine = this.getEngine();
  19852. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  19853. check = this._cache.fov === this.fov
  19854. && this._cache.fovMode === this.fovMode
  19855. && this._cache.aspectRatio === engine.getAspectRatio(this);
  19856. }
  19857. else {
  19858. check = this._cache.orthoLeft === this.orthoLeft
  19859. && this._cache.orthoRight === this.orthoRight
  19860. && this._cache.orthoBottom === this.orthoBottom
  19861. && this._cache.orthoTop === this.orthoTop
  19862. && this._cache.renderWidth === engine.getRenderWidth()
  19863. && this._cache.renderHeight === engine.getRenderHeight();
  19864. }
  19865. return check;
  19866. };
  19867. /**
  19868. * Attach the input controls to a specific dom element to get the input from.
  19869. * @param element Defines the element the controls should be listened from
  19870. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19871. */
  19872. Camera.prototype.attachControl = function (element, noPreventDefault) {
  19873. };
  19874. /**
  19875. * Detach the current controls from the specified dom element.
  19876. * @param element Defines the element to stop listening the inputs from
  19877. */
  19878. Camera.prototype.detachControl = function (element) {
  19879. };
  19880. /**
  19881. * Update the camera state according to the different inputs gathered during the frame.
  19882. */
  19883. Camera.prototype.update = function () {
  19884. this._checkInputs();
  19885. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  19886. this._updateRigCameras();
  19887. }
  19888. };
  19889. /** @hidden */
  19890. Camera.prototype._checkInputs = function () {
  19891. this.onAfterCheckInputsObservable.notifyObservers(this);
  19892. };
  19893. Object.defineProperty(Camera.prototype, "rigCameras", {
  19894. /** @hidden */
  19895. get: function () {
  19896. return this._rigCameras;
  19897. },
  19898. enumerable: true,
  19899. configurable: true
  19900. });
  19901. Object.defineProperty(Camera.prototype, "rigPostProcess", {
  19902. /**
  19903. * Gets the post process used by the rig cameras
  19904. */
  19905. get: function () {
  19906. return this._rigPostProcess;
  19907. },
  19908. enumerable: true,
  19909. configurable: true
  19910. });
  19911. /**
  19912. * Internal, gets the first post proces.
  19913. * @returns the first post process to be run on this camera.
  19914. */
  19915. Camera.prototype._getFirstPostProcess = function () {
  19916. for (var ppIndex = 0; ppIndex < this._postProcesses.length; ppIndex++) {
  19917. if (this._postProcesses[ppIndex] !== null) {
  19918. return this._postProcesses[ppIndex];
  19919. }
  19920. }
  19921. return null;
  19922. };
  19923. Camera.prototype._cascadePostProcessesToRigCams = function () {
  19924. // invalidate framebuffer
  19925. var firstPostProcess = this._getFirstPostProcess();
  19926. if (firstPostProcess) {
  19927. firstPostProcess.markTextureDirty();
  19928. }
  19929. // glue the rigPostProcess to the end of the user postprocesses & assign to each sub-camera
  19930. for (var i = 0, len = this._rigCameras.length; i < len; i++) {
  19931. var cam = this._rigCameras[i];
  19932. var rigPostProcess = cam._rigPostProcess;
  19933. // for VR rig, there does not have to be a post process
  19934. if (rigPostProcess) {
  19935. var isPass = rigPostProcess.getEffectName() === "pass";
  19936. if (isPass) {
  19937. // any rig which has a PassPostProcess for rig[0], cannot be isIntermediate when there are also user postProcesses
  19938. cam.isIntermediate = this._postProcesses.length === 0;
  19939. }
  19940. cam._postProcesses = this._postProcesses.slice(0).concat(rigPostProcess);
  19941. rigPostProcess.markTextureDirty();
  19942. }
  19943. else {
  19944. cam._postProcesses = this._postProcesses.slice(0);
  19945. }
  19946. }
  19947. };
  19948. /**
  19949. * Attach a post process to the camera.
  19950. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  19951. * @param postProcess The post process to attach to the camera
  19952. * @param insertAt The position of the post process in case several of them are in use in the scene
  19953. * @returns the position the post process has been inserted at
  19954. */
  19955. Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
  19956. if (insertAt === void 0) { insertAt = null; }
  19957. if (!postProcess.isReusable() && this._postProcesses.indexOf(postProcess) > -1) {
  19958. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Error("You're trying to reuse a post process not defined as reusable.");
  19959. return 0;
  19960. }
  19961. if (insertAt == null || insertAt < 0) {
  19962. this._postProcesses.push(postProcess);
  19963. }
  19964. else if (this._postProcesses[insertAt] === null) {
  19965. this._postProcesses[insertAt] = postProcess;
  19966. }
  19967. else {
  19968. this._postProcesses.splice(insertAt, 0, postProcess);
  19969. }
  19970. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  19971. return this._postProcesses.indexOf(postProcess);
  19972. };
  19973. /**
  19974. * Detach a post process to the camera.
  19975. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  19976. * @param postProcess The post process to detach from the camera
  19977. */
  19978. Camera.prototype.detachPostProcess = function (postProcess) {
  19979. var idx = this._postProcesses.indexOf(postProcess);
  19980. if (idx !== -1) {
  19981. this._postProcesses[idx] = null;
  19982. }
  19983. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  19984. };
  19985. /**
  19986. * Gets the current world matrix of the camera
  19987. */
  19988. Camera.prototype.getWorldMatrix = function () {
  19989. if (this._isSynchronizedViewMatrix()) {
  19990. return this._worldMatrix;
  19991. }
  19992. // Getting the the view matrix will also compute the world matrix.
  19993. this.getViewMatrix();
  19994. return this._worldMatrix;
  19995. };
  19996. /** @hidden */
  19997. Camera.prototype._getViewMatrix = function () {
  19998. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  19999. };
  20000. /**
  20001. * Gets the current view matrix of the camera.
  20002. * @param force forces the camera to recompute the matrix without looking at the cached state
  20003. * @returns the view matrix
  20004. */
  20005. Camera.prototype.getViewMatrix = function (force) {
  20006. if (!force && this._isSynchronizedViewMatrix()) {
  20007. return this._computedViewMatrix;
  20008. }
  20009. this.updateCache();
  20010. this._computedViewMatrix = this._getViewMatrix();
  20011. this._currentRenderId = this.getScene().getRenderId();
  20012. this._childRenderId = this._currentRenderId;
  20013. this._refreshFrustumPlanes = true;
  20014. if (this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix) {
  20015. this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix);
  20016. }
  20017. this.onViewMatrixChangedObservable.notifyObservers(this);
  20018. this._computedViewMatrix.invertToRef(this._worldMatrix);
  20019. return this._computedViewMatrix;
  20020. };
  20021. /**
  20022. * Freeze the projection matrix.
  20023. * It will prevent the cache check of the camera projection compute and can speed up perf
  20024. * if no parameter of the camera are meant to change
  20025. * @param projection Defines manually a projection if necessary
  20026. */
  20027. Camera.prototype.freezeProjectionMatrix = function (projection) {
  20028. this._doNotComputeProjectionMatrix = true;
  20029. if (projection !== undefined) {
  20030. this._projectionMatrix = projection;
  20031. }
  20032. };
  20033. /**
  20034. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  20035. */
  20036. Camera.prototype.unfreezeProjectionMatrix = function () {
  20037. this._doNotComputeProjectionMatrix = false;
  20038. };
  20039. /**
  20040. * Gets the current projection matrix of the camera.
  20041. * @param force forces the camera to recompute the matrix without looking at the cached state
  20042. * @returns the projection matrix
  20043. */
  20044. Camera.prototype.getProjectionMatrix = function (force) {
  20045. if (this._doNotComputeProjectionMatrix || (!force && this._isSynchronizedProjectionMatrix())) {
  20046. return this._projectionMatrix;
  20047. }
  20048. // Cache
  20049. this._cache.mode = this.mode;
  20050. this._cache.minZ = this.minZ;
  20051. this._cache.maxZ = this.maxZ;
  20052. // Matrix
  20053. this._refreshFrustumPlanes = true;
  20054. var engine = this.getEngine();
  20055. var scene = this.getScene();
  20056. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20057. this._cache.fov = this.fov;
  20058. this._cache.fovMode = this.fovMode;
  20059. this._cache.aspectRatio = engine.getAspectRatio(this);
  20060. if (this.minZ <= 0) {
  20061. this.minZ = 0.1;
  20062. }
  20063. if (scene.useRightHandedSystem) {
  20064. _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);
  20065. }
  20066. else {
  20067. _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);
  20068. }
  20069. }
  20070. else {
  20071. var halfWidth = engine.getRenderWidth() / 2.0;
  20072. var halfHeight = engine.getRenderHeight() / 2.0;
  20073. if (scene.useRightHandedSystem) {
  20074. _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);
  20075. }
  20076. else {
  20077. _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);
  20078. }
  20079. this._cache.orthoLeft = this.orthoLeft;
  20080. this._cache.orthoRight = this.orthoRight;
  20081. this._cache.orthoBottom = this.orthoBottom;
  20082. this._cache.orthoTop = this.orthoTop;
  20083. this._cache.renderWidth = engine.getRenderWidth();
  20084. this._cache.renderHeight = engine.getRenderHeight();
  20085. }
  20086. this.onProjectionMatrixChangedObservable.notifyObservers(this);
  20087. return this._projectionMatrix;
  20088. };
  20089. /**
  20090. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  20091. * @returns a Matrix
  20092. */
  20093. Camera.prototype.getTransformationMatrix = function () {
  20094. this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  20095. return this._transformMatrix;
  20096. };
  20097. Camera.prototype._updateFrustumPlanes = function () {
  20098. if (!this._refreshFrustumPlanes) {
  20099. return;
  20100. }
  20101. this.getTransformationMatrix();
  20102. if (!this._frustumPlanes) {
  20103. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanes(this._transformMatrix);
  20104. }
  20105. else {
  20106. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  20107. }
  20108. this._refreshFrustumPlanes = false;
  20109. };
  20110. /**
  20111. * Checks if a cullable object (mesh...) is in the camera frustum
  20112. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  20113. * @param target The object to check
  20114. * @returns true if the object is in frustum otherwise false
  20115. */
  20116. Camera.prototype.isInFrustum = function (target) {
  20117. this._updateFrustumPlanes();
  20118. return target.isInFrustum(this._frustumPlanes);
  20119. };
  20120. /**
  20121. * Checks if a cullable object (mesh...) is in the camera frustum
  20122. * Unlike isInFrustum this cheks the full bounding box
  20123. * @param target The object to check
  20124. * @returns true if the object is in frustum otherwise false
  20125. */
  20126. Camera.prototype.isCompletelyInFrustum = function (target) {
  20127. this._updateFrustumPlanes();
  20128. return target.isCompletelyInFrustum(this._frustumPlanes);
  20129. };
  20130. /**
  20131. * Gets a ray in the forward direction from the camera.
  20132. * @param length Defines the length of the ray to create
  20133. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  20134. * @param origin Defines the start point of the ray which defaults to the camera position
  20135. * @returns the forward ray
  20136. */
  20137. Camera.prototype.getForwardRay = function (length, transform, origin) {
  20138. if (length === void 0) { length = 100; }
  20139. if (!transform) {
  20140. transform = this.getWorldMatrix();
  20141. }
  20142. if (!origin) {
  20143. origin = this.position;
  20144. }
  20145. 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);
  20146. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormal(forward, transform);
  20147. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Normalize(forwardWorld);
  20148. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_7__["Ray"](origin, direction, length);
  20149. };
  20150. /**
  20151. * Releases resources associated with this node.
  20152. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20153. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20154. */
  20155. Camera.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  20156. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  20157. // Observables
  20158. this.onViewMatrixChangedObservable.clear();
  20159. this.onProjectionMatrixChangedObservable.clear();
  20160. this.onAfterCheckInputsObservable.clear();
  20161. this.onRestoreStateObservable.clear();
  20162. // Inputs
  20163. if (this.inputs) {
  20164. this.inputs.clear();
  20165. }
  20166. // Animations
  20167. this.getScene().stopAnimation(this);
  20168. // Remove from scene
  20169. this.getScene().removeCamera(this);
  20170. while (this._rigCameras.length > 0) {
  20171. var camera = this._rigCameras.pop();
  20172. if (camera) {
  20173. camera.dispose();
  20174. }
  20175. }
  20176. // Postprocesses
  20177. if (this._rigPostProcess) {
  20178. this._rigPostProcess.dispose(this);
  20179. this._rigPostProcess = null;
  20180. this._postProcesses = [];
  20181. }
  20182. else if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20183. this._rigPostProcess = null;
  20184. this._postProcesses = [];
  20185. }
  20186. else {
  20187. var i = this._postProcesses.length;
  20188. while (--i >= 0) {
  20189. var postProcess = this._postProcesses[i];
  20190. if (postProcess) {
  20191. postProcess.dispose(this);
  20192. }
  20193. }
  20194. }
  20195. // Render targets
  20196. var i = this.customRenderTargets.length;
  20197. while (--i >= 0) {
  20198. this.customRenderTargets[i].dispose();
  20199. }
  20200. this.customRenderTargets = [];
  20201. // Active Meshes
  20202. this._activeMeshes.dispose();
  20203. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  20204. };
  20205. Object.defineProperty(Camera.prototype, "leftCamera", {
  20206. /**
  20207. * Gets the left camera of a rig setup in case of Rigged Camera
  20208. */
  20209. get: function () {
  20210. if (this._rigCameras.length < 1) {
  20211. return null;
  20212. }
  20213. return this._rigCameras[0];
  20214. },
  20215. enumerable: true,
  20216. configurable: true
  20217. });
  20218. Object.defineProperty(Camera.prototype, "rightCamera", {
  20219. /**
  20220. * Gets the right camera of a rig setup in case of Rigged Camera
  20221. */
  20222. get: function () {
  20223. if (this._rigCameras.length < 2) {
  20224. return null;
  20225. }
  20226. return this._rigCameras[1];
  20227. },
  20228. enumerable: true,
  20229. configurable: true
  20230. });
  20231. /**
  20232. * Gets the left camera target of a rig setup in case of Rigged Camera
  20233. * @returns the target position
  20234. */
  20235. Camera.prototype.getLeftTarget = function () {
  20236. if (this._rigCameras.length < 1) {
  20237. return null;
  20238. }
  20239. return this._rigCameras[0].getTarget();
  20240. };
  20241. /**
  20242. * Gets the right camera target of a rig setup in case of Rigged Camera
  20243. * @returns the target position
  20244. */
  20245. Camera.prototype.getRightTarget = function () {
  20246. if (this._rigCameras.length < 2) {
  20247. return null;
  20248. }
  20249. return this._rigCameras[1].getTarget();
  20250. };
  20251. /**
  20252. * @hidden
  20253. */
  20254. Camera.prototype.setCameraRigMode = function (mode, rigParams) {
  20255. if (this.cameraRigMode === mode) {
  20256. return;
  20257. }
  20258. while (this._rigCameras.length > 0) {
  20259. var camera = this._rigCameras.pop();
  20260. if (camera) {
  20261. camera.dispose();
  20262. }
  20263. }
  20264. this.cameraRigMode = mode;
  20265. this._cameraRigParams = {};
  20266. //we have to implement stereo camera calcultating left and right viewpoints from interaxialDistance and target,
  20267. //not from a given angle as it is now, but until that complete code rewriting provisional stereoHalfAngle value is introduced
  20268. this._cameraRigParams.interaxialDistance = rigParams.interaxialDistance || 0.0637;
  20269. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(this._cameraRigParams.interaxialDistance / 0.0637);
  20270. // create the rig cameras, unless none
  20271. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20272. var leftCamera = this.createRigCamera(this.name + "_L", 0);
  20273. var rightCamera = this.createRigCamera(this.name + "_R", 1);
  20274. if (leftCamera && rightCamera) {
  20275. this._rigCameras.push(leftCamera);
  20276. this._rigCameras.push(rightCamera);
  20277. }
  20278. }
  20279. switch (this.cameraRigMode) {
  20280. case Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20281. Camera._setStereoscopicAnaglyphRigMode(this);
  20282. break;
  20283. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20284. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20285. case Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20286. Camera._setStereoscopicRigMode(this);
  20287. break;
  20288. case Camera.RIG_MODE_VR:
  20289. Camera._setVRRigMode(this, rigParams);
  20290. break;
  20291. case Camera.RIG_MODE_WEBVR:
  20292. Camera._setWebVRRigMode(this, rigParams);
  20293. break;
  20294. }
  20295. this._cascadePostProcessesToRigCams();
  20296. this.update();
  20297. };
  20298. /** @hidden */
  20299. Camera._setStereoscopicRigMode = function (camera) {
  20300. throw "Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode";
  20301. };
  20302. /** @hidden */
  20303. Camera._setStereoscopicAnaglyphRigMode = function (camera) {
  20304. throw "Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode";
  20305. };
  20306. /** @hidden */
  20307. Camera._setVRRigMode = function (camera, rigParams) {
  20308. throw "Import Cameras/RigModes/vrRigMode before using VR rig mode";
  20309. };
  20310. /** @hidden */
  20311. Camera._setWebVRRigMode = function (camera, rigParams) {
  20312. throw "Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode";
  20313. };
  20314. /** @hidden */
  20315. Camera.prototype._getVRProjectionMatrix = function () {
  20316. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix);
  20317. this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix);
  20318. return this._projectionMatrix;
  20319. };
  20320. Camera.prototype._updateCameraRotationMatrix = function () {
  20321. //Here for WebVR
  20322. };
  20323. Camera.prototype._updateWebVRCameraRotationMatrix = function () {
  20324. //Here for WebVR
  20325. };
  20326. /**
  20327. * This function MUST be overwritten by the different WebVR cameras available.
  20328. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  20329. * @hidden
  20330. */
  20331. Camera.prototype._getWebVRProjectionMatrix = function () {
  20332. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20333. };
  20334. /**
  20335. * This function MUST be overwritten by the different WebVR cameras available.
  20336. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  20337. * @hidden
  20338. */
  20339. Camera.prototype._getWebVRViewMatrix = function () {
  20340. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20341. };
  20342. /** @hidden */
  20343. Camera.prototype.setCameraRigParameter = function (name, value) {
  20344. if (!this._cameraRigParams) {
  20345. this._cameraRigParams = {};
  20346. }
  20347. this._cameraRigParams[name] = value;
  20348. //provisionnally:
  20349. if (name === "interaxialDistance") {
  20350. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(value / 0.0637);
  20351. }
  20352. };
  20353. /**
  20354. * needs to be overridden by children so sub has required properties to be copied
  20355. * @hidden
  20356. */
  20357. Camera.prototype.createRigCamera = function (name, cameraIndex) {
  20358. return null;
  20359. };
  20360. /**
  20361. * May need to be overridden by children
  20362. * @hidden
  20363. */
  20364. Camera.prototype._updateRigCameras = function () {
  20365. for (var i = 0; i < this._rigCameras.length; i++) {
  20366. this._rigCameras[i].minZ = this.minZ;
  20367. this._rigCameras[i].maxZ = this.maxZ;
  20368. this._rigCameras[i].fov = this.fov;
  20369. this._rigCameras[i].upVector.copyFrom(this.upVector);
  20370. }
  20371. // only update viewport when ANAGLYPH
  20372. if (this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH) {
  20373. this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport;
  20374. }
  20375. };
  20376. /** @hidden */
  20377. Camera.prototype._setupInputs = function () {
  20378. };
  20379. /**
  20380. * Serialiaze the camera setup to a json represention
  20381. * @returns the JSON representation
  20382. */
  20383. Camera.prototype.serialize = function () {
  20384. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  20385. // Type
  20386. serializationObject.type = this.getClassName();
  20387. // Parent
  20388. if (this.parent) {
  20389. serializationObject.parentId = this.parent.id;
  20390. }
  20391. if (this.inputs) {
  20392. this.inputs.serialize(serializationObject);
  20393. }
  20394. // Animations
  20395. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  20396. serializationObject.ranges = this.serializeAnimationRanges();
  20397. return serializationObject;
  20398. };
  20399. /**
  20400. * Clones the current camera.
  20401. * @param name The cloned camera name
  20402. * @returns the cloned camera
  20403. */
  20404. Camera.prototype.clone = function (name) {
  20405. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(Camera.GetConstructorFromName(this.getClassName(), name, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
  20406. };
  20407. /**
  20408. * Gets the direction of the camera relative to a given local axis.
  20409. * @param localAxis Defines the reference axis to provide a relative direction.
  20410. * @return the direction
  20411. */
  20412. Camera.prototype.getDirection = function (localAxis) {
  20413. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20414. this.getDirectionToRef(localAxis, result);
  20415. return result;
  20416. };
  20417. /**
  20418. * Gets the direction of the camera relative to a given local axis into a passed vector.
  20419. * @param localAxis Defines the reference axis to provide a relative direction.
  20420. * @param result Defines the vector to store the result in
  20421. */
  20422. Camera.prototype.getDirectionToRef = function (localAxis, result) {
  20423. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  20424. };
  20425. /**
  20426. * Gets a camera constructor for a given camera type
  20427. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  20428. * @param name The name of the camera the result will be able to instantiate
  20429. * @param scene The scene the result will construct the camera in
  20430. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  20431. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  20432. * @returns a factory method to construc the camera
  20433. */
  20434. Camera.GetConstructorFromName = function (type, name, scene, interaxial_distance, isStereoscopicSideBySide) {
  20435. if (interaxial_distance === void 0) { interaxial_distance = 0; }
  20436. if (isStereoscopicSideBySide === void 0) { isStereoscopicSideBySide = true; }
  20437. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_6__["Node"].Construct(type, name, scene, {
  20438. interaxial_distance: interaxial_distance,
  20439. isStereoscopicSideBySide: isStereoscopicSideBySide
  20440. });
  20441. if (constructorFunc) {
  20442. return constructorFunc;
  20443. }
  20444. // Default to universal camera
  20445. return function () { return Camera._createDefaultParsedCamera(name, scene); };
  20446. };
  20447. /**
  20448. * Compute the world matrix of the camera.
  20449. * @returns the camera workd matrix
  20450. */
  20451. Camera.prototype.computeWorldMatrix = function () {
  20452. return this.getWorldMatrix();
  20453. };
  20454. /**
  20455. * Parse a JSON and creates the camera from the parsed information
  20456. * @param parsedCamera The JSON to parse
  20457. * @param scene The scene to instantiate the camera in
  20458. * @returns the newly constructed camera
  20459. */
  20460. Camera.Parse = function (parsedCamera, scene) {
  20461. var type = parsedCamera.type;
  20462. var construct = Camera.GetConstructorFromName(type, parsedCamera.name, scene, parsedCamera.interaxial_distance, parsedCamera.isStereoscopicSideBySide);
  20463. var camera = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(construct, parsedCamera, scene);
  20464. // Parent
  20465. if (parsedCamera.parentId) {
  20466. camera._waitingParentId = parsedCamera.parentId;
  20467. }
  20468. //If camera has an input manager, let it parse inputs settings
  20469. if (camera.inputs) {
  20470. camera.inputs.parse(parsedCamera);
  20471. camera._setupInputs();
  20472. }
  20473. if (camera.setPosition) { // need to force position
  20474. camera.position.copyFromFloats(0, 0, 0);
  20475. camera.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.position));
  20476. }
  20477. // Target
  20478. if (parsedCamera.target) {
  20479. if (camera.setTarget) {
  20480. camera.setTarget(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.target));
  20481. }
  20482. }
  20483. // Apply 3d rig, when found
  20484. if (parsedCamera.cameraRigMode) {
  20485. var rigParams = (parsedCamera.interaxial_distance) ? { interaxialDistance: parsedCamera.interaxial_distance } : {};
  20486. camera.setCameraRigMode(parsedCamera.cameraRigMode, rigParams);
  20487. }
  20488. // Animations
  20489. if (parsedCamera.animations) {
  20490. for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
  20491. var parsedAnimation = parsedCamera.animations[animationIndex];
  20492. camera.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_9__["Animation"].Parse(parsedAnimation));
  20493. }
  20494. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(camera, parsedCamera, scene);
  20495. }
  20496. if (parsedCamera.autoAnimate) {
  20497. scene.beginAnimation(camera, parsedCamera.autoAnimateFrom, parsedCamera.autoAnimateTo, parsedCamera.autoAnimateLoop, parsedCamera.autoAnimateSpeed || 1.0);
  20498. }
  20499. return camera;
  20500. };
  20501. /** @hidden */
  20502. Camera._createDefaultParsedCamera = function (name, scene) {
  20503. throw "UniversalCamera needs to be imported before deserialization can create a default camera.";
  20504. };
  20505. /**
  20506. * This is the default projection mode used by the cameras.
  20507. * It helps recreating a feeling of perspective and better appreciate depth.
  20508. * This is the best way to simulate real life cameras.
  20509. */
  20510. Camera.PERSPECTIVE_CAMERA = 0;
  20511. /**
  20512. * This helps creating camera with an orthographic mode.
  20513. * 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.
  20514. */
  20515. Camera.ORTHOGRAPHIC_CAMERA = 1;
  20516. /**
  20517. * This is the default FOV mode for perspective cameras.
  20518. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  20519. */
  20520. Camera.FOVMODE_VERTICAL_FIXED = 0;
  20521. /**
  20522. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  20523. */
  20524. Camera.FOVMODE_HORIZONTAL_FIXED = 1;
  20525. /**
  20526. * This specifies ther is no need for a camera rig.
  20527. * Basically only one eye is rendered corresponding to the camera.
  20528. */
  20529. Camera.RIG_MODE_NONE = 0;
  20530. /**
  20531. * Simulates a camera Rig with one blue eye and one red eye.
  20532. * This can be use with 3d blue and red glasses.
  20533. */
  20534. Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10;
  20535. /**
  20536. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  20537. */
  20538. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11;
  20539. /**
  20540. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  20541. */
  20542. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12;
  20543. /**
  20544. * Defines that both eyes of the camera will be rendered over under each other.
  20545. */
  20546. Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13;
  20547. /**
  20548. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  20549. */
  20550. Camera.RIG_MODE_VR = 20;
  20551. /**
  20552. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  20553. */
  20554. Camera.RIG_MODE_WEBVR = 21;
  20555. /**
  20556. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  20557. */
  20558. Camera.RIG_MODE_CUSTOM = 22;
  20559. /**
  20560. * Defines if by default attaching controls should prevent the default javascript event to continue.
  20561. */
  20562. Camera.ForceAttachControlToAlwaysPreventDefault = false;
  20563. /**
  20564. * @hidden
  20565. * Might be removed once multiview will be a thing
  20566. */
  20567. Camera.UseAlternateWebVRRendering = false;
  20568. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20569. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20570. ], Camera.prototype, "position", void 0);
  20571. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20572. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20573. ], Camera.prototype, "upVector", void 0);
  20574. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20575. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20576. ], Camera.prototype, "orthoLeft", void 0);
  20577. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20578. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20579. ], Camera.prototype, "orthoRight", void 0);
  20580. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20581. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20582. ], Camera.prototype, "orthoBottom", void 0);
  20583. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20584. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20585. ], Camera.prototype, "orthoTop", void 0);
  20586. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20587. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20588. ], Camera.prototype, "fov", void 0);
  20589. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20590. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20591. ], Camera.prototype, "minZ", void 0);
  20592. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20593. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20594. ], Camera.prototype, "maxZ", void 0);
  20595. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20596. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20597. ], Camera.prototype, "inertia", void 0);
  20598. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20599. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20600. ], Camera.prototype, "mode", void 0);
  20601. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20602. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20603. ], Camera.prototype, "layerMask", void 0);
  20604. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20605. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20606. ], Camera.prototype, "fovMode", void 0);
  20607. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20608. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20609. ], Camera.prototype, "cameraRigMode", void 0);
  20610. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20611. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20612. ], Camera.prototype, "interaxialDistance", void 0);
  20613. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20614. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20615. ], Camera.prototype, "isStereoscopicSideBySide", void 0);
  20616. return Camera;
  20617. }(_node__WEBPACK_IMPORTED_MODULE_6__["Node"]));
  20618. /***/ }),
  20619. /***/ "./Cameras/cameraInputsManager.ts":
  20620. /*!****************************************!*\
  20621. !*** ./Cameras/cameraInputsManager.ts ***!
  20622. \****************************************/
  20623. /*! exports provided: CameraInputTypes, CameraInputsManager */
  20624. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20625. "use strict";
  20626. __webpack_require__.r(__webpack_exports__);
  20627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return CameraInputTypes; });
  20628. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return CameraInputsManager; });
  20629. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  20630. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  20631. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  20632. /**
  20633. * @ignore
  20634. * This is a list of all the different input types that are available in the application.
  20635. * Fo instance: ArcRotateCameraGamepadInput...
  20636. */
  20637. var CameraInputTypes = {};
  20638. /**
  20639. * This represents the input manager used within a camera.
  20640. * It helps dealing with all the different kind of input attached to a camera.
  20641. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  20642. */
  20643. var CameraInputsManager = /** @class */ (function () {
  20644. /**
  20645. * Instantiate a new Camera Input Manager.
  20646. * @param camera Defines the camera the input manager blongs to
  20647. */
  20648. function CameraInputsManager(camera) {
  20649. this.attached = {};
  20650. this.camera = camera;
  20651. this.checkInputs = function () { };
  20652. }
  20653. /**
  20654. * Add an input method to a camera
  20655. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  20656. * @param input camera input method
  20657. */
  20658. CameraInputsManager.prototype.add = function (input) {
  20659. var type = input.getSimpleName();
  20660. if (this.attached[type]) {
  20661. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("camera input of type " + type + " already exists on camera");
  20662. return;
  20663. }
  20664. this.attached[type] = input;
  20665. input.camera = this.camera;
  20666. //for checkInputs, we are dynamically creating a function
  20667. //the goal is to avoid the performance penalty of looping for inputs in the render loop
  20668. if (input.checkInputs) {
  20669. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  20670. }
  20671. if (this.attachedElement) {
  20672. input.attachControl(this.attachedElement);
  20673. }
  20674. };
  20675. /**
  20676. * Remove a specific input method from a camera
  20677. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  20678. * @param inputToRemove camera input method
  20679. */
  20680. CameraInputsManager.prototype.remove = function (inputToRemove) {
  20681. for (var cam in this.attached) {
  20682. var input = this.attached[cam];
  20683. if (input === inputToRemove) {
  20684. input.detachControl(this.attachedElement);
  20685. input.camera = null;
  20686. delete this.attached[cam];
  20687. this.rebuildInputCheck();
  20688. }
  20689. }
  20690. };
  20691. /**
  20692. * Remove a specific input type from a camera
  20693. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  20694. * @param inputType the type of the input to remove
  20695. */
  20696. CameraInputsManager.prototype.removeByType = function (inputType) {
  20697. for (var cam in this.attached) {
  20698. var input = this.attached[cam];
  20699. if (input.getClassName() === inputType) {
  20700. input.detachControl(this.attachedElement);
  20701. input.camera = null;
  20702. delete this.attached[cam];
  20703. this.rebuildInputCheck();
  20704. }
  20705. }
  20706. };
  20707. CameraInputsManager.prototype._addCheckInputs = function (fn) {
  20708. var current = this.checkInputs;
  20709. return function () {
  20710. current();
  20711. fn();
  20712. };
  20713. };
  20714. /**
  20715. * Attach the input controls to the currently attached dom element to listen the events from.
  20716. * @param input Defines the input to attach
  20717. */
  20718. CameraInputsManager.prototype.attachInput = function (input) {
  20719. if (this.attachedElement) {
  20720. input.attachControl(this.attachedElement, this.noPreventDefault);
  20721. }
  20722. };
  20723. /**
  20724. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  20725. * @param element Defines the dom element to collect the events from
  20726. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20727. */
  20728. CameraInputsManager.prototype.attachElement = function (element, noPreventDefault) {
  20729. if (noPreventDefault === void 0) { noPreventDefault = false; }
  20730. if (this.attachedElement) {
  20731. return;
  20732. }
  20733. noPreventDefault = _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  20734. this.attachedElement = element;
  20735. this.noPreventDefault = noPreventDefault;
  20736. for (var cam in this.attached) {
  20737. this.attached[cam].attachControl(element, noPreventDefault);
  20738. }
  20739. };
  20740. /**
  20741. * Detach the current manager inputs controls from a specific dom element.
  20742. * @param element Defines the dom element to collect the events from
  20743. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  20744. */
  20745. CameraInputsManager.prototype.detachElement = function (element, disconnect) {
  20746. if (disconnect === void 0) { disconnect = false; }
  20747. if (this.attachedElement !== element) {
  20748. return;
  20749. }
  20750. for (var cam in this.attached) {
  20751. this.attached[cam].detachControl(element);
  20752. if (disconnect) {
  20753. this.attached[cam].camera = null;
  20754. }
  20755. }
  20756. this.attachedElement = null;
  20757. };
  20758. /**
  20759. * Rebuild the dynamic inputCheck function from the current list of
  20760. * defined inputs in the manager.
  20761. */
  20762. CameraInputsManager.prototype.rebuildInputCheck = function () {
  20763. this.checkInputs = function () { };
  20764. for (var cam in this.attached) {
  20765. var input = this.attached[cam];
  20766. if (input.checkInputs) {
  20767. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  20768. }
  20769. }
  20770. };
  20771. /**
  20772. * Remove all attached input methods from a camera
  20773. */
  20774. CameraInputsManager.prototype.clear = function () {
  20775. if (this.attachedElement) {
  20776. this.detachElement(this.attachedElement, true);
  20777. }
  20778. this.attached = {};
  20779. this.attachedElement = null;
  20780. this.checkInputs = function () { };
  20781. };
  20782. /**
  20783. * Serialize the current input manager attached to a camera.
  20784. * This ensures than once parsed,
  20785. * the input associated to the camera will be identical to the current ones
  20786. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  20787. */
  20788. CameraInputsManager.prototype.serialize = function (serializedCamera) {
  20789. var inputs = {};
  20790. for (var cam in this.attached) {
  20791. var input = this.attached[cam];
  20792. var res = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(input);
  20793. inputs[input.getClassName()] = res;
  20794. }
  20795. serializedCamera.inputsmgr = inputs;
  20796. };
  20797. /**
  20798. * Parses an input manager serialized JSON to restore the previous list of inputs
  20799. * and states associated to a camera.
  20800. * @param parsedCamera Defines the JSON to parse
  20801. */
  20802. CameraInputsManager.prototype.parse = function (parsedCamera) {
  20803. var parsedInputs = parsedCamera.inputsmgr;
  20804. if (parsedInputs) {
  20805. this.clear();
  20806. for (var n in parsedInputs) {
  20807. var construct = CameraInputTypes[n];
  20808. if (construct) {
  20809. var parsedinput = parsedInputs[n];
  20810. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedinput, null);
  20811. this.add(input);
  20812. }
  20813. }
  20814. }
  20815. else {
  20816. //2016-03-08 this part is for managing backward compatibility
  20817. for (var n in this.attached) {
  20818. var construct = CameraInputTypes[this.attached[n].getClassName()];
  20819. if (construct) {
  20820. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedCamera, null);
  20821. this.remove(this.attached[n]);
  20822. this.add(input);
  20823. }
  20824. }
  20825. }
  20826. };
  20827. return CameraInputsManager;
  20828. }());
  20829. /***/ }),
  20830. /***/ "./Cameras/deviceOrientationCamera.ts":
  20831. /*!********************************************!*\
  20832. !*** ./Cameras/deviceOrientationCamera.ts ***!
  20833. \********************************************/
  20834. /*! exports provided: DeviceOrientationCamera */
  20835. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20836. "use strict";
  20837. __webpack_require__.r(__webpack_exports__);
  20838. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return DeviceOrientationCamera; });
  20839. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20840. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  20841. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  20842. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  20843. /* harmony import */ var _Inputs_freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  20844. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("DeviceOrientationCamera", function (name, scene) {
  20845. return function () { return new DeviceOrientationCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  20846. });
  20847. // We're mainly based on the logic defined into the FreeCamera code
  20848. /**
  20849. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  20850. * being tilted forward or back and left or right.
  20851. */
  20852. var DeviceOrientationCamera = /** @class */ (function (_super) {
  20853. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DeviceOrientationCamera, _super);
  20854. /**
  20855. * Creates a new device orientation camera
  20856. * @param name The name of the camera
  20857. * @param position The start position camera
  20858. * @param scene The scene the camera belongs to
  20859. */
  20860. function DeviceOrientationCamera(name, position, scene) {
  20861. var _this = _super.call(this, name, position, scene) || this;
  20862. _this._quaternionCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  20863. _this.inputs.addDeviceOrientation();
  20864. return _this;
  20865. }
  20866. /**
  20867. * Gets the current instance class name ("DeviceOrientationCamera").
  20868. * This helps avoiding instanceof at run time.
  20869. * @returns the class name
  20870. */
  20871. DeviceOrientationCamera.prototype.getClassName = function () {
  20872. return "DeviceOrientationCamera";
  20873. };
  20874. /**
  20875. * @hidden
  20876. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  20877. */
  20878. DeviceOrientationCamera.prototype._checkInputs = function () {
  20879. _super.prototype._checkInputs.call(this);
  20880. this._quaternionCache.copyFrom(this.rotationQuaternion);
  20881. if (this._initialQuaternion) {
  20882. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  20883. }
  20884. };
  20885. /**
  20886. * Reset the camera to its default orientation on the specified axis only.
  20887. * @param axis The axis to reset
  20888. */
  20889. DeviceOrientationCamera.prototype.resetToCurrentRotation = function (axis) {
  20890. var _this = this;
  20891. if (axis === void 0) { axis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y; }
  20892. //can only work if this camera has a rotation quaternion already.
  20893. if (!this.rotationQuaternion) {
  20894. return;
  20895. }
  20896. if (!this._initialQuaternion) {
  20897. this._initialQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  20898. }
  20899. this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion);
  20900. ['x', 'y', 'z'].forEach(function (axisName) {
  20901. if (!axis[axisName]) {
  20902. _this._initialQuaternion[axisName] = 0;
  20903. }
  20904. else {
  20905. _this._initialQuaternion[axisName] *= -1;
  20906. }
  20907. });
  20908. this._initialQuaternion.normalize();
  20909. //force rotation update
  20910. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  20911. };
  20912. return DeviceOrientationCamera;
  20913. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  20914. /***/ }),
  20915. /***/ "./Cameras/flyCamera.ts":
  20916. /*!******************************!*\
  20917. !*** ./Cameras/flyCamera.ts ***!
  20918. \******************************/
  20919. /*! exports provided: FlyCamera */
  20920. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20921. "use strict";
  20922. __webpack_require__.r(__webpack_exports__);
  20923. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return FlyCamera; });
  20924. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20925. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  20926. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  20927. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  20928. /* harmony import */ var _Collisions_collider__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Collisions/collider */ "./Collisions/collider.ts");
  20929. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  20930. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  20931. /**
  20932. * This is a flying camera, designed for 3D movement and rotation in all directions,
  20933. * such as in a 3D Space Shooter or a Flight Simulator.
  20934. */
  20935. var FlyCamera = /** @class */ (function (_super) {
  20936. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCamera, _super);
  20937. /**
  20938. * Instantiates a FlyCamera.
  20939. * This is a flying camera, designed for 3D movement and rotation in all directions,
  20940. * such as in a 3D Space Shooter or a Flight Simulator.
  20941. * @param name Define the name of the camera in the scene.
  20942. * @param position Define the starting position of the camera in the scene.
  20943. * @param scene Define the scene the camera belongs to.
  20944. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  20945. */
  20946. function FlyCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  20947. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  20948. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  20949. /**
  20950. * Define the collision ellipsoid of the camera.
  20951. * This is helpful for simulating a camera body, like a player's body.
  20952. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  20953. */
  20954. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  20955. /**
  20956. * Define an offset for the position of the ellipsoid around the camera.
  20957. * This can be helpful if the camera is attached away from the player's body center,
  20958. * such as at its head.
  20959. */
  20960. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  20961. /**
  20962. * Enable or disable collisions of the camera with the rest of the scene objects.
  20963. */
  20964. _this.checkCollisions = false;
  20965. /**
  20966. * Enable or disable gravity on the camera.
  20967. */
  20968. _this.applyGravity = false;
  20969. /**
  20970. * Define the current direction the camera is moving to.
  20971. */
  20972. _this.cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  20973. /**
  20974. * Track Roll to maintain the wanted Rolling when looking around.
  20975. */
  20976. _this._trackRoll = 0;
  20977. /**
  20978. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  20979. */
  20980. _this.rollCorrect = 100;
  20981. /**
  20982. * Mimic a banked turn, Rolling the camera when Yawing.
  20983. * It's recommended to use rollCorrect = 10 for faster banking correction.
  20984. */
  20985. _this.bankedTurn = false;
  20986. /**
  20987. * Limit in radians for how much Roll banking will add. (Default: 90°)
  20988. */
  20989. _this.bankedTurnLimit = Math.PI / 2;
  20990. /**
  20991. * Value of 0 disables the banked Roll.
  20992. * Value of 1 is equal to the Yaw angle in radians.
  20993. */
  20994. _this.bankedTurnMultiplier = 1;
  20995. _this._needMoveForGravity = false;
  20996. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  20997. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  20998. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  20999. // Collisions.
  21000. _this._collisionMask = -1;
  21001. /** @hidden */
  21002. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  21003. if (collidedMesh === void 0) { collidedMesh = null; }
  21004. var updatePosition = function (newPos) {
  21005. _this._newPosition.copyFrom(newPos);
  21006. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  21007. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  21008. _this.position.addInPlace(_this._diffPosition);
  21009. if (_this.onCollide && collidedMesh) {
  21010. _this.onCollide(collidedMesh);
  21011. }
  21012. }
  21013. };
  21014. updatePosition(newPosition);
  21015. };
  21016. _this.inputs = new _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FlyCameraInputsManager"](_this);
  21017. _this.inputs.addKeyboard().addMouse();
  21018. return _this;
  21019. }
  21020. Object.defineProperty(FlyCamera.prototype, "angularSensibility", {
  21021. /**
  21022. * Gets the input sensibility for mouse input.
  21023. * Higher values reduce sensitivity.
  21024. */
  21025. get: function () {
  21026. var mouse = this.inputs.attached["mouse"];
  21027. if (mouse) {
  21028. return mouse.angularSensibility;
  21029. }
  21030. return 0;
  21031. },
  21032. /**
  21033. * Sets the input sensibility for a mouse input.
  21034. * Higher values reduce sensitivity.
  21035. */
  21036. set: function (value) {
  21037. var mouse = this.inputs.attached["mouse"];
  21038. if (mouse) {
  21039. mouse.angularSensibility = value;
  21040. }
  21041. },
  21042. enumerable: true,
  21043. configurable: true
  21044. });
  21045. Object.defineProperty(FlyCamera.prototype, "keysForward", {
  21046. /**
  21047. * Get the keys for camera movement forward.
  21048. */
  21049. get: function () {
  21050. var keyboard = this.inputs.attached["keyboard"];
  21051. if (keyboard) {
  21052. return keyboard.keysForward;
  21053. }
  21054. return [];
  21055. },
  21056. /**
  21057. * Set the keys for camera movement forward.
  21058. */
  21059. set: function (value) {
  21060. var keyboard = this.inputs.attached["keyboard"];
  21061. if (keyboard) {
  21062. keyboard.keysForward = value;
  21063. }
  21064. },
  21065. enumerable: true,
  21066. configurable: true
  21067. });
  21068. Object.defineProperty(FlyCamera.prototype, "keysBackward", {
  21069. /**
  21070. * Get the keys for camera movement backward.
  21071. */
  21072. get: function () {
  21073. var keyboard = this.inputs.attached["keyboard"];
  21074. if (keyboard) {
  21075. return keyboard.keysBackward;
  21076. }
  21077. return [];
  21078. },
  21079. set: function (value) {
  21080. var keyboard = this.inputs.attached["keyboard"];
  21081. if (keyboard) {
  21082. keyboard.keysBackward = value;
  21083. }
  21084. },
  21085. enumerable: true,
  21086. configurable: true
  21087. });
  21088. Object.defineProperty(FlyCamera.prototype, "keysUp", {
  21089. /**
  21090. * Get the keys for camera movement up.
  21091. */
  21092. get: function () {
  21093. var keyboard = this.inputs.attached["keyboard"];
  21094. if (keyboard) {
  21095. return keyboard.keysUp;
  21096. }
  21097. return [];
  21098. },
  21099. /**
  21100. * Set the keys for camera movement up.
  21101. */
  21102. set: function (value) {
  21103. var keyboard = this.inputs.attached["keyboard"];
  21104. if (keyboard) {
  21105. keyboard.keysUp = value;
  21106. }
  21107. },
  21108. enumerable: true,
  21109. configurable: true
  21110. });
  21111. Object.defineProperty(FlyCamera.prototype, "keysDown", {
  21112. /**
  21113. * Get the keys for camera movement down.
  21114. */
  21115. get: function () {
  21116. var keyboard = this.inputs.attached["keyboard"];
  21117. if (keyboard) {
  21118. return keyboard.keysDown;
  21119. }
  21120. return [];
  21121. },
  21122. /**
  21123. * Set the keys for camera movement down.
  21124. */
  21125. set: function (value) {
  21126. var keyboard = this.inputs.attached["keyboard"];
  21127. if (keyboard) {
  21128. keyboard.keysDown = value;
  21129. }
  21130. },
  21131. enumerable: true,
  21132. configurable: true
  21133. });
  21134. Object.defineProperty(FlyCamera.prototype, "keysLeft", {
  21135. /**
  21136. * Get the keys for camera movement left.
  21137. */
  21138. get: function () {
  21139. var keyboard = this.inputs.attached["keyboard"];
  21140. if (keyboard) {
  21141. return keyboard.keysLeft;
  21142. }
  21143. return [];
  21144. },
  21145. /**
  21146. * Set the keys for camera movement left.
  21147. */
  21148. set: function (value) {
  21149. var keyboard = this.inputs.attached["keyboard"];
  21150. if (keyboard) {
  21151. keyboard.keysLeft = value;
  21152. }
  21153. },
  21154. enumerable: true,
  21155. configurable: true
  21156. });
  21157. Object.defineProperty(FlyCamera.prototype, "keysRight", {
  21158. /**
  21159. * Set the keys for camera movement right.
  21160. */
  21161. get: function () {
  21162. var keyboard = this.inputs.attached["keyboard"];
  21163. if (keyboard) {
  21164. return keyboard.keysRight;
  21165. }
  21166. return [];
  21167. },
  21168. /**
  21169. * Set the keys for camera movement right.
  21170. */
  21171. set: function (value) {
  21172. var keyboard = this.inputs.attached["keyboard"];
  21173. if (keyboard) {
  21174. keyboard.keysRight = value;
  21175. }
  21176. },
  21177. enumerable: true,
  21178. configurable: true
  21179. });
  21180. /**
  21181. * Attach a control to the HTML DOM element.
  21182. * @param element Defines the element that listens to the input events.
  21183. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  21184. */
  21185. FlyCamera.prototype.attachControl = function (element, noPreventDefault) {
  21186. this.inputs.attachElement(element, noPreventDefault);
  21187. };
  21188. /**
  21189. * Detach a control from the HTML DOM element.
  21190. * The camera will stop reacting to that input.
  21191. * @param element Defines the element that listens to the input events.
  21192. */
  21193. FlyCamera.prototype.detachControl = function (element) {
  21194. this.inputs.detachElement(element);
  21195. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21196. };
  21197. Object.defineProperty(FlyCamera.prototype, "collisionMask", {
  21198. /**
  21199. * Get the mask that the camera ignores in collision events.
  21200. */
  21201. get: function () {
  21202. return this._collisionMask;
  21203. },
  21204. /**
  21205. * Set the mask that the camera ignores in collision events.
  21206. */
  21207. set: function (mask) {
  21208. this._collisionMask = !isNaN(mask) ? mask : -1;
  21209. },
  21210. enumerable: true,
  21211. configurable: true
  21212. });
  21213. /** @hidden */
  21214. FlyCamera.prototype._collideWithWorld = function (displacement) {
  21215. var globalPosition;
  21216. if (this.parent) {
  21217. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  21218. }
  21219. else {
  21220. globalPosition = this.position;
  21221. }
  21222. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  21223. this._oldPosition.addInPlace(this.ellipsoidOffset);
  21224. if (!this._collider) {
  21225. this._collider = new _Collisions_collider__WEBPACK_IMPORTED_MODULE_4__["Collider"]();
  21226. }
  21227. this._collider._radius = this.ellipsoid;
  21228. this._collider.collisionMask = this._collisionMask;
  21229. // No need for clone, as long as gravity is not on.
  21230. var actualDisplacement = displacement;
  21231. // Add gravity to direction to prevent dual-collision checking.
  21232. if (this.applyGravity) {
  21233. // This prevents mending with cameraDirection, a global variable of the fly camera class.
  21234. actualDisplacement = displacement.add(this.getScene().gravity);
  21235. }
  21236. this.getScene().collisionCoordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  21237. };
  21238. /** @hidden */
  21239. FlyCamera.prototype._checkInputs = function () {
  21240. if (!this._localDirection) {
  21241. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21242. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21243. }
  21244. this.inputs.checkInputs();
  21245. _super.prototype._checkInputs.call(this);
  21246. };
  21247. /** @hidden */
  21248. FlyCamera.prototype._decideIfNeedsToMove = function () {
  21249. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  21250. };
  21251. /** @hidden */
  21252. FlyCamera.prototype._updatePosition = function () {
  21253. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  21254. this._collideWithWorld(this.cameraDirection);
  21255. }
  21256. else {
  21257. _super.prototype._updatePosition.call(this);
  21258. }
  21259. };
  21260. /**
  21261. * Restore the Roll to its target value at the rate specified.
  21262. * @param rate - Higher means slower restoring.
  21263. * @hidden
  21264. */
  21265. FlyCamera.prototype.restoreRoll = function (rate) {
  21266. var limit = this._trackRoll; // Target Roll.
  21267. var z = this.rotation.z; // Current Roll.
  21268. var delta = limit - z; // Difference in Roll.
  21269. var minRad = 0.001; // Tenth of a radian is a barely noticable difference.
  21270. // If the difference is noticable, restore the Roll.
  21271. if (Math.abs(delta) >= minRad) {
  21272. // Change Z rotation towards the target Roll.
  21273. this.rotation.z += delta / rate;
  21274. // Match when near enough.
  21275. if (Math.abs(limit - this.rotation.z) <= minRad) {
  21276. this.rotation.z = limit;
  21277. }
  21278. }
  21279. };
  21280. /**
  21281. * Destroy the camera and release the current resources held by it.
  21282. */
  21283. FlyCamera.prototype.dispose = function () {
  21284. this.inputs.clear();
  21285. _super.prototype.dispose.call(this);
  21286. };
  21287. /**
  21288. * Get the current object class name.
  21289. * @returns the class name.
  21290. */
  21291. FlyCamera.prototype.getClassName = function () {
  21292. return "FlyCamera";
  21293. };
  21294. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21295. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21296. ], FlyCamera.prototype, "ellipsoid", void 0);
  21297. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21298. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21299. ], FlyCamera.prototype, "ellipsoidOffset", void 0);
  21300. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21301. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21302. ], FlyCamera.prototype, "checkCollisions", void 0);
  21303. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21304. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21305. ], FlyCamera.prototype, "applyGravity", void 0);
  21306. return FlyCamera;
  21307. }(_targetCamera__WEBPACK_IMPORTED_MODULE_5__["TargetCamera"]));
  21308. /***/ }),
  21309. /***/ "./Cameras/flyCameraInputsManager.ts":
  21310. /*!*******************************************!*\
  21311. !*** ./Cameras/flyCameraInputsManager.ts ***!
  21312. \*******************************************/
  21313. /*! exports provided: FlyCameraInputsManager */
  21314. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21315. "use strict";
  21316. __webpack_require__.r(__webpack_exports__);
  21317. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return FlyCameraInputsManager; });
  21318. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21319. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  21320. /* harmony import */ var _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  21321. /* harmony import */ var _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  21322. /**
  21323. * Default Inputs manager for the FlyCamera.
  21324. * It groups all the default supported inputs for ease of use.
  21325. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21326. */
  21327. var FlyCameraInputsManager = /** @class */ (function (_super) {
  21328. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCameraInputsManager, _super);
  21329. /**
  21330. * Instantiates a new FlyCameraInputsManager.
  21331. * @param camera Defines the camera the inputs belong to.
  21332. */
  21333. function FlyCameraInputsManager(camera) {
  21334. return _super.call(this, camera) || this;
  21335. }
  21336. /**
  21337. * Add keyboard input support to the input manager.
  21338. * @returns the new FlyCameraKeyboardMoveInput().
  21339. */
  21340. FlyCameraInputsManager.prototype.addKeyboard = function () {
  21341. this.add(new _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__["FlyCameraKeyboardInput"]());
  21342. return this;
  21343. };
  21344. /**
  21345. * Add mouse input support to the input manager.
  21346. * @param touchEnabled Enable touch screen support.
  21347. * @returns the new FlyCameraMouseInput().
  21348. */
  21349. FlyCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  21350. if (touchEnabled === void 0) { touchEnabled = true; }
  21351. this.add(new _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__["FlyCameraMouseInput"](touchEnabled));
  21352. return this;
  21353. };
  21354. return FlyCameraInputsManager;
  21355. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  21356. /***/ }),
  21357. /***/ "./Cameras/followCamera.ts":
  21358. /*!*********************************!*\
  21359. !*** ./Cameras/followCamera.ts ***!
  21360. \*********************************/
  21361. /*! exports provided: FollowCamera, ArcFollowCamera */
  21362. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21363. "use strict";
  21364. __webpack_require__.r(__webpack_exports__);
  21365. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return FollowCamera; });
  21366. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return ArcFollowCamera; });
  21367. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21368. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21369. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  21370. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21371. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21372. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../node */ "./node.ts");
  21373. /* harmony import */ var _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./followCameraInputsManager */ "./Cameras/followCameraInputsManager.ts");
  21374. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("FollowCamera", function (name, scene) {
  21375. return function () { return new FollowCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  21376. });
  21377. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("ArcFollowCamera", function (name, scene) {
  21378. return function () { return new ArcFollowCamera(name, 0, 0, 1.0, null, scene); };
  21379. });
  21380. /**
  21381. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  21382. * an arc rotate version arcFollowCamera are available.
  21383. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21384. */
  21385. var FollowCamera = /** @class */ (function (_super) {
  21386. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCamera, _super);
  21387. /**
  21388. * Instantiates the follow camera.
  21389. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21390. * @param name Define the name of the camera in the scene
  21391. * @param position Define the position of the camera
  21392. * @param scene Define the scene the camera belong to
  21393. * @param lockedTarget Define the target of the camera
  21394. */
  21395. function FollowCamera(name, position, scene, lockedTarget) {
  21396. if (lockedTarget === void 0) { lockedTarget = null; }
  21397. var _this = _super.call(this, name, position, scene) || this;
  21398. /**
  21399. * Distance the follow camera should follow an object at
  21400. */
  21401. _this.radius = 12;
  21402. /**
  21403. * Define a rotation offset between the camera and the object it follows
  21404. */
  21405. _this.rotationOffset = 0;
  21406. /**
  21407. * Define a height offset between the camera and the object it follows.
  21408. * It can help following an object from the top (like a car chaing a plane)
  21409. */
  21410. _this.heightOffset = 4;
  21411. /**
  21412. * Define how fast the camera can accelerate to follow it s target.
  21413. */
  21414. _this.cameraAcceleration = 0.05;
  21415. /**
  21416. * Define the speed limit of the camera following an object.
  21417. */
  21418. _this.maxCameraSpeed = 20;
  21419. _this.lockedTarget = lockedTarget;
  21420. _this.inputs = new _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FollowCameraInputsManager"](_this);
  21421. _this.inputs.addKeyboard().addMouseWheel();
  21422. return _this;
  21423. // Uncomment the following line when the relevant handlers have been implemented.
  21424. // this.inputs.addKeyboard().addMouseWheel().addPointers().addVRDeviceOrientation();
  21425. }
  21426. FollowCamera.prototype._follow = function (cameraTarget) {
  21427. if (!cameraTarget) {
  21428. return;
  21429. }
  21430. var yRotation;
  21431. if (cameraTarget.rotationQuaternion) {
  21432. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  21433. cameraTarget.rotationQuaternion.toRotationMatrix(rotMatrix);
  21434. yRotation = Math.atan2(rotMatrix.m[8], rotMatrix.m[10]);
  21435. }
  21436. else {
  21437. yRotation = cameraTarget.rotation.y;
  21438. }
  21439. var radians = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this.rotationOffset) + yRotation;
  21440. var targetPosition = cameraTarget.getAbsolutePosition();
  21441. var targetX = targetPosition.x + Math.sin(radians) * this.radius;
  21442. var targetZ = targetPosition.z + Math.cos(radians) * this.radius;
  21443. var dx = targetX - this.position.x;
  21444. var dy = (targetPosition.y + this.heightOffset) - this.position.y;
  21445. var dz = (targetZ) - this.position.z;
  21446. var vx = dx * this.cameraAcceleration * 2; //this is set to .05
  21447. var vy = dy * this.cameraAcceleration;
  21448. var vz = dz * this.cameraAcceleration * 2;
  21449. if (vx > this.maxCameraSpeed || vx < -this.maxCameraSpeed) {
  21450. vx = vx < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21451. }
  21452. if (vy > this.maxCameraSpeed || vy < -this.maxCameraSpeed) {
  21453. vy = vy < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21454. }
  21455. if (vz > this.maxCameraSpeed || vz < -this.maxCameraSpeed) {
  21456. vz = vz < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21457. }
  21458. this.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](this.position.x + vx, this.position.y + vy, this.position.z + vz);
  21459. this.setTarget(targetPosition);
  21460. };
  21461. /**
  21462. * Attached controls to the current camera.
  21463. * @param element Defines the element the controls should be listened from
  21464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21465. */
  21466. FollowCamera.prototype.attachControl = function (element, noPreventDefault) {
  21467. this.inputs.attachElement(element, noPreventDefault);
  21468. this._reset = function () {
  21469. };
  21470. };
  21471. /**
  21472. * Detach the current controls from the camera.
  21473. * The camera will stop reacting to inputs.
  21474. * @param element Defines the element to stop listening the inputs from
  21475. */
  21476. FollowCamera.prototype.detachControl = function (element) {
  21477. this.inputs.detachElement(element);
  21478. if (this._reset) {
  21479. this._reset();
  21480. }
  21481. };
  21482. /** @hidden */
  21483. FollowCamera.prototype._checkInputs = function () {
  21484. this.inputs.checkInputs();
  21485. _super.prototype._checkInputs.call(this);
  21486. if (this.lockedTarget) {
  21487. this._follow(this.lockedTarget);
  21488. }
  21489. };
  21490. /**
  21491. * Gets the camera class name.
  21492. * @returns the class name
  21493. */
  21494. FollowCamera.prototype.getClassName = function () {
  21495. return "FollowCamera";
  21496. };
  21497. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21498. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21499. ], FollowCamera.prototype, "radius", void 0);
  21500. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21501. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21502. ], FollowCamera.prototype, "rotationOffset", void 0);
  21503. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21504. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21505. ], FollowCamera.prototype, "heightOffset", void 0);
  21506. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21507. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21508. ], FollowCamera.prototype, "cameraAcceleration", void 0);
  21509. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21510. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21511. ], FollowCamera.prototype, "maxCameraSpeed", void 0);
  21512. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21513. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  21514. ], FollowCamera.prototype, "lockedTarget", void 0);
  21515. return FollowCamera;
  21516. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  21517. /**
  21518. * Arc Rotate version of the follow camera.
  21519. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  21520. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21521. */
  21522. var ArcFollowCamera = /** @class */ (function (_super) {
  21523. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcFollowCamera, _super);
  21524. /**
  21525. * Instantiates a new ArcFollowCamera
  21526. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21527. * @param name Define the name of the camera
  21528. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  21529. * @param beta Define the rotation angle of the camera around the elevation axis
  21530. * @param radius Define the radius of the camera from its target point
  21531. * @param target Define the target of the camera
  21532. * @param scene Define the scene the camera belongs to
  21533. */
  21534. function ArcFollowCamera(name,
  21535. /** The longitudinal angle of the camera */
  21536. alpha,
  21537. /** The latitudinal angle of the camera */
  21538. beta,
  21539. /** The radius of the camera from its target */
  21540. radius,
  21541. /** Define the camera target (the messh it should follow) */
  21542. target, scene) {
  21543. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene) || this;
  21544. _this.alpha = alpha;
  21545. _this.beta = beta;
  21546. _this.radius = radius;
  21547. _this.target = target;
  21548. _this._cartesianCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  21549. _this._follow();
  21550. return _this;
  21551. }
  21552. ArcFollowCamera.prototype._follow = function () {
  21553. if (!this.target) {
  21554. return;
  21555. }
  21556. this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta);
  21557. this._cartesianCoordinates.y = this.radius * Math.sin(this.beta);
  21558. this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
  21559. var targetPosition = this.target.getAbsolutePosition();
  21560. this.position = targetPosition.add(this._cartesianCoordinates);
  21561. this.setTarget(targetPosition);
  21562. };
  21563. /** @hidden */
  21564. ArcFollowCamera.prototype._checkInputs = function () {
  21565. _super.prototype._checkInputs.call(this);
  21566. this._follow();
  21567. };
  21568. /**
  21569. * Returns the class name of the object.
  21570. * It is mostly used internally for serialization purposes.
  21571. */
  21572. ArcFollowCamera.prototype.getClassName = function () {
  21573. return "ArcFollowCamera";
  21574. };
  21575. return ArcFollowCamera;
  21576. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  21577. /***/ }),
  21578. /***/ "./Cameras/followCameraInputsManager.ts":
  21579. /*!**********************************************!*\
  21580. !*** ./Cameras/followCameraInputsManager.ts ***!
  21581. \**********************************************/
  21582. /*! exports provided: FollowCameraInputsManager */
  21583. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21584. "use strict";
  21585. __webpack_require__.r(__webpack_exports__);
  21586. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraInputsManager", function() { return FollowCameraInputsManager; });
  21587. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21588. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  21589. /* harmony import */ var _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Inputs/followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  21590. /* harmony import */ var _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Inputs/followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  21591. /**
  21592. * Default Inputs manager for the FollowCamera.
  21593. * It groups all the default supported inputs for ease of use.
  21594. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21595. */
  21596. var FollowCameraInputsManager = /** @class */ (function (_super) {
  21597. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraInputsManager, _super);
  21598. /**
  21599. * Instantiates a new FollowCameraInputsManager.
  21600. * @param camera Defines the camera the inputs belong to
  21601. */
  21602. function FollowCameraInputsManager(camera) {
  21603. return _super.call(this, camera) || this;
  21604. }
  21605. /**
  21606. * Add keyboard input support to the input manager.
  21607. * @returns the current input manager
  21608. */
  21609. FollowCameraInputsManager.prototype.addKeyboard = function () {
  21610. this.add(new _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FollowCameraKeyboardMoveInput"]());
  21611. return this;
  21612. };
  21613. /**
  21614. * Add mouse wheel input support to the input manager.
  21615. * @returns the current input manager
  21616. */
  21617. FollowCameraInputsManager.prototype.addMouseWheel = function () {
  21618. this.add(new _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["FollowCameraMouseWheelInput"]());
  21619. return this;
  21620. };
  21621. /**
  21622. * Add pointers input support to the input manager.
  21623. * @returns the current input manager
  21624. */
  21625. FollowCameraInputsManager.prototype.addPointers = function () {
  21626. console.warn("Pointer support not yet implemented for FollowCamera.");
  21627. return this;
  21628. };
  21629. /**
  21630. * Add orientation input support to the input manager.
  21631. * @returns the current input manager
  21632. */
  21633. FollowCameraInputsManager.prototype.addVRDeviceOrientation = function () {
  21634. console.warn("DeviceOrientation support not yet implemented for FollowCamera.");
  21635. return this;
  21636. };
  21637. return FollowCameraInputsManager;
  21638. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  21639. /***/ }),
  21640. /***/ "./Cameras/freeCamera.ts":
  21641. /*!*******************************!*\
  21642. !*** ./Cameras/freeCamera.ts ***!
  21643. \*******************************/
  21644. /*! exports provided: FreeCamera */
  21645. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21646. "use strict";
  21647. __webpack_require__.r(__webpack_exports__);
  21648. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return FreeCamera; });
  21649. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21650. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21651. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21652. /* harmony import */ var _Collisions_collider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/collider */ "./Collisions/collider.ts");
  21653. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  21654. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21655. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  21656. /**
  21657. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  21658. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  21659. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  21660. */
  21661. var FreeCamera = /** @class */ (function (_super) {
  21662. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCamera, _super);
  21663. /**
  21664. * Instantiates a Free Camera.
  21665. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  21666. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  21667. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  21668. * @param name Define the name of the camera in the scene
  21669. * @param position Define the start position of the camera in the scene
  21670. * @param scene Define the scene the camera belongs to
  21671. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  21672. */
  21673. function FreeCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  21674. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  21675. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  21676. /**
  21677. * Define the collision ellipsoid of the camera.
  21678. * This is helpful to simulate a camera body like the player body around the camera
  21679. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  21680. */
  21681. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.5, 1, 0.5);
  21682. /**
  21683. * Define an offset for the position of the ellipsoid around the camera.
  21684. * This can be helpful to determine the center of the body near the gravity center of the body
  21685. * instead of its head.
  21686. */
  21687. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21688. /**
  21689. * Enable or disable collisions of the camera with the rest of the scene objects.
  21690. */
  21691. _this.checkCollisions = false;
  21692. /**
  21693. * Enable or disable gravity on the camera.
  21694. */
  21695. _this.applyGravity = false;
  21696. _this._needMoveForGravity = false;
  21697. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21698. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21699. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21700. // Collisions
  21701. _this._collisionMask = -1;
  21702. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  21703. if (collidedMesh === void 0) { collidedMesh = null; }
  21704. var updatePosition = function (newPos) {
  21705. _this._newPosition.copyFrom(newPos);
  21706. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  21707. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].CollisionsEpsilon) {
  21708. _this.position.addInPlace(_this._diffPosition);
  21709. if (_this.onCollide && collidedMesh) {
  21710. _this.onCollide(collidedMesh);
  21711. }
  21712. }
  21713. };
  21714. updatePosition(newPosition);
  21715. };
  21716. _this.inputs = new _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FreeCameraInputsManager"](_this);
  21717. _this.inputs.addKeyboard().addMouse();
  21718. return _this;
  21719. }
  21720. Object.defineProperty(FreeCamera.prototype, "angularSensibility", {
  21721. /**
  21722. * Gets the input sensibility for a mouse input. (default is 2000.0)
  21723. * Higher values reduce sensitivity.
  21724. */
  21725. get: function () {
  21726. var mouse = this.inputs.attached["mouse"];
  21727. if (mouse) {
  21728. return mouse.angularSensibility;
  21729. }
  21730. return 0;
  21731. },
  21732. /**
  21733. * Sets the input sensibility for a mouse input. (default is 2000.0)
  21734. * Higher values reduce sensitivity.
  21735. */
  21736. set: function (value) {
  21737. var mouse = this.inputs.attached["mouse"];
  21738. if (mouse) {
  21739. mouse.angularSensibility = value;
  21740. }
  21741. },
  21742. enumerable: true,
  21743. configurable: true
  21744. });
  21745. Object.defineProperty(FreeCamera.prototype, "keysUp", {
  21746. /**
  21747. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  21748. */
  21749. get: function () {
  21750. var keyboard = this.inputs.attached["keyboard"];
  21751. if (keyboard) {
  21752. return keyboard.keysUp;
  21753. }
  21754. return [];
  21755. },
  21756. set: function (value) {
  21757. var keyboard = this.inputs.attached["keyboard"];
  21758. if (keyboard) {
  21759. keyboard.keysUp = value;
  21760. }
  21761. },
  21762. enumerable: true,
  21763. configurable: true
  21764. });
  21765. Object.defineProperty(FreeCamera.prototype, "keysDown", {
  21766. /**
  21767. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  21768. */
  21769. get: function () {
  21770. var keyboard = this.inputs.attached["keyboard"];
  21771. if (keyboard) {
  21772. return keyboard.keysDown;
  21773. }
  21774. return [];
  21775. },
  21776. set: function (value) {
  21777. var keyboard = this.inputs.attached["keyboard"];
  21778. if (keyboard) {
  21779. keyboard.keysDown = value;
  21780. }
  21781. },
  21782. enumerable: true,
  21783. configurable: true
  21784. });
  21785. Object.defineProperty(FreeCamera.prototype, "keysLeft", {
  21786. /**
  21787. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  21788. */
  21789. get: function () {
  21790. var keyboard = this.inputs.attached["keyboard"];
  21791. if (keyboard) {
  21792. return keyboard.keysLeft;
  21793. }
  21794. return [];
  21795. },
  21796. set: function (value) {
  21797. var keyboard = this.inputs.attached["keyboard"];
  21798. if (keyboard) {
  21799. keyboard.keysLeft = value;
  21800. }
  21801. },
  21802. enumerable: true,
  21803. configurable: true
  21804. });
  21805. Object.defineProperty(FreeCamera.prototype, "keysRight", {
  21806. /**
  21807. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  21808. */
  21809. get: function () {
  21810. var keyboard = this.inputs.attached["keyboard"];
  21811. if (keyboard) {
  21812. return keyboard.keysRight;
  21813. }
  21814. return [];
  21815. },
  21816. set: function (value) {
  21817. var keyboard = this.inputs.attached["keyboard"];
  21818. if (keyboard) {
  21819. keyboard.keysRight = value;
  21820. }
  21821. },
  21822. enumerable: true,
  21823. configurable: true
  21824. });
  21825. /**
  21826. * Attached controls to the current camera.
  21827. * @param element Defines the element the controls should be listened from
  21828. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21829. */
  21830. FreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  21831. this.inputs.attachElement(element, noPreventDefault);
  21832. };
  21833. /**
  21834. * Detach the current controls from the camera.
  21835. * The camera will stop reacting to inputs.
  21836. * @param element Defines the element to stop listening the inputs from
  21837. */
  21838. FreeCamera.prototype.detachControl = function (element) {
  21839. this.inputs.detachElement(element);
  21840. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21841. this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 0);
  21842. };
  21843. Object.defineProperty(FreeCamera.prototype, "collisionMask", {
  21844. /**
  21845. * Define a collision mask to limit the list of object the camera can collide with
  21846. */
  21847. get: function () {
  21848. return this._collisionMask;
  21849. },
  21850. set: function (mask) {
  21851. this._collisionMask = !isNaN(mask) ? mask : -1;
  21852. },
  21853. enumerable: true,
  21854. configurable: true
  21855. });
  21856. /** @hidden */
  21857. FreeCamera.prototype._collideWithWorld = function (displacement) {
  21858. var globalPosition;
  21859. if (this.parent) {
  21860. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  21861. }
  21862. else {
  21863. globalPosition = this.position;
  21864. }
  21865. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  21866. this._oldPosition.addInPlace(this.ellipsoidOffset);
  21867. if (!this._collider) {
  21868. this._collider = new _Collisions_collider__WEBPACK_IMPORTED_MODULE_3__["Collider"]();
  21869. }
  21870. this._collider._radius = this.ellipsoid;
  21871. this._collider.collisionMask = this._collisionMask;
  21872. //no need for clone, as long as gravity is not on.
  21873. var actualDisplacement = displacement;
  21874. //add gravity to the direction to prevent the dual-collision checking
  21875. if (this.applyGravity) {
  21876. //this prevents mending with cameraDirection, a global variable of the free camera class.
  21877. actualDisplacement = displacement.add(this.getScene().gravity);
  21878. }
  21879. this.getScene().collisionCoordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  21880. };
  21881. /** @hidden */
  21882. FreeCamera.prototype._checkInputs = function () {
  21883. if (!this._localDirection) {
  21884. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21885. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21886. }
  21887. this.inputs.checkInputs();
  21888. _super.prototype._checkInputs.call(this);
  21889. };
  21890. /** @hidden */
  21891. FreeCamera.prototype._decideIfNeedsToMove = function () {
  21892. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  21893. };
  21894. /** @hidden */
  21895. FreeCamera.prototype._updatePosition = function () {
  21896. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  21897. this._collideWithWorld(this.cameraDirection);
  21898. }
  21899. else {
  21900. _super.prototype._updatePosition.call(this);
  21901. }
  21902. };
  21903. /**
  21904. * Destroy the camera and release the current resources hold by it.
  21905. */
  21906. FreeCamera.prototype.dispose = function () {
  21907. this.inputs.clear();
  21908. _super.prototype.dispose.call(this);
  21909. };
  21910. /**
  21911. * Gets the current object class name.
  21912. * @return the class name
  21913. */
  21914. FreeCamera.prototype.getClassName = function () {
  21915. return "FreeCamera";
  21916. };
  21917. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21918. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21919. ], FreeCamera.prototype, "ellipsoid", void 0);
  21920. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21921. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21922. ], FreeCamera.prototype, "ellipsoidOffset", void 0);
  21923. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21924. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21925. ], FreeCamera.prototype, "checkCollisions", void 0);
  21926. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21927. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21928. ], FreeCamera.prototype, "applyGravity", void 0);
  21929. return FreeCamera;
  21930. }(_targetCamera__WEBPACK_IMPORTED_MODULE_5__["TargetCamera"]));
  21931. /***/ }),
  21932. /***/ "./Cameras/freeCameraInputsManager.ts":
  21933. /*!********************************************!*\
  21934. !*** ./Cameras/freeCameraInputsManager.ts ***!
  21935. \********************************************/
  21936. /*! exports provided: FreeCameraInputsManager */
  21937. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21938. "use strict";
  21939. __webpack_require__.r(__webpack_exports__);
  21940. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return FreeCameraInputsManager; });
  21941. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21942. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  21943. /* harmony import */ var _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  21944. /* harmony import */ var _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  21945. /* harmony import */ var _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  21946. /**
  21947. * Default Inputs manager for the FreeCamera.
  21948. * It groups all the default supported inputs for ease of use.
  21949. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21950. */
  21951. var FreeCameraInputsManager = /** @class */ (function (_super) {
  21952. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCameraInputsManager, _super);
  21953. /**
  21954. * Instantiates a new FreeCameraInputsManager.
  21955. * @param camera Defines the camera the inputs belong to
  21956. */
  21957. function FreeCameraInputsManager(camera) {
  21958. return _super.call(this, camera) || this;
  21959. }
  21960. /**
  21961. * Add keyboard input support to the input manager.
  21962. * @returns the current input manager
  21963. */
  21964. FreeCameraInputsManager.prototype.addKeyboard = function () {
  21965. this.add(new _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FreeCameraKeyboardMoveInput"]());
  21966. return this;
  21967. };
  21968. /**
  21969. * Add mouse input support to the input manager.
  21970. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  21971. * @returns the current input manager
  21972. */
  21973. FreeCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  21974. if (touchEnabled === void 0) { touchEnabled = true; }
  21975. this.add(new _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__["FreeCameraMouseInput"](touchEnabled));
  21976. return this;
  21977. };
  21978. /**
  21979. * Add touch input support to the input manager.
  21980. * @returns the current input manager
  21981. */
  21982. FreeCameraInputsManager.prototype.addTouch = function () {
  21983. this.add(new _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraTouchInput"]());
  21984. return this;
  21985. };
  21986. return FreeCameraInputsManager;
  21987. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  21988. /***/ }),
  21989. /***/ "./Cameras/gamepadCamera.ts":
  21990. /*!**********************************!*\
  21991. !*** ./Cameras/gamepadCamera.ts ***!
  21992. \**********************************/
  21993. /*! exports provided: GamepadCamera */
  21994. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21995. "use strict";
  21996. __webpack_require__.r(__webpack_exports__);
  21997. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return GamepadCamera; });
  21998. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21999. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  22000. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22001. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  22002. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("GamepadCamera", function (name, scene) {
  22003. return function () { return new GamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  22004. });
  22005. /**
  22006. * This represents a FPS type of camera. This is only here for back compat purpose.
  22007. * Please use the UniversalCamera instead as both are identical.
  22008. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22009. */
  22010. var GamepadCamera = /** @class */ (function (_super) {
  22011. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GamepadCamera, _super);
  22012. /**
  22013. * Instantiates a new Gamepad Camera
  22014. * This represents a FPS type of camera. This is only here for back compat purpose.
  22015. * Please use the UniversalCamera instead as both are identical.
  22016. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22017. * @param name Define the name of the camera in the scene
  22018. * @param position Define the start position of the camera in the scene
  22019. * @param scene Define the scene the camera belongs to
  22020. */
  22021. function GamepadCamera(name, position, scene) {
  22022. return _super.call(this, name, position, scene) || this;
  22023. }
  22024. /**
  22025. * Gets the current object class name.
  22026. * @return the class name
  22027. */
  22028. GamepadCamera.prototype.getClassName = function () {
  22029. return "GamepadCamera";
  22030. };
  22031. return GamepadCamera;
  22032. }(_universalCamera__WEBPACK_IMPORTED_MODULE_1__["UniversalCamera"]));
  22033. /***/ }),
  22034. /***/ "./Cameras/index.ts":
  22035. /*!**************************!*\
  22036. !*** ./Cameras/index.ts ***!
  22037. \**************************/
  22038. /*! exports provided: CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  22039. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22040. "use strict";
  22041. __webpack_require__.r(__webpack_exports__);
  22042. /* harmony import */ var _Inputs_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Inputs/index */ "./Cameras/Inputs/index.ts");
  22043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  22044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  22045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  22046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  22047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  22048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  22049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  22050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  22051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  22052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  22053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  22054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  22055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  22056. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]; });
  22058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]; });
  22059. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  22060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]; });
  22061. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]; });
  22063. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  22064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _freeCamera__WEBPACK_IMPORTED_MODULE_4__["FreeCamera"]; });
  22065. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  22066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"]; });
  22067. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  22068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _touchCamera__WEBPACK_IMPORTED_MODULE_6__["TouchCamera"]; });
  22069. /* harmony import */ var _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  22070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  22071. /* harmony import */ var _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  22072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__["ArcRotateCameraInputsManager"]; });
  22073. /* harmony import */ var _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  22074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__["DeviceOrientationCamera"]; });
  22075. /* harmony import */ var _flyCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./flyCamera */ "./Cameras/flyCamera.ts");
  22076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _flyCamera__WEBPACK_IMPORTED_MODULE_10__["FlyCamera"]; });
  22077. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  22078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["FlyCameraInputsManager"]; });
  22079. /* harmony import */ var _followCamera__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./followCamera */ "./Cameras/followCamera.ts");
  22080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["FollowCamera"]; });
  22081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["ArcFollowCamera"]; });
  22082. /* harmony import */ var _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./gamepadCamera */ "./Cameras/gamepadCamera.ts");
  22083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__["GamepadCamera"]; });
  22084. /* harmony import */ var _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Stereoscopic/index */ "./Cameras/Stereoscopic/index.ts");
  22085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphArcRotateCamera"]; });
  22086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphFreeCamera"]; });
  22087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphGamepadCamera"]; });
  22088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphUniversalCamera"]; });
  22089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicArcRotateCamera"]; });
  22090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicFreeCamera"]; });
  22091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicGamepadCamera"]; });
  22092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicUniversalCamera"]; });
  22093. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  22094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _universalCamera__WEBPACK_IMPORTED_MODULE_15__["UniversalCamera"]; });
  22095. /* harmony import */ var _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./virtualJoysticksCamera */ "./Cameras/virtualJoysticksCamera.ts");
  22096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__["VirtualJoysticksCamera"]; });
  22097. /* harmony import */ var _VR_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./VR/index */ "./Cameras/VR/index.ts");
  22098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRCameraMetrics"]; });
  22099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationArcRotateCamera"]; });
  22100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationFreeCamera"]; });
  22101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationGamepadCamera"]; });
  22102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRExperienceHelper"]; });
  22103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["WebVRFreeCamera"]; });
  22104. /* harmony import */ var _XR_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./XR/index */ "./Cameras/XR/index.ts");
  22105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRCamera"]; });
  22106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIButton"]; });
  22107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIOptions"]; });
  22108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUI"]; });
  22109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRState"]; });
  22110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRExperienceHelper"]; });
  22111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRController"]; });
  22112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRInput"]; });
  22113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRManagedOutputCanvas"]; });
  22114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRSessionManager"]; });
  22115. /***/ }),
  22116. /***/ "./Cameras/targetCamera.ts":
  22117. /*!*********************************!*\
  22118. !*** ./Cameras/targetCamera.ts ***!
  22119. \*********************************/
  22120. /*! exports provided: TargetCamera */
  22121. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22122. "use strict";
  22123. __webpack_require__.r(__webpack_exports__);
  22124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return TargetCamera; });
  22125. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22126. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22127. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  22128. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22129. /**
  22130. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  22131. * This is the base of the follow, arc rotate cameras and Free camera
  22132. * @see http://doc.babylonjs.com/features/cameras
  22133. */
  22134. var TargetCamera = /** @class */ (function (_super) {
  22135. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TargetCamera, _super);
  22136. /**
  22137. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  22138. * This is the base of the follow, arc rotate cameras and Free camera
  22139. * @see http://doc.babylonjs.com/features/cameras
  22140. * @param name Defines the name of the camera in the scene
  22141. * @param position Defines the start position of the camera in the scene
  22142. * @param scene Defines the scene the camera belongs to
  22143. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  22144. */
  22145. function TargetCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22146. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22147. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22148. /**
  22149. * Define the current direction the camera is moving to
  22150. */
  22151. _this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  22152. /**
  22153. * Define the current rotation the camera is rotating to
  22154. */
  22155. _this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  22156. /**
  22157. * When set, the up vector of the camera will be updated by the rotation of the camera
  22158. */
  22159. _this.updateUpVectorFromRotation = false;
  22160. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22161. /**
  22162. * Define the current rotation of the camera
  22163. */
  22164. _this.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  22165. /**
  22166. * Define the current speed of the camera
  22167. */
  22168. _this.speed = 2.0;
  22169. /**
  22170. * Add cconstraint to the camera to prevent it to move freely in all directions and
  22171. * around all axis.
  22172. */
  22173. _this.noRotationConstraint = false;
  22174. /**
  22175. * Define the current target of the camera as an object or a position.
  22176. */
  22177. _this.lockedTarget = null;
  22178. /** @hidden */
  22179. _this._currentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22180. /** @hidden */
  22181. _this._initialFocalDistance = 1;
  22182. /** @hidden */
  22183. _this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22184. /** @hidden */
  22185. _this._camMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22186. /** @hidden */
  22187. _this._cameraTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22188. /** @hidden */
  22189. _this._cameraRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22190. /** @hidden */
  22191. _this._referencePoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  22192. /** @hidden */
  22193. _this._transformedReferencePoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22194. _this._globalCurrentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22195. _this._globalCurrentUpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22196. _this._defaultUp = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  22197. _this._cachedRotationZ = 0;
  22198. _this._cachedQuaternionRotationZ = 0;
  22199. return _this;
  22200. }
  22201. /**
  22202. * Gets the position in front of the camera at a given distance.
  22203. * @param distance The distance from the camera we want the position to be
  22204. * @returns the position
  22205. */
  22206. TargetCamera.prototype.getFrontPosition = function (distance) {
  22207. this.getWorldMatrix();
  22208. var direction = this.getTarget().subtract(this.position);
  22209. direction.normalize();
  22210. direction.scaleInPlace(distance);
  22211. return this.globalPosition.add(direction);
  22212. };
  22213. /** @hidden */
  22214. TargetCamera.prototype._getLockedTargetPosition = function () {
  22215. if (!this.lockedTarget) {
  22216. return null;
  22217. }
  22218. if (this.lockedTarget.absolutePosition) {
  22219. this.lockedTarget.computeWorldMatrix();
  22220. }
  22221. return this.lockedTarget.absolutePosition || this.lockedTarget;
  22222. };
  22223. /**
  22224. * Store current camera state of the camera (fov, position, rotation, etc..)
  22225. * @returns the camera
  22226. */
  22227. TargetCamera.prototype.storeState = function () {
  22228. this._storedPosition = this.position.clone();
  22229. this._storedRotation = this.rotation.clone();
  22230. if (this.rotationQuaternion) {
  22231. this._storedRotationQuaternion = this.rotationQuaternion.clone();
  22232. }
  22233. return _super.prototype.storeState.call(this);
  22234. };
  22235. /**
  22236. * Restored camera state. You must call storeState() first
  22237. * @returns whether it was successful or not
  22238. * @hidden
  22239. */
  22240. TargetCamera.prototype._restoreStateValues = function () {
  22241. if (!_super.prototype._restoreStateValues.call(this)) {
  22242. return false;
  22243. }
  22244. this.position = this._storedPosition.clone();
  22245. this.rotation = this._storedRotation.clone();
  22246. if (this.rotationQuaternion) {
  22247. this.rotationQuaternion = this._storedRotationQuaternion.clone();
  22248. }
  22249. this.cameraDirection.copyFromFloats(0, 0, 0);
  22250. this.cameraRotation.copyFromFloats(0, 0);
  22251. return true;
  22252. };
  22253. /** @hidden */
  22254. TargetCamera.prototype._initCache = function () {
  22255. _super.prototype._initCache.call(this);
  22256. this._cache.lockedTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22257. this._cache.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22258. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22259. };
  22260. /** @hidden */
  22261. TargetCamera.prototype._updateCache = function (ignoreParentClass) {
  22262. if (!ignoreParentClass) {
  22263. _super.prototype._updateCache.call(this);
  22264. }
  22265. var lockedTargetPosition = this._getLockedTargetPosition();
  22266. if (!lockedTargetPosition) {
  22267. this._cache.lockedTarget = null;
  22268. }
  22269. else {
  22270. if (!this._cache.lockedTarget) {
  22271. this._cache.lockedTarget = lockedTargetPosition.clone();
  22272. }
  22273. else {
  22274. this._cache.lockedTarget.copyFrom(lockedTargetPosition);
  22275. }
  22276. }
  22277. this._cache.rotation.copyFrom(this.rotation);
  22278. if (this.rotationQuaternion) {
  22279. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22280. }
  22281. };
  22282. // Synchronized
  22283. /** @hidden */
  22284. TargetCamera.prototype._isSynchronizedViewMatrix = function () {
  22285. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  22286. return false;
  22287. }
  22288. var lockedTargetPosition = this._getLockedTargetPosition();
  22289. return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(lockedTargetPosition) : !lockedTargetPosition)
  22290. && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation));
  22291. };
  22292. // Methods
  22293. /** @hidden */
  22294. TargetCamera.prototype._computeLocalCameraSpeed = function () {
  22295. var engine = this.getEngine();
  22296. return this.speed * Math.sqrt((engine.getDeltaTime() / (engine.getFps() * 100.0)));
  22297. };
  22298. // Target
  22299. /** @hidden */
  22300. TargetCamera.prototype.setTarget = function (target) {
  22301. this.upVector.normalize();
  22302. this._initialFocalDistance = target.subtract(this.position).length();
  22303. if (this.position.z === target.z) {
  22304. this.position.z += _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  22305. }
  22306. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this.position, target, this._defaultUp, this._camMatrix);
  22307. this._camMatrix.invert();
  22308. this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
  22309. var vDir = target.subtract(this.position);
  22310. if (vDir.x >= 0.0) {
  22311. this.rotation.y = (-Math.atan(vDir.z / vDir.x) + Math.PI / 2.0);
  22312. }
  22313. else {
  22314. this.rotation.y = (-Math.atan(vDir.z / vDir.x) - Math.PI / 2.0);
  22315. }
  22316. this.rotation.z = 0;
  22317. if (isNaN(this.rotation.x)) {
  22318. this.rotation.x = 0;
  22319. }
  22320. if (isNaN(this.rotation.y)) {
  22321. this.rotation.y = 0;
  22322. }
  22323. if (isNaN(this.rotation.z)) {
  22324. this.rotation.z = 0;
  22325. }
  22326. if (this.rotationQuaternion) {
  22327. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  22328. }
  22329. };
  22330. /**
  22331. * Return the current target position of the camera. This value is expressed in local space.
  22332. * @returns the target position
  22333. */
  22334. TargetCamera.prototype.getTarget = function () {
  22335. return this._currentTarget;
  22336. };
  22337. /** @hidden */
  22338. TargetCamera.prototype._decideIfNeedsToMove = function () {
  22339. return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22340. };
  22341. /** @hidden */
  22342. TargetCamera.prototype._updatePosition = function () {
  22343. if (this.parent) {
  22344. this.parent.getWorldMatrix().invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  22345. _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]);
  22346. this.position.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  22347. return;
  22348. }
  22349. this.position.addInPlace(this.cameraDirection);
  22350. };
  22351. /** @hidden */
  22352. TargetCamera.prototype._checkInputs = function () {
  22353. var needToMove = this._decideIfNeedsToMove();
  22354. var needToRotate = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
  22355. // Move
  22356. if (needToMove) {
  22357. this._updatePosition();
  22358. }
  22359. // Rotate
  22360. if (needToRotate) {
  22361. this.rotation.x += this.cameraRotation.x;
  22362. this.rotation.y += this.cameraRotation.y;
  22363. //rotate, if quaternion is set and rotation was used
  22364. if (this.rotationQuaternion) {
  22365. var len = this.rotation.lengthSquared();
  22366. if (len) {
  22367. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  22368. }
  22369. }
  22370. if (!this.noRotationConstraint) {
  22371. var limit = (Math.PI / 2) * 0.95;
  22372. if (this.rotation.x > limit) {
  22373. this.rotation.x = limit;
  22374. }
  22375. if (this.rotation.x < -limit) {
  22376. this.rotation.x = -limit;
  22377. }
  22378. }
  22379. }
  22380. // Inertia
  22381. if (needToMove) {
  22382. if (Math.abs(this.cameraDirection.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22383. this.cameraDirection.x = 0;
  22384. }
  22385. if (Math.abs(this.cameraDirection.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22386. this.cameraDirection.y = 0;
  22387. }
  22388. if (Math.abs(this.cameraDirection.z) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22389. this.cameraDirection.z = 0;
  22390. }
  22391. this.cameraDirection.scaleInPlace(this.inertia);
  22392. }
  22393. if (needToRotate) {
  22394. if (Math.abs(this.cameraRotation.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22395. this.cameraRotation.x = 0;
  22396. }
  22397. if (Math.abs(this.cameraRotation.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22398. this.cameraRotation.y = 0;
  22399. }
  22400. this.cameraRotation.scaleInPlace(this.inertia);
  22401. }
  22402. _super.prototype._checkInputs.call(this);
  22403. };
  22404. TargetCamera.prototype._updateCameraRotationMatrix = function () {
  22405. if (this.rotationQuaternion) {
  22406. this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
  22407. }
  22408. else {
  22409. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
  22410. }
  22411. };
  22412. /**
  22413. * 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)
  22414. * @returns the current camera
  22415. */
  22416. TargetCamera.prototype._rotateUpVectorWithCameraRotationMatrix = function () {
  22417. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector);
  22418. return this;
  22419. };
  22420. /** @hidden */
  22421. TargetCamera.prototype._getViewMatrix = function () {
  22422. if (this.lockedTarget) {
  22423. this.setTarget(this._getLockedTargetPosition());
  22424. }
  22425. // Compute
  22426. this._updateCameraRotationMatrix();
  22427. // Apply the changed rotation to the upVector
  22428. if (this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z) {
  22429. this._rotateUpVectorWithCameraRotationMatrix();
  22430. this._cachedQuaternionRotationZ = this.rotationQuaternion.z;
  22431. }
  22432. else if (this._cachedRotationZ != this.rotation.z) {
  22433. this._rotateUpVectorWithCameraRotationMatrix();
  22434. this._cachedRotationZ = this.rotation.z;
  22435. }
  22436. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  22437. // Computing target and final matrix
  22438. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  22439. if (this.updateUpVectorFromRotation) {
  22440. if (this.rotationQuaternion) {
  22441. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector);
  22442. }
  22443. else {
  22444. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, this._tmpQuaternion);
  22445. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector);
  22446. }
  22447. }
  22448. this._computeViewMatrix(this.position, this._currentTarget, this.upVector);
  22449. return this._viewMatrix;
  22450. };
  22451. TargetCamera.prototype._computeViewMatrix = function (position, target, up) {
  22452. if (this.parent) {
  22453. var parentWorldMatrix = this.parent.getWorldMatrix();
  22454. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(position, parentWorldMatrix, this._globalPosition);
  22455. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(target, parentWorldMatrix, this._globalCurrentTarget);
  22456. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(up, parentWorldMatrix, this._globalCurrentUpVector);
  22457. this._markSyncedWithParent();
  22458. }
  22459. else {
  22460. this._globalPosition.copyFrom(position);
  22461. this._globalCurrentTarget.copyFrom(target);
  22462. this._globalCurrentUpVector.copyFrom(up);
  22463. }
  22464. if (this.getScene().useRightHandedSystem) {
  22465. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtRHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  22466. }
  22467. else {
  22468. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  22469. }
  22470. };
  22471. /**
  22472. * @hidden
  22473. */
  22474. TargetCamera.prototype.createRigCamera = function (name, cameraIndex) {
  22475. if (this.cameraRigMode !== _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_NONE) {
  22476. var rigCamera = new TargetCamera(name, this.position.clone(), this.getScene());
  22477. if (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR || this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_WEBVR) {
  22478. if (!this.rotationQuaternion) {
  22479. this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22480. }
  22481. rigCamera._cameraRigParams = {};
  22482. rigCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22483. }
  22484. return rigCamera;
  22485. }
  22486. return null;
  22487. };
  22488. /**
  22489. * @hidden
  22490. */
  22491. TargetCamera.prototype._updateRigCameras = function () {
  22492. var camLeft = this._rigCameras[0];
  22493. var camRight = this._rigCameras[1];
  22494. this.computeWorldMatrix();
  22495. switch (this.cameraRigMode) {
  22496. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  22497. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  22498. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  22499. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  22500. //provisionnaly using _cameraRigParams.stereoHalfAngle instead of calculations based on _cameraRigParams.interaxialDistance:
  22501. var leftSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? 1 : -1;
  22502. var rightSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? -1 : 1;
  22503. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * leftSign, camLeft);
  22504. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * rightSign, camRight);
  22505. break;
  22506. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR:
  22507. if (camLeft.rotationQuaternion) {
  22508. camLeft.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22509. camRight.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22510. }
  22511. else {
  22512. camLeft.rotation.copyFrom(this.rotation);
  22513. camRight.rotation.copyFrom(this.rotation);
  22514. }
  22515. camLeft.position.copyFrom(this.position);
  22516. camRight.position.copyFrom(this.position);
  22517. break;
  22518. }
  22519. _super.prototype._updateRigCameras.call(this);
  22520. };
  22521. TargetCamera.prototype._getRigCamPositionAndTarget = function (halfSpace, rigCamera) {
  22522. var target = this.getTarget();
  22523. target.subtractToRef(this.position, TargetCamera._TargetFocalPoint);
  22524. TargetCamera._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
  22525. var newFocalTarget = TargetCamera._TargetFocalPoint.addInPlace(this.position);
  22526. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-newFocalTarget.x, -newFocalTarget.y, -newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  22527. TargetCamera._TargetTransformMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(halfSpace), TargetCamera._RigCamTransformMatrix);
  22528. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(newFocalTarget.x, newFocalTarget.y, newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  22529. TargetCamera._RigCamTransformMatrix.multiplyToRef(TargetCamera._TargetTransformMatrix, TargetCamera._RigCamTransformMatrix);
  22530. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, TargetCamera._RigCamTransformMatrix, rigCamera.position);
  22531. rigCamera.setTarget(newFocalTarget);
  22532. };
  22533. /**
  22534. * Gets the current object class name.
  22535. * @return the class name
  22536. */
  22537. TargetCamera.prototype.getClassName = function () {
  22538. return "TargetCamera";
  22539. };
  22540. TargetCamera._RigCamTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  22541. TargetCamera._TargetTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  22542. TargetCamera._TargetFocalPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  22543. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22544. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22545. ], TargetCamera.prototype, "rotation", void 0);
  22546. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22547. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22548. ], TargetCamera.prototype, "speed", void 0);
  22549. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22550. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  22551. ], TargetCamera.prototype, "lockedTarget", void 0);
  22552. return TargetCamera;
  22553. }(_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]));
  22554. /***/ }),
  22555. /***/ "./Cameras/touchCamera.ts":
  22556. /*!********************************!*\
  22557. !*** ./Cameras/touchCamera.ts ***!
  22558. \********************************/
  22559. /*! exports provided: TouchCamera */
  22560. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22561. "use strict";
  22562. __webpack_require__.r(__webpack_exports__);
  22563. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return TouchCamera; });
  22564. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22565. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  22566. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22567. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  22568. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("TouchCamera", function (name, scene) {
  22569. return function () { return new TouchCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  22570. });
  22571. /**
  22572. * This represents a FPS type of camera controlled by touch.
  22573. * This is like a universal camera minus the Gamepad controls.
  22574. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22575. */
  22576. var TouchCamera = /** @class */ (function (_super) {
  22577. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TouchCamera, _super);
  22578. /**
  22579. * Instantiates a new touch camera.
  22580. * This represents a FPS type of camera controlled by touch.
  22581. * This is like a universal camera minus the Gamepad controls.
  22582. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22583. * @param name Define the name of the camera in the scene
  22584. * @param position Define the start position of the camera in the scene
  22585. * @param scene Define the scene the camera belongs to
  22586. */
  22587. function TouchCamera(name, position, scene) {
  22588. var _this = _super.call(this, name, position, scene) || this;
  22589. _this.inputs.addTouch();
  22590. _this._setupInputs();
  22591. return _this;
  22592. }
  22593. Object.defineProperty(TouchCamera.prototype, "touchAngularSensibility", {
  22594. /**
  22595. * Defines the touch sensibility for rotation.
  22596. * The higher the faster.
  22597. */
  22598. get: function () {
  22599. var touch = this.inputs.attached["touch"];
  22600. if (touch) {
  22601. return touch.touchAngularSensibility;
  22602. }
  22603. return 0;
  22604. },
  22605. set: function (value) {
  22606. var touch = this.inputs.attached["touch"];
  22607. if (touch) {
  22608. touch.touchAngularSensibility = value;
  22609. }
  22610. },
  22611. enumerable: true,
  22612. configurable: true
  22613. });
  22614. Object.defineProperty(TouchCamera.prototype, "touchMoveSensibility", {
  22615. /**
  22616. * Defines the touch sensibility for move.
  22617. * The higher the faster.
  22618. */
  22619. get: function () {
  22620. var touch = this.inputs.attached["touch"];
  22621. if (touch) {
  22622. return touch.touchMoveSensibility;
  22623. }
  22624. return 0;
  22625. },
  22626. set: function (value) {
  22627. var touch = this.inputs.attached["touch"];
  22628. if (touch) {
  22629. touch.touchMoveSensibility = value;
  22630. }
  22631. },
  22632. enumerable: true,
  22633. configurable: true
  22634. });
  22635. /**
  22636. * Gets the current object class name.
  22637. * @return the class name
  22638. */
  22639. TouchCamera.prototype.getClassName = function () {
  22640. return "TouchCamera";
  22641. };
  22642. /** @hidden */
  22643. TouchCamera.prototype._setupInputs = function () {
  22644. var mouse = this.inputs.attached["mouse"];
  22645. if (mouse) {
  22646. mouse.touchEnabled = false;
  22647. }
  22648. };
  22649. return TouchCamera;
  22650. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  22651. /***/ }),
  22652. /***/ "./Cameras/universalCamera.ts":
  22653. /*!************************************!*\
  22654. !*** ./Cameras/universalCamera.ts ***!
  22655. \************************************/
  22656. /*! exports provided: UniversalCamera */
  22657. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22658. "use strict";
  22659. __webpack_require__.r(__webpack_exports__);
  22660. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return UniversalCamera; });
  22661. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22662. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  22663. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node */ "./node.ts");
  22664. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22665. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  22666. _node__WEBPACK_IMPORTED_MODULE_2__["Node"].AddNodeConstructor("FreeCamera", function (name, scene) {
  22667. // Forcing to use the Universal camera
  22668. return function () { return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  22669. });
  22670. /**
  22671. * 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,
  22672. * which still works and will still be found in many Playgrounds.
  22673. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22674. */
  22675. var UniversalCamera = /** @class */ (function (_super) {
  22676. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](UniversalCamera, _super);
  22677. /**
  22678. * 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,
  22679. * which still works and will still be found in many Playgrounds.
  22680. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22681. * @param name Define the name of the camera in the scene
  22682. * @param position Define the start position of the camera in the scene
  22683. * @param scene Define the scene the camera belongs to
  22684. */
  22685. function UniversalCamera(name, position, scene) {
  22686. var _this = _super.call(this, name, position, scene) || this;
  22687. _this.inputs.addGamepad();
  22688. return _this;
  22689. }
  22690. Object.defineProperty(UniversalCamera.prototype, "gamepadAngularSensibility", {
  22691. /**
  22692. * Defines the gamepad rotation sensiblity.
  22693. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  22694. */
  22695. get: function () {
  22696. var gamepad = this.inputs.attached["gamepad"];
  22697. if (gamepad) {
  22698. return gamepad.gamepadAngularSensibility;
  22699. }
  22700. return 0;
  22701. },
  22702. set: function (value) {
  22703. var gamepad = this.inputs.attached["gamepad"];
  22704. if (gamepad) {
  22705. gamepad.gamepadAngularSensibility = value;
  22706. }
  22707. },
  22708. enumerable: true,
  22709. configurable: true
  22710. });
  22711. Object.defineProperty(UniversalCamera.prototype, "gamepadMoveSensibility", {
  22712. /**
  22713. * Defines the gamepad move sensiblity.
  22714. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  22715. */
  22716. get: function () {
  22717. var gamepad = this.inputs.attached["gamepad"];
  22718. if (gamepad) {
  22719. return gamepad.gamepadMoveSensibility;
  22720. }
  22721. return 0;
  22722. },
  22723. set: function (value) {
  22724. var gamepad = this.inputs.attached["gamepad"];
  22725. if (gamepad) {
  22726. gamepad.gamepadMoveSensibility = value;
  22727. }
  22728. },
  22729. enumerable: true,
  22730. configurable: true
  22731. });
  22732. /**
  22733. * Gets the current object class name.
  22734. * @return the class name
  22735. */
  22736. UniversalCamera.prototype.getClassName = function () {
  22737. return "UniversalCamera";
  22738. };
  22739. return UniversalCamera;
  22740. }(_touchCamera__WEBPACK_IMPORTED_MODULE_1__["TouchCamera"]));
  22741. _camera__WEBPACK_IMPORTED_MODULE_4__["Camera"]._createDefaultParsedCamera = function (name, scene) {
  22742. return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene);
  22743. };
  22744. /***/ }),
  22745. /***/ "./Cameras/virtualJoysticksCamera.ts":
  22746. /*!*******************************************!*\
  22747. !*** ./Cameras/virtualJoysticksCamera.ts ***!
  22748. \*******************************************/
  22749. /*! exports provided: VirtualJoysticksCamera */
  22750. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22751. "use strict";
  22752. __webpack_require__.r(__webpack_exports__);
  22753. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return VirtualJoysticksCamera; });
  22754. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22755. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  22756. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22757. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  22758. /* harmony import */ var _Inputs_freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  22759. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("VirtualJoysticksCamera", function (name, scene) {
  22760. return function () { return new VirtualJoysticksCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  22761. });
  22762. /**
  22763. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22764. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  22765. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  22766. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  22767. */
  22768. var VirtualJoysticksCamera = /** @class */ (function (_super) {
  22769. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualJoysticksCamera, _super);
  22770. /**
  22771. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  22772. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  22773. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  22774. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  22775. * @param name Define the name of the camera in the scene
  22776. * @param position Define the start position of the camera in the scene
  22777. * @param scene Define the scene the camera belongs to
  22778. */
  22779. function VirtualJoysticksCamera(name, position, scene) {
  22780. var _this = _super.call(this, name, position, scene) || this;
  22781. _this.inputs.addVirtualJoystick();
  22782. return _this;
  22783. }
  22784. /**
  22785. * Gets the current object class name.
  22786. * @return the class name
  22787. */
  22788. VirtualJoysticksCamera.prototype.getClassName = function () {
  22789. return "VirtualJoysticksCamera";
  22790. };
  22791. return VirtualJoysticksCamera;
  22792. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  22793. /***/ }),
  22794. /***/ "./Collisions/collider.ts":
  22795. /*!********************************!*\
  22796. !*** ./Collisions/collider.ts ***!
  22797. \********************************/
  22798. /*! exports provided: Collider */
  22799. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22800. "use strict";
  22801. __webpack_require__.r(__webpack_exports__);
  22802. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return Collider; });
  22803. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22804. var intersectBoxAASphere = function (boxMin, boxMax, sphereCenter, sphereRadius) {
  22805. if (boxMin.x > sphereCenter.x + sphereRadius) {
  22806. return false;
  22807. }
  22808. if (sphereCenter.x - sphereRadius > boxMax.x) {
  22809. return false;
  22810. }
  22811. if (boxMin.y > sphereCenter.y + sphereRadius) {
  22812. return false;
  22813. }
  22814. if (sphereCenter.y - sphereRadius > boxMax.y) {
  22815. return false;
  22816. }
  22817. if (boxMin.z > sphereCenter.z + sphereRadius) {
  22818. return false;
  22819. }
  22820. if (sphereCenter.z - sphereRadius > boxMax.z) {
  22821. return false;
  22822. }
  22823. return true;
  22824. };
  22825. var getLowestRoot = (function () {
  22826. var result = { root: 0, found: false };
  22827. return function (a, b, c, maxR) {
  22828. result.root = 0;
  22829. result.found = false;
  22830. var determinant = b * b - 4.0 * a * c;
  22831. if (determinant < 0) {
  22832. return result;
  22833. }
  22834. var sqrtD = Math.sqrt(determinant);
  22835. var r1 = (-b - sqrtD) / (2.0 * a);
  22836. var r2 = (-b + sqrtD) / (2.0 * a);
  22837. if (r1 > r2) {
  22838. var temp = r2;
  22839. r2 = r1;
  22840. r1 = temp;
  22841. }
  22842. if (r1 > 0 && r1 < maxR) {
  22843. result.root = r1;
  22844. result.found = true;
  22845. return result;
  22846. }
  22847. if (r2 > 0 && r2 < maxR) {
  22848. result.root = r2;
  22849. result.found = true;
  22850. return result;
  22851. }
  22852. return result;
  22853. };
  22854. })();
  22855. /** @hidden */
  22856. var Collider = /** @class */ (function () {
  22857. function Collider() {
  22858. this._collisionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22859. this._planeIntersectionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22860. this._tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22861. this._tempVector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22862. this._tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22863. this._tempVector4 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22864. this._edge = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22865. this._baseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22866. this._destinationPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22867. this._slidePlaneNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22868. this._displacementVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22869. /** @hidden */
  22870. this._radius = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  22871. /** @hidden */
  22872. this._retry = 0;
  22873. /** @hidden */
  22874. this._basePointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22875. this._velocityWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22876. this._normalizedVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22877. this._collisionMask = -1;
  22878. }
  22879. Object.defineProperty(Collider.prototype, "collisionMask", {
  22880. get: function () {
  22881. return this._collisionMask;
  22882. },
  22883. set: function (mask) {
  22884. this._collisionMask = !isNaN(mask) ? mask : -1;
  22885. },
  22886. enumerable: true,
  22887. configurable: true
  22888. });
  22889. Object.defineProperty(Collider.prototype, "slidePlaneNormal", {
  22890. /**
  22891. * Gets the plane normal used to compute the sliding response (in local space)
  22892. */
  22893. get: function () {
  22894. return this._slidePlaneNormal;
  22895. },
  22896. enumerable: true,
  22897. configurable: true
  22898. });
  22899. // Methods
  22900. /** @hidden */
  22901. Collider.prototype._initialize = function (source, dir, e) {
  22902. this._velocity = dir;
  22903. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].NormalizeToRef(dir, this._normalizedVelocity);
  22904. this._basePoint = source;
  22905. source.multiplyToRef(this._radius, this._basePointWorld);
  22906. dir.multiplyToRef(this._radius, this._velocityWorld);
  22907. this._velocityWorldLength = this._velocityWorld.length();
  22908. this._epsilon = e;
  22909. this.collisionFound = false;
  22910. };
  22911. /** @hidden */
  22912. Collider.prototype._checkPointInTriangle = function (point, pa, pb, pc, n) {
  22913. pa.subtractToRef(point, this._tempVector);
  22914. pb.subtractToRef(point, this._tempVector2);
  22915. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
  22916. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  22917. if (d < 0) {
  22918. return false;
  22919. }
  22920. pc.subtractToRef(point, this._tempVector3);
  22921. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4);
  22922. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  22923. if (d < 0) {
  22924. return false;
  22925. }
  22926. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector3, this._tempVector, this._tempVector4);
  22927. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  22928. return d >= 0;
  22929. };
  22930. /** @hidden */
  22931. Collider.prototype._canDoCollision = function (sphereCenter, sphereRadius, vecMin, vecMax) {
  22932. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._basePointWorld, sphereCenter);
  22933. var max = Math.max(this._radius.x, this._radius.y, this._radius.z);
  22934. if (distance > this._velocityWorldLength + max + sphereRadius) {
  22935. return false;
  22936. }
  22937. if (!intersectBoxAASphere(vecMin, vecMax, this._basePointWorld, this._velocityWorldLength + max)) {
  22938. return false;
  22939. }
  22940. return true;
  22941. };
  22942. /** @hidden */
  22943. Collider.prototype._testTriangle = function (faceIndex, trianglePlaneArray, p1, p2, p3, hasMaterial) {
  22944. var t0;
  22945. var embeddedInPlane = false;
  22946. //defensive programming, actually not needed.
  22947. if (!trianglePlaneArray) {
  22948. trianglePlaneArray = [];
  22949. }
  22950. if (!trianglePlaneArray[faceIndex]) {
  22951. trianglePlaneArray[faceIndex] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"](0, 0, 0, 0);
  22952. trianglePlaneArray[faceIndex].copyFromPoints(p1, p2, p3);
  22953. }
  22954. var trianglePlane = trianglePlaneArray[faceIndex];
  22955. if ((!hasMaterial) && !trianglePlane.isFrontFacingTo(this._normalizedVelocity, 0)) {
  22956. return;
  22957. }
  22958. var signedDistToTrianglePlane = trianglePlane.signedDistanceTo(this._basePoint);
  22959. var normalDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(trianglePlane.normal, this._velocity);
  22960. if (normalDotVelocity == 0) {
  22961. if (Math.abs(signedDistToTrianglePlane) >= 1.0) {
  22962. return;
  22963. }
  22964. embeddedInPlane = true;
  22965. t0 = 0;
  22966. }
  22967. else {
  22968. t0 = (-1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  22969. var t1 = (1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  22970. if (t0 > t1) {
  22971. var temp = t1;
  22972. t1 = t0;
  22973. t0 = temp;
  22974. }
  22975. if (t0 > 1.0 || t1 < 0.0) {
  22976. return;
  22977. }
  22978. if (t0 < 0) {
  22979. t0 = 0;
  22980. }
  22981. if (t0 > 1.0) {
  22982. t0 = 1.0;
  22983. }
  22984. }
  22985. this._collisionPoint.copyFromFloats(0, 0, 0);
  22986. var found = false;
  22987. var t = 1.0;
  22988. if (!embeddedInPlane) {
  22989. this._basePoint.subtractToRef(trianglePlane.normal, this._planeIntersectionPoint);
  22990. this._velocity.scaleToRef(t0, this._tempVector);
  22991. this._planeIntersectionPoint.addInPlace(this._tempVector);
  22992. if (this._checkPointInTriangle(this._planeIntersectionPoint, p1, p2, p3, trianglePlane.normal)) {
  22993. found = true;
  22994. t = t0;
  22995. this._collisionPoint.copyFrom(this._planeIntersectionPoint);
  22996. }
  22997. }
  22998. if (!found) {
  22999. var velocitySquaredLength = this._velocity.lengthSquared();
  23000. var a = velocitySquaredLength;
  23001. this._basePoint.subtractToRef(p1, this._tempVector);
  23002. var b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23003. var c = this._tempVector.lengthSquared() - 1.0;
  23004. var lowestRoot = getLowestRoot(a, b, c, t);
  23005. if (lowestRoot.found) {
  23006. t = lowestRoot.root;
  23007. found = true;
  23008. this._collisionPoint.copyFrom(p1);
  23009. }
  23010. this._basePoint.subtractToRef(p2, this._tempVector);
  23011. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23012. c = this._tempVector.lengthSquared() - 1.0;
  23013. lowestRoot = getLowestRoot(a, b, c, t);
  23014. if (lowestRoot.found) {
  23015. t = lowestRoot.root;
  23016. found = true;
  23017. this._collisionPoint.copyFrom(p2);
  23018. }
  23019. this._basePoint.subtractToRef(p3, this._tempVector);
  23020. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23021. c = this._tempVector.lengthSquared() - 1.0;
  23022. lowestRoot = getLowestRoot(a, b, c, t);
  23023. if (lowestRoot.found) {
  23024. t = lowestRoot.root;
  23025. found = true;
  23026. this._collisionPoint.copyFrom(p3);
  23027. }
  23028. p2.subtractToRef(p1, this._edge);
  23029. p1.subtractToRef(this._basePoint, this._baseToVertex);
  23030. var edgeSquaredLength = this._edge.lengthSquared();
  23031. var edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23032. var edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23033. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23034. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23035. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23036. lowestRoot = getLowestRoot(a, b, c, t);
  23037. if (lowestRoot.found) {
  23038. var f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23039. if (f >= 0.0 && f <= 1.0) {
  23040. t = lowestRoot.root;
  23041. found = true;
  23042. this._edge.scaleInPlace(f);
  23043. p1.addToRef(this._edge, this._collisionPoint);
  23044. }
  23045. }
  23046. p3.subtractToRef(p2, this._edge);
  23047. p2.subtractToRef(this._basePoint, this._baseToVertex);
  23048. edgeSquaredLength = this._edge.lengthSquared();
  23049. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23050. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23051. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23052. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23053. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23054. lowestRoot = getLowestRoot(a, b, c, t);
  23055. if (lowestRoot.found) {
  23056. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23057. if (f >= 0.0 && f <= 1.0) {
  23058. t = lowestRoot.root;
  23059. found = true;
  23060. this._edge.scaleInPlace(f);
  23061. p2.addToRef(this._edge, this._collisionPoint);
  23062. }
  23063. }
  23064. p1.subtractToRef(p3, this._edge);
  23065. p3.subtractToRef(this._basePoint, this._baseToVertex);
  23066. edgeSquaredLength = this._edge.lengthSquared();
  23067. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23068. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23069. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23070. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23071. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23072. lowestRoot = getLowestRoot(a, b, c, t);
  23073. if (lowestRoot.found) {
  23074. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23075. if (f >= 0.0 && f <= 1.0) {
  23076. t = lowestRoot.root;
  23077. found = true;
  23078. this._edge.scaleInPlace(f);
  23079. p3.addToRef(this._edge, this._collisionPoint);
  23080. }
  23081. }
  23082. }
  23083. if (found) {
  23084. var distToCollision = t * this._velocity.length();
  23085. if (!this.collisionFound || distToCollision < this._nearestDistance) {
  23086. if (!this.intersectionPoint) {
  23087. this.intersectionPoint = this._collisionPoint.clone();
  23088. }
  23089. else {
  23090. this.intersectionPoint.copyFrom(this._collisionPoint);
  23091. }
  23092. this._nearestDistance = distToCollision;
  23093. this.collisionFound = true;
  23094. }
  23095. }
  23096. };
  23097. /** @hidden */
  23098. Collider.prototype._collide = function (trianglePlaneArray, pts, indices, indexStart, indexEnd, decal, hasMaterial) {
  23099. for (var i = indexStart; i < indexEnd; i += 3) {
  23100. var p1 = pts[indices[i] - decal];
  23101. var p2 = pts[indices[i + 1] - decal];
  23102. var p3 = pts[indices[i + 2] - decal];
  23103. this._testTriangle(i, trianglePlaneArray, p3, p2, p1, hasMaterial);
  23104. }
  23105. };
  23106. /** @hidden */
  23107. Collider.prototype._getResponse = function (pos, vel) {
  23108. pos.addToRef(vel, this._destinationPoint);
  23109. vel.scaleInPlace((this._nearestDistance / vel.length()));
  23110. this._basePoint.addToRef(vel, pos);
  23111. pos.subtractToRef(this.intersectionPoint, this._slidePlaneNormal);
  23112. this._slidePlaneNormal.normalize();
  23113. this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector);
  23114. pos.addInPlace(this._displacementVector);
  23115. this.intersectionPoint.addInPlace(this._displacementVector);
  23116. this._slidePlaneNormal.scaleInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"].SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint));
  23117. this._destinationPoint.subtractInPlace(this._slidePlaneNormal);
  23118. this._destinationPoint.subtractToRef(this.intersectionPoint, vel);
  23119. };
  23120. return Collider;
  23121. }());
  23122. /***/ }),
  23123. /***/ "./Collisions/collisionCoordinator.ts":
  23124. /*!********************************************!*\
  23125. !*** ./Collisions/collisionCoordinator.ts ***!
  23126. \********************************************/
  23127. /*! exports provided: CollisionCoordinatorLegacy */
  23128. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23129. "use strict";
  23130. __webpack_require__.r(__webpack_exports__);
  23131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CollisionCoordinatorLegacy", function() { return CollisionCoordinatorLegacy; });
  23132. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23133. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  23134. /** @hidden */
  23135. var CollisionCoordinatorLegacy = /** @class */ (function () {
  23136. function CollisionCoordinatorLegacy() {
  23137. this._scaledPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23138. this._scaledVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23139. this._finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23140. }
  23141. CollisionCoordinatorLegacy.prototype.getNewPosition = function (position, displacement, collider, maximumRetry, excludedMesh, onNewPosition, collisionIndex) {
  23142. position.divideToRef(collider._radius, this._scaledPosition);
  23143. displacement.divideToRef(collider._radius, this._scaledVelocity);
  23144. collider.collidedMesh = null;
  23145. collider._retry = 0;
  23146. collider._initialVelocity = this._scaledVelocity;
  23147. collider._initialPosition = this._scaledPosition;
  23148. this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, this._finalPosition, excludedMesh);
  23149. this._finalPosition.multiplyInPlace(collider._radius);
  23150. //run the callback
  23151. onNewPosition(collisionIndex, this._finalPosition, collider.collidedMesh);
  23152. };
  23153. CollisionCoordinatorLegacy.prototype.init = function (scene) {
  23154. this._scene = scene;
  23155. };
  23156. CollisionCoordinatorLegacy.prototype.destroy = function () {
  23157. //Legacy need no destruction method.
  23158. };
  23159. //No update in legacy mode
  23160. CollisionCoordinatorLegacy.prototype.onMeshAdded = function (mesh) { };
  23161. CollisionCoordinatorLegacy.prototype.onMeshUpdated = function (mesh) { };
  23162. CollisionCoordinatorLegacy.prototype.onMeshRemoved = function (mesh) { };
  23163. CollisionCoordinatorLegacy.prototype.onGeometryAdded = function (geometry) { };
  23164. CollisionCoordinatorLegacy.prototype.onGeometryUpdated = function (geometry) { };
  23165. CollisionCoordinatorLegacy.prototype.onGeometryDeleted = function (geometry) { };
  23166. CollisionCoordinatorLegacy.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
  23167. if (excludedMesh === void 0) { excludedMesh = null; }
  23168. var closeDistance = _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].CollisionsEpsilon * 10.0;
  23169. if (collider._retry >= maximumRetry) {
  23170. finalPosition.copyFrom(position);
  23171. return;
  23172. }
  23173. // Check if this is a mesh else camera or -1
  23174. var collisionMask = (excludedMesh ? excludedMesh.collisionMask : collider.collisionMask);
  23175. collider._initialize(position, velocity, closeDistance);
  23176. // Check all meshes
  23177. for (var index = 0; index < this._scene.meshes.length; index++) {
  23178. var mesh = this._scene.meshes[index];
  23179. if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh && ((collisionMask & mesh.collisionGroup) !== 0)) {
  23180. mesh._checkCollision(collider);
  23181. }
  23182. }
  23183. if (!collider.collisionFound) {
  23184. position.addToRef(velocity, finalPosition);
  23185. return;
  23186. }
  23187. if (velocity.x !== 0 || velocity.y !== 0 || velocity.z !== 0) {
  23188. collider._getResponse(position, velocity);
  23189. }
  23190. if (velocity.length() <= closeDistance) {
  23191. finalPosition.copyFrom(position);
  23192. return;
  23193. }
  23194. collider._retry++;
  23195. this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
  23196. };
  23197. return CollisionCoordinatorLegacy;
  23198. }());
  23199. /***/ }),
  23200. /***/ "./Collisions/index.ts":
  23201. /*!*****************************!*\
  23202. !*** ./Collisions/index.ts ***!
  23203. \*****************************/
  23204. /*! exports provided: Collider, CollisionCoordinatorLegacy, PickingInfo, IntersectionInfo */
  23205. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23206. "use strict";
  23207. __webpack_require__.r(__webpack_exports__);
  23208. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  23209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _collider__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  23210. /* harmony import */ var _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./collisionCoordinator */ "./Collisions/collisionCoordinator.ts");
  23211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CollisionCoordinatorLegacy", function() { return _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__["CollisionCoordinatorLegacy"]; });
  23212. /* harmony import */ var _pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pickingInfo */ "./Collisions/pickingInfo.ts");
  23213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]; });
  23214. /* harmony import */ var _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./intersectionInfo */ "./Collisions/intersectionInfo.ts");
  23215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"]; });
  23216. /***/ }),
  23217. /***/ "./Collisions/intersectionInfo.ts":
  23218. /*!****************************************!*\
  23219. !*** ./Collisions/intersectionInfo.ts ***!
  23220. \****************************************/
  23221. /*! exports provided: IntersectionInfo */
  23222. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23223. "use strict";
  23224. __webpack_require__.r(__webpack_exports__);
  23225. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return IntersectionInfo; });
  23226. /**
  23227. * @hidden
  23228. */
  23229. var IntersectionInfo = /** @class */ (function () {
  23230. function IntersectionInfo(bu, bv, distance) {
  23231. this.bu = bu;
  23232. this.bv = bv;
  23233. this.distance = distance;
  23234. this.faceId = 0;
  23235. this.subMeshId = 0;
  23236. }
  23237. return IntersectionInfo;
  23238. }());
  23239. /***/ }),
  23240. /***/ "./Collisions/pickingInfo.ts":
  23241. /*!***********************************!*\
  23242. !*** ./Collisions/pickingInfo.ts ***!
  23243. \***********************************/
  23244. /*! exports provided: PickingInfo */
  23245. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23246. "use strict";
  23247. __webpack_require__.r(__webpack_exports__);
  23248. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return PickingInfo; });
  23249. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23250. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  23251. /**
  23252. * Information about the result of picking within a scene
  23253. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  23254. */
  23255. var PickingInfo = /** @class */ (function () {
  23256. function PickingInfo() {
  23257. /**
  23258. * If the pick collided with an object
  23259. */
  23260. this.hit = false;
  23261. /**
  23262. * Distance away where the pick collided
  23263. */
  23264. this.distance = 0;
  23265. /**
  23266. * The location of pick collision
  23267. */
  23268. this.pickedPoint = null;
  23269. /**
  23270. * The mesh corresponding the the pick collision
  23271. */
  23272. this.pickedMesh = null;
  23273. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  23274. this.bu = 0;
  23275. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  23276. this.bv = 0;
  23277. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23278. this.faceId = -1;
  23279. /** Id of the the submesh that was picked */
  23280. this.subMeshId = 0;
  23281. /** If a sprite was picked, this will be the sprite the pick collided with */
  23282. this.pickedSprite = null;
  23283. /**
  23284. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  23285. */
  23286. this.originMesh = null;
  23287. /**
  23288. * The ray that was used to perform the picking.
  23289. */
  23290. this.ray = null;
  23291. }
  23292. /**
  23293. * Gets the normal correspodning to the face the pick collided with
  23294. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  23295. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  23296. * @returns The normal correspodning to the face the pick collided with
  23297. */
  23298. PickingInfo.prototype.getNormal = function (useWorldCoordinates, useVerticesNormals) {
  23299. if (useWorldCoordinates === void 0) { useWorldCoordinates = false; }
  23300. if (useVerticesNormals === void 0) { useVerticesNormals = true; }
  23301. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  23302. return null;
  23303. }
  23304. var indices = this.pickedMesh.getIndices();
  23305. if (!indices) {
  23306. return null;
  23307. }
  23308. var result;
  23309. if (useVerticesNormals) {
  23310. var normals = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  23311. var normal0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3] * 3);
  23312. var normal1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 1] * 3);
  23313. var normal2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 2] * 3);
  23314. normal0 = normal0.scale(this.bu);
  23315. normal1 = normal1.scale(this.bv);
  23316. normal2 = normal2.scale(1.0 - this.bu - this.bv);
  23317. 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);
  23318. }
  23319. else {
  23320. var positions = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  23321. var vertex1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3] * 3);
  23322. var vertex2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 1] * 3);
  23323. var vertex3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 2] * 3);
  23324. var p1p2 = vertex1.subtract(vertex2);
  23325. var p3p2 = vertex3.subtract(vertex2);
  23326. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(p1p2, p3p2);
  23327. }
  23328. if (useWorldCoordinates) {
  23329. var wm = this.pickedMesh.getWorldMatrix();
  23330. if (this.pickedMesh.nonUniformScaling) {
  23331. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0].copyFrom(wm);
  23332. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  23333. wm.setTranslationFromFloats(0, 0, 0);
  23334. wm.invert();
  23335. wm.transposeToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1]);
  23336. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  23337. }
  23338. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result, wm);
  23339. }
  23340. result.normalize();
  23341. return result;
  23342. };
  23343. /**
  23344. * Gets the texture coordinates of where the pick occured
  23345. * @returns the vector containing the coordnates of the texture
  23346. */
  23347. PickingInfo.prototype.getTextureCoordinates = function () {
  23348. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  23349. return null;
  23350. }
  23351. var indices = this.pickedMesh.getIndices();
  23352. if (!indices) {
  23353. return null;
  23354. }
  23355. var uvs = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  23356. if (!uvs) {
  23357. return null;
  23358. }
  23359. var uv0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3] * 2);
  23360. var uv1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
  23361. var uv2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 2] * 2);
  23362. uv0 = uv0.scale(1.0 - this.bu - this.bv);
  23363. uv1 = uv1.scale(this.bu);
  23364. uv2 = uv2.scale(this.bv);
  23365. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
  23366. };
  23367. return PickingInfo;
  23368. }());
  23369. /***/ }),
  23370. /***/ "./Culling/Octrees/index.ts":
  23371. /*!**********************************!*\
  23372. !*** ./Culling/Octrees/index.ts ***!
  23373. \**********************************/
  23374. /*! exports provided: Octree, OctreeBlock, OctreeSceneComponent */
  23375. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23376. "use strict";
  23377. __webpack_require__.r(__webpack_exports__);
  23378. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  23379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _octree__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  23380. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  23381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]; });
  23382. /* harmony import */ var _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./octreeSceneComponent */ "./Culling/Octrees/octreeSceneComponent.ts");
  23383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__["OctreeSceneComponent"]; });
  23384. /***/ }),
  23385. /***/ "./Culling/Octrees/octree.ts":
  23386. /*!***********************************!*\
  23387. !*** ./Culling/Octrees/octree.ts ***!
  23388. \***********************************/
  23389. /*! exports provided: Octree */
  23390. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23391. "use strict";
  23392. __webpack_require__.r(__webpack_exports__);
  23393. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return Octree; });
  23394. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  23395. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  23396. /**
  23397. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  23398. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23399. */
  23400. var Octree = /** @class */ (function () {
  23401. /**
  23402. * Creates a octree
  23403. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23404. * @param creationFunc function to be used to instatiate the octree
  23405. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  23406. * @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.)
  23407. */
  23408. function Octree(creationFunc, maxBlockCapacity,
  23409. /** 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.) */
  23410. maxDepth) {
  23411. if (maxDepth === void 0) { maxDepth = 2; }
  23412. this.maxDepth = maxDepth;
  23413. /**
  23414. * Content stored in the octree
  23415. */
  23416. this.dynamicContent = new Array();
  23417. this._maxBlockCapacity = maxBlockCapacity || 64;
  23418. this._selectionContent = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"](1024);
  23419. this._creationFunc = creationFunc;
  23420. }
  23421. // Methods
  23422. /**
  23423. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  23424. * @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);
  23425. * @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);
  23426. * @param entries meshes to be added to the octree blocks
  23427. */
  23428. Octree.prototype.update = function (worldMin, worldMax, entries) {
  23429. _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]._CreateBlocks(worldMin, worldMax, entries, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc);
  23430. };
  23431. /**
  23432. * Adds a mesh to the octree
  23433. * @param entry Mesh to add to the octree
  23434. */
  23435. Octree.prototype.addMesh = function (entry) {
  23436. for (var index = 0; index < this.blocks.length; index++) {
  23437. var block = this.blocks[index];
  23438. block.addEntry(entry);
  23439. }
  23440. };
  23441. /**
  23442. * Remove an element from the octree
  23443. * @param entry defines the element to remove
  23444. */
  23445. Octree.prototype.removeMesh = function (entry) {
  23446. for (var index = 0; index < this.blocks.length; index++) {
  23447. var block = this.blocks[index];
  23448. block.removeEntry(entry);
  23449. }
  23450. };
  23451. /**
  23452. * Selects an array of meshes within the frustum
  23453. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  23454. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  23455. * @returns array of meshes within the frustum
  23456. */
  23457. Octree.prototype.select = function (frustumPlanes, allowDuplicate) {
  23458. this._selectionContent.reset();
  23459. for (var index = 0; index < this.blocks.length; index++) {
  23460. var block = this.blocks[index];
  23461. block.select(frustumPlanes, this._selectionContent, allowDuplicate);
  23462. }
  23463. if (allowDuplicate) {
  23464. this._selectionContent.concat(this.dynamicContent);
  23465. }
  23466. else {
  23467. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23468. }
  23469. return this._selectionContent;
  23470. };
  23471. /**
  23472. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  23473. * @param sphereCenter defines the bounding sphere center
  23474. * @param sphereRadius defines the bounding sphere radius
  23475. * @param allowDuplicate defines if the selection array can contains duplicated entries
  23476. * @returns an array of objects that intersect the sphere
  23477. */
  23478. Octree.prototype.intersects = function (sphereCenter, sphereRadius, allowDuplicate) {
  23479. this._selectionContent.reset();
  23480. for (var index = 0; index < this.blocks.length; index++) {
  23481. var block = this.blocks[index];
  23482. block.intersects(sphereCenter, sphereRadius, this._selectionContent, allowDuplicate);
  23483. }
  23484. if (allowDuplicate) {
  23485. this._selectionContent.concat(this.dynamicContent);
  23486. }
  23487. else {
  23488. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23489. }
  23490. return this._selectionContent;
  23491. };
  23492. /**
  23493. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  23494. * @param ray defines the ray to test with
  23495. * @returns array of intersected objects
  23496. */
  23497. Octree.prototype.intersectsRay = function (ray) {
  23498. this._selectionContent.reset();
  23499. for (var index = 0; index < this.blocks.length; index++) {
  23500. var block = this.blocks[index];
  23501. block.intersectsRay(ray, this._selectionContent);
  23502. }
  23503. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23504. return this._selectionContent;
  23505. };
  23506. /**
  23507. * Adds a mesh into the octree block if it intersects the block
  23508. */
  23509. Octree.CreationFuncForMeshes = function (entry, block) {
  23510. var boundingInfo = entry.getBoundingInfo();
  23511. if (!entry.isBlocked && boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  23512. block.entries.push(entry);
  23513. }
  23514. };
  23515. /**
  23516. * Adds a submesh into the octree block if it intersects the block
  23517. */
  23518. Octree.CreationFuncForSubMeshes = function (entry, block) {
  23519. var boundingInfo = entry.getBoundingInfo();
  23520. if (boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  23521. block.entries.push(entry);
  23522. }
  23523. };
  23524. return Octree;
  23525. }());
  23526. /***/ }),
  23527. /***/ "./Culling/Octrees/octreeBlock.ts":
  23528. /*!****************************************!*\
  23529. !*** ./Culling/Octrees/octreeBlock.ts ***!
  23530. \****************************************/
  23531. /*! exports provided: OctreeBlock */
  23532. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23533. "use strict";
  23534. __webpack_require__.r(__webpack_exports__);
  23535. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return OctreeBlock; });
  23536. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  23537. /* harmony import */ var _Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Culling/boundingBox */ "./Culling/boundingBox.ts");
  23538. /**
  23539. * Class used to store a cell in an octree
  23540. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23541. */
  23542. var OctreeBlock = /** @class */ (function () {
  23543. /**
  23544. * Creates a new block
  23545. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  23546. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  23547. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  23548. * @param depth defines the current depth of this block in the octree
  23549. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  23550. * @param creationFunc defines a callback to call when an element is added to the block
  23551. */
  23552. function OctreeBlock(minPoint, maxPoint, capacity, depth, maxDepth, creationFunc) {
  23553. /**
  23554. * Gets the content of the current block
  23555. */
  23556. this.entries = new Array();
  23557. this._boundingVectors = new Array();
  23558. this._capacity = capacity;
  23559. this._depth = depth;
  23560. this._maxDepth = maxDepth;
  23561. this._creationFunc = creationFunc;
  23562. this._minPoint = minPoint;
  23563. this._maxPoint = maxPoint;
  23564. this._boundingVectors.push(minPoint.clone());
  23565. this._boundingVectors.push(maxPoint.clone());
  23566. this._boundingVectors.push(minPoint.clone());
  23567. this._boundingVectors[2].x = maxPoint.x;
  23568. this._boundingVectors.push(minPoint.clone());
  23569. this._boundingVectors[3].y = maxPoint.y;
  23570. this._boundingVectors.push(minPoint.clone());
  23571. this._boundingVectors[4].z = maxPoint.z;
  23572. this._boundingVectors.push(maxPoint.clone());
  23573. this._boundingVectors[5].z = minPoint.z;
  23574. this._boundingVectors.push(maxPoint.clone());
  23575. this._boundingVectors[6].x = minPoint.x;
  23576. this._boundingVectors.push(maxPoint.clone());
  23577. this._boundingVectors[7].y = minPoint.y;
  23578. }
  23579. Object.defineProperty(OctreeBlock.prototype, "capacity", {
  23580. // Property
  23581. /**
  23582. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  23583. */
  23584. get: function () {
  23585. return this._capacity;
  23586. },
  23587. enumerable: true,
  23588. configurable: true
  23589. });
  23590. Object.defineProperty(OctreeBlock.prototype, "minPoint", {
  23591. /**
  23592. * Gets the minimum vector (in world space) of the block's bounding box
  23593. */
  23594. get: function () {
  23595. return this._minPoint;
  23596. },
  23597. enumerable: true,
  23598. configurable: true
  23599. });
  23600. Object.defineProperty(OctreeBlock.prototype, "maxPoint", {
  23601. /**
  23602. * Gets the maximum vector (in world space) of the block's bounding box
  23603. */
  23604. get: function () {
  23605. return this._maxPoint;
  23606. },
  23607. enumerable: true,
  23608. configurable: true
  23609. });
  23610. // Methods
  23611. /**
  23612. * Add a new element to this block
  23613. * @param entry defines the element to add
  23614. */
  23615. OctreeBlock.prototype.addEntry = function (entry) {
  23616. if (this.blocks) {
  23617. for (var index = 0; index < this.blocks.length; index++) {
  23618. var block = this.blocks[index];
  23619. block.addEntry(entry);
  23620. }
  23621. return;
  23622. }
  23623. this._creationFunc(entry, this);
  23624. if (this.entries.length > this.capacity && this._depth < this._maxDepth) {
  23625. this.createInnerBlocks();
  23626. }
  23627. };
  23628. /**
  23629. * Remove an element from this block
  23630. * @param entry defines the element to remove
  23631. */
  23632. OctreeBlock.prototype.removeEntry = function (entry) {
  23633. if (this.blocks) {
  23634. for (var index = 0; index < this.blocks.length; index++) {
  23635. var block = this.blocks[index];
  23636. block.removeEntry(entry);
  23637. }
  23638. return;
  23639. }
  23640. var entryIndex = this.entries.indexOf(entry);
  23641. if (entryIndex > -1) {
  23642. this.entries.splice(entryIndex, 1);
  23643. }
  23644. };
  23645. /**
  23646. * Add an array of elements to this block
  23647. * @param entries defines the array of elements to add
  23648. */
  23649. OctreeBlock.prototype.addEntries = function (entries) {
  23650. for (var index = 0; index < entries.length; index++) {
  23651. var mesh = entries[index];
  23652. this.addEntry(mesh);
  23653. }
  23654. };
  23655. /**
  23656. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  23657. * @param frustumPlanes defines the frustum planes to test
  23658. * @param selection defines the array to store current content if selection is positive
  23659. * @param allowDuplicate defines if the selection array can contains duplicated entries
  23660. */
  23661. OctreeBlock.prototype.select = function (frustumPlanes, selection, allowDuplicate) {
  23662. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IsInFrustum(this._boundingVectors, frustumPlanes)) {
  23663. if (this.blocks) {
  23664. for (var index = 0; index < this.blocks.length; index++) {
  23665. var block = this.blocks[index];
  23666. block.select(frustumPlanes, selection, allowDuplicate);
  23667. }
  23668. return;
  23669. }
  23670. if (allowDuplicate) {
  23671. selection.concat(this.entries);
  23672. }
  23673. else {
  23674. selection.concatWithNoDuplicate(this.entries);
  23675. }
  23676. }
  23677. };
  23678. /**
  23679. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  23680. * @param sphereCenter defines the bounding sphere center
  23681. * @param sphereRadius defines the bounding sphere radius
  23682. * @param selection defines the array to store current content if selection is positive
  23683. * @param allowDuplicate defines if the selection array can contains duplicated entries
  23684. */
  23685. OctreeBlock.prototype.intersects = function (sphereCenter, sphereRadius, selection, allowDuplicate) {
  23686. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IntersectsSphere(this._minPoint, this._maxPoint, sphereCenter, sphereRadius)) {
  23687. if (this.blocks) {
  23688. for (var index = 0; index < this.blocks.length; index++) {
  23689. var block = this.blocks[index];
  23690. block.intersects(sphereCenter, sphereRadius, selection, allowDuplicate);
  23691. }
  23692. return;
  23693. }
  23694. if (allowDuplicate) {
  23695. selection.concat(this.entries);
  23696. }
  23697. else {
  23698. selection.concatWithNoDuplicate(this.entries);
  23699. }
  23700. }
  23701. };
  23702. /**
  23703. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  23704. * @param ray defines the ray to test with
  23705. * @param selection defines the array to store current content if selection is positive
  23706. */
  23707. OctreeBlock.prototype.intersectsRay = function (ray, selection) {
  23708. if (ray.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {
  23709. if (this.blocks) {
  23710. for (var index = 0; index < this.blocks.length; index++) {
  23711. var block = this.blocks[index];
  23712. block.intersectsRay(ray, selection);
  23713. }
  23714. return;
  23715. }
  23716. selection.concatWithNoDuplicate(this.entries);
  23717. }
  23718. };
  23719. /**
  23720. * Subdivide the content into child blocks (this block will then be empty)
  23721. */
  23722. OctreeBlock.prototype.createInnerBlocks = function () {
  23723. OctreeBlock._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc);
  23724. };
  23725. /**
  23726. * @hidden
  23727. */
  23728. OctreeBlock._CreateBlocks = function (worldMin, worldMax, entries, maxBlockCapacity, currentDepth, maxDepth, target, creationFunc) {
  23729. target.blocks = new Array();
  23730. 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);
  23731. // Segmenting space
  23732. for (var x = 0; x < 2; x++) {
  23733. for (var y = 0; y < 2; y++) {
  23734. for (var z = 0; z < 2; z++) {
  23735. var localMin = worldMin.add(blockSize.multiplyByFloats(x, y, z));
  23736. var localMax = worldMin.add(blockSize.multiplyByFloats(x + 1, y + 1, z + 1));
  23737. var block = new OctreeBlock(localMin, localMax, maxBlockCapacity, currentDepth + 1, maxDepth, creationFunc);
  23738. block.addEntries(entries);
  23739. target.blocks.push(block);
  23740. }
  23741. }
  23742. }
  23743. };
  23744. return OctreeBlock;
  23745. }());
  23746. /***/ }),
  23747. /***/ "./Culling/Octrees/octreeSceneComponent.ts":
  23748. /*!*************************************************!*\
  23749. !*** ./Culling/Octrees/octreeSceneComponent.ts ***!
  23750. \*************************************************/
  23751. /*! exports provided: OctreeSceneComponent */
  23752. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23753. "use strict";
  23754. __webpack_require__.r(__webpack_exports__);
  23755. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return OctreeSceneComponent; });
  23756. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  23757. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  23758. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  23759. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  23760. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  23761. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  23762. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.createOrUpdateSelectionOctree = function (maxCapacity, maxDepth) {
  23763. if (maxCapacity === void 0) { maxCapacity = 64; }
  23764. if (maxDepth === void 0) { maxDepth = 2; }
  23765. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  23766. if (!component) {
  23767. component = new OctreeSceneComponent(this);
  23768. this._addComponent(component);
  23769. }
  23770. if (!this._selectionOctree) {
  23771. this._selectionOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForMeshes, maxCapacity, maxDepth);
  23772. }
  23773. var worldExtends = this.getWorldExtends();
  23774. // Update octree
  23775. this._selectionOctree.update(worldExtends.min, worldExtends.max, this.meshes);
  23776. return this._selectionOctree;
  23777. };
  23778. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "selectionOctree", {
  23779. get: function () {
  23780. return this._selectionOctree;
  23781. },
  23782. enumerable: true,
  23783. configurable: true
  23784. });
  23785. /**
  23786. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  23787. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23788. * @param maxCapacity defines the maximum size of each block (64 by default)
  23789. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  23790. * @returns the new octree
  23791. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  23792. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23793. */
  23794. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.createOrUpdateSubmeshesOctree = function (maxCapacity, maxDepth) {
  23795. if (maxCapacity === void 0) { maxCapacity = 64; }
  23796. if (maxDepth === void 0) { maxDepth = 2; }
  23797. var scene = this.getScene();
  23798. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  23799. if (!component) {
  23800. component = new OctreeSceneComponent(scene);
  23801. scene._addComponent(component);
  23802. }
  23803. if (!this._submeshesOctree) {
  23804. this._submeshesOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForSubMeshes, maxCapacity, maxDepth);
  23805. }
  23806. this.computeWorldMatrix(true);
  23807. var boundingInfo = this.getBoundingInfo();
  23808. // Update octree
  23809. var bbox = boundingInfo.boundingBox;
  23810. this._submeshesOctree.update(bbox.minimumWorld, bbox.maximumWorld, this.subMeshes);
  23811. return this._submeshesOctree;
  23812. };
  23813. /**
  23814. * Defines the octree scene component responsible to manage any octrees
  23815. * in a given scene.
  23816. */
  23817. var OctreeSceneComponent = /** @class */ (function () {
  23818. /**
  23819. * Creates a new instance of the component for the given scene
  23820. * @param scene Defines the scene to register the component in
  23821. */
  23822. function OctreeSceneComponent(scene) {
  23823. /**
  23824. * The component name helpfull to identify the component in the list of scene components.
  23825. */
  23826. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE;
  23827. /**
  23828. * Indicates if the meshes have been checked to make sure they are isEnabled()
  23829. */
  23830. this.checksIsEnabled = true;
  23831. 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));
  23832. this.scene = scene;
  23833. this.scene.getActiveMeshCandidates = this.getActiveMeshCandidates.bind(this);
  23834. this.scene.getActiveSubMeshCandidates = this.getActiveSubMeshCandidates.bind(this);
  23835. this.scene.getCollidingSubMeshCandidates = this.getCollidingSubMeshCandidates.bind(this);
  23836. this.scene.getIntersectingSubMeshCandidates = this.getIntersectingSubMeshCandidates.bind(this);
  23837. }
  23838. /**
  23839. * Registers the component in a given scene
  23840. */
  23841. OctreeSceneComponent.prototype.register = function () {
  23842. var _this = this;
  23843. this.scene.onMeshRemovedObservable.add(function (mesh) {
  23844. var sceneOctree = _this.scene.selectionOctree;
  23845. if (sceneOctree !== undefined && sceneOctree !== null) {
  23846. var index = sceneOctree.dynamicContent.indexOf(mesh);
  23847. if (index !== -1) {
  23848. sceneOctree.dynamicContent.splice(index, 1);
  23849. }
  23850. }
  23851. });
  23852. this.scene.onMeshImportedObservable.add(function (mesh) {
  23853. var sceneOctree = _this.scene.selectionOctree;
  23854. if (sceneOctree !== undefined && sceneOctree !== null) {
  23855. sceneOctree.addMesh(mesh);
  23856. }
  23857. });
  23858. };
  23859. /**
  23860. * Return the list of active meshes
  23861. * @returns the list of active meshes
  23862. */
  23863. OctreeSceneComponent.prototype.getActiveMeshCandidates = function () {
  23864. if (this.scene._selectionOctree) {
  23865. var selection = this.scene._selectionOctree.select(this.scene.frustumPlanes);
  23866. return selection;
  23867. }
  23868. return this.scene._getDefaultMeshCandidates();
  23869. };
  23870. /**
  23871. * Return the list of active sub meshes
  23872. * @param mesh The mesh to get the candidates sub meshes from
  23873. * @returns the list of active sub meshes
  23874. */
  23875. OctreeSceneComponent.prototype.getActiveSubMeshCandidates = function (mesh) {
  23876. if (mesh._submeshesOctree && mesh.useOctreeForRenderingSelection) {
  23877. var intersections = mesh._submeshesOctree.select(this.scene.frustumPlanes);
  23878. return intersections;
  23879. }
  23880. return this.scene._getDefaultSubMeshCandidates(mesh);
  23881. };
  23882. /**
  23883. * Return the list of sub meshes intersecting with a given local ray
  23884. * @param mesh defines the mesh to find the submesh for
  23885. * @param localRay defines the ray in local space
  23886. * @returns the list of intersecting sub meshes
  23887. */
  23888. OctreeSceneComponent.prototype.getIntersectingSubMeshCandidates = function (mesh, localRay) {
  23889. if (mesh._submeshesOctree && mesh.useOctreeForPicking) {
  23890. _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"].TransformToRef(localRay, mesh.getWorldMatrix(), this._tempRay);
  23891. var intersections = mesh._submeshesOctree.intersectsRay(this._tempRay);
  23892. return intersections;
  23893. }
  23894. return this.scene._getDefaultSubMeshCandidates(mesh);
  23895. };
  23896. /**
  23897. * Return the list of sub meshes colliding with a collider
  23898. * @param mesh defines the mesh to find the submesh for
  23899. * @param collider defines the collider to evaluate the collision against
  23900. * @returns the list of colliding sub meshes
  23901. */
  23902. OctreeSceneComponent.prototype.getCollidingSubMeshCandidates = function (mesh, collider) {
  23903. if (mesh._submeshesOctree && mesh.useOctreeForCollisions) {
  23904. var radius = collider._velocityWorldLength + Math.max(collider._radius.x, collider._radius.y, collider._radius.z);
  23905. var intersections = mesh._submeshesOctree.intersects(collider._basePointWorld, radius);
  23906. return intersections;
  23907. }
  23908. return this.scene._getDefaultSubMeshCandidates(mesh);
  23909. };
  23910. /**
  23911. * Rebuilds the elements related to this component in case of
  23912. * context lost for instance.
  23913. */
  23914. OctreeSceneComponent.prototype.rebuild = function () {
  23915. // Nothing to do here.
  23916. };
  23917. /**
  23918. * Disposes the component and the associated ressources.
  23919. */
  23920. OctreeSceneComponent.prototype.dispose = function () {
  23921. // Nothing to do here.
  23922. };
  23923. return OctreeSceneComponent;
  23924. }());
  23925. /***/ }),
  23926. /***/ "./Culling/boundingBox.ts":
  23927. /*!********************************!*\
  23928. !*** ./Culling/boundingBox.ts ***!
  23929. \********************************/
  23930. /*! exports provided: BoundingBox */
  23931. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23932. "use strict";
  23933. __webpack_require__.r(__webpack_exports__);
  23934. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return BoundingBox; });
  23935. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  23936. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23937. /**
  23938. * Class used to store bounding box information
  23939. */
  23940. var BoundingBox = /** @class */ (function () {
  23941. /**
  23942. * Creates a new bounding box
  23943. * @param min defines the minimum vector (in local space)
  23944. * @param max defines the maximum vector (in local space)
  23945. * @param worldMatrix defines the new world matrix
  23946. */
  23947. function BoundingBox(min, max, worldMatrix) {
  23948. /**
  23949. * Gets the 8 vectors representing the bounding box in local space
  23950. */
  23951. this.vectors = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  23952. /**
  23953. * Gets the center of the bounding box in local space
  23954. */
  23955. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23956. /**
  23957. * Gets the center of the bounding box in world space
  23958. */
  23959. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23960. /**
  23961. * Gets the extend size in local space
  23962. */
  23963. this.extendSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23964. /**
  23965. * Gets the extend size in world space
  23966. */
  23967. this.extendSizeWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23968. /**
  23969. * Gets the OBB (object bounding box) directions
  23970. */
  23971. this.directions = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  23972. /**
  23973. * Gets the 8 vectors representing the bounding box in world space
  23974. */
  23975. this.vectorsWorld = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  23976. /**
  23977. * Gets the minimum vector in world space
  23978. */
  23979. this.minimumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23980. /**
  23981. * Gets the maximum vector in world space
  23982. */
  23983. this.maximumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23984. /**
  23985. * Gets the minimum vector in local space
  23986. */
  23987. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23988. /**
  23989. * Gets the maximum vector in local space
  23990. */
  23991. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23992. this.reConstruct(min, max, worldMatrix);
  23993. }
  23994. // Methods
  23995. /**
  23996. * Recreates the entire bounding box from scratch as if we call the constructor in place
  23997. * @param min defines the new minimum vector (in local space)
  23998. * @param max defines the new maximum vector (in local space)
  23999. * @param worldMatrix defines the new world matrix
  24000. */
  24001. BoundingBox.prototype.reConstruct = function (min, max, worldMatrix) {
  24002. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24003. var vectors = this.vectors;
  24004. this.minimum.copyFromFloats(minX, minY, minZ);
  24005. this.maximum.copyFromFloats(maxX, maxY, maxZ);
  24006. vectors[0].copyFromFloats(minX, minY, minZ);
  24007. vectors[1].copyFromFloats(maxX, maxY, maxZ);
  24008. vectors[2].copyFromFloats(maxX, minY, minZ);
  24009. vectors[3].copyFromFloats(minX, maxY, minZ);
  24010. vectors[4].copyFromFloats(minX, minY, maxZ);
  24011. vectors[5].copyFromFloats(maxX, maxY, minZ);
  24012. vectors[6].copyFromFloats(minX, maxY, maxZ);
  24013. vectors[7].copyFromFloats(maxX, minY, maxZ);
  24014. // OBB
  24015. max.addToRef(min, this.center).scaleInPlace(0.5);
  24016. max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);
  24017. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  24018. };
  24019. /**
  24020. * Scale the current bounding box by applying a scale factor
  24021. * @param factor defines the scale factor to apply
  24022. * @returns the current bounding box
  24023. */
  24024. BoundingBox.prototype.scale = function (factor) {
  24025. var tmpVectors = BoundingBox.TmpVector3;
  24026. var diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);
  24027. var len = diff.length();
  24028. diff.normalizeFromLength(len);
  24029. var distance = len * factor;
  24030. var newRadius = diff.scaleInPlace(distance * 0.5);
  24031. var min = this.center.subtractToRef(newRadius, tmpVectors[1]);
  24032. var max = this.center.addToRef(newRadius, tmpVectors[2]);
  24033. this.reConstruct(min, max, this._worldMatrix);
  24034. return this;
  24035. };
  24036. /**
  24037. * Gets the world matrix of the bounding box
  24038. * @returns a matrix
  24039. */
  24040. BoundingBox.prototype.getWorldMatrix = function () {
  24041. return this._worldMatrix;
  24042. };
  24043. /** @hidden */
  24044. BoundingBox.prototype._update = function (world) {
  24045. var minWorld = this.minimumWorld;
  24046. var maxWorld = this.maximumWorld;
  24047. var directions = this.directions;
  24048. var vectorsWorld = this.vectorsWorld;
  24049. var vectors = this.vectors;
  24050. if (!world.isIdentity()) {
  24051. minWorld.setAll(Number.MAX_VALUE);
  24052. maxWorld.setAll(-Number.MAX_VALUE);
  24053. for (var index = 0; index < 8; ++index) {
  24054. var v = vectorsWorld[index];
  24055. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vectors[index], world, v);
  24056. minWorld.minimizeInPlace(v);
  24057. maxWorld.maximizeInPlace(v);
  24058. }
  24059. // Extend
  24060. maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);
  24061. maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);
  24062. }
  24063. else {
  24064. minWorld.copyFrom(this.minimum);
  24065. maxWorld.copyFrom(this.maximum);
  24066. for (var index = 0; index < 8; ++index) {
  24067. vectorsWorld[index].copyFrom(vectors[index]);
  24068. }
  24069. // Extend
  24070. this.extendSizeWorld.copyFrom(this.extendSize);
  24071. this.centerWorld.copyFrom(this.center);
  24072. }
  24073. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 0, directions[0]);
  24074. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 4, directions[1]);
  24075. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 8, directions[2]);
  24076. this._worldMatrix = world;
  24077. };
  24078. /**
  24079. * Tests if the bounding box is intersecting the frustum planes
  24080. * @param frustumPlanes defines the frustum planes to test
  24081. * @returns true if there is an intersection
  24082. */
  24083. BoundingBox.prototype.isInFrustum = function (frustumPlanes) {
  24084. return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);
  24085. };
  24086. /**
  24087. * Tests if the bounding box is entirely inside the frustum planes
  24088. * @param frustumPlanes defines the frustum planes to test
  24089. * @returns true if there is an inclusion
  24090. */
  24091. BoundingBox.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  24092. return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);
  24093. };
  24094. /**
  24095. * Tests if a point is inside the bounding box
  24096. * @param point defines the point to test
  24097. * @returns true if the point is inside the bounding box
  24098. */
  24099. BoundingBox.prototype.intersectsPoint = function (point) {
  24100. var min = this.minimumWorld;
  24101. var max = this.maximumWorld;
  24102. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24103. var pointX = point.x, pointY = point.y, pointZ = point.z;
  24104. var delta = -_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"];
  24105. if (maxX - pointX < delta || delta > pointX - minX) {
  24106. return false;
  24107. }
  24108. if (maxY - pointY < delta || delta > pointY - minY) {
  24109. return false;
  24110. }
  24111. if (maxZ - pointZ < delta || delta > pointZ - minZ) {
  24112. return false;
  24113. }
  24114. return true;
  24115. };
  24116. /**
  24117. * Tests if the bounding box intersects with a bounding sphere
  24118. * @param sphere defines the sphere to test
  24119. * @returns true if there is an intersection
  24120. */
  24121. BoundingBox.prototype.intersectsSphere = function (sphere) {
  24122. return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);
  24123. };
  24124. /**
  24125. * Tests if the bounding box intersects with a box defined by a min and max vectors
  24126. * @param min defines the min vector to use
  24127. * @param max defines the max vector to use
  24128. * @returns true if there is an intersection
  24129. */
  24130. BoundingBox.prototype.intersectsMinMax = function (min, max) {
  24131. var myMin = this.minimumWorld;
  24132. var myMax = this.maximumWorld;
  24133. var myMinX = myMin.x, myMinY = myMin.y, myMinZ = myMin.z, myMaxX = myMax.x, myMaxY = myMax.y, myMaxZ = myMax.z;
  24134. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24135. if (myMaxX < minX || myMinX > maxX) {
  24136. return false;
  24137. }
  24138. if (myMaxY < minY || myMinY > maxY) {
  24139. return false;
  24140. }
  24141. if (myMaxZ < minZ || myMinZ > maxZ) {
  24142. return false;
  24143. }
  24144. return true;
  24145. };
  24146. // Statics
  24147. /**
  24148. * Tests if two bounding boxes are intersections
  24149. * @param box0 defines the first box to test
  24150. * @param box1 defines the second box to test
  24151. * @returns true if there is an intersection
  24152. */
  24153. BoundingBox.Intersects = function (box0, box1) {
  24154. return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);
  24155. };
  24156. /**
  24157. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  24158. * @param minPoint defines the minimum vector of the bounding box
  24159. * @param maxPoint defines the maximum vector of the bounding box
  24160. * @param sphereCenter defines the sphere center
  24161. * @param sphereRadius defines the sphere radius
  24162. * @returns true if there is an intersection
  24163. */
  24164. BoundingBox.IntersectsSphere = function (minPoint, maxPoint, sphereCenter, sphereRadius) {
  24165. var vector = BoundingBox.TmpVector3[0];
  24166. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ClampToRef(sphereCenter, minPoint, maxPoint, vector);
  24167. var num = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphereCenter, vector);
  24168. return (num <= (sphereRadius * sphereRadius));
  24169. };
  24170. /**
  24171. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  24172. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  24173. * @param frustumPlanes defines the frustum planes to test
  24174. * @return true if there is an inclusion
  24175. */
  24176. BoundingBox.IsCompletelyInFrustum = function (boundingVectors, frustumPlanes) {
  24177. for (var p = 0; p < 6; ++p) {
  24178. var frustumPlane = frustumPlanes[p];
  24179. for (var i = 0; i < 8; ++i) {
  24180. if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {
  24181. return false;
  24182. }
  24183. }
  24184. }
  24185. return true;
  24186. };
  24187. /**
  24188. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  24189. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  24190. * @param frustumPlanes defines the frustum planes to test
  24191. * @return true if there is an intersection
  24192. */
  24193. BoundingBox.IsInFrustum = function (boundingVectors, frustumPlanes) {
  24194. for (var p = 0; p < 6; ++p) {
  24195. var canReturnFalse = true;
  24196. var frustumPlane = frustumPlanes[p];
  24197. for (var i = 0; i < 8; ++i) {
  24198. if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {
  24199. canReturnFalse = false;
  24200. break;
  24201. }
  24202. }
  24203. if (canReturnFalse) {
  24204. return false;
  24205. }
  24206. }
  24207. return true;
  24208. };
  24209. BoundingBox.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24210. return BoundingBox;
  24211. }());
  24212. /***/ }),
  24213. /***/ "./Culling/boundingInfo.ts":
  24214. /*!*********************************!*\
  24215. !*** ./Culling/boundingInfo.ts ***!
  24216. \*********************************/
  24217. /*! exports provided: BoundingInfo */
  24218. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24219. "use strict";
  24220. __webpack_require__.r(__webpack_exports__);
  24221. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return BoundingInfo; });
  24222. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24223. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24224. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  24225. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  24226. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  24227. var _result0 = { min: 0, max: 0 };
  24228. var _result1 = { min: 0, max: 0 };
  24229. var computeBoxExtents = function (axis, box, result) {
  24230. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.centerWorld, axis);
  24231. var r0 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[0], axis)) * box.extendSize.x;
  24232. var r1 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[1], axis)) * box.extendSize.y;
  24233. var r2 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[2], axis)) * box.extendSize.z;
  24234. var r = r0 + r1 + r2;
  24235. result.min = p - r;
  24236. result.max = p + r;
  24237. };
  24238. var axisOverlap = function (axis, box0, box1) {
  24239. computeBoxExtents(axis, box0, _result0);
  24240. computeBoxExtents(axis, box1, _result1);
  24241. return !(_result0.min > _result1.max || _result1.min > _result0.max);
  24242. };
  24243. /**
  24244. * Info for a bounding data of a mesh
  24245. */
  24246. var BoundingInfo = /** @class */ (function () {
  24247. /**
  24248. * Constructs bounding info
  24249. * @param minimum min vector of the bounding box/sphere
  24250. * @param maximum max vector of the bounding box/sphere
  24251. * @param worldMatrix defines the new world matrix
  24252. */
  24253. function BoundingInfo(minimum, maximum, worldMatrix) {
  24254. this._isLocked = false;
  24255. this.boundingBox = new _boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"](minimum, maximum, worldMatrix);
  24256. this.boundingSphere = new _boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"](minimum, maximum, worldMatrix);
  24257. }
  24258. /**
  24259. * Recreates the entire bounding info 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. BoundingInfo.prototype.reConstruct = function (min, max, worldMatrix) {
  24265. this.boundingBox.reConstruct(min, max, worldMatrix);
  24266. this.boundingSphere.reConstruct(min, max, worldMatrix);
  24267. };
  24268. Object.defineProperty(BoundingInfo.prototype, "minimum", {
  24269. /**
  24270. * min vector of the bounding box/sphere
  24271. */
  24272. get: function () {
  24273. return this.boundingBox.minimum;
  24274. },
  24275. enumerable: true,
  24276. configurable: true
  24277. });
  24278. Object.defineProperty(BoundingInfo.prototype, "maximum", {
  24279. /**
  24280. * max vector of the bounding box/sphere
  24281. */
  24282. get: function () {
  24283. return this.boundingBox.maximum;
  24284. },
  24285. enumerable: true,
  24286. configurable: true
  24287. });
  24288. Object.defineProperty(BoundingInfo.prototype, "isLocked", {
  24289. /**
  24290. * If the info is locked and won't be updated to avoid perf overhead
  24291. */
  24292. get: function () {
  24293. return this._isLocked;
  24294. },
  24295. set: function (value) {
  24296. this._isLocked = value;
  24297. },
  24298. enumerable: true,
  24299. configurable: true
  24300. });
  24301. // Methods
  24302. /**
  24303. * Updates the bounding sphere and box
  24304. * @param world world matrix to be used to update
  24305. */
  24306. BoundingInfo.prototype.update = function (world) {
  24307. if (this._isLocked) {
  24308. return;
  24309. }
  24310. this.boundingBox._update(world);
  24311. this.boundingSphere._update(world);
  24312. };
  24313. /**
  24314. * Recreate the bounding info to be centered around a specific point given a specific extend.
  24315. * @param center New center of the bounding info
  24316. * @param extend New extend of the bounding info
  24317. * @returns the current bounding info
  24318. */
  24319. BoundingInfo.prototype.centerOn = function (center, extend) {
  24320. var minimum = BoundingInfo.TmpVector3[0].copyFrom(center).subtractInPlace(extend);
  24321. var maximum = BoundingInfo.TmpVector3[1].copyFrom(center).addInPlace(extend);
  24322. this.boundingBox.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  24323. this.boundingSphere.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  24324. return this;
  24325. };
  24326. /**
  24327. * Scale the current bounding info by applying a scale factor
  24328. * @param factor defines the scale factor to apply
  24329. * @returns the current bounding info
  24330. */
  24331. BoundingInfo.prototype.scale = function (factor) {
  24332. this.boundingBox.scale(factor);
  24333. this.boundingSphere.scale(factor);
  24334. return this;
  24335. };
  24336. /**
  24337. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  24338. * @param frustumPlanes defines the frustum to test
  24339. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  24340. * @returns true if the bounding info is in the frustum planes
  24341. */
  24342. BoundingInfo.prototype.isInFrustum = function (frustumPlanes, strategy) {
  24343. if (strategy === void 0) { strategy = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD; }
  24344. 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);
  24345. if (inclusionTest) {
  24346. if (this.boundingSphere.isCenterInFrustum(frustumPlanes)) {
  24347. return true;
  24348. }
  24349. }
  24350. if (!this.boundingSphere.isInFrustum(frustumPlanes)) {
  24351. return false;
  24352. }
  24353. 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);
  24354. if (bSphereOnlyTest) {
  24355. return true;
  24356. }
  24357. return this.boundingBox.isInFrustum(frustumPlanes);
  24358. };
  24359. Object.defineProperty(BoundingInfo.prototype, "diagonalLength", {
  24360. /**
  24361. * Gets the world distance between the min and max points of the bounding box
  24362. */
  24363. get: function () {
  24364. var boundingBox = this.boundingBox;
  24365. var diag = boundingBox.maximumWorld.subtractToRef(boundingBox.minimumWorld, BoundingInfo.TmpVector3[0]);
  24366. return diag.length();
  24367. },
  24368. enumerable: true,
  24369. configurable: true
  24370. });
  24371. /**
  24372. * Checks if a cullable object (mesh...) is in the camera frustum
  24373. * Unlike isInFrustum this cheks the full bounding box
  24374. * @param frustumPlanes Camera near/planes
  24375. * @returns true if the object is in frustum otherwise false
  24376. */
  24377. BoundingInfo.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  24378. return this.boundingBox.isCompletelyInFrustum(frustumPlanes);
  24379. };
  24380. /** @hidden */
  24381. BoundingInfo.prototype._checkCollision = function (collider) {
  24382. return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
  24383. };
  24384. /**
  24385. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  24386. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24387. * @param point the point to check intersection with
  24388. * @returns if the point intersects
  24389. */
  24390. BoundingInfo.prototype.intersectsPoint = function (point) {
  24391. if (!this.boundingSphere.centerWorld) {
  24392. return false;
  24393. }
  24394. if (!this.boundingSphere.intersectsPoint(point)) {
  24395. return false;
  24396. }
  24397. if (!this.boundingBox.intersectsPoint(point)) {
  24398. return false;
  24399. }
  24400. return true;
  24401. };
  24402. /**
  24403. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  24404. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24405. * @param boundingInfo the bounding info to check intersection with
  24406. * @param precise if the intersection should be done using OBB
  24407. * @returns if the bounding info intersects
  24408. */
  24409. BoundingInfo.prototype.intersects = function (boundingInfo, precise) {
  24410. if (!_boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"].Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {
  24411. return false;
  24412. }
  24413. if (!_boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"].Intersects(this.boundingBox, boundingInfo.boundingBox)) {
  24414. return false;
  24415. }
  24416. if (!precise) {
  24417. return true;
  24418. }
  24419. var box0 = this.boundingBox;
  24420. var box1 = boundingInfo.boundingBox;
  24421. if (!axisOverlap(box0.directions[0], box0, box1)) {
  24422. return false;
  24423. }
  24424. if (!axisOverlap(box0.directions[1], box0, box1)) {
  24425. return false;
  24426. }
  24427. if (!axisOverlap(box0.directions[2], box0, box1)) {
  24428. return false;
  24429. }
  24430. if (!axisOverlap(box1.directions[0], box0, box1)) {
  24431. return false;
  24432. }
  24433. if (!axisOverlap(box1.directions[1], box0, box1)) {
  24434. return false;
  24435. }
  24436. if (!axisOverlap(box1.directions[2], box0, box1)) {
  24437. return false;
  24438. }
  24439. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[0]), box0, box1)) {
  24440. return false;
  24441. }
  24442. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[1]), box0, box1)) {
  24443. return false;
  24444. }
  24445. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[2]), box0, box1)) {
  24446. return false;
  24447. }
  24448. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[0]), box0, box1)) {
  24449. return false;
  24450. }
  24451. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[1]), box0, box1)) {
  24452. return false;
  24453. }
  24454. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[2]), box0, box1)) {
  24455. return false;
  24456. }
  24457. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[0]), box0, box1)) {
  24458. return false;
  24459. }
  24460. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[1]), box0, box1)) {
  24461. return false;
  24462. }
  24463. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[2]), box0, box1)) {
  24464. return false;
  24465. }
  24466. return true;
  24467. };
  24468. BoundingInfo.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24469. return BoundingInfo;
  24470. }());
  24471. /***/ }),
  24472. /***/ "./Culling/boundingSphere.ts":
  24473. /*!***********************************!*\
  24474. !*** ./Culling/boundingSphere.ts ***!
  24475. \***********************************/
  24476. /*! exports provided: BoundingSphere */
  24477. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24478. "use strict";
  24479. __webpack_require__.r(__webpack_exports__);
  24480. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return BoundingSphere; });
  24481. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24482. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24483. /**
  24484. * Class used to store bounding sphere information
  24485. */
  24486. var BoundingSphere = /** @class */ (function () {
  24487. /**
  24488. * Creates a new bounding sphere
  24489. * @param min defines the minimum vector (in local space)
  24490. * @param max defines the maximum vector (in local space)
  24491. * @param worldMatrix defines the new world matrix
  24492. */
  24493. function BoundingSphere(min, max, worldMatrix) {
  24494. /**
  24495. * Gets the center of the bounding sphere in local space
  24496. */
  24497. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24498. /**
  24499. * Gets the center of the bounding sphere in world space
  24500. */
  24501. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24502. /**
  24503. * Gets the minimum vector in local space
  24504. */
  24505. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24506. /**
  24507. * Gets the maximum vector in local space
  24508. */
  24509. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24510. this.reConstruct(min, max, worldMatrix);
  24511. }
  24512. /**
  24513. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  24514. * @param min defines the new minimum vector (in local space)
  24515. * @param max defines the new maximum vector (in local space)
  24516. * @param worldMatrix defines the new world matrix
  24517. */
  24518. BoundingSphere.prototype.reConstruct = function (min, max, worldMatrix) {
  24519. this.minimum.copyFrom(min);
  24520. this.maximum.copyFrom(max);
  24521. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(min, max);
  24522. max.addToRef(min, this.center).scaleInPlace(0.5);
  24523. this.radius = distance * 0.5;
  24524. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  24525. };
  24526. /**
  24527. * Scale the current bounding sphere by applying a scale factor
  24528. * @param factor defines the scale factor to apply
  24529. * @returns the current bounding box
  24530. */
  24531. BoundingSphere.prototype.scale = function (factor) {
  24532. var newRadius = this.radius * factor;
  24533. var tmpVectors = BoundingSphere.TmpVector3;
  24534. var tempRadiusVector = tmpVectors[0].setAll(newRadius);
  24535. var min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);
  24536. var max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);
  24537. this.reConstruct(min, max, this._worldMatrix);
  24538. return this;
  24539. };
  24540. /**
  24541. * Gets the world matrix of the bounding box
  24542. * @returns a matrix
  24543. */
  24544. BoundingSphere.prototype.getWorldMatrix = function () {
  24545. return this._worldMatrix;
  24546. };
  24547. // Methods
  24548. /** @hidden */
  24549. BoundingSphere.prototype._update = function (worldMatrix) {
  24550. if (!worldMatrix.isIdentity()) {
  24551. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(this.center, worldMatrix, this.centerWorld);
  24552. var tempVector = BoundingSphere.TmpVector3[0];
  24553. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, worldMatrix, tempVector);
  24554. this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
  24555. }
  24556. else {
  24557. this.centerWorld.copyFrom(this.center);
  24558. this.radiusWorld = this.radius;
  24559. }
  24560. };
  24561. /**
  24562. * Tests if the bounding sphere is intersecting the frustum planes
  24563. * @param frustumPlanes defines the frustum planes to test
  24564. * @returns true if there is an intersection
  24565. */
  24566. BoundingSphere.prototype.isInFrustum = function (frustumPlanes) {
  24567. var center = this.centerWorld;
  24568. var radius = this.radiusWorld;
  24569. for (var i = 0; i < 6; i++) {
  24570. if (frustumPlanes[i].dotCoordinate(center) <= -radius) {
  24571. return false;
  24572. }
  24573. }
  24574. return true;
  24575. };
  24576. /**
  24577. * Tests if the bounding sphere center is in between the frustum planes.
  24578. * Used for optimistic fast inclusion.
  24579. * @param frustumPlanes defines the frustum planes to test
  24580. * @returns true if the sphere center is in between the frustum planes
  24581. */
  24582. BoundingSphere.prototype.isCenterInFrustum = function (frustumPlanes) {
  24583. var center = this.centerWorld;
  24584. for (var i = 0; i < 6; i++) {
  24585. if (frustumPlanes[i].dotCoordinate(center) < 0) {
  24586. return false;
  24587. }
  24588. }
  24589. return true;
  24590. };
  24591. /**
  24592. * Tests if a point is inside the bounding sphere
  24593. * @param point defines the point to test
  24594. * @returns true if the point is inside the bounding sphere
  24595. */
  24596. BoundingSphere.prototype.intersectsPoint = function (point) {
  24597. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(this.centerWorld, point);
  24598. if (this.radiusWorld * this.radiusWorld < squareDistance) {
  24599. return false;
  24600. }
  24601. return true;
  24602. };
  24603. // Statics
  24604. /**
  24605. * Checks if two sphere intersct
  24606. * @param sphere0 sphere 0
  24607. * @param sphere1 sphere 1
  24608. * @returns true if the speres intersect
  24609. */
  24610. BoundingSphere.Intersects = function (sphere0, sphere1) {
  24611. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);
  24612. var radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;
  24613. if (radiusSum * radiusSum < squareDistance) {
  24614. return false;
  24615. }
  24616. return true;
  24617. };
  24618. BoundingSphere.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24619. return BoundingSphere;
  24620. }());
  24621. /***/ }),
  24622. /***/ "./Culling/index.ts":
  24623. /*!**************************!*\
  24624. !*** ./Culling/index.ts ***!
  24625. \**************************/
  24626. /*! exports provided: BoundingBox, BoundingInfo, BoundingSphere, Ray, Octree, OctreeBlock, OctreeSceneComponent */
  24627. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24628. "use strict";
  24629. __webpack_require__.r(__webpack_exports__);
  24630. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  24631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _boundingBox__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  24632. /* harmony import */ var _boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boundingInfo */ "./Culling/boundingInfo.ts");
  24633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"]; });
  24634. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  24635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"]; });
  24636. /* harmony import */ var _Octrees_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Octrees/index */ "./Culling/Octrees/index.ts");
  24637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["Octree"]; });
  24638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeBlock"]; });
  24639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeSceneComponent"]; });
  24640. /* harmony import */ var _ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ray */ "./Culling/ray.ts");
  24641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _ray__WEBPACK_IMPORTED_MODULE_4__["Ray"]; });
  24642. /***/ }),
  24643. /***/ "./Culling/ray.ts":
  24644. /*!************************!*\
  24645. !*** ./Culling/ray.ts ***!
  24646. \************************/
  24647. /*! exports provided: Ray */
  24648. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24649. "use strict";
  24650. __webpack_require__.r(__webpack_exports__);
  24651. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return Ray; });
  24652. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24653. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24654. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  24655. /**
  24656. * Class representing a ray with position and direction
  24657. */
  24658. var Ray = /** @class */ (function () {
  24659. /**
  24660. * Creates a new ray
  24661. * @param origin origin point
  24662. * @param direction direction
  24663. * @param length length of the ray
  24664. */
  24665. function Ray(
  24666. /** origin point */
  24667. origin,
  24668. /** direction */
  24669. direction,
  24670. /** length of the ray */
  24671. length) {
  24672. if (length === void 0) { length = Number.MAX_VALUE; }
  24673. this.origin = origin;
  24674. this.direction = direction;
  24675. this.length = length;
  24676. }
  24677. // Methods
  24678. /**
  24679. * Checks if the ray intersects a box
  24680. * @param minimum bound of the box
  24681. * @param maximum bound of the box
  24682. * @param intersectionTreshold extra extend to be added to the box in all direction
  24683. * @returns if the box was hit
  24684. */
  24685. Ray.prototype.intersectsBoxMinMax = function (minimum, maximum, intersectionTreshold) {
  24686. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  24687. var newMinimum = Ray.TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
  24688. var newMaximum = Ray.TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
  24689. var d = 0.0;
  24690. var maxValue = Number.MAX_VALUE;
  24691. var inv;
  24692. var min;
  24693. var max;
  24694. var temp;
  24695. if (Math.abs(this.direction.x) < 0.0000001) {
  24696. if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {
  24697. return false;
  24698. }
  24699. }
  24700. else {
  24701. inv = 1.0 / this.direction.x;
  24702. min = (newMinimum.x - this.origin.x) * inv;
  24703. max = (newMaximum.x - this.origin.x) * inv;
  24704. if (max === -Infinity) {
  24705. max = Infinity;
  24706. }
  24707. if (min > max) {
  24708. temp = min;
  24709. min = max;
  24710. max = temp;
  24711. }
  24712. d = Math.max(min, d);
  24713. maxValue = Math.min(max, maxValue);
  24714. if (d > maxValue) {
  24715. return false;
  24716. }
  24717. }
  24718. if (Math.abs(this.direction.y) < 0.0000001) {
  24719. if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {
  24720. return false;
  24721. }
  24722. }
  24723. else {
  24724. inv = 1.0 / this.direction.y;
  24725. min = (newMinimum.y - this.origin.y) * inv;
  24726. max = (newMaximum.y - this.origin.y) * inv;
  24727. if (max === -Infinity) {
  24728. max = Infinity;
  24729. }
  24730. if (min > max) {
  24731. temp = min;
  24732. min = max;
  24733. max = temp;
  24734. }
  24735. d = Math.max(min, d);
  24736. maxValue = Math.min(max, maxValue);
  24737. if (d > maxValue) {
  24738. return false;
  24739. }
  24740. }
  24741. if (Math.abs(this.direction.z) < 0.0000001) {
  24742. if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {
  24743. return false;
  24744. }
  24745. }
  24746. else {
  24747. inv = 1.0 / this.direction.z;
  24748. min = (newMinimum.z - this.origin.z) * inv;
  24749. max = (newMaximum.z - this.origin.z) * inv;
  24750. if (max === -Infinity) {
  24751. max = Infinity;
  24752. }
  24753. if (min > max) {
  24754. temp = min;
  24755. min = max;
  24756. max = temp;
  24757. }
  24758. d = Math.max(min, d);
  24759. maxValue = Math.min(max, maxValue);
  24760. if (d > maxValue) {
  24761. return false;
  24762. }
  24763. }
  24764. return true;
  24765. };
  24766. /**
  24767. * Checks if the ray intersects a box
  24768. * @param box the bounding box to check
  24769. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  24770. * @returns if the box was hit
  24771. */
  24772. Ray.prototype.intersectsBox = function (box, intersectionTreshold) {
  24773. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  24774. return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);
  24775. };
  24776. /**
  24777. * If the ray hits a sphere
  24778. * @param sphere the bounding sphere to check
  24779. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  24780. * @returns true if it hits the sphere
  24781. */
  24782. Ray.prototype.intersectsSphere = function (sphere, intersectionTreshold) {
  24783. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  24784. var x = sphere.center.x - this.origin.x;
  24785. var y = sphere.center.y - this.origin.y;
  24786. var z = sphere.center.z - this.origin.z;
  24787. var pyth = (x * x) + (y * y) + (z * z);
  24788. var radius = sphere.radius + intersectionTreshold;
  24789. var rr = radius * radius;
  24790. if (pyth <= rr) {
  24791. return true;
  24792. }
  24793. var dot = (x * this.direction.x) + (y * this.direction.y) + (z * this.direction.z);
  24794. if (dot < 0.0) {
  24795. return false;
  24796. }
  24797. var temp = pyth - (dot * dot);
  24798. return temp <= rr;
  24799. };
  24800. /**
  24801. * If the ray hits a triange
  24802. * @param vertex0 triangle vertex
  24803. * @param vertex1 triangle vertex
  24804. * @param vertex2 triangle vertex
  24805. * @returns intersection information if hit
  24806. */
  24807. Ray.prototype.intersectsTriangle = function (vertex0, vertex1, vertex2) {
  24808. var edge1 = Ray.TmpVector3[0];
  24809. var edge2 = Ray.TmpVector3[1];
  24810. var pvec = Ray.TmpVector3[2];
  24811. var tvec = Ray.TmpVector3[3];
  24812. var qvec = Ray.TmpVector3[4];
  24813. vertex1.subtractToRef(vertex0, edge1);
  24814. vertex2.subtractToRef(vertex0, edge2);
  24815. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(this.direction, edge2, pvec);
  24816. var det = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge1, pvec);
  24817. if (det === 0) {
  24818. return null;
  24819. }
  24820. var invdet = 1 / det;
  24821. this.origin.subtractToRef(vertex0, tvec);
  24822. var bu = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(tvec, pvec) * invdet;
  24823. if (bu < 0 || bu > 1.0) {
  24824. return null;
  24825. }
  24826. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(tvec, edge1, qvec);
  24827. var bv = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this.direction, qvec) * invdet;
  24828. if (bv < 0 || bu + bv > 1.0) {
  24829. return null;
  24830. }
  24831. //check if the distance is longer than the predefined length.
  24832. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge2, qvec) * invdet;
  24833. if (distance > this.length) {
  24834. return null;
  24835. }
  24836. return new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_2__["IntersectionInfo"](bu, bv, distance);
  24837. };
  24838. /**
  24839. * Checks if ray intersects a plane
  24840. * @param plane the plane to check
  24841. * @returns the distance away it was hit
  24842. */
  24843. Ray.prototype.intersectsPlane = function (plane) {
  24844. var distance;
  24845. var result1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.direction);
  24846. if (Math.abs(result1) < 9.99999997475243E-07) {
  24847. return null;
  24848. }
  24849. else {
  24850. var result2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.origin);
  24851. distance = (-plane.d - result2) / result1;
  24852. if (distance < 0.0) {
  24853. if (distance < -9.99999997475243E-07) {
  24854. return null;
  24855. }
  24856. else {
  24857. return 0;
  24858. }
  24859. }
  24860. return distance;
  24861. }
  24862. };
  24863. /**
  24864. * Checks if ray intersects a mesh
  24865. * @param mesh the mesh to check
  24866. * @param fastCheck if only the bounding box should checked
  24867. * @returns picking info of the intersecton
  24868. */
  24869. Ray.prototype.intersectsMesh = function (mesh, fastCheck) {
  24870. var tm = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  24871. mesh.getWorldMatrix().invertToRef(tm);
  24872. if (this._tmpRay) {
  24873. Ray.TransformToRef(this, tm, this._tmpRay);
  24874. }
  24875. else {
  24876. this._tmpRay = Ray.Transform(this, tm);
  24877. }
  24878. return mesh.intersects(this._tmpRay, fastCheck);
  24879. };
  24880. /**
  24881. * Checks if ray intersects a mesh
  24882. * @param meshes the meshes to check
  24883. * @param fastCheck if only the bounding box should checked
  24884. * @param results array to store result in
  24885. * @returns Array of picking infos
  24886. */
  24887. Ray.prototype.intersectsMeshes = function (meshes, fastCheck, results) {
  24888. if (results) {
  24889. results.length = 0;
  24890. }
  24891. else {
  24892. results = [];
  24893. }
  24894. for (var i = 0; i < meshes.length; i++) {
  24895. var pickInfo = this.intersectsMesh(meshes[i], fastCheck);
  24896. if (pickInfo.hit) {
  24897. results.push(pickInfo);
  24898. }
  24899. }
  24900. results.sort(this._comparePickingInfo);
  24901. return results;
  24902. };
  24903. Ray.prototype._comparePickingInfo = function (pickingInfoA, pickingInfoB) {
  24904. if (pickingInfoA.distance < pickingInfoB.distance) {
  24905. return -1;
  24906. }
  24907. else if (pickingInfoA.distance > pickingInfoB.distance) {
  24908. return 1;
  24909. }
  24910. else {
  24911. return 0;
  24912. }
  24913. };
  24914. /**
  24915. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  24916. * @param sega the first point of the segment to test the intersection against
  24917. * @param segb the second point of the segment to test the intersection against
  24918. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  24919. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  24920. */
  24921. Ray.prototype.intersectionSegment = function (sega, segb, threshold) {
  24922. var o = this.origin;
  24923. var u = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  24924. var rsegb = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  24925. var v = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  24926. var w = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  24927. segb.subtractToRef(sega, u);
  24928. this.direction.scaleToRef(Ray.rayl, v);
  24929. o.addToRef(v, rsegb);
  24930. sega.subtractToRef(o, w);
  24931. var a = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, u); // always >= 0
  24932. var b = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, v);
  24933. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, v); // always >= 0
  24934. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, w);
  24935. var e = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, w);
  24936. var D = a * c - b * b; // always >= 0
  24937. var sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0
  24938. var tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
  24939. // compute the line parameters of the two closest points
  24940. if (D < Ray.smallnum) { // the lines are almost parallel
  24941. sN = 0.0; // force using point P0 on segment S1
  24942. sD = 1.0; // to prevent possible division by 0.0 later
  24943. tN = e;
  24944. tD = c;
  24945. }
  24946. else { // get the closest points on the infinite lines
  24947. sN = (b * e - c * d);
  24948. tN = (a * e - b * d);
  24949. if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
  24950. sN = 0.0;
  24951. tN = e;
  24952. tD = c;
  24953. }
  24954. else if (sN > sD) { // sc > 1 => the s=1 edge is visible
  24955. sN = sD;
  24956. tN = e + b;
  24957. tD = c;
  24958. }
  24959. }
  24960. if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
  24961. tN = 0.0;
  24962. // recompute sc for this edge
  24963. if (-d < 0.0) {
  24964. sN = 0.0;
  24965. }
  24966. else if (-d > a) {
  24967. sN = sD;
  24968. }
  24969. else {
  24970. sN = -d;
  24971. sD = a;
  24972. }
  24973. }
  24974. else if (tN > tD) { // tc > 1 => the t=1 edge is visible
  24975. tN = tD;
  24976. // recompute sc for this edge
  24977. if ((-d + b) < 0.0) {
  24978. sN = 0;
  24979. }
  24980. else if ((-d + b) > a) {
  24981. sN = sD;
  24982. }
  24983. else {
  24984. sN = (-d + b);
  24985. sD = a;
  24986. }
  24987. }
  24988. // finally do the division to get sc and tc
  24989. sc = (Math.abs(sN) < Ray.smallnum ? 0.0 : sN / sD);
  24990. tc = (Math.abs(tN) < Ray.smallnum ? 0.0 : tN / tD);
  24991. // get the difference of the two closest points
  24992. var qtc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  24993. v.scaleToRef(tc, qtc);
  24994. var qsc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  24995. u.scaleToRef(sc, qsc);
  24996. qsc.addInPlace(w);
  24997. var dP = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  24998. qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)
  24999. var isIntersected = (tc > 0) && (tc <= this.length) && (dP.lengthSquared() < (threshold * threshold)); // return intersection result
  25000. if (isIntersected) {
  25001. return qsc.length();
  25002. }
  25003. return -1;
  25004. };
  25005. /**
  25006. * Update the ray from viewport position
  25007. * @param x position
  25008. * @param y y position
  25009. * @param viewportWidth viewport width
  25010. * @param viewportHeight viewport height
  25011. * @param world world matrix
  25012. * @param view view matrix
  25013. * @param projection projection matrix
  25014. * @returns this ray updated
  25015. */
  25016. Ray.prototype.update = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  25017. this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);
  25018. return this;
  25019. };
  25020. // Statics
  25021. /**
  25022. * Creates a ray with origin and direction of 0,0,0
  25023. * @returns the new ray
  25024. */
  25025. Ray.Zero = function () {
  25026. return new Ray(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero());
  25027. };
  25028. /**
  25029. * Creates a new ray from screen space and viewport
  25030. * @param x position
  25031. * @param y y position
  25032. * @param viewportWidth viewport width
  25033. * @param viewportHeight viewport height
  25034. * @param world world matrix
  25035. * @param view view matrix
  25036. * @param projection projection matrix
  25037. * @returns new ray
  25038. */
  25039. Ray.CreateNew = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  25040. var result = Ray.Zero();
  25041. return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);
  25042. };
  25043. /**
  25044. * 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
  25045. * transformed to the given world matrix.
  25046. * @param origin The origin point
  25047. * @param end The end point
  25048. * @param world a matrix to transform the ray to. Default is the identity matrix.
  25049. * @returns the new ray
  25050. */
  25051. Ray.CreateNewFromTo = function (origin, end, world) {
  25052. if (world === void 0) { world = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly; }
  25053. var direction = end.subtract(origin);
  25054. var length = Math.sqrt((direction.x * direction.x) + (direction.y * direction.y) + (direction.z * direction.z));
  25055. direction.normalize();
  25056. return Ray.Transform(new Ray(origin, direction, length), world);
  25057. };
  25058. /**
  25059. * Transforms a ray by a matrix
  25060. * @param ray ray to transform
  25061. * @param matrix matrix to apply
  25062. * @returns the resulting new ray
  25063. */
  25064. Ray.Transform = function (ray, matrix) {
  25065. 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));
  25066. Ray.TransformToRef(ray, matrix, result);
  25067. return result;
  25068. };
  25069. /**
  25070. * Transforms a ray by a matrix
  25071. * @param ray ray to transform
  25072. * @param matrix matrix to apply
  25073. * @param result ray to store result in
  25074. */
  25075. Ray.TransformToRef = function (ray, matrix, result) {
  25076. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(ray.origin, matrix, result.origin);
  25077. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(ray.direction, matrix, result.direction);
  25078. result.length = ray.length;
  25079. var dir = result.direction;
  25080. var len = dir.length();
  25081. if (!(len === 0 || len === 1)) {
  25082. var num = 1.0 / len;
  25083. dir.x *= num;
  25084. dir.y *= num;
  25085. dir.z *= num;
  25086. result.length *= len;
  25087. }
  25088. };
  25089. /**
  25090. * Unproject a ray from screen space to object space
  25091. * @param sourceX defines the screen space x coordinate to use
  25092. * @param sourceY defines the screen space y coordinate to use
  25093. * @param viewportWidth defines the current width of the viewport
  25094. * @param viewportHeight defines the current height of the viewport
  25095. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  25096. * @param view defines the view matrix to use
  25097. * @param projection defines the projection matrix to use
  25098. */
  25099. Ray.prototype.unprojectRayToRef = function (sourceX, sourceY, viewportWidth, viewportHeight, world, view, projection) {
  25100. var matrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  25101. world.multiplyToRef(view, matrix);
  25102. matrix.multiplyToRef(projection, matrix);
  25103. matrix.invert();
  25104. var nearScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  25105. nearScreenSource.x = sourceX / viewportWidth * 2 - 1;
  25106. nearScreenSource.y = -(sourceY / viewportHeight * 2 - 1);
  25107. nearScreenSource.z = -1.0;
  25108. var farScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0);
  25109. var nearVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  25110. var farVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  25111. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);
  25112. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);
  25113. this.origin.copyFrom(nearVec3);
  25114. farVec3.subtractToRef(nearVec3, this.direction);
  25115. this.direction.normalize();
  25116. };
  25117. Ray.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25118. Ray.smallnum = 0.00000001;
  25119. Ray.rayl = 10e8;
  25120. return Ray;
  25121. }());
  25122. /***/ }),
  25123. /***/ "./Debug/axesViewer.ts":
  25124. /*!*****************************!*\
  25125. !*** ./Debug/axesViewer.ts ***!
  25126. \*****************************/
  25127. /*! exports provided: AxesViewer */
  25128. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25129. "use strict";
  25130. __webpack_require__.r(__webpack_exports__);
  25131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return AxesViewer; });
  25132. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25133. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  25134. /* harmony import */ var _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gizmos/axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  25135. /**
  25136. * The Axes viewer will show 3 axes in a specific point in space
  25137. */
  25138. var AxesViewer = /** @class */ (function () {
  25139. /**
  25140. * Creates a new AxesViewer
  25141. * @param scene defines the hosting scene
  25142. * @param scaleLines defines a number used to scale line length (1 by default)
  25143. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  25144. * @param xAxis defines the node hierarchy used to render the x-axis
  25145. * @param yAxis defines the node hierarchy used to render the y-axis
  25146. * @param zAxis defines the node hierarchy used to render the z-axis
  25147. */
  25148. function AxesViewer(scene, scaleLines, renderingGroupId, xAxis, yAxis, zAxis) {
  25149. if (scaleLines === void 0) { scaleLines = 1; }
  25150. if (renderingGroupId === void 0) { renderingGroupId = 2; }
  25151. this._scaleLinesFactor = 4;
  25152. this._instanced = false;
  25153. /**
  25154. * Gets or sets a number used to scale line length
  25155. */
  25156. this.scaleLines = 1;
  25157. this.scaleLines = scaleLines;
  25158. if (!xAxis) {
  25159. var redColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25160. redColoredMaterial.disableLighting = true;
  25161. redColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Red().scale(0.5);
  25162. xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, redColoredMaterial);
  25163. }
  25164. if (!yAxis) {
  25165. var greenColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25166. greenColoredMaterial.disableLighting = true;
  25167. greenColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Green().scale(0.5);
  25168. yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, greenColoredMaterial);
  25169. }
  25170. if (!zAxis) {
  25171. var blueColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25172. blueColoredMaterial.disableLighting = true;
  25173. blueColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Blue().scale(0.5);
  25174. zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, blueColoredMaterial);
  25175. }
  25176. this._xAxis = xAxis;
  25177. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25178. this._yAxis = yAxis;
  25179. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25180. this._zAxis = zAxis;
  25181. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25182. if (renderingGroupId != null) {
  25183. AxesViewer._SetRenderingGroupId(this._xAxis, renderingGroupId);
  25184. AxesViewer._SetRenderingGroupId(this._yAxis, renderingGroupId);
  25185. AxesViewer._SetRenderingGroupId(this._zAxis, renderingGroupId);
  25186. }
  25187. this.scene = scene;
  25188. 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());
  25189. }
  25190. Object.defineProperty(AxesViewer.prototype, "xAxis", {
  25191. /** Gets the node hierarchy used to render x-axis */
  25192. get: function () {
  25193. return this._xAxis;
  25194. },
  25195. enumerable: true,
  25196. configurable: true
  25197. });
  25198. Object.defineProperty(AxesViewer.prototype, "yAxis", {
  25199. /** Gets the node hierarchy used to render y-axis */
  25200. get: function () {
  25201. return this._yAxis;
  25202. },
  25203. enumerable: true,
  25204. configurable: true
  25205. });
  25206. Object.defineProperty(AxesViewer.prototype, "zAxis", {
  25207. /** Gets the node hierarchy used to render z-axis */
  25208. get: function () {
  25209. return this._zAxis;
  25210. },
  25211. enumerable: true,
  25212. configurable: true
  25213. });
  25214. /**
  25215. * Force the viewer to update
  25216. * @param position defines the position of the viewer
  25217. * @param xaxis defines the x axis of the viewer
  25218. * @param yaxis defines the y axis of the viewer
  25219. * @param zaxis defines the z axis of the viewer
  25220. */
  25221. AxesViewer.prototype.update = function (position, xaxis, yaxis, zaxis) {
  25222. this._xAxis.position.copyFrom(position);
  25223. this._xAxis.setDirection(xaxis);
  25224. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25225. this._yAxis.position.copyFrom(position);
  25226. this._yAxis.setDirection(yaxis);
  25227. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25228. this._zAxis.position.copyFrom(position);
  25229. this._zAxis.setDirection(zaxis);
  25230. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25231. };
  25232. /**
  25233. * Creates an instance of this axes viewer.
  25234. * @returns a new axes viewer with instanced meshes
  25235. */
  25236. AxesViewer.prototype.createInstance = function () {
  25237. var xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._xAxis);
  25238. var yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._yAxis);
  25239. var zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._zAxis);
  25240. var axesViewer = new AxesViewer(this.scene, this.scaleLines, null, xAxis, yAxis, zAxis);
  25241. axesViewer._instanced = true;
  25242. return axesViewer;
  25243. };
  25244. /** Releases resources */
  25245. AxesViewer.prototype.dispose = function () {
  25246. if (this._xAxis) {
  25247. this._xAxis.dispose(false, !this._instanced);
  25248. delete this._xAxis;
  25249. }
  25250. if (this._yAxis) {
  25251. this._yAxis.dispose(false, !this._instanced);
  25252. delete this._yAxis;
  25253. }
  25254. if (this._zAxis) {
  25255. this._zAxis.dispose(false, !this._instanced);
  25256. delete this._zAxis;
  25257. }
  25258. delete this.scene;
  25259. };
  25260. AxesViewer._SetRenderingGroupId = function (node, id) {
  25261. node.getChildMeshes().forEach(function (mesh) {
  25262. mesh.renderingGroupId = id;
  25263. });
  25264. };
  25265. return AxesViewer;
  25266. }());
  25267. /***/ }),
  25268. /***/ "./Debug/boneAxesViewer.ts":
  25269. /*!*********************************!*\
  25270. !*** ./Debug/boneAxesViewer.ts ***!
  25271. \*********************************/
  25272. /*! exports provided: BoneAxesViewer */
  25273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25274. "use strict";
  25275. __webpack_require__.r(__webpack_exports__);
  25276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return BoneAxesViewer; });
  25277. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  25278. /* harmony import */ var _Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/axesViewer */ "./Debug/axesViewer.ts");
  25279. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25280. /**
  25281. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  25282. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  25283. */
  25284. var BoneAxesViewer = /** @class */ (function (_super) {
  25285. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoneAxesViewer, _super);
  25286. /**
  25287. * Creates a new BoneAxesViewer
  25288. * @param scene defines the hosting scene
  25289. * @param bone defines the target bone
  25290. * @param mesh defines the target mesh
  25291. * @param scaleLines defines a scaling factor for line length (1 by default)
  25292. */
  25293. function BoneAxesViewer(scene, bone, mesh, scaleLines) {
  25294. if (scaleLines === void 0) { scaleLines = 1; }
  25295. var _this = _super.call(this, scene, scaleLines) || this;
  25296. /** Gets current position */
  25297. _this.pos = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25298. /** Gets direction of X axis */
  25299. _this.xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25300. /** Gets direction of Y axis */
  25301. _this.yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25302. /** Gets direction of Z axis */
  25303. _this.zaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25304. _this.mesh = mesh;
  25305. _this.bone = bone;
  25306. return _this;
  25307. }
  25308. /**
  25309. * Force the viewer to update
  25310. */
  25311. BoneAxesViewer.prototype.update = function () {
  25312. if (!this.mesh || !this.bone) {
  25313. return;
  25314. }
  25315. var bone = this.bone;
  25316. bone.getAbsolutePositionToRef(this.mesh, this.pos);
  25317. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].X, this.mesh, this.xaxis);
  25318. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y, this.mesh, this.yaxis);
  25319. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Z, this.mesh, this.zaxis);
  25320. _super.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis);
  25321. };
  25322. /** Releases resources */
  25323. BoneAxesViewer.prototype.dispose = function () {
  25324. if (this.mesh) {
  25325. this.mesh = null;
  25326. this.bone = null;
  25327. _super.prototype.dispose.call(this);
  25328. }
  25329. };
  25330. return BoneAxesViewer;
  25331. }(_Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"]));
  25332. /***/ }),
  25333. /***/ "./Debug/debugLayer.ts":
  25334. /*!*****************************!*\
  25335. !*** ./Debug/debugLayer.ts ***!
  25336. \*****************************/
  25337. /*! exports provided: DebugLayer */
  25338. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25339. "use strict";
  25340. __webpack_require__.r(__webpack_exports__);
  25341. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return DebugLayer; });
  25342. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  25343. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  25344. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  25345. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25346. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype, "debugLayer", {
  25347. get: function () {
  25348. if (!this._debugLayer) {
  25349. this._debugLayer = new DebugLayer(this);
  25350. }
  25351. return this._debugLayer;
  25352. },
  25353. enumerable: true,
  25354. configurable: true
  25355. });
  25356. /**
  25357. * The debug layer (aka Inspector) is the go to tool in order to better understand
  25358. * what is happening in your scene
  25359. * @see http://doc.babylonjs.com/features/playground_debuglayer
  25360. */
  25361. var DebugLayer = /** @class */ (function () {
  25362. /**
  25363. * Instantiates a new debug layer.
  25364. * The debug layer (aka Inspector) is the go to tool in order to better understand
  25365. * what is happening in your scene
  25366. * @see http://doc.babylonjs.com/features/playground_debuglayer
  25367. * @param scene Defines the scene to inspect
  25368. */
  25369. function DebugLayer(scene) {
  25370. var _this = this;
  25371. this.BJSINSPECTOR = this._getGlobalInspector();
  25372. /**
  25373. * Observable triggered when a property is changed through the inspector.
  25374. */
  25375. this.onPropertyChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  25376. this._scene = scene;
  25377. this._scene.onDisposeObservable.add(function () {
  25378. // Debug layer
  25379. if (_this._scene._debugLayer) {
  25380. _this._scene._debugLayer.hide();
  25381. }
  25382. });
  25383. }
  25384. /** Creates the inspector window. */
  25385. DebugLayer.prototype._createInspector = function (config) {
  25386. if (this.isVisible()) {
  25387. return;
  25388. }
  25389. var userOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ overlay: false, showExplorer: true, showInspector: true, embedMode: false, handleResize: true, enablePopup: true }, config);
  25390. this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector();
  25391. this.BJSINSPECTOR.Inspector.Show(this._scene, userOptions);
  25392. };
  25393. /** Get the inspector from bundle or global */
  25394. DebugLayer.prototype._getGlobalInspector = function () {
  25395. // UMD Global name detection from Webpack Bundle UMD Name.
  25396. if (typeof INSPECTOR !== 'undefined') {
  25397. return INSPECTOR;
  25398. }
  25399. // In case of module let s check the global emitted from the Inspector entry point.
  25400. if (typeof BABYLON !== 'undefined' && typeof BABYLON.Inspector !== 'undefined') {
  25401. return BABYLON;
  25402. }
  25403. return undefined;
  25404. };
  25405. /**
  25406. * Get if the inspector is visible or not.
  25407. * @returns true if visible otherwise, false
  25408. */
  25409. DebugLayer.prototype.isVisible = function () {
  25410. return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;
  25411. };
  25412. /**
  25413. * Hide the inspector and close its window.
  25414. */
  25415. DebugLayer.prototype.hide = function () {
  25416. if (this.BJSINSPECTOR) {
  25417. this.BJSINSPECTOR.Inspector.Hide();
  25418. }
  25419. };
  25420. /**
  25421. * Launch the debugLayer.
  25422. * @param config Define the configuration of the inspector
  25423. */
  25424. DebugLayer.prototype.show = function (config) {
  25425. if (typeof this.BJSINSPECTOR == 'undefined') {
  25426. // Load inspector and add it to the DOM
  25427. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadScript(DebugLayer.InspectorURL, this._createInspector.bind(this, config));
  25428. }
  25429. else {
  25430. // Otherwise creates the inspector
  25431. this._createInspector(config);
  25432. }
  25433. };
  25434. /**
  25435. * Define the url to get the inspector script from.
  25436. * By default it uses the babylonjs CDN.
  25437. * @ignoreNaming
  25438. */
  25439. DebugLayer.InspectorURL = 'https://preview.babylonjs.com/inspector/babylon.inspector.bundle.js';
  25440. return DebugLayer;
  25441. }());
  25442. /***/ }),
  25443. /***/ "./Debug/index.ts":
  25444. /*!************************!*\
  25445. !*** ./Debug/index.ts ***!
  25446. \************************/
  25447. /*! exports provided: AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer */
  25448. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25449. "use strict";
  25450. __webpack_require__.r(__webpack_exports__);
  25451. /* harmony import */ var _axesViewer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axesViewer */ "./Debug/axesViewer.ts");
  25452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _axesViewer__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  25453. /* harmony import */ var _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneAxesViewer */ "./Debug/boneAxesViewer.ts");
  25454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"]; });
  25455. /* harmony import */ var _debugLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./debugLayer */ "./Debug/debugLayer.ts");
  25456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _debugLayer__WEBPACK_IMPORTED_MODULE_2__["DebugLayer"]; });
  25457. /* harmony import */ var _physicsViewer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsViewer */ "./Debug/physicsViewer.ts");
  25458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _physicsViewer__WEBPACK_IMPORTED_MODULE_3__["PhysicsViewer"]; });
  25459. /* harmony import */ var _rayHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rayHelper */ "./Debug/rayHelper.ts");
  25460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _rayHelper__WEBPACK_IMPORTED_MODULE_4__["RayHelper"]; });
  25461. /* harmony import */ var _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./skeletonViewer */ "./Debug/skeletonViewer.ts");
  25462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__["SkeletonViewer"]; });
  25463. /***/ }),
  25464. /***/ "./Debug/physicsViewer.ts":
  25465. /*!********************************!*\
  25466. !*** ./Debug/physicsViewer.ts ***!
  25467. \********************************/
  25468. /*! exports provided: PhysicsViewer */
  25469. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25470. "use strict";
  25471. __webpack_require__.r(__webpack_exports__);
  25472. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return PhysicsViewer; });
  25473. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  25474. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25475. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  25476. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  25477. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  25478. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  25479. /**
  25480. * Used to show the physics impostor around the specific mesh
  25481. */
  25482. var PhysicsViewer = /** @class */ (function () {
  25483. /**
  25484. * Creates a new PhysicsViewer
  25485. * @param scene defines the hosting scene
  25486. */
  25487. function PhysicsViewer(scene) {
  25488. /** @hidden */
  25489. this._impostors = [];
  25490. /** @hidden */
  25491. this._meshes = [];
  25492. /** @hidden */
  25493. this._numMeshes = 0;
  25494. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  25495. var physicEngine = this._scene.getPhysicsEngine();
  25496. if (physicEngine) {
  25497. this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();
  25498. }
  25499. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_5__["UtilityLayerRenderer"](this._scene, false);
  25500. this._utilityLayer.pickUtilitySceneFirst = false;
  25501. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  25502. }
  25503. /** @hidden */
  25504. PhysicsViewer.prototype._updateDebugMeshes = function () {
  25505. var plugin = this._physicsEnginePlugin;
  25506. for (var i = 0; i < this._numMeshes; i++) {
  25507. var impostor = this._impostors[i];
  25508. if (!impostor) {
  25509. continue;
  25510. }
  25511. if (impostor.isDisposed) {
  25512. this.hideImpostor(this._impostors[i--]);
  25513. }
  25514. else {
  25515. var mesh = this._meshes[i];
  25516. if (mesh && plugin) {
  25517. plugin.syncMeshWithImpostor(mesh, impostor);
  25518. }
  25519. }
  25520. }
  25521. };
  25522. /**
  25523. * Renders a specified physic impostor
  25524. * @param impostor defines the impostor to render
  25525. * @returns the new debug mesh used to render the impostor
  25526. */
  25527. PhysicsViewer.prototype.showImpostor = function (impostor) {
  25528. if (!this._scene) {
  25529. return null;
  25530. }
  25531. for (var i = 0; i < this._numMeshes; i++) {
  25532. if (this._impostors[i] == impostor) {
  25533. return null;
  25534. }
  25535. }
  25536. var debugMesh = this._getDebugMesh(impostor);
  25537. if (debugMesh) {
  25538. this._impostors[this._numMeshes] = impostor;
  25539. this._meshes[this._numMeshes] = debugMesh;
  25540. if (this._numMeshes === 0) {
  25541. this._renderFunction = this._updateDebugMeshes.bind(this);
  25542. this._scene.registerBeforeRender(this._renderFunction);
  25543. }
  25544. this._numMeshes++;
  25545. }
  25546. return debugMesh;
  25547. };
  25548. /**
  25549. * Hides a specified physic impostor
  25550. * @param impostor defines the impostor to hide
  25551. */
  25552. PhysicsViewer.prototype.hideImpostor = function (impostor) {
  25553. if (!impostor || !this._scene || !this._utilityLayer) {
  25554. return;
  25555. }
  25556. var removed = false;
  25557. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  25558. for (var i = 0; i < this._numMeshes; i++) {
  25559. if (this._impostors[i] == impostor) {
  25560. var mesh = this._meshes[i];
  25561. if (!mesh) {
  25562. continue;
  25563. }
  25564. utilityLayerScene.removeMesh(mesh);
  25565. mesh.dispose();
  25566. this._numMeshes--;
  25567. if (this._numMeshes > 0) {
  25568. this._meshes[i] = this._meshes[this._numMeshes];
  25569. this._impostors[i] = this._impostors[this._numMeshes];
  25570. this._meshes[this._numMeshes] = null;
  25571. this._impostors[this._numMeshes] = null;
  25572. }
  25573. else {
  25574. this._meshes[0] = null;
  25575. this._impostors[0] = null;
  25576. }
  25577. removed = true;
  25578. break;
  25579. }
  25580. }
  25581. if (removed && this._numMeshes === 0) {
  25582. this._scene.unregisterBeforeRender(this._renderFunction);
  25583. }
  25584. };
  25585. PhysicsViewer.prototype._getDebugMaterial = function (scene) {
  25586. if (!this._debugMaterial) {
  25587. this._debugMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_3__["StandardMaterial"]('', scene);
  25588. this._debugMaterial.wireframe = true;
  25589. this._debugMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].White();
  25590. this._debugMaterial.disableLighting = true;
  25591. }
  25592. return this._debugMaterial;
  25593. };
  25594. PhysicsViewer.prototype._getDebugBoxMesh = function (scene) {
  25595. if (!this._debugBoxMesh) {
  25596. this._debugBoxMesh = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"].CreateBox('physicsBodyBoxViewMesh', { size: 1 }, scene);
  25597. this._debugBoxMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  25598. this._debugBoxMesh.material = this._getDebugMaterial(scene);
  25599. }
  25600. return this._debugBoxMesh.createInstance('physicsBodyBoxViewInstance');
  25601. };
  25602. PhysicsViewer.prototype._getDebugSphereMesh = function (scene) {
  25603. if (!this._debugSphereMesh) {
  25604. this._debugSphereMesh = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"].CreateSphere('physicsBodySphereViewMesh', { diameter: 1 }, scene);
  25605. this._debugSphereMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  25606. this._debugSphereMesh.material = this._getDebugMaterial(scene);
  25607. }
  25608. return this._debugSphereMesh.createInstance('physicsBodyBoxViewInstance');
  25609. };
  25610. PhysicsViewer.prototype._getDebugMesh = function (impostor) {
  25611. if (!this._utilityLayer) {
  25612. return null;
  25613. }
  25614. var mesh = null;
  25615. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  25616. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_4__["PhysicsImpostor"].BoxImpostor) {
  25617. mesh = this._getDebugBoxMesh(utilityLayerScene);
  25618. impostor.getBoxSizeToRef(mesh.scaling);
  25619. }
  25620. else if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_4__["PhysicsImpostor"].SphereImpostor) {
  25621. mesh = this._getDebugSphereMesh(utilityLayerScene);
  25622. var radius = impostor.getRadius();
  25623. mesh.scaling.x = radius * 2;
  25624. mesh.scaling.y = radius * 2;
  25625. mesh.scaling.z = radius * 2;
  25626. }
  25627. return mesh;
  25628. };
  25629. /** Releases all resources */
  25630. PhysicsViewer.prototype.dispose = function () {
  25631. for (var i = 0; i < this._numMeshes; i++) {
  25632. this.hideImpostor(this._impostors[i]);
  25633. }
  25634. if (this._debugBoxMesh) {
  25635. this._debugBoxMesh.dispose();
  25636. }
  25637. if (this._debugSphereMesh) {
  25638. this._debugSphereMesh.dispose();
  25639. }
  25640. if (this._debugMaterial) {
  25641. this._debugMaterial.dispose();
  25642. }
  25643. this._impostors.length = 0;
  25644. this._scene = null;
  25645. this._physicsEnginePlugin = null;
  25646. if (this._utilityLayer) {
  25647. this._utilityLayer.dispose();
  25648. this._utilityLayer = null;
  25649. }
  25650. };
  25651. return PhysicsViewer;
  25652. }());
  25653. /***/ }),
  25654. /***/ "./Debug/rayHelper.ts":
  25655. /*!****************************!*\
  25656. !*** ./Debug/rayHelper.ts ***!
  25657. \****************************/
  25658. /*! exports provided: RayHelper */
  25659. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25660. "use strict";
  25661. __webpack_require__.r(__webpack_exports__);
  25662. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return RayHelper; });
  25663. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25664. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  25665. /**
  25666. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  25667. * in order to better appreciate the issue one might have.
  25668. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  25669. */
  25670. var RayHelper = /** @class */ (function () {
  25671. /**
  25672. * Instantiate a new ray helper.
  25673. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  25674. * in order to better appreciate the issue one might have.
  25675. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  25676. * @param ray Defines the ray we are currently tryin to visualize
  25677. */
  25678. function RayHelper(ray) {
  25679. this.ray = ray;
  25680. }
  25681. /**
  25682. * Helper function to create a colored helper in a scene in one line.
  25683. * @param ray Defines the ray we are currently tryin to visualize
  25684. * @param scene Defines the scene the ray is used in
  25685. * @param color Defines the color we want to see the ray in
  25686. * @returns The newly created ray helper.
  25687. */
  25688. RayHelper.CreateAndShow = function (ray, scene, color) {
  25689. var helper = new RayHelper(ray);
  25690. helper.show(scene, color);
  25691. return helper;
  25692. };
  25693. /**
  25694. * Shows the ray we are willing to debug.
  25695. * @param scene Defines the scene the ray needs to be rendered in
  25696. * @param color Defines the color the ray needs to be rendered in
  25697. */
  25698. RayHelper.prototype.show = function (scene, color) {
  25699. if (!this._renderFunction && this.ray) {
  25700. var ray = this.ray;
  25701. this._renderFunction = this._render.bind(this);
  25702. this._scene = scene;
  25703. this._renderPoints = [ray.origin, ray.origin.add(ray.direction.scale(ray.length))];
  25704. this._renderLine = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, scene, true);
  25705. if (this._renderFunction) {
  25706. this._scene.registerBeforeRender(this._renderFunction);
  25707. }
  25708. }
  25709. if (color && this._renderLine) {
  25710. this._renderLine.color.copyFrom(color);
  25711. }
  25712. };
  25713. /**
  25714. * Hides the ray we are debugging.
  25715. */
  25716. RayHelper.prototype.hide = function () {
  25717. if (this._renderFunction && this._scene) {
  25718. this._scene.unregisterBeforeRender(this._renderFunction);
  25719. this._scene = null;
  25720. this._renderFunction = null;
  25721. if (this._renderLine) {
  25722. this._renderLine.dispose();
  25723. this._renderLine = null;
  25724. }
  25725. this._renderPoints = [];
  25726. }
  25727. };
  25728. RayHelper.prototype._render = function () {
  25729. var ray = this.ray;
  25730. if (!ray) {
  25731. return;
  25732. }
  25733. var point = this._renderPoints[1];
  25734. var len = Math.min(ray.length, 1000000);
  25735. point.copyFrom(ray.direction);
  25736. point.scaleInPlace(len);
  25737. point.addInPlace(ray.origin);
  25738. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, this._scene, true, this._renderLine);
  25739. };
  25740. /**
  25741. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  25742. * @param mesh Defines the mesh we want the helper attached to
  25743. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  25744. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  25745. * @param length Defines the length of the ray
  25746. */
  25747. RayHelper.prototype.attachToMesh = function (mesh, meshSpaceDirection, meshSpaceOrigin, length) {
  25748. this._attachedToMesh = mesh;
  25749. var ray = this.ray;
  25750. if (!ray) {
  25751. return;
  25752. }
  25753. if (!ray.direction) {
  25754. ray.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  25755. }
  25756. if (!ray.origin) {
  25757. ray.origin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  25758. }
  25759. if (length) {
  25760. ray.length = length;
  25761. }
  25762. if (!meshSpaceOrigin) {
  25763. meshSpaceOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  25764. }
  25765. if (!meshSpaceDirection) {
  25766. // -1 so that this will work with Mesh.lookAt
  25767. meshSpaceDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1);
  25768. }
  25769. if (!this._meshSpaceDirection) {
  25770. this._meshSpaceDirection = meshSpaceDirection.clone();
  25771. this._meshSpaceOrigin = meshSpaceOrigin.clone();
  25772. }
  25773. else {
  25774. this._meshSpaceDirection.copyFrom(meshSpaceDirection);
  25775. this._meshSpaceOrigin.copyFrom(meshSpaceOrigin);
  25776. }
  25777. if (!this._updateToMeshFunction) {
  25778. this._updateToMeshFunction = this._updateToMesh.bind(this);
  25779. this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction);
  25780. }
  25781. this._updateToMesh();
  25782. };
  25783. /**
  25784. * Detach the ray helper from the mesh it has previously been attached to.
  25785. */
  25786. RayHelper.prototype.detachFromMesh = function () {
  25787. if (this._attachedToMesh) {
  25788. if (this._updateToMeshFunction) {
  25789. this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction);
  25790. }
  25791. this._attachedToMesh = null;
  25792. this._updateToMeshFunction = null;
  25793. }
  25794. };
  25795. RayHelper.prototype._updateToMesh = function () {
  25796. var ray = this.ray;
  25797. if (!this._attachedToMesh || !ray) {
  25798. return;
  25799. }
  25800. if (this._attachedToMesh._isDisposed) {
  25801. this.detachFromMesh();
  25802. return;
  25803. }
  25804. this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection, ray.direction);
  25805. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), ray.origin);
  25806. };
  25807. /**
  25808. * Dispose the helper and release its associated resources.
  25809. */
  25810. RayHelper.prototype.dispose = function () {
  25811. this.hide();
  25812. this.detachFromMesh();
  25813. this.ray = null;
  25814. };
  25815. return RayHelper;
  25816. }());
  25817. /***/ }),
  25818. /***/ "./Debug/skeletonViewer.ts":
  25819. /*!*********************************!*\
  25820. !*** ./Debug/skeletonViewer.ts ***!
  25821. \*********************************/
  25822. /*! exports provided: SkeletonViewer */
  25823. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25824. "use strict";
  25825. __webpack_require__.r(__webpack_exports__);
  25826. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return SkeletonViewer; });
  25827. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25828. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  25829. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  25830. /**
  25831. * Class used to render a debug view of a given skeleton
  25832. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  25833. */
  25834. var SkeletonViewer = /** @class */ (function () {
  25835. /**
  25836. * Creates a new SkeletonViewer
  25837. * @param skeleton defines the skeleton to render
  25838. * @param mesh defines the mesh attached to the skeleton
  25839. * @param scene defines the hosting scene
  25840. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  25841. * @param renderingGroupId defines the rendering group id to use with the viewer
  25842. */
  25843. function SkeletonViewer(
  25844. /** defines the skeleton to render */
  25845. skeleton,
  25846. /** defines the mesh attached to the skeleton */
  25847. mesh, scene,
  25848. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  25849. autoUpdateBonesMatrices,
  25850. /** defines the rendering group id to use with the viewer */
  25851. renderingGroupId) {
  25852. if (autoUpdateBonesMatrices === void 0) { autoUpdateBonesMatrices = true; }
  25853. if (renderingGroupId === void 0) { renderingGroupId = 1; }
  25854. this.skeleton = skeleton;
  25855. this.mesh = mesh;
  25856. this.autoUpdateBonesMatrices = autoUpdateBonesMatrices;
  25857. this.renderingGroupId = renderingGroupId;
  25858. /** Gets or sets the color used to render the skeleton */
  25859. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
  25860. this._debugLines = new Array();
  25861. this._isEnabled = false;
  25862. this._scene = scene;
  25863. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"](this._scene, false);
  25864. this._utilityLayer.pickUtilitySceneFirst = false;
  25865. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  25866. this.update();
  25867. this._renderFunction = this.update.bind(this);
  25868. }
  25869. Object.defineProperty(SkeletonViewer.prototype, "debugMesh", {
  25870. /**
  25871. * Returns the mesh used to render the bones
  25872. */
  25873. get: function () {
  25874. return this._debugMesh;
  25875. },
  25876. enumerable: true,
  25877. configurable: true
  25878. });
  25879. Object.defineProperty(SkeletonViewer.prototype, "isEnabled", {
  25880. get: function () {
  25881. return this._isEnabled;
  25882. },
  25883. /** Gets or sets a boolean indicating if the viewer is enabled */
  25884. set: function (value) {
  25885. if (this._isEnabled === value) {
  25886. return;
  25887. }
  25888. this._isEnabled = value;
  25889. if (value) {
  25890. this._scene.registerBeforeRender(this._renderFunction);
  25891. }
  25892. else {
  25893. this._scene.unregisterBeforeRender(this._renderFunction);
  25894. }
  25895. },
  25896. enumerable: true,
  25897. configurable: true
  25898. });
  25899. SkeletonViewer.prototype._getBonePosition = function (position, bone, meshMat, x, y, z) {
  25900. if (x === void 0) { x = 0; }
  25901. if (y === void 0) { y = 0; }
  25902. if (z === void 0) { z = 0; }
  25903. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  25904. var parentBone = bone.getParent();
  25905. tmat.copyFrom(bone.getLocalMatrix());
  25906. if (x !== 0 || y !== 0 || z !== 0) {
  25907. var tmat2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  25908. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(tmat2);
  25909. tmat2.setTranslationFromFloats(x, y, z);
  25910. tmat2.multiplyToRef(tmat, tmat);
  25911. }
  25912. if (parentBone) {
  25913. tmat.multiplyToRef(parentBone.getAbsoluteTransform(), tmat);
  25914. }
  25915. tmat.multiplyToRef(meshMat, tmat);
  25916. position.x = tmat.m[12];
  25917. position.y = tmat.m[13];
  25918. position.z = tmat.m[14];
  25919. };
  25920. SkeletonViewer.prototype._getLinesForBonesWithLength = function (bones, meshMat) {
  25921. var len = bones.length;
  25922. var meshPos = this.mesh.position;
  25923. for (var i = 0; i < len; i++) {
  25924. var bone = bones[i];
  25925. var points = this._debugLines[i];
  25926. if (!points) {
  25927. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  25928. this._debugLines[i] = points;
  25929. }
  25930. this._getBonePosition(points[0], bone, meshMat);
  25931. this._getBonePosition(points[1], bone, meshMat, 0, bone.length, 0);
  25932. points[0].subtractInPlace(meshPos);
  25933. points[1].subtractInPlace(meshPos);
  25934. }
  25935. };
  25936. SkeletonViewer.prototype._getLinesForBonesNoLength = function (bones, meshMat) {
  25937. var len = bones.length;
  25938. var boneNum = 0;
  25939. var meshPos = this.mesh.position;
  25940. for (var i = len - 1; i >= 0; i--) {
  25941. var childBone = bones[i];
  25942. var parentBone = childBone.getParent();
  25943. if (!parentBone) {
  25944. continue;
  25945. }
  25946. var points = this._debugLines[boneNum];
  25947. if (!points) {
  25948. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  25949. this._debugLines[boneNum] = points;
  25950. }
  25951. childBone.getAbsolutePositionToRef(this.mesh, points[0]);
  25952. parentBone.getAbsolutePositionToRef(this.mesh, points[1]);
  25953. points[0].subtractInPlace(meshPos);
  25954. points[1].subtractInPlace(meshPos);
  25955. boneNum++;
  25956. }
  25957. };
  25958. /** Update the viewer to sync with current skeleton state */
  25959. SkeletonViewer.prototype.update = function () {
  25960. if (!this._utilityLayer) {
  25961. return;
  25962. }
  25963. if (this.autoUpdateBonesMatrices) {
  25964. this.skeleton.computeAbsoluteTransforms();
  25965. }
  25966. if (this.skeleton.bones[0].length === undefined) {
  25967. this._getLinesForBonesNoLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  25968. }
  25969. else {
  25970. this._getLinesForBonesWithLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  25971. }
  25972. var targetScene = this._utilityLayer.utilityLayerScene;
  25973. if (!this._debugMesh) {
  25974. this._debugMesh = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_1__["MeshBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: null }, targetScene);
  25975. this._debugMesh.renderingGroupId = this.renderingGroupId;
  25976. }
  25977. else {
  25978. _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_1__["MeshBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: this._debugMesh }, targetScene);
  25979. }
  25980. this._debugMesh.position.copyFrom(this.mesh.position);
  25981. this._debugMesh.color = this.color;
  25982. };
  25983. /** Release associated resources */
  25984. SkeletonViewer.prototype.dispose = function () {
  25985. this.isEnabled = false;
  25986. if (this._debugMesh) {
  25987. this.isEnabled = false;
  25988. this._debugMesh.dispose();
  25989. this._debugMesh = null;
  25990. }
  25991. if (this._utilityLayer) {
  25992. this._utilityLayer.dispose();
  25993. this._utilityLayer = null;
  25994. }
  25995. };
  25996. return SkeletonViewer;
  25997. }());
  25998. /***/ }),
  25999. /***/ "./Engines/Extensions/engine.occlusionQuery.ts":
  26000. /*!*****************************************************!*\
  26001. !*** ./Engines/Extensions/engine.occlusionQuery.ts ***!
  26002. \*****************************************************/
  26003. /*! exports provided: _OcclusionDataStorage */
  26004. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26005. "use strict";
  26006. __webpack_require__.r(__webpack_exports__);
  26007. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _OcclusionDataStorage; });
  26008. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  26009. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  26010. /* harmony import */ var _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Instrumentation/timeToken */ "./Instrumentation/timeToken.ts");
  26011. /** @hidden */
  26012. var _OcclusionDataStorage = /** @class */ (function () {
  26013. function _OcclusionDataStorage() {
  26014. /** @hidden */
  26015. this.occlusionInternalRetryCounter = 0;
  26016. /** @hidden */
  26017. this.isOcclusionQueryInProgress = false;
  26018. /** @hidden */
  26019. this.isOccluded = false;
  26020. /** @hidden */
  26021. this.occlusionRetryCount = -1;
  26022. /** @hidden */
  26023. this.occlusionType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE;
  26024. /** @hidden */
  26025. this.occlusionQueryAlgorithmType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE;
  26026. }
  26027. return _OcclusionDataStorage;
  26028. }());
  26029. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createQuery = function () {
  26030. return this._gl.createQuery();
  26031. };
  26032. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteQuery = function (query) {
  26033. this._gl.deleteQuery(query);
  26034. return this;
  26035. };
  26036. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.isQueryResultAvailable = function (query) {
  26037. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT_AVAILABLE);
  26038. };
  26039. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.getQueryResult = function (query) {
  26040. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT);
  26041. };
  26042. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginOcclusionQuery = function (algorithmType, query) {
  26043. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  26044. this._gl.beginQuery(glAlgorithm, query);
  26045. return this;
  26046. };
  26047. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endOcclusionQuery = function (algorithmType) {
  26048. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  26049. this._gl.endQuery(glAlgorithm);
  26050. return this;
  26051. };
  26052. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._createTimeQuery = function () {
  26053. var timerQuery = this.getCaps().timerQuery;
  26054. if (timerQuery.createQueryEXT) {
  26055. return timerQuery.createQueryEXT();
  26056. }
  26057. return this.createQuery();
  26058. };
  26059. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._deleteTimeQuery = function (query) {
  26060. var timerQuery = this.getCaps().timerQuery;
  26061. if (timerQuery.deleteQueryEXT) {
  26062. timerQuery.deleteQueryEXT(query);
  26063. return;
  26064. }
  26065. this.deleteQuery(query);
  26066. };
  26067. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryResult = function (query) {
  26068. var timerQuery = this.getCaps().timerQuery;
  26069. if (timerQuery.getQueryObjectEXT) {
  26070. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_EXT);
  26071. }
  26072. return this.getQueryResult(query);
  26073. };
  26074. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryAvailability = function (query) {
  26075. var timerQuery = this.getCaps().timerQuery;
  26076. if (timerQuery.getQueryObjectEXT) {
  26077. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_AVAILABLE_EXT);
  26078. }
  26079. return this.isQueryResultAvailable(query);
  26080. };
  26081. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.startTimeQuery = function () {
  26082. var caps = this.getCaps();
  26083. var timerQuery = caps.timerQuery;
  26084. if (!timerQuery) {
  26085. return null;
  26086. }
  26087. var token = new _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]();
  26088. this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  26089. if (caps.canUseTimestampForTimerQuery) {
  26090. token._startTimeQuery = this._createTimeQuery();
  26091. timerQuery.queryCounterEXT(token._startTimeQuery, timerQuery.TIMESTAMP_EXT);
  26092. }
  26093. else {
  26094. if (this._currentNonTimestampToken) {
  26095. return this._currentNonTimestampToken;
  26096. }
  26097. token._timeElapsedQuery = this._createTimeQuery();
  26098. if (timerQuery.beginQueryEXT) {
  26099. timerQuery.beginQueryEXT(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  26100. }
  26101. else {
  26102. this._gl.beginQuery(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  26103. }
  26104. this._currentNonTimestampToken = token;
  26105. }
  26106. return token;
  26107. };
  26108. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTimeQuery = function (token) {
  26109. var caps = this.getCaps();
  26110. var timerQuery = caps.timerQuery;
  26111. if (!timerQuery || !token) {
  26112. return -1;
  26113. }
  26114. if (caps.canUseTimestampForTimerQuery) {
  26115. if (!token._startTimeQuery) {
  26116. return -1;
  26117. }
  26118. if (!token._endTimeQuery) {
  26119. token._endTimeQuery = this._createTimeQuery();
  26120. timerQuery.queryCounterEXT(token._endTimeQuery, timerQuery.TIMESTAMP_EXT);
  26121. }
  26122. }
  26123. else if (!token._timeElapsedQueryEnded) {
  26124. if (!token._timeElapsedQuery) {
  26125. return -1;
  26126. }
  26127. if (timerQuery.endQueryEXT) {
  26128. timerQuery.endQueryEXT(timerQuery.TIME_ELAPSED_EXT);
  26129. }
  26130. else {
  26131. this._gl.endQuery(timerQuery.TIME_ELAPSED_EXT);
  26132. }
  26133. token._timeElapsedQueryEnded = true;
  26134. }
  26135. var disjoint = this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  26136. var available = false;
  26137. if (token._endTimeQuery) {
  26138. available = this._getTimeQueryAvailability(token._endTimeQuery);
  26139. }
  26140. else if (token._timeElapsedQuery) {
  26141. available = this._getTimeQueryAvailability(token._timeElapsedQuery);
  26142. }
  26143. if (available && !disjoint) {
  26144. var result = 0;
  26145. if (caps.canUseTimestampForTimerQuery) {
  26146. if (!token._startTimeQuery || !token._endTimeQuery) {
  26147. return -1;
  26148. }
  26149. var timeStart = this._getTimeQueryResult(token._startTimeQuery);
  26150. var timeEnd = this._getTimeQueryResult(token._endTimeQuery);
  26151. result = timeEnd - timeStart;
  26152. this._deleteTimeQuery(token._startTimeQuery);
  26153. this._deleteTimeQuery(token._endTimeQuery);
  26154. token._startTimeQuery = null;
  26155. token._endTimeQuery = null;
  26156. }
  26157. else {
  26158. if (!token._timeElapsedQuery) {
  26159. return -1;
  26160. }
  26161. result = this._getTimeQueryResult(token._timeElapsedQuery);
  26162. this._deleteTimeQuery(token._timeElapsedQuery);
  26163. token._timeElapsedQuery = null;
  26164. token._timeElapsedQueryEnded = false;
  26165. this._currentNonTimestampToken = null;
  26166. }
  26167. return result;
  26168. }
  26169. return -1;
  26170. };
  26171. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getGlAlgorithmType = function (algorithmType) {
  26172. return algorithmType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
  26173. };
  26174. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOcclusionQueryInProgress", {
  26175. get: function () {
  26176. return this._occlusionDataStorage.isOcclusionQueryInProgress;
  26177. },
  26178. enumerable: false,
  26179. configurable: true
  26180. });
  26181. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "_occlusionDataStorage", {
  26182. get: function () {
  26183. if (!this.__occlusionDataStorage) {
  26184. this.__occlusionDataStorage = new _OcclusionDataStorage();
  26185. }
  26186. return this.__occlusionDataStorage;
  26187. },
  26188. enumerable: false,
  26189. configurable: true
  26190. });
  26191. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOccluded", {
  26192. get: function () {
  26193. return this._occlusionDataStorage.isOccluded;
  26194. },
  26195. set: function (value) {
  26196. this._occlusionDataStorage.isOccluded = value;
  26197. },
  26198. enumerable: true,
  26199. configurable: true
  26200. });
  26201. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionQueryAlgorithmType", {
  26202. get: function () {
  26203. return this._occlusionDataStorage.occlusionQueryAlgorithmType;
  26204. },
  26205. set: function (value) {
  26206. this._occlusionDataStorage.occlusionQueryAlgorithmType = value;
  26207. },
  26208. enumerable: true,
  26209. configurable: true
  26210. });
  26211. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionType", {
  26212. get: function () {
  26213. return this._occlusionDataStorage.occlusionType;
  26214. },
  26215. set: function (value) {
  26216. this._occlusionDataStorage.occlusionType = value;
  26217. },
  26218. enumerable: true,
  26219. configurable: true
  26220. });
  26221. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionRetryCount", {
  26222. get: function () {
  26223. return this._occlusionDataStorage.occlusionRetryCount;
  26224. },
  26225. set: function (value) {
  26226. this._occlusionDataStorage.occlusionRetryCount = value;
  26227. },
  26228. enumerable: true,
  26229. configurable: true
  26230. });
  26231. // We also need to update AbstractMesh as there is a portion of the code there
  26232. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype._checkOcclusionQuery = function () {
  26233. var dataStorage = this._occlusionDataStorage;
  26234. if (dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE) {
  26235. dataStorage.isOccluded = false;
  26236. return false;
  26237. }
  26238. var engine = this.getEngine();
  26239. if (engine.webGLVersion < 2) {
  26240. dataStorage.isOccluded = false;
  26241. return false;
  26242. }
  26243. if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
  26244. dataStorage.isOccluded = false;
  26245. return false;
  26246. }
  26247. if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
  26248. var isOcclusionQueryAvailable = engine.isQueryResultAvailable(this._occlusionQuery);
  26249. if (isOcclusionQueryAvailable) {
  26250. var occlusionQueryResult = engine.getQueryResult(this._occlusionQuery);
  26251. dataStorage.isOcclusionQueryInProgress = false;
  26252. dataStorage.occlusionInternalRetryCounter = 0;
  26253. dataStorage.isOccluded = occlusionQueryResult === 1 ? false : true;
  26254. }
  26255. else {
  26256. dataStorage.occlusionInternalRetryCounter++;
  26257. if (dataStorage.occlusionRetryCount !== -1 && dataStorage.occlusionInternalRetryCounter > dataStorage.occlusionRetryCount) {
  26258. dataStorage.isOcclusionQueryInProgress = false;
  26259. dataStorage.occlusionInternalRetryCounter = 0;
  26260. // if optimistic set isOccluded to false regardless of the status of isOccluded. (Render in the current render loop)
  26261. // if strict continue the last state of the object.
  26262. dataStorage.isOccluded = dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_OPTIMISTIC ? false : dataStorage.isOccluded;
  26263. }
  26264. else {
  26265. return false;
  26266. }
  26267. }
  26268. }
  26269. var scene = this.getScene();
  26270. if (scene.getBoundingBoxRenderer) {
  26271. var occlusionBoundingBoxRenderer = scene.getBoundingBoxRenderer();
  26272. if (!this._occlusionQuery) {
  26273. this._occlusionQuery = engine.createQuery();
  26274. }
  26275. engine.beginOcclusionQuery(dataStorage.occlusionQueryAlgorithmType, this._occlusionQuery);
  26276. occlusionBoundingBoxRenderer.renderOcclusionBoundingBox(this);
  26277. engine.endOcclusionQuery(dataStorage.occlusionQueryAlgorithmType);
  26278. this._occlusionDataStorage.isOcclusionQueryInProgress = true;
  26279. }
  26280. return dataStorage.isOccluded;
  26281. };
  26282. /***/ }),
  26283. /***/ "./Engines/Extensions/engine.transformFeedback.ts":
  26284. /*!********************************************************!*\
  26285. !*** ./Engines/Extensions/engine.transformFeedback.ts ***!
  26286. \********************************************************/
  26287. /*! exports provided: _forceTransformFeedbackToBundle */
  26288. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26289. "use strict";
  26290. __webpack_require__.r(__webpack_exports__);
  26291. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _forceTransformFeedbackToBundle; });
  26292. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  26293. /** @hidden */
  26294. var _forceTransformFeedbackToBundle = true;
  26295. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createTransformFeedback = function () {
  26296. return this._gl.createTransformFeedback();
  26297. };
  26298. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteTransformFeedback = function (value) {
  26299. this._gl.deleteTransformFeedback(value);
  26300. };
  26301. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedback = function (value) {
  26302. this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, value);
  26303. };
  26304. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginTransformFeedback = function (usePoints) {
  26305. if (usePoints === void 0) { usePoints = true; }
  26306. this._gl.beginTransformFeedback(usePoints ? this._gl.POINTS : this._gl.TRIANGLES);
  26307. };
  26308. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTransformFeedback = function () {
  26309. this._gl.endTransformFeedback();
  26310. };
  26311. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.setTranformFeedbackVaryings = function (program, value) {
  26312. this._gl.transformFeedbackVaryings(program, value, this._gl.INTERLEAVED_ATTRIBS);
  26313. };
  26314. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedbackBuffer = function (value) {
  26315. this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, value);
  26316. };
  26317. /***/ }),
  26318. /***/ "./Engines/Extensions/index.ts":
  26319. /*!*************************************!*\
  26320. !*** ./Engines/Extensions/index.ts ***!
  26321. \*************************************/
  26322. /*! exports provided: _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  26323. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26324. "use strict";
  26325. __webpack_require__.r(__webpack_exports__);
  26326. /* harmony import */ var _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.occlusionQuery */ "./Engines/Extensions/engine.occlusionQuery.ts");
  26327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  26328. /* harmony import */ var _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.transformFeedback */ "./Engines/Extensions/engine.transformFeedback.ts");
  26329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__["_forceTransformFeedbackToBundle"]; });
  26330. /***/ }),
  26331. /***/ "./Engines/constants.ts":
  26332. /*!******************************!*\
  26333. !*** ./Engines/constants.ts ***!
  26334. \******************************/
  26335. /*! exports provided: Constants */
  26336. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26337. "use strict";
  26338. __webpack_require__.r(__webpack_exports__);
  26339. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return Constants; });
  26340. /** Defines the cross module used constants to avoid circular dependncies */
  26341. var Constants = /** @class */ (function () {
  26342. function Constants() {
  26343. }
  26344. /** Defines that alpha blending is disabled */
  26345. Constants.ALPHA_DISABLE = 0;
  26346. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26347. Constants.ALPHA_ADD = 1;
  26348. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26349. Constants.ALPHA_COMBINE = 2;
  26350. /** Defines that alpha blending to DEST - SRC * DEST */
  26351. Constants.ALPHA_SUBTRACT = 3;
  26352. /** Defines that alpha blending to SRC * DEST */
  26353. Constants.ALPHA_MULTIPLY = 4;
  26354. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26355. Constants.ALPHA_MAXIMIZED = 5;
  26356. /** Defines that alpha blending to SRC + DEST */
  26357. Constants.ALPHA_ONEONE = 6;
  26358. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26359. Constants.ALPHA_PREMULTIPLIED = 7;
  26360. /**
  26361. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26362. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26363. */
  26364. Constants.ALPHA_PREMULTIPLIED_PORTERDUFF = 8;
  26365. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26366. Constants.ALPHA_INTERPOLATE = 9;
  26367. /**
  26368. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26369. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26370. */
  26371. Constants.ALPHA_SCREENMODE = 10;
  26372. /** Defines that the ressource is not delayed*/
  26373. Constants.DELAYLOADSTATE_NONE = 0;
  26374. /** Defines that the ressource was successfully delay loaded */
  26375. Constants.DELAYLOADSTATE_LOADED = 1;
  26376. /** Defines that the ressource is currently delay loading */
  26377. Constants.DELAYLOADSTATE_LOADING = 2;
  26378. /** Defines that the ressource is delayed and has not started loading */
  26379. Constants.DELAYLOADSTATE_NOTLOADED = 4;
  26380. // Depht or Stencil test Constants.
  26381. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26382. Constants.NEVER = 0x0200;
  26383. /** 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 */
  26384. Constants.ALWAYS = 0x0207;
  26385. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26386. Constants.LESS = 0x0201;
  26387. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26388. Constants.EQUAL = 0x0202;
  26389. /** 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 */
  26390. Constants.LEQUAL = 0x0203;
  26391. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26392. Constants.GREATER = 0x0204;
  26393. /** 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 */
  26394. Constants.GEQUAL = 0x0206;
  26395. /** 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 */
  26396. Constants.NOTEQUAL = 0x0205;
  26397. // Stencil Actions Constants.
  26398. /** Passed to stencilOperation to specify that stencil value must be kept */
  26399. Constants.KEEP = 0x1E00;
  26400. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26401. Constants.REPLACE = 0x1E01;
  26402. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26403. Constants.INCR = 0x1E02;
  26404. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26405. Constants.DECR = 0x1E03;
  26406. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26407. Constants.INVERT = 0x150A;
  26408. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26409. Constants.INCR_WRAP = 0x8507;
  26410. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26411. Constants.DECR_WRAP = 0x8508;
  26412. /** Texture is not repeating outside of 0..1 UVs */
  26413. Constants.TEXTURE_CLAMP_ADDRESSMODE = 0;
  26414. /** Texture is repeating outside of 0..1 UVs */
  26415. Constants.TEXTURE_WRAP_ADDRESSMODE = 1;
  26416. /** Texture is repeating and mirrored */
  26417. Constants.TEXTURE_MIRROR_ADDRESSMODE = 2;
  26418. /** ALPHA */
  26419. Constants.TEXTUREFORMAT_ALPHA = 0;
  26420. /** LUMINANCE */
  26421. Constants.TEXTUREFORMAT_LUMINANCE = 1;
  26422. /** LUMINANCE_ALPHA */
  26423. Constants.TEXTUREFORMAT_LUMINANCE_ALPHA = 2;
  26424. /** RGB */
  26425. Constants.TEXTUREFORMAT_RGB = 4;
  26426. /** RGBA */
  26427. Constants.TEXTUREFORMAT_RGBA = 5;
  26428. /** RED */
  26429. Constants.TEXTUREFORMAT_RED = 6;
  26430. /** RED (2nd reference) */
  26431. Constants.TEXTUREFORMAT_R = 6;
  26432. /** RG */
  26433. Constants.TEXTUREFORMAT_RG = 7;
  26434. /** RED_INTEGER */
  26435. Constants.TEXTUREFORMAT_RED_INTEGER = 8;
  26436. /** RED_INTEGER (2nd reference) */
  26437. Constants.TEXTUREFORMAT_R_INTEGER = 8;
  26438. /** RG_INTEGER */
  26439. Constants.TEXTUREFORMAT_RG_INTEGER = 9;
  26440. /** RGB_INTEGER */
  26441. Constants.TEXTUREFORMAT_RGB_INTEGER = 10;
  26442. /** RGBA_INTEGER */
  26443. Constants.TEXTUREFORMAT_RGBA_INTEGER = 11;
  26444. /** UNSIGNED_BYTE */
  26445. Constants.TEXTURETYPE_UNSIGNED_BYTE = 0;
  26446. /** UNSIGNED_BYTE (2nd reference) */
  26447. Constants.TEXTURETYPE_UNSIGNED_INT = 0;
  26448. /** FLOAT */
  26449. Constants.TEXTURETYPE_FLOAT = 1;
  26450. /** HALF_FLOAT */
  26451. Constants.TEXTURETYPE_HALF_FLOAT = 2;
  26452. /** BYTE */
  26453. Constants.TEXTURETYPE_BYTE = 3;
  26454. /** SHORT */
  26455. Constants.TEXTURETYPE_SHORT = 4;
  26456. /** UNSIGNED_SHORT */
  26457. Constants.TEXTURETYPE_UNSIGNED_SHORT = 5;
  26458. /** INT */
  26459. Constants.TEXTURETYPE_INT = 6;
  26460. /** UNSIGNED_INT */
  26461. Constants.TEXTURETYPE_UNSIGNED_INTEGER = 7;
  26462. /** UNSIGNED_SHORT_4_4_4_4 */
  26463. Constants.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8;
  26464. /** UNSIGNED_SHORT_5_5_5_1 */
  26465. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9;
  26466. /** UNSIGNED_SHORT_5_6_5 */
  26467. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10;
  26468. /** UNSIGNED_INT_2_10_10_10_REV */
  26469. Constants.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11;
  26470. /** UNSIGNED_INT_24_8 */
  26471. Constants.TEXTURETYPE_UNSIGNED_INT_24_8 = 12;
  26472. /** UNSIGNED_INT_10F_11F_11F_REV */
  26473. Constants.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13;
  26474. /** UNSIGNED_INT_5_9_9_9_REV */
  26475. Constants.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14;
  26476. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26477. Constants.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15;
  26478. /** nearest is mag = nearest and min = nearest and mip = linear */
  26479. Constants.TEXTURE_NEAREST_SAMPLINGMODE = 1;
  26480. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26481. Constants.TEXTURE_BILINEAR_SAMPLINGMODE = 2;
  26482. /** Trilinear is mag = linear and min = linear and mip = linear */
  26483. Constants.TEXTURE_TRILINEAR_SAMPLINGMODE = 3;
  26484. /** nearest is mag = nearest and min = nearest and mip = linear */
  26485. Constants.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 1;
  26486. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26487. Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 2;
  26488. /** Trilinear is mag = linear and min = linear and mip = linear */
  26489. Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3;
  26490. /** mag = nearest and min = nearest and mip = nearest */
  26491. Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4;
  26492. /** mag = nearest and min = linear and mip = nearest */
  26493. Constants.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5;
  26494. /** mag = nearest and min = linear and mip = linear */
  26495. Constants.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6;
  26496. /** mag = nearest and min = linear and mip = none */
  26497. Constants.TEXTURE_NEAREST_LINEAR = 7;
  26498. /** mag = nearest and min = nearest and mip = none */
  26499. Constants.TEXTURE_NEAREST_NEAREST = 8;
  26500. /** mag = linear and min = nearest and mip = nearest */
  26501. Constants.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9;
  26502. /** mag = linear and min = nearest and mip = linear */
  26503. Constants.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10;
  26504. /** mag = linear and min = linear and mip = none */
  26505. Constants.TEXTURE_LINEAR_LINEAR = 11;
  26506. /** mag = linear and min = nearest and mip = none */
  26507. Constants.TEXTURE_LINEAR_NEAREST = 12;
  26508. /** Explicit coordinates mode */
  26509. Constants.TEXTURE_EXPLICIT_MODE = 0;
  26510. /** Spherical coordinates mode */
  26511. Constants.TEXTURE_SPHERICAL_MODE = 1;
  26512. /** Planar coordinates mode */
  26513. Constants.TEXTURE_PLANAR_MODE = 2;
  26514. /** Cubic coordinates mode */
  26515. Constants.TEXTURE_CUBIC_MODE = 3;
  26516. /** Projection coordinates mode */
  26517. Constants.TEXTURE_PROJECTION_MODE = 4;
  26518. /** Skybox coordinates mode */
  26519. Constants.TEXTURE_SKYBOX_MODE = 5;
  26520. /** Inverse Cubic coordinates mode */
  26521. Constants.TEXTURE_INVCUBIC_MODE = 6;
  26522. /** Equirectangular coordinates mode */
  26523. Constants.TEXTURE_EQUIRECTANGULAR_MODE = 7;
  26524. /** Equirectangular Fixed coordinates mode */
  26525. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8;
  26526. /** Equirectangular Fixed Mirrored coordinates mode */
  26527. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9;
  26528. // Texture rescaling mode
  26529. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26530. Constants.SCALEMODE_FLOOR = 1;
  26531. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26532. Constants.SCALEMODE_NEAREST = 2;
  26533. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26534. Constants.SCALEMODE_CEILING = 3;
  26535. /**
  26536. * The dirty texture flag value
  26537. */
  26538. Constants.MATERIAL_TextureDirtyFlag = 1;
  26539. /**
  26540. * The dirty light flag value
  26541. */
  26542. Constants.MATERIAL_LightDirtyFlag = 2;
  26543. /**
  26544. * The dirty fresnel flag value
  26545. */
  26546. Constants.MATERIAL_FresnelDirtyFlag = 4;
  26547. /**
  26548. * The dirty attribute flag value
  26549. */
  26550. Constants.MATERIAL_AttributesDirtyFlag = 8;
  26551. /**
  26552. * The dirty misc flag value
  26553. */
  26554. Constants.MATERIAL_MiscDirtyFlag = 16;
  26555. /**
  26556. * The all dirty flag value
  26557. */
  26558. Constants.MATERIAL_AllDirtyFlag = 31;
  26559. /**
  26560. * Returns the triangle fill mode
  26561. */
  26562. Constants.MATERIAL_TriangleFillMode = 0;
  26563. /**
  26564. * Returns the wireframe mode
  26565. */
  26566. Constants.MATERIAL_WireFrameFillMode = 1;
  26567. /**
  26568. * Returns the point fill mode
  26569. */
  26570. Constants.MATERIAL_PointFillMode = 2;
  26571. /**
  26572. * Returns the point list draw mode
  26573. */
  26574. Constants.MATERIAL_PointListDrawMode = 3;
  26575. /**
  26576. * Returns the line list draw mode
  26577. */
  26578. Constants.MATERIAL_LineListDrawMode = 4;
  26579. /**
  26580. * Returns the line loop draw mode
  26581. */
  26582. Constants.MATERIAL_LineLoopDrawMode = 5;
  26583. /**
  26584. * Returns the line strip draw mode
  26585. */
  26586. Constants.MATERIAL_LineStripDrawMode = 6;
  26587. /**
  26588. * Returns the triangle strip draw mode
  26589. */
  26590. Constants.MATERIAL_TriangleStripDrawMode = 7;
  26591. /**
  26592. * Returns the triangle fan draw mode
  26593. */
  26594. Constants.MATERIAL_TriangleFanDrawMode = 8;
  26595. /**
  26596. * Stores the clock-wise side orientation
  26597. */
  26598. Constants.MATERIAL_ClockWiseSideOrientation = 0;
  26599. /**
  26600. * Stores the counter clock-wise side orientation
  26601. */
  26602. Constants.MATERIAL_CounterClockWiseSideOrientation = 1;
  26603. /**
  26604. * Nothing
  26605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26606. */
  26607. Constants.ACTION_NothingTrigger = 0;
  26608. /**
  26609. * On pick
  26610. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26611. */
  26612. Constants.ACTION_OnPickTrigger = 1;
  26613. /**
  26614. * On left pick
  26615. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26616. */
  26617. Constants.ACTION_OnLeftPickTrigger = 2;
  26618. /**
  26619. * On right pick
  26620. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26621. */
  26622. Constants.ACTION_OnRightPickTrigger = 3;
  26623. /**
  26624. * On center pick
  26625. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26626. */
  26627. Constants.ACTION_OnCenterPickTrigger = 4;
  26628. /**
  26629. * On pick down
  26630. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26631. */
  26632. Constants.ACTION_OnPickDownTrigger = 5;
  26633. /**
  26634. * On double pick
  26635. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26636. */
  26637. Constants.ACTION_OnDoublePickTrigger = 6;
  26638. /**
  26639. * On pick up
  26640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26641. */
  26642. Constants.ACTION_OnPickUpTrigger = 7;
  26643. /**
  26644. * On pick out.
  26645. * This trigger will only be raised if you also declared a OnPickDown
  26646. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26647. */
  26648. Constants.ACTION_OnPickOutTrigger = 16;
  26649. /**
  26650. * On long press
  26651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26652. */
  26653. Constants.ACTION_OnLongPressTrigger = 8;
  26654. /**
  26655. * On pointer over
  26656. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26657. */
  26658. Constants.ACTION_OnPointerOverTrigger = 9;
  26659. /**
  26660. * On pointer out
  26661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26662. */
  26663. Constants.ACTION_OnPointerOutTrigger = 10;
  26664. /**
  26665. * On every frame
  26666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26667. */
  26668. Constants.ACTION_OnEveryFrameTrigger = 11;
  26669. /**
  26670. * On intersection enter
  26671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26672. */
  26673. Constants.ACTION_OnIntersectionEnterTrigger = 12;
  26674. /**
  26675. * On intersection exit
  26676. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26677. */
  26678. Constants.ACTION_OnIntersectionExitTrigger = 13;
  26679. /**
  26680. * On key down
  26681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26682. */
  26683. Constants.ACTION_OnKeyDownTrigger = 14;
  26684. /**
  26685. * On key up
  26686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26687. */
  26688. Constants.ACTION_OnKeyUpTrigger = 15;
  26689. /**
  26690. * Billboard mode will only apply to Y axis
  26691. */
  26692. Constants.PARTICLES_BILLBOARDMODE_Y = 2;
  26693. /**
  26694. * Billboard mode will apply to all axes
  26695. */
  26696. Constants.PARTICLES_BILLBOARDMODE_ALL = 7;
  26697. /**
  26698. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  26699. */
  26700. Constants.PARTICLES_BILLBOARDMODE_STRETCHED = 8;
  26701. /**
  26702. * Gets or sets base Assets URL
  26703. */
  26704. Constants.PARTICLES_BaseAssetsUrl = "https://assets.babylonjs.com/particles";
  26705. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26706. * Test order :
  26707. * Is the bounding sphere outside the frustum ?
  26708. * If not, are the bounding box vertices outside the frustum ?
  26709. * It not, then the cullable object is in the frustum.
  26710. */
  26711. Constants.MESHES_CULLINGSTRATEGY_STANDARD = 0;
  26712. /** Culling strategy : Bounding Sphere Only.
  26713. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26714. * It's also less accurate than the standard because some not visible objects can still be selected.
  26715. * Test : is the bounding sphere outside the frustum ?
  26716. * If not, then the cullable object is in the frustum.
  26717. */
  26718. Constants.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1;
  26719. /** Culling strategy : Optimistic Inclusion.
  26720. * This in an inclusion test first, then the standard exclusion test.
  26721. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26722. * 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.
  26723. * Anyway, it's as accurate as the standard strategy.
  26724. * Test :
  26725. * Is the cullable object bounding sphere center in the frustum ?
  26726. * If not, apply the default culling strategy.
  26727. */
  26728. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2;
  26729. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26730. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26731. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26732. * 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.
  26733. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26734. * Test :
  26735. * Is the cullable object bounding sphere center in the frustum ?
  26736. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26737. */
  26738. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3;
  26739. /**
  26740. * No logging while loading
  26741. */
  26742. Constants.SCENELOADER_NO_LOGGING = 0;
  26743. /**
  26744. * Minimal logging while loading
  26745. */
  26746. Constants.SCENELOADER_MINIMAL_LOGGING = 1;
  26747. /**
  26748. * Summary logging while loading
  26749. */
  26750. Constants.SCENELOADER_SUMMARY_LOGGING = 2;
  26751. /**
  26752. * Detailled logging while loading
  26753. */
  26754. Constants.SCENELOADER_DETAILED_LOGGING = 3;
  26755. return Constants;
  26756. }());
  26757. /***/ }),
  26758. /***/ "./Engines/engine.ts":
  26759. /*!***************************!*\
  26760. !*** ./Engines/engine.ts ***!
  26761. \***************************/
  26762. /*! exports provided: InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine */
  26763. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26764. "use strict";
  26765. __webpack_require__.r(__webpack_exports__);
  26766. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return InstancingAttributeInfo; });
  26767. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return DepthTextureCreationOptions; });
  26768. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return EngineCapabilities; });
  26769. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return Engine; });
  26770. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  26771. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  26772. /* harmony import */ var _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/performanceMonitor */ "./Misc/performanceMonitor.ts");
  26773. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  26774. /* harmony import */ var _Misc_promise__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/promise */ "./Misc/promise.ts");
  26775. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  26776. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26777. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  26778. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  26779. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  26780. /* harmony import */ var _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  26781. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  26782. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../States/index */ "./States/index.ts");
  26783. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  26784. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  26785. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  26786. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  26787. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  26788. /**
  26789. * Keeps track of all the buffer info used in engine.
  26790. */
  26791. var BufferPointer = /** @class */ (function () {
  26792. function BufferPointer() {
  26793. }
  26794. return BufferPointer;
  26795. }());
  26796. /**
  26797. * Interface for attribute information associated with buffer instanciation
  26798. */
  26799. var InstancingAttributeInfo = /** @class */ (function () {
  26800. function InstancingAttributeInfo() {
  26801. }
  26802. return InstancingAttributeInfo;
  26803. }());
  26804. /**
  26805. * Define options used to create a depth texture
  26806. */
  26807. var DepthTextureCreationOptions = /** @class */ (function () {
  26808. function DepthTextureCreationOptions() {
  26809. }
  26810. return DepthTextureCreationOptions;
  26811. }());
  26812. /**
  26813. * Class used to describe the capabilities of the engine relatively to the current browser
  26814. */
  26815. var EngineCapabilities = /** @class */ (function () {
  26816. function EngineCapabilities() {
  26817. }
  26818. return EngineCapabilities;
  26819. }());
  26820. /**
  26821. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26822. */
  26823. var Engine = /** @class */ (function () {
  26824. /**
  26825. * Creates a new engine
  26826. * @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
  26827. * @param antialias defines enable antialiasing (default: false)
  26828. * @param options defines further options to be sent to the getContext() function
  26829. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  26830. */
  26831. function Engine(canvasOrContext, antialias, options, adaptToDeviceRatio) {
  26832. if (adaptToDeviceRatio === void 0) { adaptToDeviceRatio = false; }
  26833. var _this = this;
  26834. // Public members
  26835. /**
  26836. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  26837. */
  26838. this.forcePOTTextures = false;
  26839. /**
  26840. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  26841. */
  26842. this.isFullscreen = false;
  26843. /**
  26844. * Gets a boolean indicating if the pointer is currently locked
  26845. */
  26846. this.isPointerLock = false;
  26847. /**
  26848. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  26849. */
  26850. this.cullBackFaces = true;
  26851. /**
  26852. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  26853. */
  26854. this.renderEvenInBackground = true;
  26855. /**
  26856. * Gets or sets a boolean indicating that cache can be kept between frames
  26857. */
  26858. this.preventCacheWipeBetweenFrames = false;
  26859. /**
  26860. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  26861. **/
  26862. this.enableOfflineSupport = false;
  26863. /**
  26864. * 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)
  26865. **/
  26866. this.disableManifestCheck = false;
  26867. /**
  26868. * Gets the list of created scenes
  26869. */
  26870. this.scenes = new Array();
  26871. /**
  26872. * Event raised when a new scene is created
  26873. */
  26874. this.onNewSceneAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26875. /**
  26876. * Gets the list of created postprocesses
  26877. */
  26878. this.postProcesses = new Array();
  26879. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  26880. this.validateShaderPrograms = false;
  26881. // Observables
  26882. /**
  26883. * Observable event triggered each time the rendering canvas is resized
  26884. */
  26885. this.onResizeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26886. /**
  26887. * Observable event triggered each time the canvas loses focus
  26888. */
  26889. this.onCanvasBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26890. /**
  26891. * Observable event triggered each time the canvas gains focus
  26892. */
  26893. this.onCanvasFocusObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26894. /**
  26895. * Observable event triggered each time the canvas receives pointerout event
  26896. */
  26897. this.onCanvasPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26898. /**
  26899. * Observable event triggered before each texture is initialized
  26900. */
  26901. this.onBeforeTextureInitObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26902. //WebVR
  26903. this._vrDisplay = undefined;
  26904. this._vrSupported = false;
  26905. this._vrExclusivePointerMode = false;
  26906. // Uniform buffers list
  26907. /**
  26908. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  26909. */
  26910. this.disableUniformBuffers = false;
  26911. /** @hidden */
  26912. this._uniformBuffers = new Array();
  26913. // Observables
  26914. /**
  26915. * Observable raised when the engine begins a new frame
  26916. */
  26917. this.onBeginFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26918. /**
  26919. * If set, will be used to request the next animation frame for the render loop
  26920. */
  26921. this.customAnimationFrameRequester = null;
  26922. /**
  26923. * Observable raised when the engine ends the current frame
  26924. */
  26925. this.onEndFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26926. /**
  26927. * Observable raised when the engine is about to compile a shader
  26928. */
  26929. this.onBeforeShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26930. /**
  26931. * Observable raised when the engine has jsut compiled a shader
  26932. */
  26933. this.onAfterShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26934. this._windowIsBackground = false;
  26935. this._webGLVersion = 1.0;
  26936. /** @hidden */
  26937. this._badOS = false;
  26938. /** @hidden */
  26939. this._badDesktopOS = false;
  26940. /**
  26941. * Gets or sets a value indicating if we want to disable texture binding optimization.
  26942. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  26943. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  26944. */
  26945. this.disableTextureBindingOptimization = false;
  26946. /**
  26947. * Observable signaled when VR display mode changes
  26948. */
  26949. this.onVRDisplayChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26950. /**
  26951. * Observable signaled when VR request present is complete
  26952. */
  26953. this.onVRRequestPresentComplete = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26954. /**
  26955. * Observable signaled when VR request present starts
  26956. */
  26957. this.onVRRequestPresentStart = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26958. this._colorWrite = true;
  26959. /** @hidden */
  26960. this._drawCalls = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  26961. /** @hidden */
  26962. this._textureCollisions = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  26963. this._renderingQueueLaunched = false;
  26964. this._activeRenderLoops = new Array();
  26965. // Deterministic lockstepMaxSteps
  26966. this._deterministicLockstep = false;
  26967. this._lockstepMaxSteps = 4;
  26968. // Lost context
  26969. /**
  26970. * Observable signaled when a context lost event is raised
  26971. */
  26972. this.onContextLostObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26973. /**
  26974. * Observable signaled when a context restored event is raised
  26975. */
  26976. this.onContextRestoredObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26977. this._contextWasLost = false;
  26978. this._doNotHandleContextLost = false;
  26979. // FPS
  26980. this._performanceMonitor = new _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__["PerformanceMonitor"]();
  26981. this._fps = 60;
  26982. this._deltaTime = 0;
  26983. /**
  26984. * Turn this value on if you want to pause FPS computation when in background
  26985. */
  26986. this.disablePerformanceMonitorInBackground = false;
  26987. // States
  26988. /** @hidden */
  26989. this._depthCullingState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_DepthCullingState"]();
  26990. /** @hidden */
  26991. this._stencilState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_StencilState"]();
  26992. /** @hidden */
  26993. this._alphaState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_AlphaState"]();
  26994. /** @hidden */
  26995. this._alphaMode = Engine.ALPHA_DISABLE;
  26996. // Cache
  26997. this._internalTexturesCache = new Array();
  26998. /** @hidden */
  26999. this._activeChannel = 0;
  27000. this._currentTextureChannel = -1;
  27001. /** @hidden */
  27002. this._boundTexturesCache = {};
  27003. this._compiledEffects = {};
  27004. this._vertexAttribArraysEnabled = [];
  27005. this._uintIndicesCurrentlySet = false;
  27006. this._currentBoundBuffer = new Array();
  27007. /** @hidden */
  27008. this._currentFramebuffer = null;
  27009. this._currentBufferPointers = new Array();
  27010. this._currentInstanceLocations = new Array();
  27011. this._currentInstanceBuffers = new Array();
  27012. this._firstBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  27013. this._lastBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  27014. this._vaoRecordInProgress = false;
  27015. this._mustWipeVertexAttributes = false;
  27016. this._nextFreeTextureSlots = new Array();
  27017. this._maxSimultaneousTextures = 0;
  27018. this._activeRequests = new Array();
  27019. // Hardware supported Compressed Textures
  27020. this._texturesSupported = new Array();
  27021. /**
  27022. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27023. */
  27024. this.premultipliedAlpha = true;
  27025. this._viewportCached = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](0, 0, 0, 0);
  27026. this._onVRFullScreenTriggered = function () {
  27027. if (_this._vrDisplay && _this._vrDisplay.isPresenting) {
  27028. //get the old size before we change
  27029. _this._oldSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Size"](_this.getRenderWidth(), _this.getRenderHeight());
  27030. _this._oldHardwareScaleFactor = _this.getHardwareScalingLevel();
  27031. //get the width and height, change the render size
  27032. var leftEye = _this._vrDisplay.getEyeParameters('left');
  27033. _this.setHardwareScalingLevel(1);
  27034. _this.setSize(leftEye.renderWidth * 2, leftEye.renderHeight);
  27035. }
  27036. else {
  27037. _this.setHardwareScalingLevel(_this._oldHardwareScaleFactor);
  27038. _this.setSize(_this._oldSize.width, _this._oldSize.height);
  27039. }
  27040. };
  27041. this._unpackFlipYCached = null;
  27042. /**
  27043. * In case you are sharing the context with other applications, it might
  27044. * be interested to not cache the unpack flip y state to ensure a consistent
  27045. * value would be set.
  27046. */
  27047. this.enableUnpackFlipYCached = true;
  27048. this._boundUniforms = {};
  27049. // Register promises
  27050. _Misc_promise__WEBPACK_IMPORTED_MODULE_4__["PromisePolyfill"].Apply();
  27051. var canvas = null;
  27052. Engine.Instances.push(this);
  27053. if (!canvasOrContext) {
  27054. return;
  27055. }
  27056. options = options || {};
  27057. if (canvasOrContext.getContext) {
  27058. canvas = canvasOrContext;
  27059. this._renderingCanvas = canvas;
  27060. if (antialias != null) {
  27061. options.antialias = antialias;
  27062. }
  27063. if (options.deterministicLockstep === undefined) {
  27064. options.deterministicLockstep = false;
  27065. }
  27066. if (options.lockstepMaxSteps === undefined) {
  27067. options.lockstepMaxSteps = 4;
  27068. }
  27069. if (options.preserveDrawingBuffer === undefined) {
  27070. options.preserveDrawingBuffer = false;
  27071. }
  27072. if (options.audioEngine === undefined) {
  27073. options.audioEngine = true;
  27074. }
  27075. if (options.stencil === undefined) {
  27076. options.stencil = true;
  27077. }
  27078. if (options.premultipliedAlpha === false) {
  27079. this.premultipliedAlpha = false;
  27080. }
  27081. this._deterministicLockstep = options.deterministicLockstep;
  27082. this._lockstepMaxSteps = options.lockstepMaxSteps;
  27083. this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
  27084. // Exceptions
  27085. if (navigator && navigator.userAgent) {
  27086. var ua = navigator.userAgent;
  27087. for (var _i = 0, _a = Engine.ExceptionList; _i < _a.length; _i++) {
  27088. var exception = _a[_i];
  27089. var key = exception.key;
  27090. var targets = exception.targets;
  27091. if (ua.indexOf(key) > -1) {
  27092. if (exception.capture && exception.captureConstraint) {
  27093. var capture = exception.capture;
  27094. var constraint = exception.captureConstraint;
  27095. var regex = new RegExp(capture);
  27096. var matches = regex.exec(ua);
  27097. if (matches && matches.length > 0) {
  27098. var capturedValue = parseInt(matches[matches.length - 1]);
  27099. if (capturedValue >= constraint) {
  27100. continue;
  27101. }
  27102. }
  27103. }
  27104. for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {
  27105. var target = targets_1[_b];
  27106. switch (target) {
  27107. case "uniformBuffer":
  27108. this.disableUniformBuffers = true;
  27109. break;
  27110. case "textureBindingOptimization":
  27111. this.disableTextureBindingOptimization = true;
  27112. break;
  27113. }
  27114. }
  27115. }
  27116. }
  27117. }
  27118. // GL
  27119. if (!options.disableWebGL2Support) {
  27120. try {
  27121. this._gl = (canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
  27122. if (this._gl) {
  27123. this._webGLVersion = 2.0;
  27124. // Prevent weird browsers to lie :-)
  27125. if (!this._gl.deleteQuery) {
  27126. this._webGLVersion = 1.0;
  27127. }
  27128. }
  27129. }
  27130. catch (e) {
  27131. // Do nothing
  27132. }
  27133. }
  27134. if (!this._gl) {
  27135. if (!canvas) {
  27136. throw new Error("The provided canvas is null or undefined.");
  27137. }
  27138. try {
  27139. this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
  27140. }
  27141. catch (e) {
  27142. throw new Error("WebGL not supported");
  27143. }
  27144. }
  27145. if (!this._gl) {
  27146. throw new Error("WebGL not supported");
  27147. }
  27148. this._onCanvasFocus = function () {
  27149. _this.onCanvasFocusObservable.notifyObservers(_this);
  27150. };
  27151. this._onCanvasBlur = function () {
  27152. _this.onCanvasBlurObservable.notifyObservers(_this);
  27153. };
  27154. canvas.addEventListener("focus", this._onCanvasFocus);
  27155. canvas.addEventListener("blur", this._onCanvasBlur);
  27156. this._onBlur = function () {
  27157. if (_this.disablePerformanceMonitorInBackground) {
  27158. _this._performanceMonitor.disable();
  27159. }
  27160. _this._windowIsBackground = true;
  27161. };
  27162. this._onFocus = function () {
  27163. if (_this.disablePerformanceMonitorInBackground) {
  27164. _this._performanceMonitor.enable();
  27165. }
  27166. _this._windowIsBackground = false;
  27167. };
  27168. this._onCanvasPointerOut = function (ev) {
  27169. _this.onCanvasPointerOutObservable.notifyObservers(ev);
  27170. };
  27171. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  27172. window.addEventListener("blur", this._onBlur);
  27173. window.addEventListener("focus", this._onFocus);
  27174. }
  27175. canvas.addEventListener("pointerout", this._onCanvasPointerOut);
  27176. // Context lost
  27177. if (!this._doNotHandleContextLost) {
  27178. this._onContextLost = function (evt) {
  27179. evt.preventDefault();
  27180. _this._contextWasLost = true;
  27181. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context lost.");
  27182. _this.onContextLostObservable.notifyObservers(_this);
  27183. };
  27184. this._onContextRestored = function () {
  27185. // Adding a timeout to avoid race condition at browser level
  27186. setTimeout(function () {
  27187. // Rebuild gl context
  27188. _this._initGLContext();
  27189. // Rebuild effects
  27190. _this._rebuildEffects();
  27191. // Rebuild textures
  27192. _this._rebuildInternalTextures();
  27193. // Rebuild buffers
  27194. _this._rebuildBuffers();
  27195. // Cache
  27196. _this.wipeCaches(true);
  27197. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context successfully restored.");
  27198. _this.onContextRestoredObservable.notifyObservers(_this);
  27199. _this._contextWasLost = false;
  27200. }, 0);
  27201. };
  27202. canvas.addEventListener("webglcontextlost", this._onContextLost, false);
  27203. canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
  27204. }
  27205. if (!options.doNotHandleTouchAction) {
  27206. this._disableTouchAction();
  27207. }
  27208. }
  27209. else {
  27210. this._gl = canvasOrContext;
  27211. this._renderingCanvas = this._gl.canvas;
  27212. if (this._gl.renderbufferStorageMultisample) {
  27213. this._webGLVersion = 2.0;
  27214. }
  27215. var attributes = this._gl.getContextAttributes();
  27216. if (attributes) {
  27217. options.stencil = attributes.stencil;
  27218. }
  27219. }
  27220. // Viewport
  27221. var devicePixelRatio = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist() ? (window.devicePixelRatio || 1.0) : 1.0;
  27222. var limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
  27223. this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
  27224. this.resize();
  27225. this._isStencilEnable = options.stencil ? true : false;
  27226. this._initGLContext();
  27227. if (canvas) {
  27228. // Fullscreen
  27229. this._onFullscreenChange = function () {
  27230. if (document.fullscreen !== undefined) {
  27231. _this.isFullscreen = document.fullscreen;
  27232. }
  27233. else if (document.mozFullScreen !== undefined) {
  27234. _this.isFullscreen = document.mozFullScreen;
  27235. }
  27236. else if (document.webkitIsFullScreen !== undefined) {
  27237. _this.isFullscreen = document.webkitIsFullScreen;
  27238. }
  27239. else if (document.msIsFullScreen !== undefined) {
  27240. _this.isFullscreen = document.msIsFullScreen;
  27241. }
  27242. // Pointer lock
  27243. if (_this.isFullscreen && _this._pointerLockRequested && canvas) {
  27244. canvas.requestPointerLock = canvas.requestPointerLock ||
  27245. canvas.msRequestPointerLock ||
  27246. canvas.mozRequestPointerLock ||
  27247. canvas.webkitRequestPointerLock;
  27248. if (canvas.requestPointerLock) {
  27249. canvas.requestPointerLock();
  27250. }
  27251. }
  27252. };
  27253. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  27254. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  27255. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  27256. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  27257. // Pointer lock
  27258. this._onPointerLockChange = function () {
  27259. _this.isPointerLock = (document.mozPointerLockElement === canvas ||
  27260. document.webkitPointerLockElement === canvas ||
  27261. document.msPointerLockElement === canvas ||
  27262. document.pointerLockElement === canvas);
  27263. };
  27264. document.addEventListener("pointerlockchange", this._onPointerLockChange, false);
  27265. document.addEventListener("mspointerlockchange", this._onPointerLockChange, false);
  27266. document.addEventListener("mozpointerlockchange", this._onPointerLockChange, false);
  27267. document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, false);
  27268. this._onVRDisplayPointerRestricted = function () {
  27269. if (canvas) {
  27270. canvas.requestPointerLock();
  27271. }
  27272. };
  27273. this._onVRDisplayPointerUnrestricted = function () {
  27274. document.exitPointerLock();
  27275. };
  27276. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  27277. window.addEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted, false);
  27278. window.addEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted, false);
  27279. }
  27280. }
  27281. // Create Audio Engine if needed.
  27282. if (!Engine.audioEngine && options.audioEngine && Engine.AudioEngineFactory) {
  27283. Engine.audioEngine = Engine.AudioEngineFactory(this.getRenderingCanvas());
  27284. }
  27285. // Prepare buffer pointers
  27286. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  27287. this._currentBufferPointers[i] = new BufferPointer();
  27288. }
  27289. this._linkTrackers(this._firstBoundInternalTextureTracker, this._lastBoundInternalTextureTracker);
  27290. // Load WebVR Devices
  27291. if (options.autoEnableWebVR) {
  27292. this.initWebVR();
  27293. }
  27294. // Detect if we are running on a faulty buggy OS.
  27295. this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
  27296. // Detect if we are running on a faulty buggy desktop OS.
  27297. this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  27298. console.log("Babylon.js v" + Engine.Version + " - " + this.description);
  27299. this.enableOfflineSupport = Engine.OfflineProviderFactory !== undefined;
  27300. }
  27301. Object.defineProperty(Engine, "Instances", {
  27302. /** Gets the list of created engines */
  27303. get: function () {
  27304. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].Instances;
  27305. },
  27306. enumerable: true,
  27307. configurable: true
  27308. });
  27309. Object.defineProperty(Engine, "LastCreatedEngine", {
  27310. /**
  27311. * Gets the latest created engine
  27312. */
  27313. get: function () {
  27314. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine;
  27315. },
  27316. enumerable: true,
  27317. configurable: true
  27318. });
  27319. Object.defineProperty(Engine, "LastCreatedScene", {
  27320. /**
  27321. * Gets the latest created scene
  27322. */
  27323. get: function () {
  27324. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  27325. },
  27326. enumerable: true,
  27327. configurable: true
  27328. });
  27329. /**
  27330. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27331. * @param flag defines which part of the materials must be marked as dirty
  27332. * @param predicate defines a predicate used to filter which materials should be affected
  27333. */
  27334. Engine.MarkAllMaterialsAsDirty = function (flag, predicate) {
  27335. for (var engineIndex = 0; engineIndex < Engine.Instances.length; engineIndex++) {
  27336. var engine = Engine.Instances[engineIndex];
  27337. for (var sceneIndex = 0; sceneIndex < engine.scenes.length; sceneIndex++) {
  27338. engine.scenes[sceneIndex].markAllMaterialsAsDirty(flag, predicate);
  27339. }
  27340. }
  27341. };
  27342. Object.defineProperty(Engine, "Version", {
  27343. /**
  27344. * Returns the current version of the framework
  27345. */
  27346. get: function () {
  27347. return "4.0.0-alpha.18";
  27348. },
  27349. enumerable: true,
  27350. configurable: true
  27351. });
  27352. Object.defineProperty(Engine.prototype, "description", {
  27353. /**
  27354. * Returns a string describing the current engine
  27355. */
  27356. get: function () {
  27357. var description = "WebGL" + this.webGLVersion;
  27358. if (this._caps.parallelShaderCompile) {
  27359. description += " - Parallel shader compilation";
  27360. }
  27361. return description;
  27362. },
  27363. enumerable: true,
  27364. configurable: true
  27365. });
  27366. Object.defineProperty(Engine, "ShadersRepository", {
  27367. /**
  27368. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27369. */
  27370. get: function () {
  27371. return _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository;
  27372. },
  27373. set: function (value) {
  27374. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository = value;
  27375. },
  27376. enumerable: true,
  27377. configurable: true
  27378. });
  27379. /**
  27380. * Method called to create the default loading screen.
  27381. * This can be overriden in your own app.
  27382. * @param canvas The rendering canvas element
  27383. * @returns The loading screen
  27384. */
  27385. Engine.DefaultLoadingScreenFactory = function (canvas) {
  27386. throw "Import LoadingScreen or set DefaultLoadingScreenFactory on engine before using the loading screen";
  27387. };
  27388. Object.defineProperty(Engine.prototype, "isInVRExclusivePointerMode", {
  27389. /**
  27390. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27391. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27392. */
  27393. get: function () {
  27394. return this._vrExclusivePointerMode;
  27395. },
  27396. enumerable: true,
  27397. configurable: true
  27398. });
  27399. Object.defineProperty(Engine.prototype, "supportsUniformBuffers", {
  27400. /**
  27401. * Gets a boolean indicating that the engine supports uniform buffers
  27402. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27403. */
  27404. get: function () {
  27405. return this.webGLVersion > 1 && !this.disableUniformBuffers;
  27406. },
  27407. enumerable: true,
  27408. configurable: true
  27409. });
  27410. Object.defineProperty(Engine.prototype, "needPOTTextures", {
  27411. /**
  27412. * Gets a boolean indicating that only power of 2 textures are supported
  27413. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27414. */
  27415. get: function () {
  27416. return this._webGLVersion < 2 || this.forcePOTTextures;
  27417. },
  27418. enumerable: true,
  27419. configurable: true
  27420. });
  27421. Object.defineProperty(Engine.prototype, "doNotHandleContextLost", {
  27422. /**
  27423. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27424. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27425. */
  27426. get: function () {
  27427. return this._doNotHandleContextLost;
  27428. },
  27429. set: function (value) {
  27430. this._doNotHandleContextLost = value;
  27431. },
  27432. enumerable: true,
  27433. configurable: true
  27434. });
  27435. Object.defineProperty(Engine.prototype, "performanceMonitor", {
  27436. /**
  27437. * Gets the performance monitor attached to this engine
  27438. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27439. */
  27440. get: function () {
  27441. return this._performanceMonitor;
  27442. },
  27443. enumerable: true,
  27444. configurable: true
  27445. });
  27446. Object.defineProperty(Engine.prototype, "texturesSupported", {
  27447. /**
  27448. * Gets the list of texture formats supported
  27449. */
  27450. get: function () {
  27451. return this._texturesSupported;
  27452. },
  27453. enumerable: true,
  27454. configurable: true
  27455. });
  27456. Object.defineProperty(Engine.prototype, "textureFormatInUse", {
  27457. /**
  27458. * Gets the list of texture formats in use
  27459. */
  27460. get: function () {
  27461. return this._textureFormatInUse;
  27462. },
  27463. enumerable: true,
  27464. configurable: true
  27465. });
  27466. Object.defineProperty(Engine.prototype, "currentViewport", {
  27467. /**
  27468. * Gets the current viewport
  27469. */
  27470. get: function () {
  27471. return this._cachedViewport;
  27472. },
  27473. enumerable: true,
  27474. configurable: true
  27475. });
  27476. Object.defineProperty(Engine.prototype, "emptyTexture", {
  27477. /**
  27478. * Gets the default empty texture
  27479. */
  27480. get: function () {
  27481. if (!this._emptyTexture) {
  27482. this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  27483. }
  27484. return this._emptyTexture;
  27485. },
  27486. enumerable: true,
  27487. configurable: true
  27488. });
  27489. Object.defineProperty(Engine.prototype, "emptyTexture3D", {
  27490. /**
  27491. * Gets the default empty 3D texture
  27492. */
  27493. get: function () {
  27494. if (!this._emptyTexture3D) {
  27495. this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  27496. }
  27497. return this._emptyTexture3D;
  27498. },
  27499. enumerable: true,
  27500. configurable: true
  27501. });
  27502. Object.defineProperty(Engine.prototype, "emptyCubeTexture", {
  27503. /**
  27504. * Gets the default empty cube texture
  27505. */
  27506. get: function () {
  27507. if (!this._emptyCubeTexture) {
  27508. var faceData = new Uint8Array(4);
  27509. var cubeData = [faceData, faceData, faceData, faceData, faceData, faceData];
  27510. this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, Engine.TEXTUREFORMAT_RGBA, Engine.TEXTURETYPE_UNSIGNED_INT, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  27511. }
  27512. return this._emptyCubeTexture;
  27513. },
  27514. enumerable: true,
  27515. configurable: true
  27516. });
  27517. Engine.prototype._disableTouchAction = function () {
  27518. if (!this._renderingCanvas) {
  27519. return;
  27520. }
  27521. this._renderingCanvas.setAttribute("touch-action", "none");
  27522. this._renderingCanvas.style.touchAction = "none";
  27523. this._renderingCanvas.style.msTouchAction = "none";
  27524. };
  27525. Engine.prototype._rebuildInternalTextures = function () {
  27526. var currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies
  27527. for (var _i = 0, currentState_1 = currentState; _i < currentState_1.length; _i++) {
  27528. var internalTexture = currentState_1[_i];
  27529. internalTexture._rebuild();
  27530. }
  27531. };
  27532. Engine.prototype._rebuildEffects = function () {
  27533. for (var key in this._compiledEffects) {
  27534. var effect = this._compiledEffects[key];
  27535. effect._prepareEffect();
  27536. }
  27537. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  27538. };
  27539. /**
  27540. * Gets a boolean indicating if all created effects are ready
  27541. * @returns true if all effects are ready
  27542. */
  27543. Engine.prototype.areAllEffectsReady = function () {
  27544. for (var key in this._compiledEffects) {
  27545. var effect = this._compiledEffects[key];
  27546. if (!effect.isReady()) {
  27547. return false;
  27548. }
  27549. }
  27550. return true;
  27551. };
  27552. Engine.prototype._rebuildBuffers = function () {
  27553. // Index / Vertex
  27554. for (var _i = 0, _a = this.scenes; _i < _a.length; _i++) {
  27555. var scene = _a[_i];
  27556. scene.resetCachedMaterial();
  27557. scene._rebuildGeometries();
  27558. scene._rebuildTextures();
  27559. }
  27560. // Uniforms
  27561. for (var _b = 0, _c = this._uniformBuffers; _b < _c.length; _b++) {
  27562. var uniformBuffer = _c[_b];
  27563. uniformBuffer._rebuild();
  27564. }
  27565. };
  27566. Engine.prototype._initGLContext = function () {
  27567. // Caps
  27568. this._caps = new EngineCapabilities();
  27569. this._caps.maxTexturesImageUnits = this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);
  27570. this._caps.maxCombinedTexturesImageUnits = this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  27571. this._caps.maxVertexTextureImageUnits = this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
  27572. this._caps.maxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
  27573. this._caps.maxCubemapTextureSize = this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE);
  27574. this._caps.maxRenderTextureSize = this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE);
  27575. this._caps.maxVertexAttribs = this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS);
  27576. this._caps.maxVaryingVectors = this._gl.getParameter(this._gl.MAX_VARYING_VECTORS);
  27577. this._caps.maxFragmentUniformVectors = this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS);
  27578. this._caps.maxVertexUniformVectors = this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS);
  27579. // Infos
  27580. this._glVersion = this._gl.getParameter(this._gl.VERSION);
  27581. var rendererInfo = this._gl.getExtension("WEBGL_debug_renderer_info");
  27582. if (rendererInfo != null) {
  27583. this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);
  27584. this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);
  27585. }
  27586. if (!this._glVendor) {
  27587. this._glVendor = "Unknown vendor";
  27588. }
  27589. if (!this._glRenderer) {
  27590. this._glRenderer = "Unknown renderer";
  27591. }
  27592. // Constants
  27593. this._gl.HALF_FLOAT_OES = 0x8D61; // Half floating-point type (16-bit).
  27594. if (this._gl.RGBA16F !== 0x881A) {
  27595. this._gl.RGBA16F = 0x881A; // RGBA 16-bit floating-point color-renderable internal sized format.
  27596. }
  27597. if (this._gl.RGBA32F !== 0x8814) {
  27598. this._gl.RGBA32F = 0x8814; // RGBA 32-bit floating-point color-renderable internal sized format.
  27599. }
  27600. if (this._gl.DEPTH24_STENCIL8 !== 35056) {
  27601. this._gl.DEPTH24_STENCIL8 = 35056;
  27602. }
  27603. // Extensions
  27604. this._caps.standardDerivatives = this._webGLVersion > 1 || (this._gl.getExtension('OES_standard_derivatives') !== null);
  27605. this._caps.astc = this._gl.getExtension('WEBGL_compressed_texture_astc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_astc');
  27606. this._caps.s3tc = this._gl.getExtension('WEBGL_compressed_texture_s3tc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');
  27607. this._caps.pvrtc = this._gl.getExtension('WEBGL_compressed_texture_pvrtc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');
  27608. this._caps.etc1 = this._gl.getExtension('WEBGL_compressed_texture_etc1') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc1');
  27609. this._caps.etc2 = this._gl.getExtension('WEBGL_compressed_texture_etc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc') ||
  27610. this._gl.getExtension('WEBGL_compressed_texture_es3_0'); // also a requirement of OpenGL ES 3
  27611. 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');
  27612. this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;
  27613. this._caps.uintIndices = this._webGLVersion > 1 || this._gl.getExtension('OES_element_index_uint') !== null;
  27614. this._caps.fragmentDepthSupported = this._webGLVersion > 1 || this._gl.getExtension('EXT_frag_depth') !== null;
  27615. this._caps.highPrecisionShaderSupported = false;
  27616. this._caps.timerQuery = this._gl.getExtension('EXT_disjoint_timer_query_webgl2') || this._gl.getExtension("EXT_disjoint_timer_query");
  27617. if (this._caps.timerQuery) {
  27618. if (this._webGLVersion === 1) {
  27619. this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery);
  27620. }
  27621. this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0;
  27622. }
  27623. // Checks if some of the format renders first to allow the use of webgl inspector.
  27624. this._caps.colorBufferFloat = this._webGLVersion > 1 && this._gl.getExtension('EXT_color_buffer_float');
  27625. this._caps.textureFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_float')) ? true : false;
  27626. this._caps.textureFloatLinearFiltering = this._caps.textureFloat && this._gl.getExtension('OES_texture_float_linear') ? true : false;
  27627. this._caps.textureFloatRender = this._caps.textureFloat && this._canRenderToFloatFramebuffer() ? true : false;
  27628. this._caps.textureHalfFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_half_float')) ? true : false;
  27629. this._caps.textureHalfFloatLinearFiltering = (this._webGLVersion > 1 || (this._caps.textureHalfFloat && this._gl.getExtension('OES_texture_half_float_linear'))) ? true : false;
  27630. if (this._webGLVersion > 1) {
  27631. this._gl.HALF_FLOAT_OES = 0x140B;
  27632. }
  27633. this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer();
  27634. this._caps.textureLOD = (this._webGLVersion > 1 || this._gl.getExtension('EXT_shader_texture_lod')) ? true : false;
  27635. // Draw buffers
  27636. if (this._webGLVersion > 1) {
  27637. this._caps.drawBuffersExtension = true;
  27638. }
  27639. else {
  27640. var drawBuffersExtension = this._gl.getExtension('WEBGL_draw_buffers');
  27641. if (drawBuffersExtension !== null) {
  27642. this._caps.drawBuffersExtension = true;
  27643. this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);
  27644. this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
  27645. for (var i = 0; i < 16; i++) {
  27646. this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = drawBuffersExtension["COLOR_ATTACHMENT" + i + "_WEBGL"];
  27647. }
  27648. }
  27649. else {
  27650. this._caps.drawBuffersExtension = false;
  27651. }
  27652. }
  27653. // Shader compiler threads
  27654. this._caps.parallelShaderCompile = this._gl.getExtension('KHR_parallel_shader_compile');
  27655. if (this._caps.parallelShaderCompile) {
  27656. var threads = this._gl.getParameter(this._caps.parallelShaderCompile.MAX_SHADER_COMPILER_THREADS_KHR);
  27657. this._caps.parallelShaderCompile.maxShaderCompilerThreadsKHR(threads);
  27658. }
  27659. // Depth Texture
  27660. if (this._webGLVersion > 1) {
  27661. this._caps.depthTextureExtension = true;
  27662. }
  27663. else {
  27664. var depthTextureExtension = this._gl.getExtension('WEBGL_depth_texture');
  27665. if (depthTextureExtension != null) {
  27666. this._caps.depthTextureExtension = true;
  27667. this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;
  27668. }
  27669. }
  27670. // Vertex array object
  27671. if (this._webGLVersion > 1) {
  27672. this._caps.vertexArrayObject = true;
  27673. }
  27674. else {
  27675. var vertexArrayObjectExtension = this._gl.getExtension('OES_vertex_array_object');
  27676. if (vertexArrayObjectExtension != null) {
  27677. this._caps.vertexArrayObject = true;
  27678. this._gl.createVertexArray = vertexArrayObjectExtension.createVertexArrayOES.bind(vertexArrayObjectExtension);
  27679. this._gl.bindVertexArray = vertexArrayObjectExtension.bindVertexArrayOES.bind(vertexArrayObjectExtension);
  27680. this._gl.deleteVertexArray = vertexArrayObjectExtension.deleteVertexArrayOES.bind(vertexArrayObjectExtension);
  27681. }
  27682. else {
  27683. this._caps.vertexArrayObject = false;
  27684. }
  27685. }
  27686. // Instances count
  27687. if (this._webGLVersion > 1) {
  27688. this._caps.instancedArrays = true;
  27689. }
  27690. else {
  27691. var instanceExtension = this._gl.getExtension('ANGLE_instanced_arrays');
  27692. if (instanceExtension != null) {
  27693. this._caps.instancedArrays = true;
  27694. this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);
  27695. this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);
  27696. this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);
  27697. }
  27698. else {
  27699. this._caps.instancedArrays = false;
  27700. }
  27701. }
  27702. // Intelligently add supported compressed formats in order to check for.
  27703. // Check for ASTC support first as it is most powerful and to be very cross platform.
  27704. // Next PVRTC & DXT, which are probably superior to ETC1/2.
  27705. // Likely no hardware which supports both PVR & DXT, so order matters little.
  27706. // ETC2 is newer and handles ETC1 (no alpha capability), so check for first.
  27707. if (this._caps.astc) {
  27708. this.texturesSupported.push('-astc.ktx');
  27709. }
  27710. if (this._caps.s3tc) {
  27711. this.texturesSupported.push('-dxt.ktx');
  27712. }
  27713. if (this._caps.pvrtc) {
  27714. this.texturesSupported.push('-pvrtc.ktx');
  27715. }
  27716. if (this._caps.etc2) {
  27717. this.texturesSupported.push('-etc2.ktx');
  27718. }
  27719. if (this._caps.etc1) {
  27720. this.texturesSupported.push('-etc1.ktx');
  27721. }
  27722. if (this._gl.getShaderPrecisionFormat) {
  27723. var vertex_highp = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT);
  27724. var fragment_highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
  27725. if (vertex_highp && fragment_highp) {
  27726. this._caps.highPrecisionShaderSupported = vertex_highp.precision !== 0 && fragment_highp.precision !== 0;
  27727. }
  27728. }
  27729. // Depth buffer
  27730. this.setDepthBuffer(true);
  27731. this.setDepthFunctionToLessOrEqual();
  27732. this.setDepthWrite(true);
  27733. // Texture maps
  27734. this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
  27735. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  27736. this._nextFreeTextureSlots.push(slot);
  27737. }
  27738. };
  27739. Object.defineProperty(Engine.prototype, "webGLVersion", {
  27740. /**
  27741. * Gets version of the current webGL context
  27742. */
  27743. get: function () {
  27744. return this._webGLVersion;
  27745. },
  27746. enumerable: true,
  27747. configurable: true
  27748. });
  27749. Object.defineProperty(Engine.prototype, "isStencilEnable", {
  27750. /**
  27751. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27752. */
  27753. get: function () {
  27754. return this._isStencilEnable;
  27755. },
  27756. enumerable: true,
  27757. configurable: true
  27758. });
  27759. Engine.prototype._prepareWorkingCanvas = function () {
  27760. if (this._workingCanvas) {
  27761. return;
  27762. }
  27763. this._workingCanvas = document.createElement("canvas");
  27764. var context = this._workingCanvas.getContext("2d");
  27765. if (context) {
  27766. this._workingContext = context;
  27767. }
  27768. };
  27769. /**
  27770. * Reset the texture cache to empty state
  27771. */
  27772. Engine.prototype.resetTextureCache = function () {
  27773. for (var key in this._boundTexturesCache) {
  27774. if (!this._boundTexturesCache.hasOwnProperty(key)) {
  27775. continue;
  27776. }
  27777. var boundTexture = this._boundTexturesCache[key];
  27778. if (boundTexture) {
  27779. this._removeDesignatedSlot(boundTexture);
  27780. }
  27781. this._boundTexturesCache[key] = null;
  27782. }
  27783. if (!this.disableTextureBindingOptimization) {
  27784. this._nextFreeTextureSlots = [];
  27785. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  27786. this._nextFreeTextureSlots.push(slot);
  27787. }
  27788. }
  27789. this._currentTextureChannel = -1;
  27790. };
  27791. /**
  27792. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27793. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27794. * @returns true if engine is in deterministic lock step mode
  27795. */
  27796. Engine.prototype.isDeterministicLockStep = function () {
  27797. return this._deterministicLockstep;
  27798. };
  27799. /**
  27800. * Gets the max steps when engine is running in deterministic lock step
  27801. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27802. * @returns the max steps
  27803. */
  27804. Engine.prototype.getLockstepMaxSteps = function () {
  27805. return this._lockstepMaxSteps;
  27806. };
  27807. /**
  27808. * Gets an object containing information about the current webGL context
  27809. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27810. */
  27811. Engine.prototype.getGlInfo = function () {
  27812. return {
  27813. vendor: this._glVendor,
  27814. renderer: this._glRenderer,
  27815. version: this._glVersion
  27816. };
  27817. };
  27818. /**
  27819. * Gets current aspect ratio
  27820. * @param camera defines the camera to use to get the aspect ratio
  27821. * @param useScreen defines if screen size must be used (or the current render target if any)
  27822. * @returns a number defining the aspect ratio
  27823. */
  27824. Engine.prototype.getAspectRatio = function (camera, useScreen) {
  27825. if (useScreen === void 0) { useScreen = false; }
  27826. var viewport = camera.viewport;
  27827. return (this.getRenderWidth(useScreen) * viewport.width) / (this.getRenderHeight(useScreen) * viewport.height);
  27828. };
  27829. /**
  27830. * Gets current screen aspect ratio
  27831. * @returns a number defining the aspect ratio
  27832. */
  27833. Engine.prototype.getScreenAspectRatio = function () {
  27834. return (this.getRenderWidth(true)) / (this.getRenderHeight(true));
  27835. };
  27836. /**
  27837. * Gets the current render width
  27838. * @param useScreen defines if screen size must be used (or the current render target if any)
  27839. * @returns a number defining the current render width
  27840. */
  27841. Engine.prototype.getRenderWidth = function (useScreen) {
  27842. if (useScreen === void 0) { useScreen = false; }
  27843. if (!useScreen && this._currentRenderTarget) {
  27844. return this._currentRenderTarget.width;
  27845. }
  27846. return this._gl.drawingBufferWidth;
  27847. };
  27848. /**
  27849. * Gets the current render height
  27850. * @param useScreen defines if screen size must be used (or the current render target if any)
  27851. * @returns a number defining the current render height
  27852. */
  27853. Engine.prototype.getRenderHeight = function (useScreen) {
  27854. if (useScreen === void 0) { useScreen = false; }
  27855. if (!useScreen && this._currentRenderTarget) {
  27856. return this._currentRenderTarget.height;
  27857. }
  27858. return this._gl.drawingBufferHeight;
  27859. };
  27860. /**
  27861. * Gets the HTML canvas attached with the current webGL context
  27862. * @returns a HTML canvas
  27863. */
  27864. Engine.prototype.getRenderingCanvas = function () {
  27865. return this._renderingCanvas;
  27866. };
  27867. /**
  27868. * Gets the client rect of the HTML canvas attached with the current webGL context
  27869. * @returns a client rectanglee
  27870. */
  27871. Engine.prototype.getRenderingCanvasClientRect = function () {
  27872. if (!this._renderingCanvas) {
  27873. return null;
  27874. }
  27875. return this._renderingCanvas.getBoundingClientRect();
  27876. };
  27877. /**
  27878. * Defines the hardware scaling level.
  27879. * By default the hardware scaling level is computed from the window device ratio.
  27880. * 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.
  27881. * @param level defines the level to use
  27882. */
  27883. Engine.prototype.setHardwareScalingLevel = function (level) {
  27884. this._hardwareScalingLevel = level;
  27885. this.resize();
  27886. };
  27887. /**
  27888. * Gets the current hardware scaling level.
  27889. * By default the hardware scaling level is computed from the window device ratio.
  27890. * 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.
  27891. * @returns a number indicating the current hardware scaling level
  27892. */
  27893. Engine.prototype.getHardwareScalingLevel = function () {
  27894. return this._hardwareScalingLevel;
  27895. };
  27896. /**
  27897. * Gets the list of loaded textures
  27898. * @returns an array containing all loaded textures
  27899. */
  27900. Engine.prototype.getLoadedTexturesCache = function () {
  27901. return this._internalTexturesCache;
  27902. };
  27903. /**
  27904. * Gets the object containing all engine capabilities
  27905. * @returns the EngineCapabilities object
  27906. */
  27907. Engine.prototype.getCaps = function () {
  27908. return this._caps;
  27909. };
  27910. /**
  27911. * Gets the current depth function
  27912. * @returns a number defining the depth function
  27913. */
  27914. Engine.prototype.getDepthFunction = function () {
  27915. return this._depthCullingState.depthFunc;
  27916. };
  27917. /**
  27918. * Sets the current depth function
  27919. * @param depthFunc defines the function to use
  27920. */
  27921. Engine.prototype.setDepthFunction = function (depthFunc) {
  27922. this._depthCullingState.depthFunc = depthFunc;
  27923. };
  27924. /**
  27925. * Sets the current depth function to GREATER
  27926. */
  27927. Engine.prototype.setDepthFunctionToGreater = function () {
  27928. this._depthCullingState.depthFunc = this._gl.GREATER;
  27929. };
  27930. /**
  27931. * Sets the current depth function to GEQUAL
  27932. */
  27933. Engine.prototype.setDepthFunctionToGreaterOrEqual = function () {
  27934. this._depthCullingState.depthFunc = this._gl.GEQUAL;
  27935. };
  27936. /**
  27937. * Sets the current depth function to LESS
  27938. */
  27939. Engine.prototype.setDepthFunctionToLess = function () {
  27940. this._depthCullingState.depthFunc = this._gl.LESS;
  27941. };
  27942. /**
  27943. * Sets the current depth function to LEQUAL
  27944. */
  27945. Engine.prototype.setDepthFunctionToLessOrEqual = function () {
  27946. this._depthCullingState.depthFunc = this._gl.LEQUAL;
  27947. };
  27948. /**
  27949. * Gets a boolean indicating if stencil buffer is enabled
  27950. * @returns the current stencil buffer state
  27951. */
  27952. Engine.prototype.getStencilBuffer = function () {
  27953. return this._stencilState.stencilTest;
  27954. };
  27955. /**
  27956. * Enable or disable the stencil buffer
  27957. * @param enable defines if the stencil buffer must be enabled or disabled
  27958. */
  27959. Engine.prototype.setStencilBuffer = function (enable) {
  27960. this._stencilState.stencilTest = enable;
  27961. };
  27962. /**
  27963. * Gets the current stencil mask
  27964. * @returns a number defining the new stencil mask to use
  27965. */
  27966. Engine.prototype.getStencilMask = function () {
  27967. return this._stencilState.stencilMask;
  27968. };
  27969. /**
  27970. * Sets the current stencil mask
  27971. * @param mask defines the new stencil mask to use
  27972. */
  27973. Engine.prototype.setStencilMask = function (mask) {
  27974. this._stencilState.stencilMask = mask;
  27975. };
  27976. /**
  27977. * Gets the current stencil function
  27978. * @returns a number defining the stencil function to use
  27979. */
  27980. Engine.prototype.getStencilFunction = function () {
  27981. return this._stencilState.stencilFunc;
  27982. };
  27983. /**
  27984. * Gets the current stencil reference value
  27985. * @returns a number defining the stencil reference value to use
  27986. */
  27987. Engine.prototype.getStencilFunctionReference = function () {
  27988. return this._stencilState.stencilFuncRef;
  27989. };
  27990. /**
  27991. * Gets the current stencil mask
  27992. * @returns a number defining the stencil mask to use
  27993. */
  27994. Engine.prototype.getStencilFunctionMask = function () {
  27995. return this._stencilState.stencilFuncMask;
  27996. };
  27997. /**
  27998. * Sets the current stencil function
  27999. * @param stencilFunc defines the new stencil function to use
  28000. */
  28001. Engine.prototype.setStencilFunction = function (stencilFunc) {
  28002. this._stencilState.stencilFunc = stencilFunc;
  28003. };
  28004. /**
  28005. * Sets the current stencil reference
  28006. * @param reference defines the new stencil reference to use
  28007. */
  28008. Engine.prototype.setStencilFunctionReference = function (reference) {
  28009. this._stencilState.stencilFuncRef = reference;
  28010. };
  28011. /**
  28012. * Sets the current stencil mask
  28013. * @param mask defines the new stencil mask to use
  28014. */
  28015. Engine.prototype.setStencilFunctionMask = function (mask) {
  28016. this._stencilState.stencilFuncMask = mask;
  28017. };
  28018. /**
  28019. * Gets the current stencil operation when stencil fails
  28020. * @returns a number defining stencil operation to use when stencil fails
  28021. */
  28022. Engine.prototype.getStencilOperationFail = function () {
  28023. return this._stencilState.stencilOpStencilFail;
  28024. };
  28025. /**
  28026. * Gets the current stencil operation when depth fails
  28027. * @returns a number defining stencil operation to use when depth fails
  28028. */
  28029. Engine.prototype.getStencilOperationDepthFail = function () {
  28030. return this._stencilState.stencilOpDepthFail;
  28031. };
  28032. /**
  28033. * Gets the current stencil operation when stencil passes
  28034. * @returns a number defining stencil operation to use when stencil passes
  28035. */
  28036. Engine.prototype.getStencilOperationPass = function () {
  28037. return this._stencilState.stencilOpStencilDepthPass;
  28038. };
  28039. /**
  28040. * Sets the stencil operation to use when stencil fails
  28041. * @param operation defines the stencil operation to use when stencil fails
  28042. */
  28043. Engine.prototype.setStencilOperationFail = function (operation) {
  28044. this._stencilState.stencilOpStencilFail = operation;
  28045. };
  28046. /**
  28047. * Sets the stencil operation to use when depth fails
  28048. * @param operation defines the stencil operation to use when depth fails
  28049. */
  28050. Engine.prototype.setStencilOperationDepthFail = function (operation) {
  28051. this._stencilState.stencilOpDepthFail = operation;
  28052. };
  28053. /**
  28054. * Sets the stencil operation to use when stencil passes
  28055. * @param operation defines the stencil operation to use when stencil passes
  28056. */
  28057. Engine.prototype.setStencilOperationPass = function (operation) {
  28058. this._stencilState.stencilOpStencilDepthPass = operation;
  28059. };
  28060. /**
  28061. * Sets a boolean indicating if the dithering state is enabled or disabled
  28062. * @param value defines the dithering state
  28063. */
  28064. Engine.prototype.setDitheringState = function (value) {
  28065. if (value) {
  28066. this._gl.enable(this._gl.DITHER);
  28067. }
  28068. else {
  28069. this._gl.disable(this._gl.DITHER);
  28070. }
  28071. };
  28072. /**
  28073. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28074. * @param value defines the rasterizer state
  28075. */
  28076. Engine.prototype.setRasterizerState = function (value) {
  28077. if (value) {
  28078. this._gl.disable(this._gl.RASTERIZER_DISCARD);
  28079. }
  28080. else {
  28081. this._gl.enable(this._gl.RASTERIZER_DISCARD);
  28082. }
  28083. };
  28084. /**
  28085. * stop executing a render loop function and remove it from the execution array
  28086. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28087. */
  28088. Engine.prototype.stopRenderLoop = function (renderFunction) {
  28089. if (!renderFunction) {
  28090. this._activeRenderLoops = [];
  28091. return;
  28092. }
  28093. var index = this._activeRenderLoops.indexOf(renderFunction);
  28094. if (index >= 0) {
  28095. this._activeRenderLoops.splice(index, 1);
  28096. }
  28097. };
  28098. /** @hidden */
  28099. Engine.prototype._renderLoop = function () {
  28100. if (!this._contextWasLost) {
  28101. var shouldRender = true;
  28102. if (!this.renderEvenInBackground && this._windowIsBackground) {
  28103. shouldRender = false;
  28104. }
  28105. if (shouldRender) {
  28106. // Start new frame
  28107. this.beginFrame();
  28108. for (var index = 0; index < this._activeRenderLoops.length; index++) {
  28109. var renderFunction = this._activeRenderLoops[index];
  28110. renderFunction();
  28111. }
  28112. // Present
  28113. this.endFrame();
  28114. }
  28115. }
  28116. if (this._activeRenderLoops.length > 0) {
  28117. // Register new frame
  28118. if (this.customAnimationFrameRequester) {
  28119. this.customAnimationFrameRequester.requestID = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this.customAnimationFrameRequester.renderFunction || this._bindedRenderFunction, this.customAnimationFrameRequester);
  28120. this._frameHandler = this.customAnimationFrameRequester.requestID;
  28121. }
  28122. else if (this._vrDisplay && this._vrDisplay.isPresenting) {
  28123. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction, this._vrDisplay);
  28124. }
  28125. else {
  28126. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  28127. }
  28128. }
  28129. else {
  28130. this._renderingQueueLaunched = false;
  28131. }
  28132. };
  28133. /**
  28134. * Register and execute a render loop. The engine can have more than one render function
  28135. * @param renderFunction defines the function to continuously execute
  28136. */
  28137. Engine.prototype.runRenderLoop = function (renderFunction) {
  28138. if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
  28139. return;
  28140. }
  28141. this._activeRenderLoops.push(renderFunction);
  28142. if (!this._renderingQueueLaunched) {
  28143. this._renderingQueueLaunched = true;
  28144. this._bindedRenderFunction = this._renderLoop.bind(this);
  28145. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  28146. }
  28147. };
  28148. /**
  28149. * Toggle full screen mode
  28150. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28151. */
  28152. Engine.prototype.switchFullscreen = function (requestPointerLock) {
  28153. if (this.isFullscreen) {
  28154. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].ExitFullscreen();
  28155. }
  28156. else {
  28157. this._pointerLockRequested = requestPointerLock;
  28158. if (this._renderingCanvas) {
  28159. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].RequestFullscreen(this._renderingCanvas);
  28160. }
  28161. }
  28162. };
  28163. /**
  28164. * Clear the current render buffer or the current render target (if any is set up)
  28165. * @param color defines the color to use
  28166. * @param backBuffer defines if the back buffer must be cleared
  28167. * @param depth defines if the depth buffer must be cleared
  28168. * @param stencil defines if the stencil buffer must be cleared
  28169. */
  28170. Engine.prototype.clear = function (color, backBuffer, depth, stencil) {
  28171. if (stencil === void 0) { stencil = false; }
  28172. this.applyStates();
  28173. var mode = 0;
  28174. if (backBuffer && color) {
  28175. this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
  28176. mode |= this._gl.COLOR_BUFFER_BIT;
  28177. }
  28178. if (depth) {
  28179. this._gl.clearDepth(1.0);
  28180. mode |= this._gl.DEPTH_BUFFER_BIT;
  28181. }
  28182. if (stencil) {
  28183. this._gl.clearStencil(0);
  28184. mode |= this._gl.STENCIL_BUFFER_BIT;
  28185. }
  28186. this._gl.clear(mode);
  28187. };
  28188. /**
  28189. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28190. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28191. * @param y defines the y-coordinate of the corner of the clear rectangle
  28192. * @param width defines the width of the clear rectangle
  28193. * @param height defines the height of the clear rectangle
  28194. * @param clearColor defines the clear color
  28195. */
  28196. Engine.prototype.scissorClear = function (x, y, width, height, clearColor) {
  28197. this.enableScissor(x, y, width, height);
  28198. this.clear(clearColor, true, true, true);
  28199. this.disableScissor();
  28200. };
  28201. /**
  28202. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28203. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28204. * @param y defines the y-coordinate of the corner of the clear rectangle
  28205. * @param width defines the width of the clear rectangle
  28206. * @param height defines the height of the clear rectangle
  28207. */
  28208. Engine.prototype.enableScissor = function (x, y, width, height) {
  28209. var gl = this._gl;
  28210. // Change state
  28211. gl.enable(gl.SCISSOR_TEST);
  28212. gl.scissor(x, y, width, height);
  28213. };
  28214. /**
  28215. * Disable previously set scissor test rectangle
  28216. */
  28217. Engine.prototype.disableScissor = function () {
  28218. var gl = this._gl;
  28219. gl.disable(gl.SCISSOR_TEST);
  28220. };
  28221. /** @hidden */
  28222. Engine.prototype._viewport = function (x, y, width, height) {
  28223. if (x !== this._viewportCached.x ||
  28224. y !== this._viewportCached.y ||
  28225. width !== this._viewportCached.z ||
  28226. height !== this._viewportCached.w) {
  28227. this._viewportCached.x = x;
  28228. this._viewportCached.y = y;
  28229. this._viewportCached.z = width;
  28230. this._viewportCached.w = height;
  28231. this._gl.viewport(x, y, width, height);
  28232. }
  28233. };
  28234. /**
  28235. * Set the WebGL's viewport
  28236. * @param viewport defines the viewport element to be used
  28237. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28238. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28239. */
  28240. Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  28241. var width = requiredWidth || this.getRenderWidth();
  28242. var height = requiredHeight || this.getRenderHeight();
  28243. var x = viewport.x || 0;
  28244. var y = viewport.y || 0;
  28245. this._cachedViewport = viewport;
  28246. this._viewport(x * width, y * height, width * viewport.width, height * viewport.height);
  28247. };
  28248. /**
  28249. * Directly set the WebGL Viewport
  28250. * @param x defines the x coordinate of the viewport (in screen space)
  28251. * @param y defines the y coordinate of the viewport (in screen space)
  28252. * @param width defines the width of the viewport (in screen space)
  28253. * @param height defines the height of the viewport (in screen space)
  28254. * @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
  28255. */
  28256. Engine.prototype.setDirectViewport = function (x, y, width, height) {
  28257. var currentViewport = this._cachedViewport;
  28258. this._cachedViewport = null;
  28259. this._viewport(x, y, width, height);
  28260. return currentViewport;
  28261. };
  28262. /**
  28263. * Begin a new frame
  28264. */
  28265. Engine.prototype.beginFrame = function () {
  28266. this.onBeginFrameObservable.notifyObservers(this);
  28267. this._measureFps();
  28268. };
  28269. /**
  28270. * Enf the current frame
  28271. */
  28272. Engine.prototype.endFrame = function () {
  28273. // Force a flush in case we are using a bad OS.
  28274. if (this._badOS) {
  28275. this.flushFramebuffer();
  28276. }
  28277. // Submit frame to the vr device, if enabled
  28278. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  28279. // TODO: We should only submit the frame if we read frameData successfully.
  28280. this._vrDisplay.submitFrame();
  28281. }
  28282. this.onEndFrameObservable.notifyObservers(this);
  28283. };
  28284. /**
  28285. * Resize the view according to the canvas' size
  28286. */
  28287. Engine.prototype.resize = function () {
  28288. // We're not resizing the size of the canvas while in VR mode & presenting
  28289. if (!(this._vrDisplay && this._vrDisplay.isPresenting)) {
  28290. var width = this._renderingCanvas ? this._renderingCanvas.clientWidth : window.innerWidth;
  28291. var height = this._renderingCanvas ? this._renderingCanvas.clientHeight : window.innerHeight;
  28292. this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);
  28293. }
  28294. };
  28295. /**
  28296. * Force a specific size of the canvas
  28297. * @param width defines the new canvas' width
  28298. * @param height defines the new canvas' height
  28299. */
  28300. Engine.prototype.setSize = function (width, height) {
  28301. if (!this._renderingCanvas) {
  28302. return;
  28303. }
  28304. if (this._renderingCanvas.width === width && this._renderingCanvas.height === height) {
  28305. return;
  28306. }
  28307. this._renderingCanvas.width = width;
  28308. this._renderingCanvas.height = height;
  28309. for (var index = 0; index < this.scenes.length; index++) {
  28310. var scene = this.scenes[index];
  28311. for (var camIndex = 0; camIndex < scene.cameras.length; camIndex++) {
  28312. var cam = scene.cameras[camIndex];
  28313. cam._currentRenderId = 0;
  28314. }
  28315. }
  28316. if (this.onResizeObservable.hasObservers) {
  28317. this.onResizeObservable.notifyObservers(this);
  28318. }
  28319. };
  28320. // WebVR functions
  28321. /**
  28322. * Gets a boolean indicating if a webVR device was detected
  28323. * @returns true if a webVR device was detected
  28324. */
  28325. Engine.prototype.isVRDevicePresent = function () {
  28326. return !!this._vrDisplay;
  28327. };
  28328. /**
  28329. * Gets the current webVR device
  28330. * @returns the current webVR device (or null)
  28331. */
  28332. Engine.prototype.getVRDevice = function () {
  28333. return this._vrDisplay;
  28334. };
  28335. /**
  28336. * Initializes a webVR display and starts listening to display change events
  28337. * The onVRDisplayChangedObservable will be notified upon these changes
  28338. * @returns The onVRDisplayChangedObservable
  28339. */
  28340. Engine.prototype.initWebVR = function () {
  28341. this.initWebVRAsync();
  28342. return this.onVRDisplayChangedObservable;
  28343. };
  28344. /**
  28345. * Initializes a webVR display and starts listening to display change events
  28346. * The onVRDisplayChangedObservable will be notified upon these changes
  28347. * @returns A promise containing a VRDisplay and if vr is supported
  28348. */
  28349. Engine.prototype.initWebVRAsync = function () {
  28350. var _this = this;
  28351. var notifyObservers = function () {
  28352. var eventArgs = {
  28353. vrDisplay: _this._vrDisplay,
  28354. vrSupported: _this._vrSupported
  28355. };
  28356. _this.onVRDisplayChangedObservable.notifyObservers(eventArgs);
  28357. _this._webVRInitPromise = new Promise(function (res) { res(eventArgs); });
  28358. };
  28359. if (!this._onVrDisplayConnect) {
  28360. this._onVrDisplayConnect = function (event) {
  28361. _this._vrDisplay = event.display;
  28362. notifyObservers();
  28363. };
  28364. this._onVrDisplayDisconnect = function () {
  28365. _this._vrDisplay.cancelAnimationFrame(_this._frameHandler);
  28366. _this._vrDisplay = undefined;
  28367. _this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(_this._bindedRenderFunction);
  28368. notifyObservers();
  28369. };
  28370. this._onVrDisplayPresentChange = function () {
  28371. _this._vrExclusivePointerMode = _this._vrDisplay && _this._vrDisplay.isPresenting;
  28372. };
  28373. window.addEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  28374. window.addEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  28375. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  28376. }
  28377. this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync();
  28378. this._webVRInitPromise.then(notifyObservers);
  28379. return this._webVRInitPromise;
  28380. };
  28381. /**
  28382. * Call this function to switch to webVR mode
  28383. * Will do nothing if webVR is not supported or if there is no webVR device
  28384. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28385. */
  28386. Engine.prototype.enableVR = function () {
  28387. var _this = this;
  28388. if (this._vrDisplay && !this._vrDisplay.isPresenting) {
  28389. var onResolved = function () {
  28390. _this.onVRRequestPresentComplete.notifyObservers(true);
  28391. _this._onVRFullScreenTriggered();
  28392. };
  28393. var onRejected = function () {
  28394. _this.onVRRequestPresentComplete.notifyObservers(false);
  28395. };
  28396. this.onVRRequestPresentStart.notifyObservers(this);
  28397. this._vrDisplay.requestPresent([{ source: this.getRenderingCanvas() }]).then(onResolved).catch(onRejected);
  28398. }
  28399. };
  28400. /**
  28401. * Call this function to leave webVR mode
  28402. * Will do nothing if webVR is not supported or if there is no webVR device
  28403. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28404. */
  28405. Engine.prototype.disableVR = function () {
  28406. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  28407. this._vrDisplay.exitPresent().then(this._onVRFullScreenTriggered).catch(this._onVRFullScreenTriggered);
  28408. }
  28409. };
  28410. Engine.prototype._getVRDisplaysAsync = function () {
  28411. var _this = this;
  28412. return new Promise(function (res) {
  28413. if (navigator.getVRDisplays) {
  28414. navigator.getVRDisplays().then(function (devices) {
  28415. _this._vrSupported = true;
  28416. // note that devices may actually be an empty array. This is fine;
  28417. // we expect this._vrDisplay to be undefined in this case.
  28418. _this._vrDisplay = devices[0];
  28419. res({
  28420. vrDisplay: _this._vrDisplay,
  28421. vrSupported: _this._vrSupported
  28422. });
  28423. });
  28424. }
  28425. else {
  28426. _this._vrDisplay = undefined;
  28427. _this._vrSupported = false;
  28428. res({
  28429. vrDisplay: _this._vrDisplay,
  28430. vrSupported: _this._vrSupported
  28431. });
  28432. }
  28433. });
  28434. };
  28435. /**
  28436. * Binds the frame buffer to the specified texture.
  28437. * @param texture The texture to render to or null for the default canvas
  28438. * @param faceIndex The face of the texture to render to in case of cube texture
  28439. * @param requiredWidth The width of the target to render to
  28440. * @param requiredHeight The height of the target to render to
  28441. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28442. * @param depthStencilTexture The depth stencil texture to use to render
  28443. * @param lodLevel defines le lod level to bind to the frame buffer
  28444. */
  28445. Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport, depthStencilTexture, lodLevel) {
  28446. if (lodLevel === void 0) { lodLevel = 0; }
  28447. if (this._currentRenderTarget) {
  28448. this.unBindFramebuffer(this._currentRenderTarget);
  28449. }
  28450. this._currentRenderTarget = texture;
  28451. this.bindUnboundFramebuffer(texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer);
  28452. var gl = this._gl;
  28453. if (texture.isCube) {
  28454. if (faceIndex === undefined) {
  28455. faceIndex = 0;
  28456. }
  28457. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, lodLevel);
  28458. if (depthStencilTexture) {
  28459. if (depthStencilTexture._generateStencilBuffer) {
  28460. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  28461. }
  28462. else {
  28463. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  28464. }
  28465. }
  28466. }
  28467. if (this._cachedViewport && !forceFullscreenViewport) {
  28468. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  28469. }
  28470. else {
  28471. if (!requiredWidth) {
  28472. requiredWidth = texture.width;
  28473. if (lodLevel) {
  28474. requiredWidth = requiredWidth / Math.pow(2, lodLevel);
  28475. }
  28476. }
  28477. if (!requiredHeight) {
  28478. requiredHeight = texture.height;
  28479. if (lodLevel) {
  28480. requiredHeight = requiredHeight / Math.pow(2, lodLevel);
  28481. }
  28482. }
  28483. this._viewport(0, 0, requiredWidth, requiredHeight);
  28484. }
  28485. this.wipeCaches();
  28486. };
  28487. Engine.prototype.bindUnboundFramebuffer = function (framebuffer) {
  28488. if (this._currentFramebuffer !== framebuffer) {
  28489. this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer);
  28490. this._currentFramebuffer = framebuffer;
  28491. }
  28492. };
  28493. /**
  28494. * Unbind the current render target texture from the webGL context
  28495. * @param texture defines the render target texture to unbind
  28496. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28497. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28498. */
  28499. Engine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  28500. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  28501. this._currentRenderTarget = null;
  28502. // If MSAA, we need to bitblt back to main texture
  28503. var gl = this._gl;
  28504. if (texture._MSAAFramebuffer) {
  28505. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, texture._MSAAFramebuffer);
  28506. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, texture._framebuffer);
  28507. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  28508. }
  28509. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  28510. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  28511. gl.generateMipmap(gl.TEXTURE_2D);
  28512. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  28513. }
  28514. if (onBeforeUnbind) {
  28515. if (texture._MSAAFramebuffer) {
  28516. // Bind the correct framebuffer
  28517. this.bindUnboundFramebuffer(texture._framebuffer);
  28518. }
  28519. onBeforeUnbind();
  28520. }
  28521. this.bindUnboundFramebuffer(null);
  28522. };
  28523. /**
  28524. * Unbind a list of render target textures from the webGL context
  28525. * This is used only when drawBuffer extension or webGL2 are active
  28526. * @param textures defines the render target textures to unbind
  28527. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28528. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28529. */
  28530. Engine.prototype.unBindMultiColorAttachmentFramebuffer = function (textures, disableGenerateMipMaps, onBeforeUnbind) {
  28531. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  28532. this._currentRenderTarget = null;
  28533. // If MSAA, we need to bitblt back to main texture
  28534. var gl = this._gl;
  28535. if (textures[0]._MSAAFramebuffer) {
  28536. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, textures[0]._MSAAFramebuffer);
  28537. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, textures[0]._framebuffer);
  28538. var attachments = textures[0]._attachments;
  28539. if (!attachments) {
  28540. attachments = new Array(textures.length);
  28541. textures[0]._attachments = attachments;
  28542. }
  28543. for (var i = 0; i < textures.length; i++) {
  28544. var texture = textures[i];
  28545. for (var j = 0; j < attachments.length; j++) {
  28546. attachments[j] = gl.NONE;
  28547. }
  28548. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  28549. gl.readBuffer(attachments[i]);
  28550. gl.drawBuffers(attachments);
  28551. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  28552. }
  28553. for (var i = 0; i < attachments.length; i++) {
  28554. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  28555. }
  28556. gl.drawBuffers(attachments);
  28557. }
  28558. for (var i = 0; i < textures.length; i++) {
  28559. var texture = textures[i];
  28560. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  28561. this._bindTextureDirectly(gl.TEXTURE_2D, texture);
  28562. gl.generateMipmap(gl.TEXTURE_2D);
  28563. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  28564. }
  28565. }
  28566. if (onBeforeUnbind) {
  28567. if (textures[0]._MSAAFramebuffer) {
  28568. // Bind the correct framebuffer
  28569. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  28570. }
  28571. onBeforeUnbind();
  28572. }
  28573. this.bindUnboundFramebuffer(null);
  28574. };
  28575. /**
  28576. * Force the mipmap generation for the given render target texture
  28577. * @param texture defines the render target texture to use
  28578. */
  28579. Engine.prototype.generateMipMapsForCubemap = function (texture) {
  28580. if (texture.generateMipMaps) {
  28581. var gl = this._gl;
  28582. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  28583. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  28584. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  28585. }
  28586. };
  28587. /**
  28588. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28589. */
  28590. Engine.prototype.flushFramebuffer = function () {
  28591. this._gl.flush();
  28592. };
  28593. /**
  28594. * Unbind the current render target and bind the default framebuffer
  28595. */
  28596. Engine.prototype.restoreDefaultFramebuffer = function () {
  28597. if (this._currentRenderTarget) {
  28598. this.unBindFramebuffer(this._currentRenderTarget);
  28599. }
  28600. else {
  28601. this.bindUnboundFramebuffer(null);
  28602. }
  28603. if (this._cachedViewport) {
  28604. this.setViewport(this._cachedViewport);
  28605. }
  28606. this.wipeCaches();
  28607. };
  28608. // UBOs
  28609. /**
  28610. * Create an uniform buffer
  28611. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28612. * @param elements defines the content of the uniform buffer
  28613. * @returns the webGL uniform buffer
  28614. */
  28615. Engine.prototype.createUniformBuffer = function (elements) {
  28616. var ubo = this._gl.createBuffer();
  28617. if (!ubo) {
  28618. throw new Error("Unable to create uniform buffer");
  28619. }
  28620. this.bindUniformBuffer(ubo);
  28621. if (elements instanceof Float32Array) {
  28622. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.STATIC_DRAW);
  28623. }
  28624. else {
  28625. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.STATIC_DRAW);
  28626. }
  28627. this.bindUniformBuffer(null);
  28628. ubo.references = 1;
  28629. return ubo;
  28630. };
  28631. /**
  28632. * Create a dynamic uniform buffer
  28633. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28634. * @param elements defines the content of the uniform buffer
  28635. * @returns the webGL uniform buffer
  28636. */
  28637. Engine.prototype.createDynamicUniformBuffer = function (elements) {
  28638. var ubo = this._gl.createBuffer();
  28639. if (!ubo) {
  28640. throw new Error("Unable to create dynamic uniform buffer");
  28641. }
  28642. this.bindUniformBuffer(ubo);
  28643. if (elements instanceof Float32Array) {
  28644. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.DYNAMIC_DRAW);
  28645. }
  28646. else {
  28647. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.DYNAMIC_DRAW);
  28648. }
  28649. this.bindUniformBuffer(null);
  28650. ubo.references = 1;
  28651. return ubo;
  28652. };
  28653. /**
  28654. * Update an existing uniform buffer
  28655. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28656. * @param uniformBuffer defines the target uniform buffer
  28657. * @param elements defines the content to update
  28658. * @param offset defines the offset in the uniform buffer where update should start
  28659. * @param count defines the size of the data to update
  28660. */
  28661. Engine.prototype.updateUniformBuffer = function (uniformBuffer, elements, offset, count) {
  28662. this.bindUniformBuffer(uniformBuffer);
  28663. if (offset === undefined) {
  28664. offset = 0;
  28665. }
  28666. if (count === undefined) {
  28667. if (elements instanceof Float32Array) {
  28668. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, elements);
  28669. }
  28670. else {
  28671. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, new Float32Array(elements));
  28672. }
  28673. }
  28674. else {
  28675. if (elements instanceof Float32Array) {
  28676. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, elements.subarray(offset, offset + count));
  28677. }
  28678. else {
  28679. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(elements).subarray(offset, offset + count));
  28680. }
  28681. }
  28682. this.bindUniformBuffer(null);
  28683. };
  28684. // VBOs
  28685. Engine.prototype._resetVertexBufferBinding = function () {
  28686. this.bindArrayBuffer(null);
  28687. this._cachedVertexBuffers = null;
  28688. };
  28689. /**
  28690. * Creates a vertex buffer
  28691. * @param data the data for the vertex buffer
  28692. * @returns the new WebGL static buffer
  28693. */
  28694. Engine.prototype.createVertexBuffer = function (data) {
  28695. var vbo = this._gl.createBuffer();
  28696. if (!vbo) {
  28697. throw new Error("Unable to create vertex buffer");
  28698. }
  28699. this.bindArrayBuffer(vbo);
  28700. if (data instanceof Array) {
  28701. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.STATIC_DRAW);
  28702. }
  28703. else {
  28704. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.STATIC_DRAW);
  28705. }
  28706. this._resetVertexBufferBinding();
  28707. vbo.references = 1;
  28708. return vbo;
  28709. };
  28710. /**
  28711. * Creates a dynamic vertex buffer
  28712. * @param data the data for the dynamic vertex buffer
  28713. * @returns the new WebGL dynamic buffer
  28714. */
  28715. Engine.prototype.createDynamicVertexBuffer = function (data) {
  28716. var vbo = this._gl.createBuffer();
  28717. if (!vbo) {
  28718. throw new Error("Unable to create dynamic vertex buffer");
  28719. }
  28720. this.bindArrayBuffer(vbo);
  28721. if (data instanceof Array) {
  28722. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.DYNAMIC_DRAW);
  28723. }
  28724. else {
  28725. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.DYNAMIC_DRAW);
  28726. }
  28727. this._resetVertexBufferBinding();
  28728. vbo.references = 1;
  28729. return vbo;
  28730. };
  28731. /**
  28732. * Update a dynamic index buffer
  28733. * @param indexBuffer defines the target index buffer
  28734. * @param indices defines the data to update
  28735. * @param offset defines the offset in the target index buffer where update should start
  28736. */
  28737. Engine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  28738. if (offset === void 0) { offset = 0; }
  28739. // Force cache update
  28740. this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
  28741. this.bindIndexBuffer(indexBuffer);
  28742. var arrayBuffer;
  28743. if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
  28744. arrayBuffer = indices;
  28745. }
  28746. else {
  28747. arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  28748. }
  28749. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
  28750. this._resetIndexBufferBinding();
  28751. };
  28752. /**
  28753. * Updates a dynamic vertex buffer.
  28754. * @param vertexBuffer the vertex buffer to update
  28755. * @param data the data used to update the vertex buffer
  28756. * @param byteOffset the byte offset of the data
  28757. * @param byteLength the byte length of the data
  28758. */
  28759. Engine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, data, byteOffset, byteLength) {
  28760. this.bindArrayBuffer(vertexBuffer);
  28761. if (byteOffset === undefined) {
  28762. byteOffset = 0;
  28763. }
  28764. if (byteLength === undefined) {
  28765. if (data instanceof Array) {
  28766. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data));
  28767. }
  28768. else {
  28769. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);
  28770. }
  28771. }
  28772. else {
  28773. if (data instanceof Array) {
  28774. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(data).subarray(byteOffset, byteOffset + byteLength));
  28775. }
  28776. else {
  28777. if (data instanceof ArrayBuffer) {
  28778. data = new Uint8Array(data, byteOffset, byteLength);
  28779. }
  28780. else {
  28781. data = new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength);
  28782. }
  28783. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  28784. }
  28785. }
  28786. this._resetVertexBufferBinding();
  28787. };
  28788. Engine.prototype._resetIndexBufferBinding = function () {
  28789. this.bindIndexBuffer(null);
  28790. this._cachedIndexBuffer = null;
  28791. };
  28792. /**
  28793. * Creates a new index buffer
  28794. * @param indices defines the content of the index buffer
  28795. * @param updatable defines if the index buffer must be updatable
  28796. * @returns a new webGL buffer
  28797. */
  28798. Engine.prototype.createIndexBuffer = function (indices, updatable) {
  28799. var vbo = this._gl.createBuffer();
  28800. if (!vbo) {
  28801. throw new Error("Unable to create index buffer");
  28802. }
  28803. this.bindIndexBuffer(vbo);
  28804. // Check for 32 bits indices
  28805. var arrayBuffer;
  28806. var need32Bits = false;
  28807. if (indices instanceof Uint16Array) {
  28808. arrayBuffer = indices;
  28809. }
  28810. else {
  28811. //check 32 bit support
  28812. if (this._caps.uintIndices) {
  28813. if (indices instanceof Uint32Array) {
  28814. arrayBuffer = indices;
  28815. need32Bits = true;
  28816. }
  28817. else {
  28818. //number[] or Int32Array, check if 32 bit is necessary
  28819. for (var index = 0; index < indices.length; index++) {
  28820. if (indices[index] > 65535) {
  28821. need32Bits = true;
  28822. break;
  28823. }
  28824. }
  28825. arrayBuffer = need32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  28826. }
  28827. }
  28828. else {
  28829. //no 32 bit support, force conversion to 16 bit (values greater 16 bit are lost)
  28830. arrayBuffer = new Uint16Array(indices);
  28831. }
  28832. }
  28833. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
  28834. this._resetIndexBufferBinding();
  28835. vbo.references = 1;
  28836. vbo.is32Bits = need32Bits;
  28837. return vbo;
  28838. };
  28839. /**
  28840. * Bind a webGL buffer to the webGL context
  28841. * @param buffer defines the buffer to bind
  28842. */
  28843. Engine.prototype.bindArrayBuffer = function (buffer) {
  28844. if (!this._vaoRecordInProgress) {
  28845. this._unbindVertexArrayObject();
  28846. }
  28847. this.bindBuffer(buffer, this._gl.ARRAY_BUFFER);
  28848. };
  28849. /**
  28850. * Bind an uniform buffer to the current webGL context
  28851. * @param buffer defines the buffer to bind
  28852. */
  28853. Engine.prototype.bindUniformBuffer = function (buffer) {
  28854. this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, buffer);
  28855. };
  28856. /**
  28857. * Bind a buffer to the current webGL context at a given location
  28858. * @param buffer defines the buffer to bind
  28859. * @param location defines the index where to bind the buffer
  28860. */
  28861. Engine.prototype.bindUniformBufferBase = function (buffer, location) {
  28862. this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, location, buffer);
  28863. };
  28864. /**
  28865. * Bind a specific block at a given index in a specific shader program
  28866. * @param shaderProgram defines the shader program
  28867. * @param blockName defines the block name
  28868. * @param index defines the index where to bind the block
  28869. */
  28870. Engine.prototype.bindUniformBlock = function (shaderProgram, blockName, index) {
  28871. var uniformLocation = this._gl.getUniformBlockIndex(shaderProgram, blockName);
  28872. this._gl.uniformBlockBinding(shaderProgram, uniformLocation, index);
  28873. };
  28874. Engine.prototype.bindIndexBuffer = function (buffer) {
  28875. if (!this._vaoRecordInProgress) {
  28876. this._unbindVertexArrayObject();
  28877. }
  28878. this.bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);
  28879. };
  28880. Engine.prototype.bindBuffer = function (buffer, target) {
  28881. if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {
  28882. this._gl.bindBuffer(target, buffer);
  28883. this._currentBoundBuffer[target] = buffer;
  28884. }
  28885. };
  28886. /**
  28887. * update the bound buffer with the given data
  28888. * @param data defines the data to update
  28889. */
  28890. Engine.prototype.updateArrayBuffer = function (data) {
  28891. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  28892. };
  28893. Engine.prototype._vertexAttribPointer = function (buffer, indx, size, type, normalized, stride, offset) {
  28894. var pointer = this._currentBufferPointers[indx];
  28895. var changed = false;
  28896. if (!pointer.active) {
  28897. changed = true;
  28898. pointer.active = true;
  28899. pointer.index = indx;
  28900. pointer.size = size;
  28901. pointer.type = type;
  28902. pointer.normalized = normalized;
  28903. pointer.stride = stride;
  28904. pointer.offset = offset;
  28905. pointer.buffer = buffer;
  28906. }
  28907. else {
  28908. if (pointer.buffer !== buffer) {
  28909. pointer.buffer = buffer;
  28910. changed = true;
  28911. }
  28912. if (pointer.size !== size) {
  28913. pointer.size = size;
  28914. changed = true;
  28915. }
  28916. if (pointer.type !== type) {
  28917. pointer.type = type;
  28918. changed = true;
  28919. }
  28920. if (pointer.normalized !== normalized) {
  28921. pointer.normalized = normalized;
  28922. changed = true;
  28923. }
  28924. if (pointer.stride !== stride) {
  28925. pointer.stride = stride;
  28926. changed = true;
  28927. }
  28928. if (pointer.offset !== offset) {
  28929. pointer.offset = offset;
  28930. changed = true;
  28931. }
  28932. }
  28933. if (changed || this._vaoRecordInProgress) {
  28934. this.bindArrayBuffer(buffer);
  28935. this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);
  28936. }
  28937. };
  28938. Engine.prototype._bindIndexBufferWithCache = function (indexBuffer) {
  28939. if (indexBuffer == null) {
  28940. return;
  28941. }
  28942. if (this._cachedIndexBuffer !== indexBuffer) {
  28943. this._cachedIndexBuffer = indexBuffer;
  28944. this.bindIndexBuffer(indexBuffer);
  28945. this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
  28946. }
  28947. };
  28948. Engine.prototype._bindVertexBuffersAttributes = function (vertexBuffers, effect) {
  28949. var attributes = effect.getAttributesNames();
  28950. if (!this._vaoRecordInProgress) {
  28951. this._unbindVertexArrayObject();
  28952. }
  28953. this.unbindAllAttributes();
  28954. for (var index = 0; index < attributes.length; index++) {
  28955. var order = effect.getAttributeLocation(index);
  28956. if (order >= 0) {
  28957. var vertexBuffer = vertexBuffers[attributes[index]];
  28958. if (!vertexBuffer) {
  28959. continue;
  28960. }
  28961. this._gl.enableVertexAttribArray(order);
  28962. if (!this._vaoRecordInProgress) {
  28963. this._vertexAttribArraysEnabled[order] = true;
  28964. }
  28965. var buffer = vertexBuffer.getBuffer();
  28966. if (buffer) {
  28967. this._vertexAttribPointer(buffer, order, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized, vertexBuffer.byteStride, vertexBuffer.byteOffset);
  28968. if (vertexBuffer.getIsInstanced()) {
  28969. this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());
  28970. if (!this._vaoRecordInProgress) {
  28971. this._currentInstanceLocations.push(order);
  28972. this._currentInstanceBuffers.push(buffer);
  28973. }
  28974. }
  28975. }
  28976. }
  28977. }
  28978. };
  28979. /**
  28980. * Records a vertex array object
  28981. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28982. * @param vertexBuffers defines the list of vertex buffers to store
  28983. * @param indexBuffer defines the index buffer to store
  28984. * @param effect defines the effect to store
  28985. * @returns the new vertex array object
  28986. */
  28987. Engine.prototype.recordVertexArrayObject = function (vertexBuffers, indexBuffer, effect) {
  28988. var vao = this._gl.createVertexArray();
  28989. this._vaoRecordInProgress = true;
  28990. this._gl.bindVertexArray(vao);
  28991. this._mustWipeVertexAttributes = true;
  28992. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  28993. this.bindIndexBuffer(indexBuffer);
  28994. this._vaoRecordInProgress = false;
  28995. this._gl.bindVertexArray(null);
  28996. return vao;
  28997. };
  28998. /**
  28999. * Bind a specific vertex array object
  29000. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29001. * @param vertexArrayObject defines the vertex array object to bind
  29002. * @param indexBuffer defines the index buffer to bind
  29003. */
  29004. Engine.prototype.bindVertexArrayObject = function (vertexArrayObject, indexBuffer) {
  29005. if (this._cachedVertexArrayObject !== vertexArrayObject) {
  29006. this._cachedVertexArrayObject = vertexArrayObject;
  29007. this._gl.bindVertexArray(vertexArrayObject);
  29008. this._cachedVertexBuffers = null;
  29009. this._cachedIndexBuffer = null;
  29010. this._uintIndicesCurrentlySet = indexBuffer != null && indexBuffer.is32Bits;
  29011. this._mustWipeVertexAttributes = true;
  29012. }
  29013. };
  29014. /**
  29015. * Bind webGl buffers directly to the webGL context
  29016. * @param vertexBuffer defines the vertex buffer to bind
  29017. * @param indexBuffer defines the index buffer to bind
  29018. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29019. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29020. * @param effect defines the effect associated with the vertex buffer
  29021. */
  29022. Engine.prototype.bindBuffersDirectly = function (vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {
  29023. if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
  29024. this._cachedVertexBuffers = vertexBuffer;
  29025. this._cachedEffectForVertexBuffers = effect;
  29026. var attributesCount = effect.getAttributesCount();
  29027. this._unbindVertexArrayObject();
  29028. this.unbindAllAttributes();
  29029. var offset = 0;
  29030. for (var index = 0; index < attributesCount; index++) {
  29031. if (index < vertexDeclaration.length) {
  29032. var order = effect.getAttributeLocation(index);
  29033. if (order >= 0) {
  29034. this._gl.enableVertexAttribArray(order);
  29035. this._vertexAttribArraysEnabled[order] = true;
  29036. this._vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);
  29037. }
  29038. offset += vertexDeclaration[index] * 4;
  29039. }
  29040. }
  29041. }
  29042. this._bindIndexBufferWithCache(indexBuffer);
  29043. };
  29044. Engine.prototype._unbindVertexArrayObject = function () {
  29045. if (!this._cachedVertexArrayObject) {
  29046. return;
  29047. }
  29048. this._cachedVertexArrayObject = null;
  29049. this._gl.bindVertexArray(null);
  29050. };
  29051. /**
  29052. * Bind a list of vertex buffers to the webGL context
  29053. * @param vertexBuffers defines the list of vertex buffers to bind
  29054. * @param indexBuffer defines the index buffer to bind
  29055. * @param effect defines the effect associated with the vertex buffers
  29056. */
  29057. Engine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  29058. if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
  29059. this._cachedVertexBuffers = vertexBuffers;
  29060. this._cachedEffectForVertexBuffers = effect;
  29061. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  29062. }
  29063. this._bindIndexBufferWithCache(indexBuffer);
  29064. };
  29065. /**
  29066. * Unbind all instance attributes
  29067. */
  29068. Engine.prototype.unbindInstanceAttributes = function () {
  29069. var boundBuffer;
  29070. for (var i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {
  29071. var instancesBuffer = this._currentInstanceBuffers[i];
  29072. if (boundBuffer != instancesBuffer && instancesBuffer.references) {
  29073. boundBuffer = instancesBuffer;
  29074. this.bindArrayBuffer(instancesBuffer);
  29075. }
  29076. var offsetLocation = this._currentInstanceLocations[i];
  29077. this._gl.vertexAttribDivisor(offsetLocation, 0);
  29078. }
  29079. this._currentInstanceBuffers.length = 0;
  29080. this._currentInstanceLocations.length = 0;
  29081. };
  29082. /**
  29083. * Release and free the memory of a vertex array object
  29084. * @param vao defines the vertex array object to delete
  29085. */
  29086. Engine.prototype.releaseVertexArrayObject = function (vao) {
  29087. this._gl.deleteVertexArray(vao);
  29088. };
  29089. /** @hidden */
  29090. Engine.prototype._releaseBuffer = function (buffer) {
  29091. buffer.references--;
  29092. if (buffer.references === 0) {
  29093. this._gl.deleteBuffer(buffer);
  29094. return true;
  29095. }
  29096. return false;
  29097. };
  29098. /**
  29099. * Creates a webGL buffer to use with instanciation
  29100. * @param capacity defines the size of the buffer
  29101. * @returns the webGL buffer
  29102. */
  29103. Engine.prototype.createInstancesBuffer = function (capacity) {
  29104. var buffer = this._gl.createBuffer();
  29105. if (!buffer) {
  29106. throw new Error("Unable to create instance buffer");
  29107. }
  29108. buffer.capacity = capacity;
  29109. this.bindArrayBuffer(buffer);
  29110. this._gl.bufferData(this._gl.ARRAY_BUFFER, capacity, this._gl.DYNAMIC_DRAW);
  29111. return buffer;
  29112. };
  29113. /**
  29114. * Delete a webGL buffer used with instanciation
  29115. * @param buffer defines the webGL buffer to delete
  29116. */
  29117. Engine.prototype.deleteInstancesBuffer = function (buffer) {
  29118. this._gl.deleteBuffer(buffer);
  29119. };
  29120. /**
  29121. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29122. * @param instancesBuffer defines the webGL buffer to update and bind
  29123. * @param data defines the data to store in the buffer
  29124. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29125. */
  29126. Engine.prototype.updateAndBindInstancesBuffer = function (instancesBuffer, data, offsetLocations) {
  29127. this.bindArrayBuffer(instancesBuffer);
  29128. if (data) {
  29129. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  29130. }
  29131. if (offsetLocations[0].index !== undefined) {
  29132. var stride = 0;
  29133. for (var i = 0; i < offsetLocations.length; i++) {
  29134. var ai = offsetLocations[i];
  29135. stride += ai.attributeSize * 4;
  29136. }
  29137. for (var i = 0; i < offsetLocations.length; i++) {
  29138. var ai = offsetLocations[i];
  29139. if (!this._vertexAttribArraysEnabled[ai.index]) {
  29140. this._gl.enableVertexAttribArray(ai.index);
  29141. this._vertexAttribArraysEnabled[ai.index] = true;
  29142. }
  29143. this._vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attribyteType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);
  29144. this._gl.vertexAttribDivisor(ai.index, 1);
  29145. this._currentInstanceLocations.push(ai.index);
  29146. this._currentInstanceBuffers.push(instancesBuffer);
  29147. }
  29148. }
  29149. else {
  29150. for (var index = 0; index < 4; index++) {
  29151. var offsetLocation = offsetLocations[index];
  29152. if (!this._vertexAttribArraysEnabled[offsetLocation]) {
  29153. this._gl.enableVertexAttribArray(offsetLocation);
  29154. this._vertexAttribArraysEnabled[offsetLocation] = true;
  29155. }
  29156. this._vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);
  29157. this._gl.vertexAttribDivisor(offsetLocation, 1);
  29158. this._currentInstanceLocations.push(offsetLocation);
  29159. this._currentInstanceBuffers.push(instancesBuffer);
  29160. }
  29161. }
  29162. };
  29163. /**
  29164. * Apply all cached states (depth, culling, stencil and alpha)
  29165. */
  29166. Engine.prototype.applyStates = function () {
  29167. this._depthCullingState.apply(this._gl);
  29168. this._stencilState.apply(this._gl);
  29169. this._alphaState.apply(this._gl);
  29170. };
  29171. /**
  29172. * Send a draw order
  29173. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29174. * @param indexStart defines the starting index
  29175. * @param indexCount defines the number of index to draw
  29176. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29177. */
  29178. Engine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  29179. this.drawElementsType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, indexStart, indexCount, instancesCount);
  29180. };
  29181. /**
  29182. * Draw a list of points
  29183. * @param verticesStart defines the index of first vertex to draw
  29184. * @param verticesCount defines the count of vertices to draw
  29185. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29186. */
  29187. Engine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {
  29188. this.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode, verticesStart, verticesCount, instancesCount);
  29189. };
  29190. /**
  29191. * Draw a list of unindexed primitives
  29192. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29193. * @param verticesStart defines the index of first vertex to draw
  29194. * @param verticesCount defines the count of vertices to draw
  29195. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29196. */
  29197. Engine.prototype.drawUnIndexed = function (useTriangles, verticesStart, verticesCount, instancesCount) {
  29198. this.drawArraysType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, verticesStart, verticesCount, instancesCount);
  29199. };
  29200. /**
  29201. * Draw a list of indexed primitives
  29202. * @param fillMode defines the primitive to use
  29203. * @param indexStart defines the starting index
  29204. * @param indexCount defines the number of index to draw
  29205. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29206. */
  29207. Engine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  29208. // Apply states
  29209. this.applyStates();
  29210. this._drawCalls.addCount(1, false);
  29211. // Render
  29212. var drawMode = this._drawMode(fillMode);
  29213. var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
  29214. var mult = this._uintIndicesCurrentlySet ? 4 : 2;
  29215. if (instancesCount) {
  29216. this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);
  29217. }
  29218. else {
  29219. this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);
  29220. }
  29221. };
  29222. /**
  29223. * Draw a list of unindexed primitives
  29224. * @param fillMode defines the primitive to use
  29225. * @param verticesStart defines the index of first vertex to draw
  29226. * @param verticesCount defines the count of vertices to draw
  29227. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29228. */
  29229. Engine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  29230. // Apply states
  29231. this.applyStates();
  29232. this._drawCalls.addCount(1, false);
  29233. var drawMode = this._drawMode(fillMode);
  29234. if (instancesCount) {
  29235. this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);
  29236. }
  29237. else {
  29238. this._gl.drawArrays(drawMode, verticesStart, verticesCount);
  29239. }
  29240. };
  29241. Engine.prototype._drawMode = function (fillMode) {
  29242. switch (fillMode) {
  29243. // Triangle views
  29244. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode:
  29245. return this._gl.TRIANGLES;
  29246. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode:
  29247. return this._gl.POINTS;
  29248. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode:
  29249. return this._gl.LINES;
  29250. // Draw modes
  29251. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointListDrawMode:
  29252. return this._gl.POINTS;
  29253. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineListDrawMode:
  29254. return this._gl.LINES;
  29255. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineLoopDrawMode:
  29256. return this._gl.LINE_LOOP;
  29257. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineStripDrawMode:
  29258. return this._gl.LINE_STRIP;
  29259. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleStripDrawMode:
  29260. return this._gl.TRIANGLE_STRIP;
  29261. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFanDrawMode:
  29262. return this._gl.TRIANGLE_FAN;
  29263. default:
  29264. return this._gl.TRIANGLES;
  29265. }
  29266. };
  29267. // Shaders
  29268. /** @hidden */
  29269. Engine.prototype._releaseEffect = function (effect) {
  29270. if (this._compiledEffects[effect._key]) {
  29271. delete this._compiledEffects[effect._key];
  29272. this._deleteProgram(effect.getProgram());
  29273. }
  29274. };
  29275. /** @hidden */
  29276. Engine.prototype._deleteProgram = function (program) {
  29277. if (program) {
  29278. program.__SPECTOR_rebuildProgram = null;
  29279. if (program.transformFeedback) {
  29280. this.deleteTransformFeedback(program.transformFeedback);
  29281. program.transformFeedback = null;
  29282. }
  29283. this._gl.deleteProgram(program);
  29284. }
  29285. };
  29286. /**
  29287. * Create a new effect (used to store vertex/fragment shaders)
  29288. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29289. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29290. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29291. * @param samplers defines an array of string used to represent textures
  29292. * @param defines defines the string containing the defines to use to compile the shaders
  29293. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29294. * @param onCompiled defines a function to call when the effect creation is successful
  29295. * @param onError defines a function to call when the effect creation has failed
  29296. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29297. * @returns the new Effect
  29298. */
  29299. Engine.prototype.createEffect = function (baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters) {
  29300. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  29301. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  29302. var name = vertex + "+" + fragment + "@" + (defines ? defines : attributesNamesOrOptions.defines);
  29303. if (this._compiledEffects[name]) {
  29304. var compiledEffect = this._compiledEffects[name];
  29305. if (onCompiled && compiledEffect.isReady()) {
  29306. onCompiled(compiledEffect);
  29307. }
  29308. return compiledEffect;
  29309. }
  29310. var effect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"](baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters);
  29311. effect._key = name;
  29312. this._compiledEffects[name] = effect;
  29313. return effect;
  29314. };
  29315. Engine.prototype._compileShader = function (source, type, defines, shaderVersion) {
  29316. return this._compileRawShader(shaderVersion + (defines ? defines + "\n" : "") + source, type);
  29317. };
  29318. Engine.prototype._compileRawShader = function (source, type) {
  29319. var gl = this._gl;
  29320. var shader = gl.createShader(type === "vertex" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
  29321. if (!shader) {
  29322. throw new Error("Something went wrong while compile the shader.");
  29323. }
  29324. gl.shaderSource(shader, source);
  29325. gl.compileShader(shader);
  29326. if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
  29327. var log = gl.getShaderInfoLog(shader);
  29328. if (log) {
  29329. throw new Error(log);
  29330. }
  29331. }
  29332. return shader;
  29333. };
  29334. /**
  29335. * Directly creates a webGL program
  29336. * @param vertexCode defines the vertex shader code to use
  29337. * @param fragmentCode defines the fragment shader code to use
  29338. * @param context defines the webGL context to use (if not set, the current one will be used)
  29339. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29340. * @returns the new webGL program
  29341. */
  29342. Engine.prototype.createRawShaderProgram = function (vertexCode, fragmentCode, context, transformFeedbackVaryings) {
  29343. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  29344. context = context || this._gl;
  29345. var vertexShader = this._compileRawShader(vertexCode, "vertex");
  29346. var fragmentShader = this._compileRawShader(fragmentCode, "fragment");
  29347. return this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  29348. };
  29349. /**
  29350. * Creates a webGL program
  29351. * @param vertexCode defines the vertex shader code to use
  29352. * @param fragmentCode defines the fragment shader code to use
  29353. * @param defines defines the string containing the defines to use to compile the shaders
  29354. * @param context defines the webGL context to use (if not set, the current one will be used)
  29355. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29356. * @returns the new webGL program
  29357. */
  29358. Engine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context, transformFeedbackVaryings) {
  29359. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  29360. context = context || this._gl;
  29361. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  29362. var shaderVersion = (this._webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  29363. var vertexShader = this._compileShader(vertexCode, "vertex", defines, shaderVersion);
  29364. var fragmentShader = this._compileShader(fragmentCode, "fragment", defines, shaderVersion);
  29365. var program = this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  29366. this.onAfterShaderCompilationObservable.notifyObservers(this);
  29367. return program;
  29368. };
  29369. Engine.prototype._createShaderProgram = function (vertexShader, fragmentShader, context, transformFeedbackVaryings) {
  29370. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  29371. var shaderProgram = context.createProgram();
  29372. if (!shaderProgram) {
  29373. throw new Error("Unable to create program");
  29374. }
  29375. context.attachShader(shaderProgram, vertexShader);
  29376. context.attachShader(shaderProgram, fragmentShader);
  29377. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  29378. var transformFeedback = this.createTransformFeedback();
  29379. this.bindTransformFeedback(transformFeedback);
  29380. this.setTranformFeedbackVaryings(shaderProgram, transformFeedbackVaryings);
  29381. shaderProgram.transformFeedback = transformFeedback;
  29382. }
  29383. context.linkProgram(shaderProgram);
  29384. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  29385. this.bindTransformFeedback(null);
  29386. }
  29387. shaderProgram.context = context;
  29388. shaderProgram.vertexShader = vertexShader;
  29389. shaderProgram.fragmentShader = fragmentShader;
  29390. if (!this._caps.parallelShaderCompile) {
  29391. this._finalizeProgram(shaderProgram);
  29392. }
  29393. else {
  29394. shaderProgram.isParallelCompiled = true;
  29395. }
  29396. return shaderProgram;
  29397. };
  29398. Engine.prototype._finalizeProgram = function (shaderProgram) {
  29399. var context = shaderProgram.context;
  29400. var vertexShader = shaderProgram.vertexShader;
  29401. var fragmentShader = shaderProgram.fragmentShader;
  29402. var linked = context.getProgramParameter(shaderProgram, context.LINK_STATUS);
  29403. if (!linked) {
  29404. var error = context.getProgramInfoLog(shaderProgram);
  29405. if (error) {
  29406. throw new Error(error);
  29407. }
  29408. }
  29409. if (this.validateShaderPrograms) {
  29410. context.validateProgram(shaderProgram);
  29411. var validated = context.getProgramParameter(shaderProgram, context.VALIDATE_STATUS);
  29412. if (!validated) {
  29413. var error = context.getProgramInfoLog(shaderProgram);
  29414. if (error) {
  29415. throw new Error(error);
  29416. }
  29417. }
  29418. }
  29419. context.deleteShader(vertexShader);
  29420. context.deleteShader(fragmentShader);
  29421. shaderProgram.context = undefined;
  29422. shaderProgram.vertexShader = undefined;
  29423. shaderProgram.fragmentShader = undefined;
  29424. if (shaderProgram.onCompiled) {
  29425. shaderProgram.onCompiled();
  29426. shaderProgram.onCompiled = undefined;
  29427. }
  29428. };
  29429. /** @hidden */
  29430. Engine.prototype._isProgramCompiled = function (shaderProgram) {
  29431. if (!shaderProgram.isParallelCompiled) {
  29432. return true;
  29433. }
  29434. if (this._gl.getProgramParameter(shaderProgram, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
  29435. this._finalizeProgram(shaderProgram);
  29436. return true;
  29437. }
  29438. return false;
  29439. };
  29440. /** @hidden */
  29441. Engine.prototype._executeWhenProgramIsCompiled = function (shaderProgram, action) {
  29442. if (!shaderProgram.isParallelCompiled) {
  29443. action();
  29444. return;
  29445. }
  29446. shaderProgram.onCompiled = action;
  29447. };
  29448. /**
  29449. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29450. * @param shaderProgram defines the webGL program to use
  29451. * @param uniformsNames defines the list of uniform names
  29452. * @returns an array of webGL uniform locations
  29453. */
  29454. Engine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  29455. var results = new Array();
  29456. for (var index = 0; index < uniformsNames.length; index++) {
  29457. results.push(this._gl.getUniformLocation(shaderProgram, uniformsNames[index]));
  29458. }
  29459. return results;
  29460. };
  29461. /**
  29462. * Gets the lsit of active attributes for a given webGL program
  29463. * @param shaderProgram defines the webGL program to use
  29464. * @param attributesNames defines the list of attribute names to get
  29465. * @returns an array of indices indicating the offset of each attribute
  29466. */
  29467. Engine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  29468. var results = [];
  29469. for (var index = 0; index < attributesNames.length; index++) {
  29470. try {
  29471. results.push(this._gl.getAttribLocation(shaderProgram, attributesNames[index]));
  29472. }
  29473. catch (e) {
  29474. results.push(-1);
  29475. }
  29476. }
  29477. return results;
  29478. };
  29479. /**
  29480. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29481. * @param effect defines the effect to activate
  29482. */
  29483. Engine.prototype.enableEffect = function (effect) {
  29484. if (!effect || effect === this._currentEffect) {
  29485. return;
  29486. }
  29487. // Use program
  29488. this.bindSamplers(effect);
  29489. this._currentEffect = effect;
  29490. if (effect.onBind) {
  29491. effect.onBind(effect);
  29492. }
  29493. if (effect._onBindObservable) {
  29494. effect._onBindObservable.notifyObservers(effect);
  29495. }
  29496. };
  29497. /**
  29498. * Set the value of an uniform to an array of int32
  29499. * @param uniform defines the webGL uniform location where to store the value
  29500. * @param array defines the array of int32 to store
  29501. */
  29502. Engine.prototype.setIntArray = function (uniform, array) {
  29503. if (!uniform) {
  29504. return;
  29505. }
  29506. this._gl.uniform1iv(uniform, array);
  29507. };
  29508. /**
  29509. * Set the value of an uniform to an array of int32 (stored as vec2)
  29510. * @param uniform defines the webGL uniform location where to store the value
  29511. * @param array defines the array of int32 to store
  29512. */
  29513. Engine.prototype.setIntArray2 = function (uniform, array) {
  29514. if (!uniform || array.length % 2 !== 0) {
  29515. return;
  29516. }
  29517. this._gl.uniform2iv(uniform, array);
  29518. };
  29519. /**
  29520. * Set the value of an uniform to an array of int32 (stored as vec3)
  29521. * @param uniform defines the webGL uniform location where to store the value
  29522. * @param array defines the array of int32 to store
  29523. */
  29524. Engine.prototype.setIntArray3 = function (uniform, array) {
  29525. if (!uniform || array.length % 3 !== 0) {
  29526. return;
  29527. }
  29528. this._gl.uniform3iv(uniform, array);
  29529. };
  29530. /**
  29531. * Set the value of an uniform to an array of int32 (stored as vec4)
  29532. * @param uniform defines the webGL uniform location where to store the value
  29533. * @param array defines the array of int32 to store
  29534. */
  29535. Engine.prototype.setIntArray4 = function (uniform, array) {
  29536. if (!uniform || array.length % 4 !== 0) {
  29537. return;
  29538. }
  29539. this._gl.uniform4iv(uniform, array);
  29540. };
  29541. /**
  29542. * Set the value of an uniform to an array of float32
  29543. * @param uniform defines the webGL uniform location where to store the value
  29544. * @param array defines the array of float32 to store
  29545. */
  29546. Engine.prototype.setFloatArray = function (uniform, array) {
  29547. if (!uniform) {
  29548. return;
  29549. }
  29550. this._gl.uniform1fv(uniform, array);
  29551. };
  29552. /**
  29553. * Set the value of an uniform to an array of float32 (stored as vec2)
  29554. * @param uniform defines the webGL uniform location where to store the value
  29555. * @param array defines the array of float32 to store
  29556. */
  29557. Engine.prototype.setFloatArray2 = function (uniform, array) {
  29558. if (!uniform || array.length % 2 !== 0) {
  29559. return;
  29560. }
  29561. this._gl.uniform2fv(uniform, array);
  29562. };
  29563. /**
  29564. * Set the value of an uniform to an array of float32 (stored as vec3)
  29565. * @param uniform defines the webGL uniform location where to store the value
  29566. * @param array defines the array of float32 to store
  29567. */
  29568. Engine.prototype.setFloatArray3 = function (uniform, array) {
  29569. if (!uniform || array.length % 3 !== 0) {
  29570. return;
  29571. }
  29572. this._gl.uniform3fv(uniform, array);
  29573. };
  29574. /**
  29575. * Set the value of an uniform to an array of float32 (stored as vec4)
  29576. * @param uniform defines the webGL uniform location where to store the value
  29577. * @param array defines the array of float32 to store
  29578. */
  29579. Engine.prototype.setFloatArray4 = function (uniform, array) {
  29580. if (!uniform || array.length % 4 !== 0) {
  29581. return;
  29582. }
  29583. this._gl.uniform4fv(uniform, array);
  29584. };
  29585. /**
  29586. * Set the value of an uniform to an array of number
  29587. * @param uniform defines the webGL uniform location where to store the value
  29588. * @param array defines the array of number to store
  29589. */
  29590. Engine.prototype.setArray = function (uniform, array) {
  29591. if (!uniform) {
  29592. return;
  29593. }
  29594. this._gl.uniform1fv(uniform, array);
  29595. };
  29596. /**
  29597. * Set the value of an uniform to an array of number (stored as vec2)
  29598. * @param uniform defines the webGL uniform location where to store the value
  29599. * @param array defines the array of number to store
  29600. */
  29601. Engine.prototype.setArray2 = function (uniform, array) {
  29602. if (!uniform || array.length % 2 !== 0) {
  29603. return;
  29604. }
  29605. this._gl.uniform2fv(uniform, array);
  29606. };
  29607. /**
  29608. * Set the value of an uniform to an array of number (stored as vec3)
  29609. * @param uniform defines the webGL uniform location where to store the value
  29610. * @param array defines the array of number to store
  29611. */
  29612. Engine.prototype.setArray3 = function (uniform, array) {
  29613. if (!uniform || array.length % 3 !== 0) {
  29614. return;
  29615. }
  29616. this._gl.uniform3fv(uniform, array);
  29617. };
  29618. /**
  29619. * Set the value of an uniform to an array of number (stored as vec4)
  29620. * @param uniform defines the webGL uniform location where to store the value
  29621. * @param array defines the array of number to store
  29622. */
  29623. Engine.prototype.setArray4 = function (uniform, array) {
  29624. if (!uniform || array.length % 4 !== 0) {
  29625. return;
  29626. }
  29627. this._gl.uniform4fv(uniform, array);
  29628. };
  29629. /**
  29630. * Set the value of an uniform to an array of float32 (stored as matrices)
  29631. * @param uniform defines the webGL uniform location where to store the value
  29632. * @param matrices defines the array of float32 to store
  29633. */
  29634. Engine.prototype.setMatrices = function (uniform, matrices) {
  29635. if (!uniform) {
  29636. return;
  29637. }
  29638. this._gl.uniformMatrix4fv(uniform, false, matrices);
  29639. };
  29640. /**
  29641. * Set the value of an uniform to a matrix
  29642. * @param uniform defines the webGL uniform location where to store the value
  29643. * @param matrix defines the matrix to store
  29644. */
  29645. Engine.prototype.setMatrix = function (uniform, matrix) {
  29646. if (!uniform) {
  29647. return;
  29648. }
  29649. this._gl.uniformMatrix4fv(uniform, false, matrix.toArray());
  29650. };
  29651. /**
  29652. * Set the value of an uniform to a matrix (3x3)
  29653. * @param uniform defines the webGL uniform location where to store the value
  29654. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29655. */
  29656. Engine.prototype.setMatrix3x3 = function (uniform, matrix) {
  29657. if (!uniform) {
  29658. return;
  29659. }
  29660. this._gl.uniformMatrix3fv(uniform, false, matrix);
  29661. };
  29662. /**
  29663. * Set the value of an uniform to a matrix (2x2)
  29664. * @param uniform defines the webGL uniform location where to store the value
  29665. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29666. */
  29667. Engine.prototype.setMatrix2x2 = function (uniform, matrix) {
  29668. if (!uniform) {
  29669. return;
  29670. }
  29671. this._gl.uniformMatrix2fv(uniform, false, matrix);
  29672. };
  29673. /**
  29674. * Set the value of an uniform to a number (int)
  29675. * @param uniform defines the webGL uniform location where to store the value
  29676. * @param value defines the int number to store
  29677. */
  29678. Engine.prototype.setInt = function (uniform, value) {
  29679. if (!uniform) {
  29680. return;
  29681. }
  29682. this._gl.uniform1i(uniform, value);
  29683. };
  29684. /**
  29685. * Set the value of an uniform to a number (float)
  29686. * @param uniform defines the webGL uniform location where to store the value
  29687. * @param value defines the float number to store
  29688. */
  29689. Engine.prototype.setFloat = function (uniform, value) {
  29690. if (!uniform) {
  29691. return;
  29692. }
  29693. this._gl.uniform1f(uniform, value);
  29694. };
  29695. /**
  29696. * Set the value of an uniform to a vec2
  29697. * @param uniform defines the webGL uniform location where to store the value
  29698. * @param x defines the 1st component of the value
  29699. * @param y defines the 2nd component of the value
  29700. */
  29701. Engine.prototype.setFloat2 = function (uniform, x, y) {
  29702. if (!uniform) {
  29703. return;
  29704. }
  29705. this._gl.uniform2f(uniform, x, y);
  29706. };
  29707. /**
  29708. * Set the value of an uniform to a vec3
  29709. * @param uniform defines the webGL uniform location where to store the value
  29710. * @param x defines the 1st component of the value
  29711. * @param y defines the 2nd component of the value
  29712. * @param z defines the 3rd component of the value
  29713. */
  29714. Engine.prototype.setFloat3 = function (uniform, x, y, z) {
  29715. if (!uniform) {
  29716. return;
  29717. }
  29718. this._gl.uniform3f(uniform, x, y, z);
  29719. };
  29720. /**
  29721. * Set the value of an uniform to a boolean
  29722. * @param uniform defines the webGL uniform location where to store the value
  29723. * @param bool defines the boolean to store
  29724. */
  29725. Engine.prototype.setBool = function (uniform, bool) {
  29726. if (!uniform) {
  29727. return;
  29728. }
  29729. this._gl.uniform1i(uniform, bool);
  29730. };
  29731. /**
  29732. * Set the value of an uniform to a vec4
  29733. * @param uniform defines the webGL uniform location where to store the value
  29734. * @param x defines the 1st component of the value
  29735. * @param y defines the 2nd component of the value
  29736. * @param z defines the 3rd component of the value
  29737. * @param w defines the 4th component of the value
  29738. */
  29739. Engine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  29740. if (!uniform) {
  29741. return;
  29742. }
  29743. this._gl.uniform4f(uniform, x, y, z, w);
  29744. };
  29745. /**
  29746. * Set the value of an uniform to a Color3
  29747. * @param uniform defines the webGL uniform location where to store the value
  29748. * @param color3 defines the color to store
  29749. */
  29750. Engine.prototype.setColor3 = function (uniform, color3) {
  29751. if (!uniform) {
  29752. return;
  29753. }
  29754. this._gl.uniform3f(uniform, color3.r, color3.g, color3.b);
  29755. };
  29756. /**
  29757. * Set the value of an uniform to a Color3 and an alpha value
  29758. * @param uniform defines the webGL uniform location where to store the value
  29759. * @param color3 defines the color to store
  29760. * @param alpha defines the alpha component to store
  29761. */
  29762. Engine.prototype.setColor4 = function (uniform, color3, alpha) {
  29763. if (!uniform) {
  29764. return;
  29765. }
  29766. this._gl.uniform4f(uniform, color3.r, color3.g, color3.b, alpha);
  29767. };
  29768. /**
  29769. * Sets a Color4 on a uniform variable
  29770. * @param uniform defines the uniform location
  29771. * @param color4 defines the value to be set
  29772. */
  29773. Engine.prototype.setDirectColor4 = function (uniform, color4) {
  29774. if (!uniform) {
  29775. return;
  29776. }
  29777. this._gl.uniform4f(uniform, color4.r, color4.g, color4.b, color4.a);
  29778. };
  29779. // States
  29780. /**
  29781. * Set various states to the webGL context
  29782. * @param culling defines backface culling state
  29783. * @param zOffset defines the value to apply to zOffset (0 by default)
  29784. * @param force defines if states must be applied even if cache is up to date
  29785. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29786. */
  29787. Engine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  29788. if (zOffset === void 0) { zOffset = 0; }
  29789. if (reverseSide === void 0) { reverseSide = false; }
  29790. // Culling
  29791. if (this._depthCullingState.cull !== culling || force) {
  29792. this._depthCullingState.cull = culling;
  29793. }
  29794. // Cull face
  29795. var cullFace = this.cullBackFaces ? this._gl.BACK : this._gl.FRONT;
  29796. if (this._depthCullingState.cullFace !== cullFace || force) {
  29797. this._depthCullingState.cullFace = cullFace;
  29798. }
  29799. // Z offset
  29800. this.setZOffset(zOffset);
  29801. // Front face
  29802. var frontFace = reverseSide ? this._gl.CW : this._gl.CCW;
  29803. if (this._depthCullingState.frontFace !== frontFace || force) {
  29804. this._depthCullingState.frontFace = frontFace;
  29805. }
  29806. };
  29807. /**
  29808. * Set the z offset to apply to current rendering
  29809. * @param value defines the offset to apply
  29810. */
  29811. Engine.prototype.setZOffset = function (value) {
  29812. this._depthCullingState.zOffset = value;
  29813. };
  29814. /**
  29815. * Gets the current value of the zOffset
  29816. * @returns the current zOffset state
  29817. */
  29818. Engine.prototype.getZOffset = function () {
  29819. return this._depthCullingState.zOffset;
  29820. };
  29821. /**
  29822. * Enable or disable depth buffering
  29823. * @param enable defines the state to set
  29824. */
  29825. Engine.prototype.setDepthBuffer = function (enable) {
  29826. this._depthCullingState.depthTest = enable;
  29827. };
  29828. /**
  29829. * Gets a boolean indicating if depth writing is enabled
  29830. * @returns the current depth writing state
  29831. */
  29832. Engine.prototype.getDepthWrite = function () {
  29833. return this._depthCullingState.depthMask;
  29834. };
  29835. /**
  29836. * Enable or disable depth writing
  29837. * @param enable defines the state to set
  29838. */
  29839. Engine.prototype.setDepthWrite = function (enable) {
  29840. this._depthCullingState.depthMask = enable;
  29841. };
  29842. /**
  29843. * Enable or disable color writing
  29844. * @param enable defines the state to set
  29845. */
  29846. Engine.prototype.setColorWrite = function (enable) {
  29847. this._gl.colorMask(enable, enable, enable, enable);
  29848. this._colorWrite = enable;
  29849. };
  29850. /**
  29851. * Gets a boolean indicating if color writing is enabled
  29852. * @returns the current color writing state
  29853. */
  29854. Engine.prototype.getColorWrite = function () {
  29855. return this._colorWrite;
  29856. };
  29857. /**
  29858. * Sets alpha constants used by some alpha blending modes
  29859. * @param r defines the red component
  29860. * @param g defines the green component
  29861. * @param b defines the blue component
  29862. * @param a defines the alpha component
  29863. */
  29864. Engine.prototype.setAlphaConstants = function (r, g, b, a) {
  29865. this._alphaState.setAlphaBlendConstants(r, g, b, a);
  29866. };
  29867. /**
  29868. * Sets the current alpha mode
  29869. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29870. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29871. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29872. */
  29873. Engine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  29874. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  29875. if (this._alphaMode === mode) {
  29876. return;
  29877. }
  29878. switch (mode) {
  29879. case Engine.ALPHA_DISABLE:
  29880. this._alphaState.alphaBlend = false;
  29881. break;
  29882. case Engine.ALPHA_PREMULTIPLIED:
  29883. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  29884. this._alphaState.alphaBlend = true;
  29885. break;
  29886. case Engine.ALPHA_PREMULTIPLIED_PORTERDUFF:
  29887. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  29888. this._alphaState.alphaBlend = true;
  29889. break;
  29890. case Engine.ALPHA_COMBINE:
  29891. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  29892. this._alphaState.alphaBlend = true;
  29893. break;
  29894. case Engine.ALPHA_ONEONE:
  29895. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  29896. this._alphaState.alphaBlend = true;
  29897. break;
  29898. case Engine.ALPHA_ADD:
  29899. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  29900. this._alphaState.alphaBlend = true;
  29901. break;
  29902. case Engine.ALPHA_SUBTRACT:
  29903. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  29904. this._alphaState.alphaBlend = true;
  29905. break;
  29906. case Engine.ALPHA_MULTIPLY:
  29907. this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE);
  29908. this._alphaState.alphaBlend = true;
  29909. break;
  29910. case Engine.ALPHA_MAXIMIZED:
  29911. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  29912. this._alphaState.alphaBlend = true;
  29913. break;
  29914. case Engine.ALPHA_INTERPOLATE:
  29915. this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA);
  29916. this._alphaState.alphaBlend = true;
  29917. break;
  29918. case Engine.ALPHA_SCREENMODE:
  29919. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  29920. this._alphaState.alphaBlend = true;
  29921. break;
  29922. }
  29923. if (!noDepthWriteChange) {
  29924. this.setDepthWrite(mode === Engine.ALPHA_DISABLE);
  29925. }
  29926. this._alphaMode = mode;
  29927. };
  29928. /**
  29929. * Gets the current alpha mode
  29930. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29931. * @returns the current alpha mode
  29932. */
  29933. Engine.prototype.getAlphaMode = function () {
  29934. return this._alphaMode;
  29935. };
  29936. // Textures
  29937. /**
  29938. * Clears the list of texture accessible through engine.
  29939. * This can help preventing texture load conflict due to name collision.
  29940. */
  29941. Engine.prototype.clearInternalTexturesCache = function () {
  29942. this._internalTexturesCache = [];
  29943. };
  29944. /**
  29945. * Force the entire cache to be cleared
  29946. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29947. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29948. */
  29949. Engine.prototype.wipeCaches = function (bruteForce) {
  29950. if (this.preventCacheWipeBetweenFrames && !bruteForce) {
  29951. return;
  29952. }
  29953. this._currentEffect = null;
  29954. this._viewportCached.x = 0;
  29955. this._viewportCached.y = 0;
  29956. this._viewportCached.z = 0;
  29957. this._viewportCached.w = 0;
  29958. if (bruteForce) {
  29959. this.resetTextureCache();
  29960. this._currentProgram = null;
  29961. this._stencilState.reset();
  29962. this._depthCullingState.reset();
  29963. this.setDepthFunctionToLessOrEqual();
  29964. this._alphaState.reset();
  29965. this._unpackFlipYCached = null;
  29966. }
  29967. this._resetVertexBufferBinding();
  29968. this._cachedIndexBuffer = null;
  29969. this._cachedEffectForVertexBuffers = null;
  29970. this._unbindVertexArrayObject();
  29971. this.bindIndexBuffer(null);
  29972. };
  29973. /**
  29974. * Set the compressed texture format to use, based on the formats you have, and the formats
  29975. * supported by the hardware / browser.
  29976. *
  29977. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29978. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29979. * to API arguments needed to compressed textures. This puts the burden on the container
  29980. * generator to house the arcane code for determining these for current & future formats.
  29981. *
  29982. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29983. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29984. *
  29985. * Note: The result of this call is not taken into account when a texture is base64.
  29986. *
  29987. * @param formatsAvailable defines the list of those format families you have created
  29988. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29989. *
  29990. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29991. * @returns The extension selected.
  29992. */
  29993. Engine.prototype.setTextureFormatToUse = function (formatsAvailable) {
  29994. for (var i = 0, len1 = this.texturesSupported.length; i < len1; i++) {
  29995. for (var j = 0, len2 = formatsAvailable.length; j < len2; j++) {
  29996. if (this._texturesSupported[i] === formatsAvailable[j].toLowerCase()) {
  29997. return this._textureFormatInUse = this._texturesSupported[i];
  29998. }
  29999. }
  30000. }
  30001. // actively set format to nothing, to allow this to be called more than once
  30002. // and possibly fail the 2nd time
  30003. this._textureFormatInUse = null;
  30004. return null;
  30005. };
  30006. Engine.prototype._getSamplingParameters = function (samplingMode, generateMipMaps) {
  30007. var gl = this._gl;
  30008. var magFilter = gl.NEAREST;
  30009. var minFilter = gl.NEAREST;
  30010. switch (samplingMode) {
  30011. case Engine.TEXTURE_BILINEAR_SAMPLINGMODE:
  30012. magFilter = gl.LINEAR;
  30013. if (generateMipMaps) {
  30014. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  30015. }
  30016. else {
  30017. minFilter = gl.LINEAR;
  30018. }
  30019. break;
  30020. case Engine.TEXTURE_TRILINEAR_SAMPLINGMODE:
  30021. magFilter = gl.LINEAR;
  30022. if (generateMipMaps) {
  30023. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  30024. }
  30025. else {
  30026. minFilter = gl.LINEAR;
  30027. }
  30028. break;
  30029. case Engine.TEXTURE_NEAREST_SAMPLINGMODE:
  30030. magFilter = gl.NEAREST;
  30031. if (generateMipMaps) {
  30032. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  30033. }
  30034. else {
  30035. minFilter = gl.NEAREST;
  30036. }
  30037. break;
  30038. case Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
  30039. magFilter = gl.NEAREST;
  30040. if (generateMipMaps) {
  30041. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  30042. }
  30043. else {
  30044. minFilter = gl.NEAREST;
  30045. }
  30046. break;
  30047. case Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
  30048. magFilter = gl.NEAREST;
  30049. if (generateMipMaps) {
  30050. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  30051. }
  30052. else {
  30053. minFilter = gl.LINEAR;
  30054. }
  30055. break;
  30056. case Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
  30057. magFilter = gl.NEAREST;
  30058. if (generateMipMaps) {
  30059. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  30060. }
  30061. else {
  30062. minFilter = gl.LINEAR;
  30063. }
  30064. break;
  30065. case Engine.TEXTURE_NEAREST_LINEAR:
  30066. magFilter = gl.NEAREST;
  30067. minFilter = gl.LINEAR;
  30068. break;
  30069. case Engine.TEXTURE_NEAREST_NEAREST:
  30070. magFilter = gl.NEAREST;
  30071. minFilter = gl.NEAREST;
  30072. break;
  30073. case Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
  30074. magFilter = gl.LINEAR;
  30075. if (generateMipMaps) {
  30076. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  30077. }
  30078. else {
  30079. minFilter = gl.NEAREST;
  30080. }
  30081. break;
  30082. case Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
  30083. magFilter = gl.LINEAR;
  30084. if (generateMipMaps) {
  30085. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  30086. }
  30087. else {
  30088. minFilter = gl.NEAREST;
  30089. }
  30090. break;
  30091. case Engine.TEXTURE_LINEAR_LINEAR:
  30092. magFilter = gl.LINEAR;
  30093. minFilter = gl.LINEAR;
  30094. break;
  30095. case Engine.TEXTURE_LINEAR_NEAREST:
  30096. magFilter = gl.LINEAR;
  30097. minFilter = gl.NEAREST;
  30098. break;
  30099. }
  30100. return {
  30101. min: minFilter,
  30102. mag: magFilter
  30103. };
  30104. };
  30105. Engine.prototype._partialLoadImg = function (url, index, loadedImages, scene, onfinish, onErrorCallBack) {
  30106. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  30107. var img;
  30108. var onload = function () {
  30109. loadedImages[index] = img;
  30110. loadedImages._internalCount++;
  30111. if (scene) {
  30112. scene._removePendingData(img);
  30113. }
  30114. if (loadedImages._internalCount === 6) {
  30115. onfinish(loadedImages);
  30116. }
  30117. };
  30118. var onerror = function (message, exception) {
  30119. if (scene) {
  30120. scene._removePendingData(img);
  30121. }
  30122. if (onErrorCallBack) {
  30123. onErrorCallBack(message, exception);
  30124. }
  30125. };
  30126. img = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onerror, scene ? scene.offlineProvider : null);
  30127. if (scene) {
  30128. scene._addPendingData(img);
  30129. }
  30130. };
  30131. Engine.prototype._cascadeLoadImgs = function (scene, onfinish, files, onError) {
  30132. if (onError === void 0) { onError = null; }
  30133. var loadedImages = [];
  30134. loadedImages._internalCount = 0;
  30135. for (var index = 0; index < 6; index++) {
  30136. this._partialLoadImg(files[index], index, loadedImages, scene, onfinish, onError);
  30137. }
  30138. };
  30139. /** @hidden */
  30140. Engine.prototype._createTexture = function () {
  30141. var texture = this._gl.createTexture();
  30142. if (!texture) {
  30143. throw new Error("Unable to create texture");
  30144. }
  30145. return texture;
  30146. };
  30147. /**
  30148. * Usually called from Texture.ts.
  30149. * Passed information to create a WebGLTexture
  30150. * @param urlArg defines a value which contains one of the following:
  30151. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30152. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30153. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30154. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30155. * @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)
  30156. * @param scene needed for loading to the correct scene
  30157. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30158. * @param onLoad optional callback to be called upon successful completion
  30159. * @param onError optional callback to be called upon failure
  30160. * @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
  30161. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30162. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30163. * @param forcedExtension defines the extension to use to pick the right loader
  30164. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30165. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30166. */
  30167. Engine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, excludeLoaders) {
  30168. var _this = this;
  30169. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  30170. if (onLoad === void 0) { onLoad = null; }
  30171. if (onError === void 0) { onError = null; }
  30172. if (buffer === void 0) { buffer = null; }
  30173. if (fallback === void 0) { fallback = null; }
  30174. if (format === void 0) { format = null; }
  30175. if (forcedExtension === void 0) { forcedExtension = null; }
  30176. if (excludeLoaders === void 0) { excludeLoaders = []; }
  30177. var url = String(urlArg); // assign a new string, so that the original is still available in case of fallback
  30178. var fromData = url.substr(0, 5) === "data:";
  30179. var fromBlob = url.substr(0, 5) === "blob:";
  30180. var isBase64 = fromData && url.indexOf(";base64,") !== -1;
  30181. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_URL);
  30182. // establish the file extension, if possible
  30183. var lastDot = url.lastIndexOf('.');
  30184. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? url.substring(lastDot).toLowerCase() : "");
  30185. var loader = null;
  30186. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  30187. var availableLoader = _a[_i];
  30188. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, isBase64, buffer ? true : false)) {
  30189. loader = availableLoader;
  30190. break;
  30191. }
  30192. }
  30193. if (loader) {
  30194. url = loader.transformUrl(url, this._textureFormatInUse);
  30195. }
  30196. if (scene) {
  30197. scene._addPendingData(texture);
  30198. }
  30199. texture.url = url;
  30200. texture.generateMipMaps = !noMipmap;
  30201. texture.samplingMode = samplingMode;
  30202. texture.invertY = invertY;
  30203. if (!this._doNotHandleContextLost) {
  30204. // Keep a link to the buffer only if we plan to handle context lost
  30205. texture._buffer = buffer;
  30206. }
  30207. var onLoadObserver = null;
  30208. if (onLoad && !fallback) {
  30209. onLoadObserver = texture.onLoadedObservable.add(onLoad);
  30210. }
  30211. if (!fallback) {
  30212. this._internalTexturesCache.push(texture);
  30213. }
  30214. var onInternalError = function (message, exception) {
  30215. if (scene) {
  30216. scene._removePendingData(texture);
  30217. }
  30218. var customFallback = false;
  30219. if (loader) {
  30220. var fallbackUrl = loader.getFallbackTextureUrl(url, _this._textureFormatInUse);
  30221. if (fallbackUrl) {
  30222. // Add Back
  30223. customFallback = true;
  30224. excludeLoaders.push(loader);
  30225. _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");
  30226. _this.createTexture(urlArg, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture, undefined, undefined, excludeLoaders);
  30227. }
  30228. }
  30229. if (!customFallback) {
  30230. if (onLoadObserver) {
  30231. texture.onLoadedObservable.remove(onLoadObserver);
  30232. }
  30233. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].UseFallbackTexture) {
  30234. _this.createTexture(_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].fallbackTexture, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture);
  30235. }
  30236. }
  30237. if (onError) {
  30238. onError(message || "Unknown error", exception);
  30239. }
  30240. };
  30241. // processing for non-image formats
  30242. if (loader) {
  30243. var callback = function (data) {
  30244. loader.loadData(data, texture, function (width, height, loadMipmap, isCompressed, done, loadFailed) {
  30245. if (loadFailed) {
  30246. onInternalError("TextureLoader failed to load data");
  30247. }
  30248. else {
  30249. _this._prepareWebGLTexture(texture, scene, width, height, texture.invertY, !loadMipmap, isCompressed, function () {
  30250. done();
  30251. return false;
  30252. }, samplingMode);
  30253. }
  30254. });
  30255. };
  30256. if (!buffer) {
  30257. this._loadFile(url, callback, undefined, scene ? scene.offlineProvider : undefined, true, function (request, exception) {
  30258. onInternalError("Unable to load " + (request ? request.responseURL : url, exception));
  30259. });
  30260. }
  30261. else {
  30262. callback(buffer);
  30263. }
  30264. }
  30265. else {
  30266. var onload = function (img) {
  30267. if (fromBlob && !_this._doNotHandleContextLost) {
  30268. // We need to store the image if we need to rebuild the texture
  30269. // in case of a webgl context lost
  30270. texture._buffer = img;
  30271. }
  30272. _this._prepareWebGLTexture(texture, scene, img.width, img.height, texture.invertY, noMipmap, false, function (potWidth, potHeight, continuationCallback) {
  30273. var gl = _this._gl;
  30274. var isPot = (img.width === potWidth && img.height === potHeight);
  30275. var internalFormat = format ? _this._getInternalFormat(format) : ((extension === ".jpg") ? gl.RGB : gl.RGBA);
  30276. if (isPot) {
  30277. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  30278. return false;
  30279. }
  30280. var maxTextureSize = _this._caps.maxTextureSize;
  30281. if (img.width > maxTextureSize || img.height > maxTextureSize || Engine._RescalePostProcessFactory === null) {
  30282. _this._prepareWorkingCanvas();
  30283. if (!_this._workingCanvas || !_this._workingContext) {
  30284. return false;
  30285. }
  30286. _this._workingCanvas.width = potWidth;
  30287. _this._workingCanvas.height = potHeight;
  30288. _this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);
  30289. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  30290. texture.width = potWidth;
  30291. texture.height = potHeight;
  30292. return false;
  30293. }
  30294. else {
  30295. // Using shaders when possible to rescale because canvas.drawImage is lossy
  30296. var source_1 = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_TEMP);
  30297. _this._bindTextureDirectly(gl.TEXTURE_2D, source_1, true);
  30298. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  30299. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  30300. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  30301. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  30302. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  30303. _this._rescaleTexture(source_1, texture, scene, internalFormat, function () {
  30304. _this._releaseTexture(source_1);
  30305. _this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  30306. continuationCallback();
  30307. });
  30308. }
  30309. return true;
  30310. }, samplingMode);
  30311. };
  30312. if (!fromData || isBase64) {
  30313. if (buffer instanceof HTMLImageElement) {
  30314. onload(buffer);
  30315. }
  30316. else {
  30317. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onInternalError, scene ? scene.offlineProvider : null);
  30318. }
  30319. }
  30320. else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || buffer instanceof Blob) {
  30321. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null);
  30322. }
  30323. else {
  30324. onload(buffer);
  30325. }
  30326. }
  30327. return texture;
  30328. };
  30329. Engine.prototype._rescaleTexture = function (source, destination, scene, internalFormat, onComplete) {
  30330. var _this = this;
  30331. var rtt = this.createRenderTargetTexture({
  30332. width: destination.width,
  30333. height: destination.height,
  30334. }, {
  30335. generateMipMaps: false,
  30336. type: Engine.TEXTURETYPE_UNSIGNED_INT,
  30337. samplingMode: Engine.TEXTURE_BILINEAR_SAMPLINGMODE,
  30338. generateDepthBuffer: false,
  30339. generateStencilBuffer: false
  30340. });
  30341. if (!this._rescalePostProcess && Engine._RescalePostProcessFactory) {
  30342. this._rescalePostProcess = Engine._RescalePostProcessFactory(this);
  30343. }
  30344. this._rescalePostProcess.getEffect().executeWhenCompiled(function () {
  30345. _this._rescalePostProcess.onApply = function (effect) {
  30346. effect._bindTexture("textureSampler", source);
  30347. };
  30348. var hostingScene = scene;
  30349. if (!hostingScene) {
  30350. hostingScene = _this.scenes[_this.scenes.length - 1];
  30351. }
  30352. hostingScene.postProcessManager.directRender([_this._rescalePostProcess], rtt, true);
  30353. _this._bindTextureDirectly(_this._gl.TEXTURE_2D, destination, true);
  30354. _this._gl.copyTexImage2D(_this._gl.TEXTURE_2D, 0, internalFormat, 0, 0, destination.width, destination.height, 0);
  30355. _this.unBindFramebuffer(rtt);
  30356. _this._releaseTexture(rtt);
  30357. if (onComplete) {
  30358. onComplete();
  30359. }
  30360. });
  30361. };
  30362. /**
  30363. * Update a raw texture
  30364. * @param texture defines the texture to update
  30365. * @param data defines the data to store in the texture
  30366. * @param format defines the format of the data
  30367. * @param invertY defines if data must be stored with Y axis inverted
  30368. * @param compression defines the compression used (null by default)
  30369. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30370. */
  30371. Engine.prototype.updateRawTexture = function (texture, data, format, invertY, compression, type) {
  30372. if (compression === void 0) { compression = null; }
  30373. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  30374. if (!texture) {
  30375. return;
  30376. }
  30377. // babylon's internalSizedFomat but gl's texImage2D internalFormat
  30378. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type, format);
  30379. // babylon's internalFormat but gl's texImage2D format
  30380. var internalFormat = this._getInternalFormat(format);
  30381. var textureType = this._getWebGLTextureType(type);
  30382. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  30383. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  30384. if (!this._doNotHandleContextLost) {
  30385. texture._bufferView = data;
  30386. texture.format = format;
  30387. texture.type = type;
  30388. texture.invertY = invertY;
  30389. texture._compression = compression;
  30390. }
  30391. if (texture.width % 4 !== 0) {
  30392. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  30393. }
  30394. if (compression && data) {
  30395. this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, 0, data);
  30396. }
  30397. else {
  30398. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, data);
  30399. }
  30400. if (texture.generateMipMaps) {
  30401. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  30402. }
  30403. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  30404. // this.resetTextureCache();
  30405. texture.isReady = true;
  30406. };
  30407. /**
  30408. * Creates a raw texture
  30409. * @param data defines the data to store in the texture
  30410. * @param width defines the width of the texture
  30411. * @param height defines the height of the texture
  30412. * @param format defines the format of the data
  30413. * @param generateMipMaps defines if the engine should generate the mip levels
  30414. * @param invertY defines if data must be stored with Y axis inverted
  30415. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30416. * @param compression defines the compression used (null by default)
  30417. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30418. * @returns the raw texture inside an InternalTexture
  30419. */
  30420. Engine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {
  30421. if (compression === void 0) { compression = null; }
  30422. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  30423. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW);
  30424. texture.baseWidth = width;
  30425. texture.baseHeight = height;
  30426. texture.width = width;
  30427. texture.height = height;
  30428. texture.format = format;
  30429. texture.generateMipMaps = generateMipMaps;
  30430. texture.samplingMode = samplingMode;
  30431. texture.invertY = invertY;
  30432. texture._compression = compression;
  30433. texture.type = type;
  30434. if (!this._doNotHandleContextLost) {
  30435. texture._bufferView = data;
  30436. }
  30437. this.updateRawTexture(texture, data, format, invertY, compression, type);
  30438. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  30439. // Filters
  30440. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  30441. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  30442. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  30443. if (generateMipMaps) {
  30444. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  30445. }
  30446. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  30447. this._internalTexturesCache.push(texture);
  30448. return texture;
  30449. };
  30450. /** @hidden */
  30451. Engine.prototype._unpackFlipY = function (value) {
  30452. if (this._unpackFlipYCached !== value) {
  30453. this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);
  30454. if (this.enableUnpackFlipYCached) {
  30455. this._unpackFlipYCached = value;
  30456. }
  30457. }
  30458. };
  30459. /** @hidden */
  30460. Engine.prototype._getUnpackAlignement = function () {
  30461. return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);
  30462. };
  30463. /**
  30464. * Creates a dynamic texture
  30465. * @param width defines the width of the texture
  30466. * @param height defines the height of the texture
  30467. * @param generateMipMaps defines if the engine should generate the mip levels
  30468. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30469. * @returns the dynamic texture inside an InternalTexture
  30470. */
  30471. Engine.prototype.createDynamicTexture = function (width, height, generateMipMaps, samplingMode) {
  30472. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DYNAMIC);
  30473. texture.baseWidth = width;
  30474. texture.baseHeight = height;
  30475. if (generateMipMaps) {
  30476. width = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, this._caps.maxTextureSize) : width;
  30477. height = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, this._caps.maxTextureSize) : height;
  30478. }
  30479. // this.resetTextureCache();
  30480. texture.width = width;
  30481. texture.height = height;
  30482. texture.isReady = false;
  30483. texture.generateMipMaps = generateMipMaps;
  30484. texture.samplingMode = samplingMode;
  30485. this.updateTextureSamplingMode(samplingMode, texture);
  30486. this._internalTexturesCache.push(texture);
  30487. return texture;
  30488. };
  30489. /**
  30490. * Update the sampling mode of a given texture
  30491. * @param samplingMode defines the required sampling mode
  30492. * @param texture defines the texture to update
  30493. */
  30494. Engine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  30495. var filters = this._getSamplingParameters(samplingMode, texture.generateMipMaps);
  30496. if (texture.isCube) {
  30497. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  30498. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MIN_FILTER, filters.min);
  30499. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  30500. }
  30501. else if (texture.is3D) {
  30502. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  30503. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  30504. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  30505. }
  30506. else {
  30507. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  30508. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  30509. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  30510. }
  30511. texture.samplingMode = samplingMode;
  30512. };
  30513. /**
  30514. * Update the content of a dynamic texture
  30515. * @param texture defines the texture to update
  30516. * @param canvas defines the canvas containing the source
  30517. * @param invertY defines if data must be stored with Y axis inverted
  30518. * @param premulAlpha defines if alpha is stored as premultiplied
  30519. * @param format defines the format of the data
  30520. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  30521. */
  30522. Engine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format, forceBindTexture) {
  30523. if (premulAlpha === void 0) { premulAlpha = false; }
  30524. if (forceBindTexture === void 0) { forceBindTexture = false; }
  30525. if (!texture) {
  30526. return;
  30527. }
  30528. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true, forceBindTexture);
  30529. this._unpackFlipY(invertY);
  30530. if (premulAlpha) {
  30531. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
  30532. }
  30533. var internalFormat = format ? this._getInternalFormat(format) : this._gl.RGBA;
  30534. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, internalFormat, this._gl.UNSIGNED_BYTE, canvas);
  30535. if (texture.generateMipMaps) {
  30536. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  30537. }
  30538. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  30539. if (premulAlpha) {
  30540. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
  30541. }
  30542. texture.isReady = true;
  30543. };
  30544. /**
  30545. * Update a video texture
  30546. * @param texture defines the texture to update
  30547. * @param video defines the video element to use
  30548. * @param invertY defines if data must be stored with Y axis inverted
  30549. */
  30550. Engine.prototype.updateVideoTexture = function (texture, video, invertY) {
  30551. if (!texture || texture._isDisabled) {
  30552. return;
  30553. }
  30554. var wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  30555. this._unpackFlipY(!invertY); // Video are upside down by default
  30556. try {
  30557. // Testing video texture support
  30558. if (this._videoTextureSupported === undefined) {
  30559. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  30560. if (this._gl.getError() !== 0) {
  30561. this._videoTextureSupported = false;
  30562. }
  30563. else {
  30564. this._videoTextureSupported = true;
  30565. }
  30566. }
  30567. // Copy video through the current working canvas if video texture is not supported
  30568. if (!this._videoTextureSupported) {
  30569. if (!texture._workingCanvas) {
  30570. texture._workingCanvas = document.createElement("canvas");
  30571. var context = texture._workingCanvas.getContext("2d");
  30572. if (!context) {
  30573. throw new Error("Unable to get 2d context");
  30574. }
  30575. texture._workingContext = context;
  30576. texture._workingCanvas.width = texture.width;
  30577. texture._workingCanvas.height = texture.height;
  30578. }
  30579. texture._workingContext.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);
  30580. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, texture._workingCanvas);
  30581. }
  30582. else {
  30583. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  30584. }
  30585. if (texture.generateMipMaps) {
  30586. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  30587. }
  30588. if (!wasPreviouslyBound) {
  30589. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  30590. }
  30591. // this.resetTextureCache();
  30592. texture.isReady = true;
  30593. }
  30594. catch (ex) {
  30595. // Something unexpected
  30596. // Let's disable the texture
  30597. texture._isDisabled = true;
  30598. }
  30599. };
  30600. /**
  30601. * Updates a depth texture Comparison Mode and Function.
  30602. * If the comparison Function is equal to 0, the mode will be set to none.
  30603. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30604. * @param texture The texture to set the comparison function for
  30605. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30606. */
  30607. Engine.prototype.updateTextureComparisonFunction = function (texture, comparisonFunction) {
  30608. if (this.webGLVersion === 1) {
  30609. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("WebGL 1 does not support texture comparison.");
  30610. return;
  30611. }
  30612. var gl = this._gl;
  30613. if (texture.isCube) {
  30614. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  30615. if (comparisonFunction === 0) {
  30616. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  30617. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  30618. }
  30619. else {
  30620. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  30621. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  30622. }
  30623. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  30624. }
  30625. else {
  30626. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  30627. if (comparisonFunction === 0) {
  30628. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  30629. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  30630. }
  30631. else {
  30632. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  30633. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  30634. }
  30635. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  30636. }
  30637. texture._comparisonFunction = comparisonFunction;
  30638. };
  30639. Engine.prototype._setupDepthStencilTexture = function (internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction) {
  30640. var width = size.width || size;
  30641. var height = size.height || size;
  30642. internalTexture.baseWidth = width;
  30643. internalTexture.baseHeight = height;
  30644. internalTexture.width = width;
  30645. internalTexture.height = height;
  30646. internalTexture.isReady = true;
  30647. internalTexture.samples = 1;
  30648. internalTexture.generateMipMaps = false;
  30649. internalTexture._generateDepthBuffer = true;
  30650. internalTexture._generateStencilBuffer = generateStencil;
  30651. internalTexture.samplingMode = bilinearFiltering ? Engine.TEXTURE_BILINEAR_SAMPLINGMODE : Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  30652. internalTexture.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  30653. internalTexture._comparisonFunction = comparisonFunction;
  30654. var gl = this._gl;
  30655. var target = internalTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  30656. var samplingParameters = this._getSamplingParameters(internalTexture.samplingMode, false);
  30657. gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, samplingParameters.mag);
  30658. gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, samplingParameters.min);
  30659. gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  30660. gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  30661. if (comparisonFunction === 0) {
  30662. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  30663. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  30664. }
  30665. else {
  30666. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  30667. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  30668. }
  30669. };
  30670. /**
  30671. * Creates a depth stencil texture.
  30672. * This is only available in WebGL 2 or with the depth texture extension available.
  30673. * @param size The size of face edge in the texture.
  30674. * @param options The options defining the texture.
  30675. * @returns The texture
  30676. */
  30677. Engine.prototype.createDepthStencilTexture = function (size, options) {
  30678. if (options.isCube) {
  30679. var width = size.width || size;
  30680. return this._createDepthStencilCubeTexture(width, options);
  30681. }
  30682. else {
  30683. return this._createDepthStencilTexture(size, options);
  30684. }
  30685. };
  30686. /**
  30687. * Creates a depth stencil texture.
  30688. * This is only available in WebGL 2 or with the depth texture extension available.
  30689. * @param size The size of face edge in the texture.
  30690. * @param options The options defining the texture.
  30691. * @returns The texture
  30692. */
  30693. Engine.prototype._createDepthStencilTexture = function (size, options) {
  30694. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DEPTHTEXTURE);
  30695. if (!this._caps.depthTextureExtension) {
  30696. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth texture is not supported by your browser or hardware.");
  30697. return internalTexture;
  30698. }
  30699. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  30700. var gl = this._gl;
  30701. this._bindTextureDirectly(gl.TEXTURE_2D, internalTexture, true);
  30702. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  30703. if (this.webGLVersion > 1) {
  30704. if (internalOptions.generateStencil) {
  30705. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH24_STENCIL8, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  30706. }
  30707. else {
  30708. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT24, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  30709. }
  30710. }
  30711. else {
  30712. if (internalOptions.generateStencil) {
  30713. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  30714. }
  30715. else {
  30716. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  30717. }
  30718. }
  30719. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  30720. return internalTexture;
  30721. };
  30722. /**
  30723. * Creates a depth stencil cube texture.
  30724. * This is only available in WebGL 2.
  30725. * @param size The size of face edge in the cube texture.
  30726. * @param options The options defining the cube texture.
  30727. * @returns The cube texture
  30728. */
  30729. Engine.prototype._createDepthStencilCubeTexture = function (size, options) {
  30730. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_UNKNOWN);
  30731. internalTexture.isCube = true;
  30732. if (this.webGLVersion === 1) {
  30733. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth cube texture is not supported by WebGL 1.");
  30734. return internalTexture;
  30735. }
  30736. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  30737. var gl = this._gl;
  30738. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, internalTexture, true);
  30739. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  30740. // Create the depth/stencil buffer
  30741. for (var face = 0; face < 6; face++) {
  30742. if (internalOptions.generateStencil) {
  30743. 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);
  30744. }
  30745. else {
  30746. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH_COMPONENT24, size, size, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  30747. }
  30748. }
  30749. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  30750. return internalTexture;
  30751. };
  30752. /**
  30753. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  30754. * @param renderTarget The render target to set the frame buffer for
  30755. */
  30756. Engine.prototype.setFrameBufferDepthStencilTexture = function (renderTarget) {
  30757. // Create the framebuffer
  30758. var internalTexture = renderTarget.getInternalTexture();
  30759. if (!internalTexture || !internalTexture._framebuffer || !renderTarget.depthStencilTexture) {
  30760. return;
  30761. }
  30762. var gl = this._gl;
  30763. var depthStencilTexture = renderTarget.depthStencilTexture;
  30764. this.bindUnboundFramebuffer(internalTexture._framebuffer);
  30765. if (depthStencilTexture.isCube) {
  30766. if (depthStencilTexture._generateStencilBuffer) {
  30767. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  30768. }
  30769. else {
  30770. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  30771. }
  30772. }
  30773. else {
  30774. if (depthStencilTexture._generateStencilBuffer) {
  30775. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  30776. }
  30777. else {
  30778. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  30779. }
  30780. }
  30781. this.bindUnboundFramebuffer(null);
  30782. };
  30783. /**
  30784. * Creates a new render target texture
  30785. * @param size defines the size of the texture
  30786. * @param options defines the options used to create the texture
  30787. * @returns a new render target texture stored in an InternalTexture
  30788. */
  30789. Engine.prototype.createRenderTargetTexture = function (size, options) {
  30790. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__["RenderTargetCreationOptions"]();
  30791. if (options !== undefined && typeof options === "object") {
  30792. fullOptions.generateMipMaps = options.generateMipMaps;
  30793. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  30794. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  30795. fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
  30796. fullOptions.samplingMode = options.samplingMode === undefined ? Engine.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  30797. fullOptions.format = options.format === undefined ? Engine.TEXTUREFORMAT_RGBA : options.format;
  30798. }
  30799. else {
  30800. fullOptions.generateMipMaps = options;
  30801. fullOptions.generateDepthBuffer = true;
  30802. fullOptions.generateStencilBuffer = false;
  30803. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  30804. fullOptions.samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  30805. fullOptions.format = Engine.TEXTUREFORMAT_RGBA;
  30806. }
  30807. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  30808. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  30809. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  30810. }
  30811. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  30812. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  30813. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  30814. }
  30815. var gl = this._gl;
  30816. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  30817. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  30818. var width = size.width || size;
  30819. var height = size.height || size;
  30820. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps ? true : false);
  30821. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  30822. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  30823. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  30824. }
  30825. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  30826. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  30827. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  30828. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  30829. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type, fullOptions.format), width, height, 0, this._getInternalFormat(fullOptions.format), this._getWebGLTextureType(fullOptions.type), null);
  30830. // Create the framebuffer
  30831. var currentFrameBuffer = this._currentFramebuffer;
  30832. var framebuffer = gl.createFramebuffer();
  30833. this.bindUnboundFramebuffer(framebuffer);
  30834. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
  30835. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer ? true : false, fullOptions.generateDepthBuffer, width, height);
  30836. if (fullOptions.generateMipMaps) {
  30837. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  30838. }
  30839. // Unbind
  30840. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  30841. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  30842. this.bindUnboundFramebuffer(currentFrameBuffer);
  30843. texture._framebuffer = framebuffer;
  30844. texture.baseWidth = width;
  30845. texture.baseHeight = height;
  30846. texture.width = width;
  30847. texture.height = height;
  30848. texture.isReady = true;
  30849. texture.samples = 1;
  30850. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  30851. texture.samplingMode = fullOptions.samplingMode;
  30852. texture.type = fullOptions.type;
  30853. texture.format = fullOptions.format;
  30854. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  30855. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  30856. // this.resetTextureCache();
  30857. this._internalTexturesCache.push(texture);
  30858. return texture;
  30859. };
  30860. /**
  30861. * Create a multi render target texture
  30862. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  30863. * @param size defines the size of the texture
  30864. * @param options defines the creation options
  30865. * @returns the cube texture as an InternalTexture
  30866. */
  30867. Engine.prototype.createMultipleRenderTarget = function (size, options) {
  30868. var generateMipMaps = false;
  30869. var generateDepthBuffer = true;
  30870. var generateStencilBuffer = false;
  30871. var generateDepthTexture = false;
  30872. var textureCount = 1;
  30873. var defaultType = Engine.TEXTURETYPE_UNSIGNED_INT;
  30874. var defaultSamplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  30875. var types = new Array();
  30876. var samplingModes = new Array();
  30877. if (options !== undefined) {
  30878. generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;
  30879. generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  30880. generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  30881. generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;
  30882. textureCount = options.textureCount || 1;
  30883. if (options.types) {
  30884. types = options.types;
  30885. }
  30886. if (options.samplingModes) {
  30887. samplingModes = options.samplingModes;
  30888. }
  30889. }
  30890. var gl = this._gl;
  30891. // Create the framebuffer
  30892. var framebuffer = gl.createFramebuffer();
  30893. this.bindUnboundFramebuffer(framebuffer);
  30894. var width = size.width || size;
  30895. var height = size.height || size;
  30896. var textures = [];
  30897. var attachments = [];
  30898. var depthStencilBuffer = this._setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height);
  30899. for (var i = 0; i < textureCount; i++) {
  30900. var samplingMode = samplingModes[i] || defaultSamplingMode;
  30901. var type = types[i] || defaultType;
  30902. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  30903. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  30904. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  30905. }
  30906. else if (type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  30907. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  30908. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  30909. }
  30910. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  30911. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  30912. type = Engine.TEXTURETYPE_UNSIGNED_INT;
  30913. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  30914. }
  30915. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  30916. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  30917. textures.push(texture);
  30918. attachments.push(attachment);
  30919. gl.activeTexture(gl["TEXTURE" + i]);
  30920. gl.bindTexture(gl.TEXTURE_2D, texture._webGLTexture);
  30921. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  30922. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  30923. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  30924. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  30925. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), width, height, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  30926. gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, attachment, gl.TEXTURE_2D, texture._webGLTexture, 0);
  30927. if (generateMipMaps) {
  30928. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  30929. }
  30930. // Unbind
  30931. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  30932. texture._framebuffer = framebuffer;
  30933. texture._depthStencilBuffer = depthStencilBuffer;
  30934. texture.baseWidth = width;
  30935. texture.baseHeight = height;
  30936. texture.width = width;
  30937. texture.height = height;
  30938. texture.isReady = true;
  30939. texture.samples = 1;
  30940. texture.generateMipMaps = generateMipMaps;
  30941. texture.samplingMode = samplingMode;
  30942. texture.type = type;
  30943. texture._generateDepthBuffer = generateDepthBuffer;
  30944. texture._generateStencilBuffer = generateStencilBuffer;
  30945. texture._attachments = attachments;
  30946. this._internalTexturesCache.push(texture);
  30947. }
  30948. if (generateDepthTexture && this._caps.depthTextureExtension) {
  30949. // Depth texture
  30950. var depthTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  30951. gl.activeTexture(gl.TEXTURE0);
  30952. gl.bindTexture(gl.TEXTURE_2D, depthTexture._webGLTexture);
  30953. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  30954. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  30955. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  30956. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  30957. 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);
  30958. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthTexture._webGLTexture, 0);
  30959. depthTexture._framebuffer = framebuffer;
  30960. depthTexture.baseWidth = width;
  30961. depthTexture.baseHeight = height;
  30962. depthTexture.width = width;
  30963. depthTexture.height = height;
  30964. depthTexture.isReady = true;
  30965. depthTexture.samples = 1;
  30966. depthTexture.generateMipMaps = generateMipMaps;
  30967. depthTexture.samplingMode = gl.NEAREST;
  30968. depthTexture._generateDepthBuffer = generateDepthBuffer;
  30969. depthTexture._generateStencilBuffer = generateStencilBuffer;
  30970. textures.push(depthTexture);
  30971. this._internalTexturesCache.push(depthTexture);
  30972. }
  30973. gl.drawBuffers(attachments);
  30974. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  30975. this.bindUnboundFramebuffer(null);
  30976. this.resetTextureCache();
  30977. return textures;
  30978. };
  30979. Engine.prototype._setupFramebufferDepthAttachments = function (generateStencilBuffer, generateDepthBuffer, width, height, samples) {
  30980. if (samples === void 0) { samples = 1; }
  30981. var depthStencilBuffer = null;
  30982. var gl = this._gl;
  30983. // Create the depth/stencil buffer
  30984. if (generateStencilBuffer) {
  30985. depthStencilBuffer = gl.createRenderbuffer();
  30986. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  30987. if (samples > 1) {
  30988. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH24_STENCIL8, width, height);
  30989. }
  30990. else {
  30991. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
  30992. }
  30993. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  30994. }
  30995. else if (generateDepthBuffer) {
  30996. depthStencilBuffer = gl.createRenderbuffer();
  30997. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  30998. if (samples > 1) {
  30999. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH_COMPONENT16, width, height);
  31000. }
  31001. else {
  31002. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
  31003. }
  31004. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  31005. }
  31006. return depthStencilBuffer;
  31007. };
  31008. /**
  31009. * Updates the sample count of a render target texture
  31010. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31011. * @param texture defines the texture to update
  31012. * @param samples defines the sample count to set
  31013. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31014. */
  31015. Engine.prototype.updateRenderTargetTextureSampleCount = function (texture, samples) {
  31016. if (this.webGLVersion < 2 || !texture) {
  31017. return 1;
  31018. }
  31019. if (texture.samples === samples) {
  31020. return samples;
  31021. }
  31022. var gl = this._gl;
  31023. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  31024. // Dispose previous render buffers
  31025. if (texture._depthStencilBuffer) {
  31026. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  31027. texture._depthStencilBuffer = null;
  31028. }
  31029. if (texture._MSAAFramebuffer) {
  31030. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  31031. texture._MSAAFramebuffer = null;
  31032. }
  31033. if (texture._MSAARenderBuffer) {
  31034. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  31035. texture._MSAARenderBuffer = null;
  31036. }
  31037. if (samples > 1) {
  31038. var framebuffer = gl.createFramebuffer();
  31039. if (!framebuffer) {
  31040. throw new Error("Unable to create multi sampled framebuffer");
  31041. }
  31042. texture._MSAAFramebuffer = framebuffer;
  31043. this.bindUnboundFramebuffer(texture._MSAAFramebuffer);
  31044. var colorRenderbuffer = gl.createRenderbuffer();
  31045. if (!colorRenderbuffer) {
  31046. throw new Error("Unable to create multi sampled framebuffer");
  31047. }
  31048. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  31049. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  31050. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorRenderbuffer);
  31051. texture._MSAARenderBuffer = colorRenderbuffer;
  31052. }
  31053. else {
  31054. this.bindUnboundFramebuffer(texture._framebuffer);
  31055. }
  31056. texture.samples = samples;
  31057. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(texture._generateStencilBuffer, texture._generateDepthBuffer, texture.width, texture.height, samples);
  31058. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31059. this.bindUnboundFramebuffer(null);
  31060. return samples;
  31061. };
  31062. /**
  31063. * Update the sample count for a given multiple render target texture
  31064. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31065. * @param textures defines the textures to update
  31066. * @param samples defines the sample count to set
  31067. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31068. */
  31069. Engine.prototype.updateMultipleRenderTargetTextureSampleCount = function (textures, samples) {
  31070. if (this.webGLVersion < 2 || !textures || textures.length == 0) {
  31071. return 1;
  31072. }
  31073. if (textures[0].samples === samples) {
  31074. return samples;
  31075. }
  31076. var gl = this._gl;
  31077. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  31078. // Dispose previous render buffers
  31079. if (textures[0]._depthStencilBuffer) {
  31080. gl.deleteRenderbuffer(textures[0]._depthStencilBuffer);
  31081. textures[0]._depthStencilBuffer = null;
  31082. }
  31083. if (textures[0]._MSAAFramebuffer) {
  31084. gl.deleteFramebuffer(textures[0]._MSAAFramebuffer);
  31085. textures[0]._MSAAFramebuffer = null;
  31086. }
  31087. for (var i = 0; i < textures.length; i++) {
  31088. if (textures[i]._MSAARenderBuffer) {
  31089. gl.deleteRenderbuffer(textures[i]._MSAARenderBuffer);
  31090. textures[i]._MSAARenderBuffer = null;
  31091. }
  31092. }
  31093. if (samples > 1) {
  31094. var framebuffer = gl.createFramebuffer();
  31095. if (!framebuffer) {
  31096. throw new Error("Unable to create multi sampled framebuffer");
  31097. }
  31098. this.bindUnboundFramebuffer(framebuffer);
  31099. var depthStencilBuffer = this._setupFramebufferDepthAttachments(textures[0]._generateStencilBuffer, textures[0]._generateDepthBuffer, textures[0].width, textures[0].height, samples);
  31100. var attachments = [];
  31101. for (var i = 0; i < textures.length; i++) {
  31102. var texture = textures[i];
  31103. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  31104. var colorRenderbuffer = gl.createRenderbuffer();
  31105. if (!colorRenderbuffer) {
  31106. throw new Error("Unable to create multi sampled framebuffer");
  31107. }
  31108. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  31109. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  31110. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, colorRenderbuffer);
  31111. texture._MSAAFramebuffer = framebuffer;
  31112. texture._MSAARenderBuffer = colorRenderbuffer;
  31113. texture.samples = samples;
  31114. texture._depthStencilBuffer = depthStencilBuffer;
  31115. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31116. attachments.push(attachment);
  31117. }
  31118. gl.drawBuffers(attachments);
  31119. }
  31120. else {
  31121. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  31122. }
  31123. this.bindUnboundFramebuffer(null);
  31124. return samples;
  31125. };
  31126. /** @hidden */
  31127. Engine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  31128. if (faceIndex === void 0) { faceIndex = 0; }
  31129. if (lod === void 0) { lod = 0; }
  31130. var gl = this._gl;
  31131. var target = gl.TEXTURE_2D;
  31132. if (texture.isCube) {
  31133. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  31134. }
  31135. this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
  31136. };
  31137. /** @hidden */
  31138. Engine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  31139. if (faceIndex === void 0) { faceIndex = 0; }
  31140. if (lod === void 0) { lod = 0; }
  31141. var gl = this._gl;
  31142. var textureType = this._getWebGLTextureType(texture.type);
  31143. var format = this._getInternalFormat(texture.format);
  31144. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  31145. this._unpackFlipY(texture.invertY);
  31146. var target = gl.TEXTURE_2D;
  31147. if (texture.isCube) {
  31148. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  31149. }
  31150. var lodMaxWidth = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.width));
  31151. var lodMaxHeight = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.height));
  31152. var width = Math.pow(2, Math.max(lodMaxWidth - lod, 0));
  31153. var height = Math.pow(2, Math.max(lodMaxHeight - lod, 0));
  31154. gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);
  31155. };
  31156. /** @hidden */
  31157. Engine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  31158. if (faceIndex === void 0) { faceIndex = 0; }
  31159. if (lod === void 0) { lod = 0; }
  31160. var gl = this._gl;
  31161. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31162. this._bindTextureDirectly(bindTarget, texture, true);
  31163. this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);
  31164. this._bindTextureDirectly(bindTarget, null, true);
  31165. };
  31166. /** @hidden */
  31167. Engine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  31168. if (faceIndex === void 0) { faceIndex = 0; }
  31169. if (lod === void 0) { lod = 0; }
  31170. var gl = this._gl;
  31171. var textureType = this._getWebGLTextureType(texture.type);
  31172. var format = this._getInternalFormat(texture.format);
  31173. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  31174. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31175. this._bindTextureDirectly(bindTarget, texture, true);
  31176. this._unpackFlipY(texture.invertY);
  31177. var target = gl.TEXTURE_2D;
  31178. if (texture.isCube) {
  31179. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  31180. }
  31181. gl.texImage2D(target, lod, internalFormat, format, textureType, image);
  31182. this._bindTextureDirectly(bindTarget, null, true);
  31183. };
  31184. /**
  31185. * Creates a new render target cube texture
  31186. * @param size defines the size of the texture
  31187. * @param options defines the options used to create the texture
  31188. * @returns a new render target cube texture stored in an InternalTexture
  31189. */
  31190. Engine.prototype.createRenderTargetCubeTexture = function (size, options) {
  31191. 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);
  31192. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && fullOptions.generateStencilBuffer;
  31193. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  31194. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  31195. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31196. }
  31197. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  31198. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  31199. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31200. }
  31201. var gl = this._gl;
  31202. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  31203. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31204. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps);
  31205. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  31206. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31207. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type");
  31208. }
  31209. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  31210. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  31211. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31212. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31213. for (var face = 0; face < 6; face++) {
  31214. 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);
  31215. }
  31216. // Create the framebuffer
  31217. var framebuffer = gl.createFramebuffer();
  31218. this.bindUnboundFramebuffer(framebuffer);
  31219. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer, fullOptions.generateDepthBuffer, size, size);
  31220. // MipMaps
  31221. if (fullOptions.generateMipMaps) {
  31222. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  31223. }
  31224. // Unbind
  31225. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31226. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31227. this.bindUnboundFramebuffer(null);
  31228. texture._framebuffer = framebuffer;
  31229. texture.width = size;
  31230. texture.height = size;
  31231. texture.isReady = true;
  31232. texture.isCube = true;
  31233. texture.samples = 1;
  31234. texture.generateMipMaps = fullOptions.generateMipMaps;
  31235. texture.samplingMode = fullOptions.samplingMode;
  31236. texture.type = fullOptions.type;
  31237. texture.format = fullOptions.format;
  31238. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  31239. texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
  31240. this._internalTexturesCache.push(texture);
  31241. return texture;
  31242. };
  31243. /**
  31244. * Creates a cube texture
  31245. * @param rootUrl defines the url where the files to load is located
  31246. * @param scene defines the current scene
  31247. * @param files defines the list of files to load (1 per face)
  31248. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  31249. * @param onLoad defines an optional callback raised when the texture is loaded
  31250. * @param onError defines an optional callback raised if there is an issue to load the texture
  31251. * @param format defines the format of the data
  31252. * @param forcedExtension defines the extension to use to pick the right loader
  31253. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  31254. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  31255. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  31256. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  31257. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  31258. * @returns the cube texture as an InternalTexture
  31259. */
  31260. Engine.prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback, excludeLoaders) {
  31261. var _this = this;
  31262. if (onLoad === void 0) { onLoad = null; }
  31263. if (onError === void 0) { onError = null; }
  31264. if (forcedExtension === void 0) { forcedExtension = null; }
  31265. if (createPolynomials === void 0) { createPolynomials = false; }
  31266. if (lodScale === void 0) { lodScale = 0; }
  31267. if (lodOffset === void 0) { lodOffset = 0; }
  31268. if (fallback === void 0) { fallback = null; }
  31269. if (excludeLoaders === void 0) { excludeLoaders = []; }
  31270. var gl = this._gl;
  31271. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBE);
  31272. texture.isCube = true;
  31273. texture.url = rootUrl;
  31274. texture.generateMipMaps = !noMipmap;
  31275. texture._lodGenerationScale = lodScale;
  31276. texture._lodGenerationOffset = lodOffset;
  31277. if (!this._doNotHandleContextLost) {
  31278. texture._extension = forcedExtension;
  31279. texture._files = files;
  31280. }
  31281. var lastDot = rootUrl.lastIndexOf('.');
  31282. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  31283. var loader = null;
  31284. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  31285. var availableLoader = _a[_i];
  31286. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, false, false)) {
  31287. loader = availableLoader;
  31288. break;
  31289. }
  31290. }
  31291. var onInternalError = function (request, exception) {
  31292. if (loader) {
  31293. var fallbackUrl = loader.getFallbackTextureUrl(texture.url, _this._textureFormatInUse);
  31294. _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");
  31295. if (fallbackUrl) {
  31296. excludeLoaders.push(loader);
  31297. _this.createCubeTexture(fallbackUrl, scene, files, noMipmap, onLoad, onError, format, extension, createPolynomials, lodScale, lodOffset, texture, excludeLoaders);
  31298. return;
  31299. }
  31300. }
  31301. if (onError && request) {
  31302. onError(request.status + " " + request.statusText, exception);
  31303. }
  31304. };
  31305. if (loader) {
  31306. rootUrl = loader.transformUrl(rootUrl, this._textureFormatInUse);
  31307. var onloaddata = function (data) {
  31308. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31309. loader.loadCubeData(data, texture, createPolynomials, onLoad, onError);
  31310. };
  31311. if (files && files.length === 6) {
  31312. if (loader.supportCascades) {
  31313. this._cascadeLoadFiles(scene, onloaddata, files, onError);
  31314. }
  31315. else if (onError) {
  31316. onError("Textures type does not support cascades.");
  31317. }
  31318. }
  31319. else {
  31320. this._loadFile(rootUrl, onloaddata, undefined, undefined, true, onInternalError);
  31321. }
  31322. }
  31323. else {
  31324. if (!files) {
  31325. throw new Error("Cannot load cubemap because files were not defined");
  31326. }
  31327. this._cascadeLoadImgs(scene, function (imgs) {
  31328. var width = _this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(imgs[0].width, _this._caps.maxCubemapTextureSize) : imgs[0].width;
  31329. var height = width;
  31330. _this._prepareWorkingCanvas();
  31331. if (!_this._workingCanvas || !_this._workingContext) {
  31332. return;
  31333. }
  31334. _this._workingCanvas.width = width;
  31335. _this._workingCanvas.height = height;
  31336. var faces = [
  31337. gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
  31338. gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
  31339. ];
  31340. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31341. _this._unpackFlipY(false);
  31342. var internalFormat = format ? _this._getInternalFormat(format) : _this._gl.RGBA;
  31343. for (var index = 0; index < faces.length; index++) {
  31344. _this._workingContext.drawImage(imgs[index], 0, 0, imgs[index].width, imgs[index].height, 0, 0, width, height);
  31345. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  31346. }
  31347. if (!noMipmap) {
  31348. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  31349. }
  31350. _this._setCubeMapTextureParams(!noMipmap);
  31351. texture.width = width;
  31352. texture.height = height;
  31353. texture.isReady = true;
  31354. if (format) {
  31355. texture.format = format;
  31356. }
  31357. texture.onLoadedObservable.notifyObservers(texture);
  31358. texture.onLoadedObservable.clear();
  31359. if (onLoad) {
  31360. onLoad();
  31361. }
  31362. }, files, onError);
  31363. }
  31364. this._internalTexturesCache.push(texture);
  31365. return texture;
  31366. };
  31367. /**
  31368. * @hidden
  31369. */
  31370. Engine.prototype._setCubeMapTextureParams = function (loadMipmap) {
  31371. var gl = this._gl;
  31372. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  31373. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, loadMipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
  31374. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31375. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31376. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31377. // this.resetTextureCache();
  31378. };
  31379. /**
  31380. * Update a raw cube texture
  31381. * @param texture defines the texture to udpdate
  31382. * @param data defines the data to store
  31383. * @param format defines the data format
  31384. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31385. * @param invertY defines if data must be stored with Y axis inverted
  31386. * @param compression defines the compression used (null by default)
  31387. * @param level defines which level of the texture to update
  31388. */
  31389. Engine.prototype.updateRawCubeTexture = function (texture, data, format, type, invertY, compression, level) {
  31390. if (compression === void 0) { compression = null; }
  31391. if (level === void 0) { level = 0; }
  31392. texture._bufferViewArray = data;
  31393. texture.format = format;
  31394. texture.type = type;
  31395. texture.invertY = invertY;
  31396. texture._compression = compression;
  31397. var gl = this._gl;
  31398. var textureType = this._getWebGLTextureType(type);
  31399. var internalFormat = this._getInternalFormat(format);
  31400. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);
  31401. var needConversion = false;
  31402. if (internalFormat === gl.RGB) {
  31403. internalFormat = gl.RGBA;
  31404. needConversion = true;
  31405. }
  31406. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31407. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  31408. if (texture.width % 4 !== 0) {
  31409. gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
  31410. }
  31411. // Data are known to be in +X +Y +Z -X -Y -Z
  31412. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  31413. var faceData = data[faceIndex];
  31414. if (compression) {
  31415. gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, (this.getCaps().s3tc)[compression], texture.width, texture.height, 0, faceData);
  31416. }
  31417. else {
  31418. if (needConversion) {
  31419. faceData = this._convertRGBtoRGBATextureData(faceData, texture.width, texture.height, type);
  31420. }
  31421. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, faceData);
  31422. }
  31423. }
  31424. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  31425. if (isPot && texture.generateMipMaps && level === 0) {
  31426. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  31427. }
  31428. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31429. // this.resetTextureCache();
  31430. texture.isReady = true;
  31431. };
  31432. /**
  31433. * Creates a new raw cube texture
  31434. * @param data defines the array of data to use to create each face
  31435. * @param size defines the size of the textures
  31436. * @param format defines the format of the data
  31437. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31438. * @param generateMipMaps defines if the engine should generate the mip levels
  31439. * @param invertY defines if data must be stored with Y axis inverted
  31440. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31441. * @param compression defines the compression used (null by default)
  31442. * @returns the cube texture as an InternalTexture
  31443. */
  31444. Engine.prototype.createRawCubeTexture = function (data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  31445. if (compression === void 0) { compression = null; }
  31446. var gl = this._gl;
  31447. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBERAW);
  31448. texture.isCube = true;
  31449. texture.format = format;
  31450. texture.type = type;
  31451. if (!this._doNotHandleContextLost) {
  31452. texture._bufferViewArray = data;
  31453. }
  31454. var textureType = this._getWebGLTextureType(type);
  31455. var internalFormat = this._getInternalFormat(format);
  31456. if (internalFormat === gl.RGB) {
  31457. internalFormat = gl.RGBA;
  31458. }
  31459. // Mipmap generation needs a sized internal format that is both color-renderable and texture-filterable
  31460. if (textureType === gl.FLOAT && !this._caps.textureFloatLinearFiltering) {
  31461. generateMipMaps = false;
  31462. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31463. _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.");
  31464. }
  31465. else if (textureType === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering) {
  31466. generateMipMaps = false;
  31467. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31468. _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.");
  31469. }
  31470. else if (textureType === gl.FLOAT && !this._caps.textureFloatRender) {
  31471. generateMipMaps = false;
  31472. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to float textures is not supported. Mipmap generation forced to false.");
  31473. }
  31474. else if (textureType === gl.HALF_FLOAT && !this._caps.colorBufferFloat) {
  31475. generateMipMaps = false;
  31476. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to half float textures is not supported. Mipmap generation forced to false.");
  31477. }
  31478. var width = size;
  31479. var height = width;
  31480. texture.width = width;
  31481. texture.height = height;
  31482. // Double check on POT to generate Mips.
  31483. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  31484. if (!isPot) {
  31485. generateMipMaps = false;
  31486. }
  31487. // Upload data if needed. The texture won't be ready until then.
  31488. if (data) {
  31489. this.updateRawCubeTexture(texture, data, format, type, invertY, compression);
  31490. }
  31491. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  31492. // Filters
  31493. if (data && generateMipMaps) {
  31494. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  31495. }
  31496. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  31497. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  31498. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  31499. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31500. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31501. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31502. texture.generateMipMaps = generateMipMaps;
  31503. return texture;
  31504. };
  31505. /**
  31506. * Creates a new raw cube texture from a specified url
  31507. * @param url defines the url where the data is located
  31508. * @param scene defines the current scene
  31509. * @param size defines the size of the textures
  31510. * @param format defines the format of the data
  31511. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31512. * @param noMipmap defines if the engine should avoid generating the mip levels
  31513. * @param callback defines a callback used to extract texture data from loaded data
  31514. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  31515. * @param onLoad defines a callback called when texture is loaded
  31516. * @param onError defines a callback called if there is an error
  31517. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31518. * @param invertY defines if data must be stored with Y axis inverted
  31519. * @returns the cube texture as an InternalTexture
  31520. */
  31521. Engine.prototype.createRawCubeTextureFromUrl = function (url, scene, size, format, type, noMipmap, callback, mipmapGenerator, onLoad, onError, samplingMode, invertY) {
  31522. var _this = this;
  31523. if (onLoad === void 0) { onLoad = null; }
  31524. if (onError === void 0) { onError = null; }
  31525. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  31526. if (invertY === void 0) { invertY = false; }
  31527. var gl = this._gl;
  31528. var texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode);
  31529. scene._addPendingData(texture);
  31530. texture.url = url;
  31531. this._internalTexturesCache.push(texture);
  31532. var onerror = function (request, exception) {
  31533. scene._removePendingData(texture);
  31534. if (onError && request) {
  31535. onError(request.status + " " + request.statusText, exception);
  31536. }
  31537. };
  31538. var internalCallback = function (data) {
  31539. var width = texture.width;
  31540. var faceDataArrays = callback(data);
  31541. if (!faceDataArrays) {
  31542. return;
  31543. }
  31544. if (mipmapGenerator) {
  31545. var textureType = _this._getWebGLTextureType(type);
  31546. var internalFormat = _this._getInternalFormat(format);
  31547. var internalSizedFomat = _this._getRGBABufferInternalSizedFormat(type);
  31548. var needConversion = false;
  31549. if (internalFormat === gl.RGB) {
  31550. internalFormat = gl.RGBA;
  31551. needConversion = true;
  31552. }
  31553. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31554. _this._unpackFlipY(false);
  31555. var mipData = mipmapGenerator(faceDataArrays);
  31556. for (var level = 0; level < mipData.length; level++) {
  31557. var mipSize = width >> level;
  31558. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  31559. var mipFaceData = mipData[level][faceIndex];
  31560. if (needConversion) {
  31561. mipFaceData = _this._convertRGBtoRGBATextureData(mipFaceData, mipSize, mipSize, type);
  31562. }
  31563. gl.texImage2D(faceIndex, level, internalSizedFomat, mipSize, mipSize, 0, internalFormat, textureType, mipFaceData);
  31564. }
  31565. }
  31566. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31567. }
  31568. else {
  31569. _this.updateRawCubeTexture(texture, faceDataArrays, format, type, invertY);
  31570. }
  31571. texture.isReady = true;
  31572. // this.resetTextureCache();
  31573. scene._removePendingData(texture);
  31574. if (onLoad) {
  31575. onLoad();
  31576. }
  31577. };
  31578. this._loadFile(url, function (data) {
  31579. internalCallback(data);
  31580. }, undefined, scene.offlineProvider, true, onerror);
  31581. return texture;
  31582. };
  31583. /**
  31584. * Update a raw 3D texture
  31585. * @param texture defines the texture to update
  31586. * @param data defines the data to store
  31587. * @param format defines the data format
  31588. * @param invertY defines if data must be stored with Y axis inverted
  31589. * @param compression defines the used compression (can be null)
  31590. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  31591. */
  31592. Engine.prototype.updateRawTexture3D = function (texture, data, format, invertY, compression, textureType) {
  31593. if (compression === void 0) { compression = null; }
  31594. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31595. var internalType = this._getWebGLTextureType(textureType);
  31596. var internalFormat = this._getInternalFormat(format);
  31597. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(textureType, format);
  31598. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  31599. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  31600. if (!this._doNotHandleContextLost) {
  31601. texture._bufferView = data;
  31602. texture.format = format;
  31603. texture.invertY = invertY;
  31604. texture._compression = compression;
  31605. }
  31606. if (texture.width % 4 !== 0) {
  31607. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  31608. }
  31609. if (compression && data) {
  31610. this._gl.compressedTexImage3D(this._gl.TEXTURE_3D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, texture.depth, 0, data);
  31611. }
  31612. else {
  31613. this._gl.texImage3D(this._gl.TEXTURE_3D, 0, internalSizedFomat, texture.width, texture.height, texture.depth, 0, internalFormat, internalType, data);
  31614. }
  31615. if (texture.generateMipMaps) {
  31616. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  31617. }
  31618. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  31619. // this.resetTextureCache();
  31620. texture.isReady = true;
  31621. };
  31622. /**
  31623. * Creates a new raw 3D texture
  31624. * @param data defines the data used to create the texture
  31625. * @param width defines the width of the texture
  31626. * @param height defines the height of the texture
  31627. * @param depth defines the depth of the texture
  31628. * @param format defines the format of the texture
  31629. * @param generateMipMaps defines if the engine must generate mip levels
  31630. * @param invertY defines if data must be stored with Y axis inverted
  31631. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31632. * @param compression defines the compressed used (can be null)
  31633. * @param textureType defines the compressed used (can be null)
  31634. * @returns a new raw 3D texture (stored in an InternalTexture)
  31635. */
  31636. Engine.prototype.createRawTexture3D = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression, textureType) {
  31637. if (compression === void 0) { compression = null; }
  31638. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31639. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW3D);
  31640. texture.baseWidth = width;
  31641. texture.baseHeight = height;
  31642. texture.baseDepth = depth;
  31643. texture.width = width;
  31644. texture.height = height;
  31645. texture.depth = depth;
  31646. texture.format = format;
  31647. texture.type = textureType;
  31648. texture.generateMipMaps = generateMipMaps;
  31649. texture.samplingMode = samplingMode;
  31650. texture.is3D = true;
  31651. if (!this._doNotHandleContextLost) {
  31652. texture._bufferView = data;
  31653. }
  31654. this.updateRawTexture3D(texture, data, format, invertY, compression, textureType);
  31655. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  31656. // Filters
  31657. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  31658. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  31659. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31660. if (generateMipMaps) {
  31661. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  31662. }
  31663. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  31664. this._internalTexturesCache.push(texture);
  31665. return texture;
  31666. };
  31667. Engine.prototype._prepareWebGLTextureContinuation = function (texture, scene, noMipmap, isCompressed, samplingMode) {
  31668. var gl = this._gl;
  31669. if (!gl) {
  31670. return;
  31671. }
  31672. var filters = this._getSamplingParameters(samplingMode, !noMipmap);
  31673. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  31674. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  31675. if (!noMipmap && !isCompressed) {
  31676. gl.generateMipmap(gl.TEXTURE_2D);
  31677. }
  31678. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31679. // this.resetTextureCache();
  31680. if (scene) {
  31681. scene._removePendingData(texture);
  31682. }
  31683. texture.onLoadedObservable.notifyObservers(texture);
  31684. texture.onLoadedObservable.clear();
  31685. };
  31686. Engine.prototype._prepareWebGLTexture = function (texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode) {
  31687. var _this = this;
  31688. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  31689. var maxTextureSize = this.getCaps().maxTextureSize;
  31690. var potWidth = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, maxTextureSize) : width);
  31691. var potHeight = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, maxTextureSize) : height);
  31692. var gl = this._gl;
  31693. if (!gl) {
  31694. return;
  31695. }
  31696. if (!texture._webGLTexture) {
  31697. // this.resetTextureCache();
  31698. if (scene) {
  31699. scene._removePendingData(texture);
  31700. }
  31701. return;
  31702. }
  31703. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  31704. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  31705. texture.baseWidth = width;
  31706. texture.baseHeight = height;
  31707. texture.width = potWidth;
  31708. texture.height = potHeight;
  31709. texture.isReady = true;
  31710. if (processFunction(potWidth, potHeight, function () {
  31711. _this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  31712. })) {
  31713. // Returning as texture needs extra async steps
  31714. return;
  31715. }
  31716. this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  31717. };
  31718. Engine.prototype._convertRGBtoRGBATextureData = function (rgbData, width, height, textureType) {
  31719. // Create new RGBA data container.
  31720. var rgbaData;
  31721. if (textureType === Engine.TEXTURETYPE_FLOAT) {
  31722. rgbaData = new Float32Array(width * height * 4);
  31723. }
  31724. else {
  31725. rgbaData = new Uint32Array(width * height * 4);
  31726. }
  31727. // Convert each pixel.
  31728. for (var x = 0; x < width; x++) {
  31729. for (var y = 0; y < height; y++) {
  31730. var index = (y * width + x) * 3;
  31731. var newIndex = (y * width + x) * 4;
  31732. // Map Old Value to new value.
  31733. rgbaData[newIndex + 0] = rgbData[index + 0];
  31734. rgbaData[newIndex + 1] = rgbData[index + 1];
  31735. rgbaData[newIndex + 2] = rgbData[index + 2];
  31736. // Add fully opaque alpha channel.
  31737. rgbaData[newIndex + 3] = 1;
  31738. }
  31739. }
  31740. return rgbaData;
  31741. };
  31742. /** @hidden */
  31743. Engine.prototype._releaseFramebufferObjects = function (texture) {
  31744. var gl = this._gl;
  31745. if (texture._framebuffer) {
  31746. gl.deleteFramebuffer(texture._framebuffer);
  31747. texture._framebuffer = null;
  31748. }
  31749. if (texture._depthStencilBuffer) {
  31750. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  31751. texture._depthStencilBuffer = null;
  31752. }
  31753. if (texture._MSAAFramebuffer) {
  31754. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  31755. texture._MSAAFramebuffer = null;
  31756. }
  31757. if (texture._MSAARenderBuffer) {
  31758. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  31759. texture._MSAARenderBuffer = null;
  31760. }
  31761. };
  31762. /** @hidden */
  31763. Engine.prototype._releaseTexture = function (texture) {
  31764. var gl = this._gl;
  31765. this._releaseFramebufferObjects(texture);
  31766. gl.deleteTexture(texture._webGLTexture);
  31767. // Unbind channels
  31768. this.unbindAllTextures();
  31769. var index = this._internalTexturesCache.indexOf(texture);
  31770. if (index !== -1) {
  31771. this._internalTexturesCache.splice(index, 1);
  31772. }
  31773. // Integrated fixed lod samplers.
  31774. if (texture._lodTextureHigh) {
  31775. texture._lodTextureHigh.dispose();
  31776. }
  31777. if (texture._lodTextureMid) {
  31778. texture._lodTextureMid.dispose();
  31779. }
  31780. if (texture._lodTextureLow) {
  31781. texture._lodTextureLow.dispose();
  31782. }
  31783. // Set output texture of post process to null if the texture has been released/disposed
  31784. this.scenes.forEach(function (scene) {
  31785. scene.postProcesses.forEach(function (postProcess) {
  31786. if (postProcess._outputTexture == texture) {
  31787. postProcess._outputTexture = null;
  31788. }
  31789. });
  31790. scene.cameras.forEach(function (camera) {
  31791. camera._postProcesses.forEach(function (postProcess) {
  31792. if (postProcess) {
  31793. if (postProcess._outputTexture == texture) {
  31794. postProcess._outputTexture = null;
  31795. }
  31796. }
  31797. });
  31798. });
  31799. });
  31800. };
  31801. Engine.prototype.setProgram = function (program) {
  31802. if (this._currentProgram !== program) {
  31803. this._gl.useProgram(program);
  31804. this._currentProgram = program;
  31805. }
  31806. };
  31807. /**
  31808. * Binds an effect to the webGL context
  31809. * @param effect defines the effect to bind
  31810. */
  31811. Engine.prototype.bindSamplers = function (effect) {
  31812. this.setProgram(effect.getProgram());
  31813. var samplers = effect.getSamplers();
  31814. for (var index = 0; index < samplers.length; index++) {
  31815. var uniform = effect.getUniform(samplers[index]);
  31816. if (uniform) {
  31817. this._boundUniforms[index] = uniform;
  31818. }
  31819. }
  31820. this._currentEffect = null;
  31821. };
  31822. Engine.prototype._moveBoundTextureOnTop = function (internalTexture) {
  31823. if (this.disableTextureBindingOptimization || this._lastBoundInternalTextureTracker.previous === internalTexture) {
  31824. return;
  31825. }
  31826. // Remove
  31827. this._linkTrackers(internalTexture.previous, internalTexture.next);
  31828. // Bind last to it
  31829. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, internalTexture);
  31830. // Bind to dummy
  31831. this._linkTrackers(internalTexture, this._lastBoundInternalTextureTracker);
  31832. };
  31833. Engine.prototype._getCorrectTextureChannel = function (channel, internalTexture) {
  31834. if (!internalTexture) {
  31835. return -1;
  31836. }
  31837. internalTexture._initialSlot = channel;
  31838. if (this.disableTextureBindingOptimization) { // We want texture sampler ID === texture channel
  31839. if (channel !== internalTexture._designatedSlot) {
  31840. this._textureCollisions.addCount(1, false);
  31841. }
  31842. }
  31843. else {
  31844. if (channel !== internalTexture._designatedSlot) {
  31845. if (internalTexture._designatedSlot > -1) { // Texture is already assigned to a slot
  31846. return internalTexture._designatedSlot;
  31847. }
  31848. else {
  31849. // No slot for this texture, let's pick a new one (if we find a free slot)
  31850. if (this._nextFreeTextureSlots.length) {
  31851. return this._nextFreeTextureSlots[0];
  31852. }
  31853. // We need to recycle the oldest bound texture, sorry.
  31854. this._textureCollisions.addCount(1, false);
  31855. return this._removeDesignatedSlot(this._firstBoundInternalTextureTracker.next);
  31856. }
  31857. }
  31858. }
  31859. return channel;
  31860. };
  31861. Engine.prototype._linkTrackers = function (previous, next) {
  31862. previous.next = next;
  31863. next.previous = previous;
  31864. };
  31865. Engine.prototype._removeDesignatedSlot = function (internalTexture) {
  31866. var currentSlot = internalTexture._designatedSlot;
  31867. if (currentSlot === -1) {
  31868. return -1;
  31869. }
  31870. internalTexture._designatedSlot = -1;
  31871. if (this.disableTextureBindingOptimization) {
  31872. return -1;
  31873. }
  31874. // Remove from bound list
  31875. this._linkTrackers(internalTexture.previous, internalTexture.next);
  31876. // Free the slot
  31877. this._boundTexturesCache[currentSlot] = null;
  31878. this._nextFreeTextureSlots.push(currentSlot);
  31879. return currentSlot;
  31880. };
  31881. Engine.prototype._activateCurrentTexture = function () {
  31882. if (this._currentTextureChannel !== this._activeChannel) {
  31883. this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel);
  31884. this._currentTextureChannel = this._activeChannel;
  31885. }
  31886. };
  31887. /** @hidden */
  31888. Engine.prototype._bindTextureDirectly = function (target, texture, forTextureDataUpdate, force) {
  31889. if (forTextureDataUpdate === void 0) { forTextureDataUpdate = false; }
  31890. if (force === void 0) { force = false; }
  31891. var wasPreviouslyBound = false;
  31892. if (forTextureDataUpdate && texture && texture._designatedSlot > -1) {
  31893. this._activeChannel = texture._designatedSlot;
  31894. }
  31895. var currentTextureBound = this._boundTexturesCache[this._activeChannel];
  31896. var isTextureForRendering = texture && texture._initialSlot > -1;
  31897. if (currentTextureBound !== texture || force) {
  31898. if (currentTextureBound) {
  31899. this._removeDesignatedSlot(currentTextureBound);
  31900. }
  31901. this._activateCurrentTexture();
  31902. this._gl.bindTexture(target, texture ? texture._webGLTexture : null);
  31903. this._boundTexturesCache[this._activeChannel] = texture;
  31904. if (texture) {
  31905. if (!this.disableTextureBindingOptimization) {
  31906. var slotIndex = this._nextFreeTextureSlots.indexOf(this._activeChannel);
  31907. if (slotIndex > -1) {
  31908. this._nextFreeTextureSlots.splice(slotIndex, 1);
  31909. }
  31910. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, texture);
  31911. this._linkTrackers(texture, this._lastBoundInternalTextureTracker);
  31912. }
  31913. texture._designatedSlot = this._activeChannel;
  31914. }
  31915. }
  31916. else if (forTextureDataUpdate) {
  31917. wasPreviouslyBound = true;
  31918. this._activateCurrentTexture();
  31919. }
  31920. if (isTextureForRendering && !forTextureDataUpdate) {
  31921. this._bindSamplerUniformToChannel(texture._initialSlot, this._activeChannel);
  31922. }
  31923. return wasPreviouslyBound;
  31924. };
  31925. /** @hidden */
  31926. Engine.prototype._bindTexture = function (channel, texture) {
  31927. if (channel < 0) {
  31928. return;
  31929. }
  31930. if (texture) {
  31931. channel = this._getCorrectTextureChannel(channel, texture);
  31932. }
  31933. this._activeChannel = channel;
  31934. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
  31935. };
  31936. /**
  31937. * Sets a texture to the webGL context from a postprocess
  31938. * @param channel defines the channel to use
  31939. * @param postProcess defines the source postprocess
  31940. */
  31941. Engine.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  31942. this._bindTexture(channel, postProcess ? postProcess._textures.data[postProcess._currentRenderTextureInd] : null);
  31943. };
  31944. /**
  31945. * Binds the output of the passed in post process to the texture channel specified
  31946. * @param channel The channel the texture should be bound to
  31947. * @param postProcess The post process which's output should be bound
  31948. */
  31949. Engine.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  31950. this._bindTexture(channel, postProcess ? postProcess._outputTexture : null);
  31951. };
  31952. /**
  31953. * Unbind all textures from the webGL context
  31954. */
  31955. Engine.prototype.unbindAllTextures = function () {
  31956. for (var channel = 0; channel < this._maxSimultaneousTextures; channel++) {
  31957. this._activeChannel = channel;
  31958. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31959. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31960. if (this.webGLVersion > 1) {
  31961. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  31962. }
  31963. }
  31964. };
  31965. /**
  31966. * Sets a texture to the according uniform.
  31967. * @param channel The texture channel
  31968. * @param uniform The uniform to set
  31969. * @param texture The texture to apply
  31970. */
  31971. Engine.prototype.setTexture = function (channel, uniform, texture) {
  31972. if (channel < 0) {
  31973. return;
  31974. }
  31975. if (uniform) {
  31976. this._boundUniforms[channel] = uniform;
  31977. }
  31978. this._setTexture(channel, texture);
  31979. };
  31980. /**
  31981. * Sets a depth stencil texture from a render target to the according uniform.
  31982. * @param channel The texture channel
  31983. * @param uniform The uniform to set
  31984. * @param texture The render target texture containing the depth stencil texture to apply
  31985. */
  31986. Engine.prototype.setDepthStencilTexture = function (channel, uniform, texture) {
  31987. if (channel < 0) {
  31988. return;
  31989. }
  31990. if (uniform) {
  31991. this._boundUniforms[channel] = uniform;
  31992. }
  31993. if (!texture || !texture.depthStencilTexture) {
  31994. this._setTexture(channel, null);
  31995. }
  31996. else {
  31997. this._setTexture(channel, texture, false, true);
  31998. }
  31999. };
  32000. Engine.prototype._bindSamplerUniformToChannel = function (sourceSlot, destination) {
  32001. var uniform = this._boundUniforms[sourceSlot];
  32002. if (uniform._currentState === destination) {
  32003. return;
  32004. }
  32005. this._gl.uniform1i(uniform, destination);
  32006. uniform._currentState = destination;
  32007. };
  32008. Engine.prototype._getTextureWrapMode = function (mode) {
  32009. switch (mode) {
  32010. case Engine.TEXTURE_WRAP_ADDRESSMODE:
  32011. return this._gl.REPEAT;
  32012. case Engine.TEXTURE_CLAMP_ADDRESSMODE:
  32013. return this._gl.CLAMP_TO_EDGE;
  32014. case Engine.TEXTURE_MIRROR_ADDRESSMODE:
  32015. return this._gl.MIRRORED_REPEAT;
  32016. }
  32017. return this._gl.REPEAT;
  32018. };
  32019. Engine.prototype._setTexture = function (channel, texture, isPartOfTextureArray, depthStencilTexture) {
  32020. if (isPartOfTextureArray === void 0) { isPartOfTextureArray = false; }
  32021. if (depthStencilTexture === void 0) { depthStencilTexture = false; }
  32022. // Not ready?
  32023. if (!texture) {
  32024. if (this._boundTexturesCache[channel] != null) {
  32025. this._activeChannel = channel;
  32026. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32027. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32028. if (this.webGLVersion > 1) {
  32029. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32030. }
  32031. }
  32032. return false;
  32033. }
  32034. // Video
  32035. if (texture.video) {
  32036. this._activeChannel = channel;
  32037. texture.update();
  32038. }
  32039. else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) { // Delay loading
  32040. texture.delayLoad();
  32041. return false;
  32042. }
  32043. var internalTexture;
  32044. if (depthStencilTexture) {
  32045. internalTexture = texture.depthStencilTexture;
  32046. }
  32047. else if (texture.isReady()) {
  32048. internalTexture = texture.getInternalTexture();
  32049. }
  32050. else if (texture.isCube) {
  32051. internalTexture = this.emptyCubeTexture;
  32052. }
  32053. else if (texture.is3D) {
  32054. internalTexture = this.emptyTexture3D;
  32055. }
  32056. else {
  32057. internalTexture = this.emptyTexture;
  32058. }
  32059. if (!isPartOfTextureArray) {
  32060. channel = this._getCorrectTextureChannel(channel, internalTexture);
  32061. }
  32062. var needToBind = true;
  32063. if (this._boundTexturesCache[channel] === internalTexture) {
  32064. this._moveBoundTextureOnTop(internalTexture);
  32065. if (!isPartOfTextureArray) {
  32066. this._bindSamplerUniformToChannel(internalTexture._initialSlot, channel);
  32067. }
  32068. needToBind = false;
  32069. }
  32070. this._activeChannel = channel;
  32071. if (internalTexture && internalTexture.is3D) {
  32072. if (needToBind) {
  32073. this._bindTextureDirectly(this._gl.TEXTURE_3D, internalTexture, isPartOfTextureArray);
  32074. }
  32075. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  32076. internalTexture._cachedWrapU = texture.wrapU;
  32077. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  32078. }
  32079. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  32080. internalTexture._cachedWrapV = texture.wrapV;
  32081. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  32082. }
  32083. if (internalTexture && internalTexture._cachedWrapR !== texture.wrapR) {
  32084. internalTexture._cachedWrapR = texture.wrapR;
  32085. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(texture.wrapR), internalTexture);
  32086. }
  32087. this._setAnisotropicLevel(this._gl.TEXTURE_3D, texture);
  32088. }
  32089. else if (internalTexture && internalTexture.isCube) {
  32090. if (needToBind) {
  32091. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, internalTexture, isPartOfTextureArray);
  32092. }
  32093. if (internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {
  32094. internalTexture._cachedCoordinatesMode = texture.coordinatesMode;
  32095. // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.
  32096. var textureWrapMode = (texture.coordinatesMode !== Engine.TEXTURE_CUBIC_MODE && texture.coordinatesMode !== Engine.TEXTURE_SKYBOX_MODE) ? this._gl.REPEAT : this._gl.CLAMP_TO_EDGE;
  32097. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_S, textureWrapMode, internalTexture);
  32098. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_T, textureWrapMode);
  32099. }
  32100. this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP, texture);
  32101. }
  32102. else {
  32103. if (needToBind) {
  32104. this._bindTextureDirectly(this._gl.TEXTURE_2D, internalTexture, isPartOfTextureArray);
  32105. }
  32106. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  32107. internalTexture._cachedWrapU = texture.wrapU;
  32108. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  32109. }
  32110. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  32111. internalTexture._cachedWrapV = texture.wrapV;
  32112. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  32113. }
  32114. this._setAnisotropicLevel(this._gl.TEXTURE_2D, texture);
  32115. }
  32116. return true;
  32117. };
  32118. /**
  32119. * Sets an array of texture to the webGL context
  32120. * @param channel defines the channel where the texture array must be set
  32121. * @param uniform defines the associated uniform location
  32122. * @param textures defines the array of textures to bind
  32123. */
  32124. Engine.prototype.setTextureArray = function (channel, uniform, textures) {
  32125. if (channel < 0 || !uniform) {
  32126. return;
  32127. }
  32128. if (!this._textureUnits || this._textureUnits.length !== textures.length) {
  32129. this._textureUnits = new Int32Array(textures.length);
  32130. }
  32131. for (var i = 0; i < textures.length; i++) {
  32132. this._textureUnits[i] = this._getCorrectTextureChannel(channel + i, textures[i].getInternalTexture());
  32133. }
  32134. this._gl.uniform1iv(uniform, this._textureUnits);
  32135. for (var index = 0; index < textures.length; index++) {
  32136. this._setTexture(this._textureUnits[index], textures[index], true);
  32137. }
  32138. };
  32139. /** @hidden */
  32140. Engine.prototype._setAnisotropicLevel = function (target, texture) {
  32141. var internalTexture = texture.getInternalTexture();
  32142. if (!internalTexture) {
  32143. return;
  32144. }
  32145. var anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;
  32146. var value = texture.anisotropicFilteringLevel;
  32147. if (internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST
  32148. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR
  32149. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR) {
  32150. value = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear
  32151. }
  32152. if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== value) {
  32153. this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(value, this._caps.maxAnisotropy), internalTexture);
  32154. internalTexture._cachedAnisotropicFilteringLevel = value;
  32155. }
  32156. };
  32157. Engine.prototype._setTextureParameterFloat = function (target, parameter, value, texture) {
  32158. this._bindTextureDirectly(target, texture, true, true);
  32159. this._gl.texParameterf(target, parameter, value);
  32160. };
  32161. Engine.prototype._setTextureParameterInteger = function (target, parameter, value, texture) {
  32162. if (texture) {
  32163. this._bindTextureDirectly(target, texture, true, true);
  32164. }
  32165. this._gl.texParameteri(target, parameter, value);
  32166. };
  32167. /**
  32168. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32169. * @param x defines the x coordinate of the rectangle where pixels must be read
  32170. * @param y defines the y coordinate of the rectangle where pixels must be read
  32171. * @param width defines the width of the rectangle where pixels must be read
  32172. * @param height defines the height of the rectangle where pixels must be read
  32173. * @returns a Uint8Array containing RGBA colors
  32174. */
  32175. Engine.prototype.readPixels = function (x, y, width, height) {
  32176. var data = new Uint8Array(height * width * 4);
  32177. this._gl.readPixels(x, y, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data);
  32178. return data;
  32179. };
  32180. /**
  32181. * Add an externaly attached data from its key.
  32182. * This method call will fail and return false, if such key already exists.
  32183. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32184. * @param key the unique key that identifies the data
  32185. * @param data the data object to associate to the key for this Engine instance
  32186. * @return true if no such key were already present and the data was added successfully, false otherwise
  32187. */
  32188. Engine.prototype.addExternalData = function (key, data) {
  32189. if (!this._externalData) {
  32190. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32191. }
  32192. return this._externalData.add(key, data);
  32193. };
  32194. /**
  32195. * Get an externaly attached data from its key
  32196. * @param key the unique key that identifies the data
  32197. * @return the associated data, if present (can be null), or undefined if not present
  32198. */
  32199. Engine.prototype.getExternalData = function (key) {
  32200. if (!this._externalData) {
  32201. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32202. }
  32203. return this._externalData.get(key);
  32204. };
  32205. /**
  32206. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32207. * @param key the unique key that identifies the data
  32208. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32209. * @return the associated data, can be null if the factory returned null.
  32210. */
  32211. Engine.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  32212. if (!this._externalData) {
  32213. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32214. }
  32215. return this._externalData.getOrAddWithFactory(key, factory);
  32216. };
  32217. /**
  32218. * Remove an externaly attached data from the Engine instance
  32219. * @param key the unique key that identifies the data
  32220. * @return true if the data was successfully removed, false if it doesn't exist
  32221. */
  32222. Engine.prototype.removeExternalData = function (key) {
  32223. if (!this._externalData) {
  32224. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32225. }
  32226. return this._externalData.remove(key);
  32227. };
  32228. /**
  32229. * Unbind all vertex attributes from the webGL context
  32230. */
  32231. Engine.prototype.unbindAllAttributes = function () {
  32232. if (this._mustWipeVertexAttributes) {
  32233. this._mustWipeVertexAttributes = false;
  32234. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  32235. this._gl.disableVertexAttribArray(i);
  32236. this._vertexAttribArraysEnabled[i] = false;
  32237. this._currentBufferPointers[i].active = false;
  32238. }
  32239. return;
  32240. }
  32241. for (var i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {
  32242. if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {
  32243. continue;
  32244. }
  32245. this._gl.disableVertexAttribArray(i);
  32246. this._vertexAttribArraysEnabled[i] = false;
  32247. this._currentBufferPointers[i].active = false;
  32248. }
  32249. };
  32250. /**
  32251. * 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
  32252. */
  32253. Engine.prototype.releaseEffects = function () {
  32254. for (var name in this._compiledEffects) {
  32255. this._deleteProgram(this._compiledEffects[name]._program);
  32256. }
  32257. this._compiledEffects = {};
  32258. };
  32259. /**
  32260. * Dispose and release all associated resources
  32261. */
  32262. Engine.prototype.dispose = function () {
  32263. this.hideLoadingUI();
  32264. this.stopRenderLoop();
  32265. this.onNewSceneAddedObservable.clear();
  32266. // Release postProcesses
  32267. while (this.postProcesses.length) {
  32268. this.postProcesses[0].dispose();
  32269. }
  32270. // Empty texture
  32271. if (this._emptyTexture) {
  32272. this._releaseTexture(this._emptyTexture);
  32273. this._emptyTexture = null;
  32274. }
  32275. if (this._emptyCubeTexture) {
  32276. this._releaseTexture(this._emptyCubeTexture);
  32277. this._emptyCubeTexture = null;
  32278. }
  32279. // Rescale PP
  32280. if (this._rescalePostProcess) {
  32281. this._rescalePostProcess.dispose();
  32282. }
  32283. // Release scenes
  32284. while (this.scenes.length) {
  32285. this.scenes[0].dispose();
  32286. }
  32287. // Release audio engine
  32288. if (Engine.Instances.length === 1 && Engine.audioEngine) {
  32289. Engine.audioEngine.dispose();
  32290. }
  32291. // Release effects
  32292. this.releaseEffects();
  32293. // Unbind
  32294. this.unbindAllAttributes();
  32295. this._boundUniforms = [];
  32296. if (this._dummyFramebuffer) {
  32297. this._gl.deleteFramebuffer(this._dummyFramebuffer);
  32298. }
  32299. //WebVR
  32300. this.disableVR();
  32301. // Events
  32302. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  32303. window.removeEventListener("blur", this._onBlur);
  32304. window.removeEventListener("focus", this._onFocus);
  32305. window.removeEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted);
  32306. window.removeEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted);
  32307. if (this._renderingCanvas) {
  32308. this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus);
  32309. this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur);
  32310. this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut);
  32311. if (!this._doNotHandleContextLost) {
  32312. this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
  32313. this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored);
  32314. }
  32315. }
  32316. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  32317. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  32318. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  32319. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  32320. document.removeEventListener("pointerlockchange", this._onPointerLockChange);
  32321. document.removeEventListener("mspointerlockchange", this._onPointerLockChange);
  32322. document.removeEventListener("mozpointerlockchange", this._onPointerLockChange);
  32323. document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange);
  32324. if (this._onVrDisplayConnect) {
  32325. window.removeEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  32326. if (this._onVrDisplayDisconnect) {
  32327. window.removeEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  32328. }
  32329. if (this._onVrDisplayPresentChange) {
  32330. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  32331. }
  32332. this._onVrDisplayConnect = null;
  32333. this._onVrDisplayDisconnect = null;
  32334. }
  32335. }
  32336. // Remove from Instances
  32337. var index = Engine.Instances.indexOf(this);
  32338. if (index >= 0) {
  32339. Engine.Instances.splice(index, 1);
  32340. }
  32341. this._workingCanvas = null;
  32342. this._workingContext = null;
  32343. this._currentBufferPointers = [];
  32344. this._renderingCanvas = null;
  32345. this._currentProgram = null;
  32346. this._bindedRenderFunction = null;
  32347. this.onResizeObservable.clear();
  32348. this.onCanvasBlurObservable.clear();
  32349. this.onCanvasFocusObservable.clear();
  32350. this.onCanvasPointerOutObservable.clear();
  32351. this.onBeginFrameObservable.clear();
  32352. this.onEndFrameObservable.clear();
  32353. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  32354. // Abort active requests
  32355. for (var _i = 0, _a = this._activeRequests; _i < _a.length; _i++) {
  32356. var request = _a[_i];
  32357. request.abort();
  32358. }
  32359. };
  32360. // Loading screen
  32361. /**
  32362. * Display the loading screen
  32363. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32364. */
  32365. Engine.prototype.displayLoadingUI = function () {
  32366. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  32367. return;
  32368. }
  32369. var loadingScreen = this.loadingScreen;
  32370. if (loadingScreen) {
  32371. loadingScreen.displayLoadingUI();
  32372. }
  32373. };
  32374. /**
  32375. * Hide the loading screen
  32376. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32377. */
  32378. Engine.prototype.hideLoadingUI = function () {
  32379. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  32380. return;
  32381. }
  32382. var loadingScreen = this.loadingScreen;
  32383. if (loadingScreen) {
  32384. loadingScreen.hideLoadingUI();
  32385. }
  32386. };
  32387. Object.defineProperty(Engine.prototype, "loadingScreen", {
  32388. /**
  32389. * Gets the current loading screen object
  32390. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32391. */
  32392. get: function () {
  32393. if (!this._loadingScreen && this._renderingCanvas) {
  32394. this._loadingScreen = Engine.DefaultLoadingScreenFactory(this._renderingCanvas);
  32395. }
  32396. return this._loadingScreen;
  32397. },
  32398. /**
  32399. * Sets the current loading screen object
  32400. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32401. */
  32402. set: function (loadingScreen) {
  32403. this._loadingScreen = loadingScreen;
  32404. },
  32405. enumerable: true,
  32406. configurable: true
  32407. });
  32408. Object.defineProperty(Engine.prototype, "loadingUIText", {
  32409. /**
  32410. * Sets the current loading screen text
  32411. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32412. */
  32413. set: function (text) {
  32414. this.loadingScreen.loadingUIText = text;
  32415. },
  32416. enumerable: true,
  32417. configurable: true
  32418. });
  32419. Object.defineProperty(Engine.prototype, "loadingUIBackgroundColor", {
  32420. /**
  32421. * Sets the current loading screen background color
  32422. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32423. */
  32424. set: function (color) {
  32425. this.loadingScreen.loadingUIBackgroundColor = color;
  32426. },
  32427. enumerable: true,
  32428. configurable: true
  32429. });
  32430. /**
  32431. * Attach a new callback raised when context lost event is fired
  32432. * @param callback defines the callback to call
  32433. */
  32434. Engine.prototype.attachContextLostEvent = function (callback) {
  32435. if (this._renderingCanvas) {
  32436. this._renderingCanvas.addEventListener("webglcontextlost", callback, false);
  32437. }
  32438. };
  32439. /**
  32440. * Attach a new callback raised when context restored event is fired
  32441. * @param callback defines the callback to call
  32442. */
  32443. Engine.prototype.attachContextRestoredEvent = function (callback) {
  32444. if (this._renderingCanvas) {
  32445. this._renderingCanvas.addEventListener("webglcontextrestored", callback, false);
  32446. }
  32447. };
  32448. /**
  32449. * Gets the source code of the vertex shader associated with a specific webGL program
  32450. * @param program defines the program to use
  32451. * @returns a string containing the source code of the vertex shader associated with the program
  32452. */
  32453. Engine.prototype.getVertexShaderSource = function (program) {
  32454. var shaders = this._gl.getAttachedShaders(program);
  32455. if (!shaders) {
  32456. return null;
  32457. }
  32458. return this._gl.getShaderSource(shaders[0]);
  32459. };
  32460. /**
  32461. * Gets the source code of the fragment shader associated with a specific webGL program
  32462. * @param program defines the program to use
  32463. * @returns a string containing the source code of the fragment shader associated with the program
  32464. */
  32465. Engine.prototype.getFragmentShaderSource = function (program) {
  32466. var shaders = this._gl.getAttachedShaders(program);
  32467. if (!shaders) {
  32468. return null;
  32469. }
  32470. return this._gl.getShaderSource(shaders[1]);
  32471. };
  32472. /**
  32473. * Get the current error code of the webGL context
  32474. * @returns the error code
  32475. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32476. */
  32477. Engine.prototype.getError = function () {
  32478. return this._gl.getError();
  32479. };
  32480. // FPS
  32481. /**
  32482. * Gets the current framerate
  32483. * @returns a number representing the framerate
  32484. */
  32485. Engine.prototype.getFps = function () {
  32486. return this._fps;
  32487. };
  32488. /**
  32489. * Gets the time spent between current and previous frame
  32490. * @returns a number representing the delta time in ms
  32491. */
  32492. Engine.prototype.getDeltaTime = function () {
  32493. return this._deltaTime;
  32494. };
  32495. Engine.prototype._measureFps = function () {
  32496. this._performanceMonitor.sampleFrame();
  32497. this._fps = this._performanceMonitor.averageFPS;
  32498. this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;
  32499. };
  32500. /** @hidden */
  32501. Engine.prototype._readTexturePixels = function (texture, width, height, faceIndex, level, buffer) {
  32502. if (faceIndex === void 0) { faceIndex = -1; }
  32503. if (level === void 0) { level = 0; }
  32504. if (buffer === void 0) { buffer = null; }
  32505. var gl = this._gl;
  32506. if (!this._dummyFramebuffer) {
  32507. var dummy = gl.createFramebuffer();
  32508. if (!dummy) {
  32509. throw new Error("Unable to create dummy framebuffer");
  32510. }
  32511. this._dummyFramebuffer = dummy;
  32512. }
  32513. gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);
  32514. if (faceIndex > -1) {
  32515. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, level);
  32516. }
  32517. else {
  32518. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, level);
  32519. }
  32520. var readType = (texture.type !== undefined) ? this._getWebGLTextureType(texture.type) : gl.UNSIGNED_BYTE;
  32521. switch (readType) {
  32522. case gl.UNSIGNED_BYTE:
  32523. if (!buffer) {
  32524. buffer = new Uint8Array(4 * width * height);
  32525. }
  32526. readType = gl.UNSIGNED_BYTE;
  32527. break;
  32528. default:
  32529. if (!buffer) {
  32530. buffer = new Float32Array(4 * width * height);
  32531. }
  32532. readType = gl.FLOAT;
  32533. break;
  32534. }
  32535. gl.readPixels(0, 0, width, height, gl.RGBA, readType, buffer);
  32536. gl.bindFramebuffer(gl.FRAMEBUFFER, this._currentFramebuffer);
  32537. return buffer;
  32538. };
  32539. Engine.prototype._canRenderToFloatFramebuffer = function () {
  32540. if (this._webGLVersion > 1) {
  32541. return this._caps.colorBufferFloat;
  32542. }
  32543. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_FLOAT);
  32544. };
  32545. Engine.prototype._canRenderToHalfFloatFramebuffer = function () {
  32546. if (this._webGLVersion > 1) {
  32547. return this._caps.colorBufferFloat;
  32548. }
  32549. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_HALF_FLOAT);
  32550. };
  32551. // Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture
  32552. Engine.prototype._canRenderToFramebuffer = function (type) {
  32553. var gl = this._gl;
  32554. //clear existing errors
  32555. while (gl.getError() !== gl.NO_ERROR) { }
  32556. var successful = true;
  32557. var texture = gl.createTexture();
  32558. gl.bindTexture(gl.TEXTURE_2D, texture);
  32559. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), 1, 1, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  32560. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  32561. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  32562. var fb = gl.createFramebuffer();
  32563. gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
  32564. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
  32565. var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
  32566. successful = successful && (status === gl.FRAMEBUFFER_COMPLETE);
  32567. successful = successful && (gl.getError() === gl.NO_ERROR);
  32568. //try render by clearing frame buffer's color buffer
  32569. if (successful) {
  32570. gl.clear(gl.COLOR_BUFFER_BIT);
  32571. successful = successful && (gl.getError() === gl.NO_ERROR);
  32572. }
  32573. //try reading from frame to ensure render occurs (just creating the FBO is not sufficient to determine if rendering is supported)
  32574. if (successful) {
  32575. //in practice it's sufficient to just read from the backbuffer rather than handle potentially issues reading from the texture
  32576. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  32577. var readFormat = gl.RGBA;
  32578. var readType = gl.UNSIGNED_BYTE;
  32579. var buffer = new Uint8Array(4);
  32580. gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer);
  32581. successful = successful && (gl.getError() === gl.NO_ERROR);
  32582. }
  32583. //clean up
  32584. gl.deleteTexture(texture);
  32585. gl.deleteFramebuffer(fb);
  32586. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  32587. //clear accumulated errors
  32588. while (!successful && (gl.getError() !== gl.NO_ERROR)) { }
  32589. return successful;
  32590. };
  32591. /** @hidden */
  32592. Engine.prototype._getWebGLTextureType = function (type) {
  32593. if (this._webGLVersion === 1) {
  32594. switch (type) {
  32595. case Engine.TEXTURETYPE_FLOAT:
  32596. return this._gl.FLOAT;
  32597. case Engine.TEXTURETYPE_HALF_FLOAT:
  32598. return this._gl.HALF_FLOAT_OES;
  32599. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  32600. return this._gl.UNSIGNED_BYTE;
  32601. }
  32602. return this._gl.UNSIGNED_BYTE;
  32603. }
  32604. switch (type) {
  32605. case Engine.TEXTURETYPE_BYTE:
  32606. return this._gl.BYTE;
  32607. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  32608. return this._gl.UNSIGNED_BYTE;
  32609. case Engine.TEXTURETYPE_SHORT:
  32610. return this._gl.SHORT;
  32611. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  32612. return this._gl.UNSIGNED_SHORT;
  32613. case Engine.TEXTURETYPE_INT:
  32614. return this._gl.INT;
  32615. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  32616. return this._gl.UNSIGNED_INT;
  32617. case Engine.TEXTURETYPE_FLOAT:
  32618. return this._gl.FLOAT;
  32619. case Engine.TEXTURETYPE_HALF_FLOAT:
  32620. return this._gl.HALF_FLOAT;
  32621. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  32622. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  32623. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  32624. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  32625. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  32626. return this._gl.UNSIGNED_SHORT_5_6_5;
  32627. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  32628. return this._gl.UNSIGNED_INT_2_10_10_10_REV;
  32629. case Engine.TEXTURETYPE_UNSIGNED_INT_24_8:
  32630. return this._gl.UNSIGNED_INT_24_8;
  32631. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  32632. return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
  32633. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  32634. return this._gl.UNSIGNED_INT_5_9_9_9_REV;
  32635. case Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
  32636. return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
  32637. }
  32638. return this._gl.UNSIGNED_BYTE;
  32639. };
  32640. Engine.prototype._getInternalFormat = function (format) {
  32641. var internalFormat = this._gl.RGBA;
  32642. switch (format) {
  32643. case Engine.TEXTUREFORMAT_ALPHA:
  32644. internalFormat = this._gl.ALPHA;
  32645. break;
  32646. case Engine.TEXTUREFORMAT_LUMINANCE:
  32647. internalFormat = this._gl.LUMINANCE;
  32648. break;
  32649. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  32650. internalFormat = this._gl.LUMINANCE_ALPHA;
  32651. break;
  32652. case Engine.TEXTUREFORMAT_RED:
  32653. internalFormat = this._gl.RED;
  32654. break;
  32655. case Engine.TEXTUREFORMAT_RG:
  32656. internalFormat = this._gl.RG;
  32657. break;
  32658. case Engine.TEXTUREFORMAT_RGB:
  32659. internalFormat = this._gl.RGB;
  32660. break;
  32661. case Engine.TEXTUREFORMAT_RGBA:
  32662. internalFormat = this._gl.RGBA;
  32663. break;
  32664. }
  32665. if (this._webGLVersion > 1) {
  32666. switch (format) {
  32667. case Engine.TEXTUREFORMAT_RED_INTEGER:
  32668. internalFormat = this._gl.RED_INTEGER;
  32669. break;
  32670. case Engine.TEXTUREFORMAT_RG_INTEGER:
  32671. internalFormat = this._gl.RG_INTEGER;
  32672. break;
  32673. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  32674. internalFormat = this._gl.RGB_INTEGER;
  32675. break;
  32676. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32677. internalFormat = this._gl.RGBA_INTEGER;
  32678. break;
  32679. }
  32680. }
  32681. return internalFormat;
  32682. };
  32683. /** @hidden */
  32684. Engine.prototype._getRGBABufferInternalSizedFormat = function (type, format) {
  32685. if (this._webGLVersion === 1) {
  32686. if (format !== undefined) {
  32687. switch (format) {
  32688. case Engine.TEXTUREFORMAT_ALPHA:
  32689. return this._gl.ALPHA;
  32690. case Engine.TEXTUREFORMAT_LUMINANCE:
  32691. return this._gl.LUMINANCE;
  32692. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  32693. return this._gl.LUMINANCE_ALPHA;
  32694. }
  32695. }
  32696. return this._gl.RGBA;
  32697. }
  32698. switch (type) {
  32699. case Engine.TEXTURETYPE_BYTE:
  32700. switch (format) {
  32701. case Engine.TEXTUREFORMAT_RED:
  32702. return this._gl.R8_SNORM;
  32703. case Engine.TEXTUREFORMAT_RG:
  32704. return this._gl.RG8_SNORM;
  32705. case Engine.TEXTUREFORMAT_RGB:
  32706. return this._gl.RGB8_SNORM;
  32707. case Engine.TEXTUREFORMAT_RED_INTEGER:
  32708. return this._gl.R8I;
  32709. case Engine.TEXTUREFORMAT_RG_INTEGER:
  32710. return this._gl.RG8I;
  32711. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  32712. return this._gl.RGB8I;
  32713. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32714. return this._gl.RGBA8I;
  32715. default:
  32716. return this._gl.RGBA8_SNORM;
  32717. }
  32718. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  32719. switch (format) {
  32720. case Engine.TEXTUREFORMAT_RED:
  32721. return this._gl.R8;
  32722. case Engine.TEXTUREFORMAT_RG:
  32723. return this._gl.RG8;
  32724. case Engine.TEXTUREFORMAT_RGB:
  32725. return this._gl.RGB8; // By default. Other possibilities are RGB565, SRGB8.
  32726. case Engine.TEXTUREFORMAT_RGBA:
  32727. return this._gl.RGBA8; // By default. Other possibilities are RGB5_A1, RGBA4, SRGB8_ALPHA8.
  32728. case Engine.TEXTUREFORMAT_RED_INTEGER:
  32729. return this._gl.R8UI;
  32730. case Engine.TEXTUREFORMAT_RG_INTEGER:
  32731. return this._gl.RG8UI;
  32732. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  32733. return this._gl.RGB8UI;
  32734. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32735. return this._gl.RGBA8UI;
  32736. default:
  32737. return this._gl.RGBA8;
  32738. }
  32739. case Engine.TEXTURETYPE_SHORT:
  32740. switch (format) {
  32741. case Engine.TEXTUREFORMAT_RED_INTEGER:
  32742. return this._gl.R16I;
  32743. case Engine.TEXTUREFORMAT_RG_INTEGER:
  32744. return this._gl.RG16I;
  32745. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  32746. return this._gl.RGB16I;
  32747. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32748. return this._gl.RGBA16I;
  32749. default:
  32750. return this._gl.RGBA16I;
  32751. }
  32752. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  32753. switch (format) {
  32754. case Engine.TEXTUREFORMAT_RED_INTEGER:
  32755. return this._gl.R16UI;
  32756. case Engine.TEXTUREFORMAT_RG_INTEGER:
  32757. return this._gl.RG16UI;
  32758. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  32759. return this._gl.RGB16UI;
  32760. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32761. return this._gl.RGBA16UI;
  32762. default:
  32763. return this._gl.RGBA16UI;
  32764. }
  32765. case Engine.TEXTURETYPE_INT:
  32766. switch (format) {
  32767. case Engine.TEXTUREFORMAT_RED_INTEGER:
  32768. return this._gl.R32I;
  32769. case Engine.TEXTUREFORMAT_RG_INTEGER:
  32770. return this._gl.RG32I;
  32771. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  32772. return this._gl.RGB32I;
  32773. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32774. return this._gl.RGBA32I;
  32775. default:
  32776. return this._gl.RGBA32I;
  32777. }
  32778. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  32779. switch (format) {
  32780. case Engine.TEXTUREFORMAT_RED_INTEGER:
  32781. return this._gl.R32UI;
  32782. case Engine.TEXTUREFORMAT_RG_INTEGER:
  32783. return this._gl.RG32UI;
  32784. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  32785. return this._gl.RGB32UI;
  32786. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32787. return this._gl.RGBA32UI;
  32788. default:
  32789. return this._gl.RGBA32UI;
  32790. }
  32791. case Engine.TEXTURETYPE_FLOAT:
  32792. switch (format) {
  32793. case Engine.TEXTUREFORMAT_RED:
  32794. return this._gl.R32F; // By default. Other possibility is R16F.
  32795. case Engine.TEXTUREFORMAT_RG:
  32796. return this._gl.RG32F; // By default. Other possibility is RG16F.
  32797. case Engine.TEXTUREFORMAT_RGB:
  32798. return this._gl.RGB32F; // By default. Other possibilities are RGB16F, R11F_G11F_B10F, RGB9_E5.
  32799. case Engine.TEXTUREFORMAT_RGBA:
  32800. return this._gl.RGBA32F; // By default. Other possibility is RGBA16F.
  32801. default:
  32802. return this._gl.RGBA32F;
  32803. }
  32804. case Engine.TEXTURETYPE_HALF_FLOAT:
  32805. switch (format) {
  32806. case Engine.TEXTUREFORMAT_RED:
  32807. return this._gl.R16F;
  32808. case Engine.TEXTUREFORMAT_RG:
  32809. return this._gl.RG16F;
  32810. case Engine.TEXTUREFORMAT_RGB:
  32811. return this._gl.RGB16F; // By default. Other possibilities are R11F_G11F_B10F, RGB9_E5.
  32812. case Engine.TEXTUREFORMAT_RGBA:
  32813. return this._gl.RGBA16F;
  32814. default:
  32815. return this._gl.RGBA16F;
  32816. }
  32817. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  32818. return this._gl.RGB565;
  32819. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  32820. return this._gl.R11F_G11F_B10F;
  32821. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  32822. return this._gl.RGB9_E5;
  32823. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  32824. return this._gl.RGBA4;
  32825. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  32826. return this._gl.RGB5_A1;
  32827. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  32828. switch (format) {
  32829. case Engine.TEXTUREFORMAT_RGBA:
  32830. return this._gl.RGB10_A2; // By default. Other possibility is RGB5_A1.
  32831. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32832. return this._gl.RGB10_A2UI;
  32833. default:
  32834. return this._gl.RGB10_A2;
  32835. }
  32836. }
  32837. return this._gl.RGBA8;
  32838. };
  32839. /** @hidden */
  32840. Engine.prototype._getRGBAMultiSampleBufferFormat = function (type) {
  32841. if (type === Engine.TEXTURETYPE_FLOAT) {
  32842. return this._gl.RGBA32F;
  32843. }
  32844. else if (type === Engine.TEXTURETYPE_HALF_FLOAT) {
  32845. return this._gl.RGBA16F;
  32846. }
  32847. return this._gl.RGBA8;
  32848. };
  32849. /** @hidden */
  32850. Engine.prototype._loadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  32851. var _this = this;
  32852. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError);
  32853. this._activeRequests.push(request);
  32854. request.onCompleteObservable.add(function (request) {
  32855. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  32856. });
  32857. return request;
  32858. };
  32859. /** @hidden */
  32860. Engine.prototype._loadFileAsync = function (url, offlineProvider, useArrayBuffer) {
  32861. var _this = this;
  32862. return new Promise(function (resolve, reject) {
  32863. _this._loadFile(url, function (data) {
  32864. resolve(data);
  32865. }, undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  32866. reject(exception);
  32867. });
  32868. });
  32869. };
  32870. Engine.prototype._partialLoadFile = function (url, index, loadedFiles, onfinish, onErrorCallBack) {
  32871. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  32872. var onload = function (data) {
  32873. loadedFiles[index] = data;
  32874. loadedFiles._internalCount++;
  32875. if (loadedFiles._internalCount === 6) {
  32876. onfinish(loadedFiles);
  32877. }
  32878. };
  32879. var onerror = function (request, exception) {
  32880. if (onErrorCallBack && request) {
  32881. onErrorCallBack(request.status + " " + request.statusText, exception);
  32882. }
  32883. };
  32884. this._loadFile(url, onload, undefined, undefined, true, onerror);
  32885. };
  32886. Engine.prototype._cascadeLoadFiles = function (scene, onfinish, files, onError) {
  32887. if (onError === void 0) { onError = null; }
  32888. var loadedFiles = [];
  32889. loadedFiles._internalCount = 0;
  32890. for (var index = 0; index < 6; index++) {
  32891. this._partialLoadFile(files[index], index, loadedFiles, onfinish, onError);
  32892. }
  32893. };
  32894. // Statics
  32895. /**
  32896. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32897. * @returns true if the engine can be created
  32898. * @ignorenaming
  32899. */
  32900. Engine.isSupported = function () {
  32901. try {
  32902. var tempcanvas = document.createElement("canvas");
  32903. var gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
  32904. return gl != null && !!window.WebGLRenderingContext;
  32905. }
  32906. catch (e) {
  32907. return false;
  32908. }
  32909. };
  32910. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  32911. Engine.ExceptionList = [
  32912. { key: "Chrome/63.0", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
  32913. { key: "Firefox/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  32914. { key: "Firefox/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  32915. { key: "Macintosh", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  32916. { key: "iPhone", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  32917. { key: "iPad", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] }
  32918. ];
  32919. /**
  32920. * Hidden
  32921. */
  32922. Engine._TextureLoaders = [];
  32923. // Const statics
  32924. /** Defines that alpha blending is disabled */
  32925. Engine.ALPHA_DISABLE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_DISABLE;
  32926. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32927. Engine.ALPHA_ADD = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ADD;
  32928. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32929. Engine.ALPHA_COMBINE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_COMBINE;
  32930. /** Defines that alpha blending to DEST - SRC * DEST */
  32931. Engine.ALPHA_SUBTRACT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SUBTRACT;
  32932. /** Defines that alpha blending to SRC * DEST */
  32933. Engine.ALPHA_MULTIPLY = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MULTIPLY;
  32934. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32935. Engine.ALPHA_MAXIMIZED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MAXIMIZED;
  32936. /** Defines that alpha blending to SRC + DEST */
  32937. Engine.ALPHA_ONEONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ONEONE;
  32938. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32939. Engine.ALPHA_PREMULTIPLIED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED;
  32940. /**
  32941. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32942. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32943. */
  32944. Engine.ALPHA_PREMULTIPLIED_PORTERDUFF = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  32945. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32946. Engine.ALPHA_INTERPOLATE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_INTERPOLATE;
  32947. /**
  32948. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32949. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32950. */
  32951. Engine.ALPHA_SCREENMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SCREENMODE;
  32952. /** Defines that the ressource is not delayed*/
  32953. Engine.DELAYLOADSTATE_NONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NONE;
  32954. /** Defines that the ressource was successfully delay loaded */
  32955. Engine.DELAYLOADSTATE_LOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADED;
  32956. /** Defines that the ressource is currently delay loading */
  32957. Engine.DELAYLOADSTATE_LOADING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADING;
  32958. /** Defines that the ressource is delayed and has not started loading */
  32959. Engine.DELAYLOADSTATE_NOTLOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NOTLOADED;
  32960. // Depht or Stencil test Constants.
  32961. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32962. Engine.NEVER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NEVER;
  32963. /** 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 */
  32964. Engine.ALWAYS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALWAYS;
  32965. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32966. Engine.LESS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LESS;
  32967. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32968. Engine.EQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].EQUAL;
  32969. /** 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 */
  32970. Engine.LEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LEQUAL;
  32971. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32972. Engine.GREATER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GREATER;
  32973. /** 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 */
  32974. Engine.GEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GEQUAL;
  32975. /** 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 */
  32976. Engine.NOTEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NOTEQUAL;
  32977. // Stencil Actions Constants.
  32978. /** Passed to stencilOperation to specify that stencil value must be kept */
  32979. Engine.KEEP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].KEEP;
  32980. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32981. Engine.REPLACE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].REPLACE;
  32982. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32983. Engine.INCR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR;
  32984. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32985. Engine.DECR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR;
  32986. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32987. Engine.INVERT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INVERT;
  32988. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32989. Engine.INCR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR_WRAP;
  32990. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32991. Engine.DECR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR_WRAP;
  32992. /** Texture is not repeating outside of 0..1 UVs */
  32993. Engine.TEXTURE_CLAMP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  32994. /** Texture is repeating outside of 0..1 UVs */
  32995. Engine.TEXTURE_WRAP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  32996. /** Texture is repeating and mirrored */
  32997. Engine.TEXTURE_MIRROR_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  32998. /** ALPHA */
  32999. Engine.TEXTUREFORMAT_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_ALPHA;
  33000. /** LUMINANCE */
  33001. Engine.TEXTUREFORMAT_LUMINANCE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE;
  33002. /** LUMINANCE_ALPHA */
  33003. Engine.TEXTUREFORMAT_LUMINANCE_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA;
  33004. /** RGB */
  33005. Engine.TEXTUREFORMAT_RGB = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB;
  33006. /** RGBA */
  33007. Engine.TEXTUREFORMAT_RGBA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA;
  33008. /** RED */
  33009. Engine.TEXTUREFORMAT_RED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED;
  33010. /** RED (2nd reference) */
  33011. Engine.TEXTUREFORMAT_R = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R;
  33012. /** RG */
  33013. Engine.TEXTUREFORMAT_RG = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG;
  33014. /** RED_INTEGER */
  33015. Engine.TEXTUREFORMAT_RED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED_INTEGER;
  33016. /** RED_INTEGER (2nd reference) */
  33017. Engine.TEXTUREFORMAT_R_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R_INTEGER;
  33018. /** RG_INTEGER */
  33019. Engine.TEXTUREFORMAT_RG_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG_INTEGER;
  33020. /** RGB_INTEGER */
  33021. Engine.TEXTUREFORMAT_RGB_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB_INTEGER;
  33022. /** RGBA_INTEGER */
  33023. Engine.TEXTUREFORMAT_RGBA_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA_INTEGER;
  33024. /** UNSIGNED_BYTE */
  33025. Engine.TEXTURETYPE_UNSIGNED_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_BYTE;
  33026. /** UNSIGNED_BYTE (2nd reference) */
  33027. Engine.TEXTURETYPE_UNSIGNED_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  33028. /** FLOAT */
  33029. Engine.TEXTURETYPE_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT;
  33030. /** HALF_FLOAT */
  33031. Engine.TEXTURETYPE_HALF_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_HALF_FLOAT;
  33032. /** BYTE */
  33033. Engine.TEXTURETYPE_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_BYTE;
  33034. /** SHORT */
  33035. Engine.TEXTURETYPE_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_SHORT;
  33036. /** UNSIGNED_SHORT */
  33037. Engine.TEXTURETYPE_UNSIGNED_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT;
  33038. /** INT */
  33039. Engine.TEXTURETYPE_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_INT;
  33040. /** UNSIGNED_INT */
  33041. Engine.TEXTURETYPE_UNSIGNED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INTEGER;
  33042. /** UNSIGNED_SHORT_4_4_4_4 */
  33043. Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4;
  33044. /** UNSIGNED_SHORT_5_5_5_1 */
  33045. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1;
  33046. /** UNSIGNED_SHORT_5_6_5 */
  33047. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_6_5;
  33048. /** UNSIGNED_INT_2_10_10_10_REV */
  33049. Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV;
  33050. /** UNSIGNED_INT_24_8 */
  33051. Engine.TEXTURETYPE_UNSIGNED_INT_24_8 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_24_8;
  33052. /** UNSIGNED_INT_10F_11F_11F_REV */
  33053. Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV;
  33054. /** UNSIGNED_INT_5_9_9_9_REV */
  33055. Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV;
  33056. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33057. Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV;
  33058. /** nearest is mag = nearest and min = nearest and mip = linear */
  33059. Engine.TEXTURE_NEAREST_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  33060. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33061. Engine.TEXTURE_BILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  33062. /** Trilinear is mag = linear and min = linear and mip = linear */
  33063. Engine.TEXTURE_TRILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  33064. /** nearest is mag = nearest and min = nearest and mip = linear */
  33065. Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPLINEAR;
  33066. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33067. Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPNEAREST;
  33068. /** Trilinear is mag = linear and min = linear and mip = linear */
  33069. Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPLINEAR;
  33070. /** mag = nearest and min = nearest and mip = nearest */
  33071. Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  33072. /** mag = nearest and min = linear and mip = nearest */
  33073. Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  33074. /** mag = nearest and min = linear and mip = linear */
  33075. Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  33076. /** mag = nearest and min = linear and mip = none */
  33077. Engine.TEXTURE_NEAREST_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR;
  33078. /** mag = nearest and min = nearest and mip = none */
  33079. Engine.TEXTURE_NEAREST_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST;
  33080. /** mag = linear and min = nearest and mip = nearest */
  33081. Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  33082. /** mag = linear and min = nearest and mip = linear */
  33083. Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  33084. /** mag = linear and min = linear and mip = none */
  33085. Engine.TEXTURE_LINEAR_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR;
  33086. /** mag = linear and min = nearest and mip = none */
  33087. Engine.TEXTURE_LINEAR_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST;
  33088. /** Explicit coordinates mode */
  33089. Engine.TEXTURE_EXPLICIT_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EXPLICIT_MODE;
  33090. /** Spherical coordinates mode */
  33091. Engine.TEXTURE_SPHERICAL_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SPHERICAL_MODE;
  33092. /** Planar coordinates mode */
  33093. Engine.TEXTURE_PLANAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PLANAR_MODE;
  33094. /** Cubic coordinates mode */
  33095. Engine.TEXTURE_CUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CUBIC_MODE;
  33096. /** Projection coordinates mode */
  33097. Engine.TEXTURE_PROJECTION_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PROJECTION_MODE;
  33098. /** Skybox coordinates mode */
  33099. Engine.TEXTURE_SKYBOX_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SKYBOX_MODE;
  33100. /** Inverse Cubic coordinates mode */
  33101. Engine.TEXTURE_INVCUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_INVCUBIC_MODE;
  33102. /** Equirectangular coordinates mode */
  33103. Engine.TEXTURE_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  33104. /** Equirectangular Fixed coordinates mode */
  33105. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  33106. /** Equirectangular Fixed Mirrored coordinates mode */
  33107. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  33108. // Texture rescaling mode
  33109. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33110. Engine.SCALEMODE_FLOOR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_FLOOR;
  33111. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33112. Engine.SCALEMODE_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_NEAREST;
  33113. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33114. Engine.SCALEMODE_CEILING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_CEILING;
  33115. // Updatable statics so stick with vars here
  33116. /**
  33117. * Gets or sets the epsilon value used by collision engine
  33118. */
  33119. Engine.CollisionsEpsilon = 0.001;
  33120. /**
  33121. * Method called to create the default rescale post process on each engine.
  33122. */
  33123. Engine._RescalePostProcessFactory = null;
  33124. return Engine;
  33125. }());
  33126. /***/ }),
  33127. /***/ "./Engines/engineStore.ts":
  33128. /*!********************************!*\
  33129. !*** ./Engines/engineStore.ts ***!
  33130. \********************************/
  33131. /*! exports provided: EngineStore */
  33132. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33133. "use strict";
  33134. __webpack_require__.r(__webpack_exports__);
  33135. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return EngineStore; });
  33136. /**
  33137. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33138. * during the life time of the application.
  33139. */
  33140. var EngineStore = /** @class */ (function () {
  33141. function EngineStore() {
  33142. }
  33143. Object.defineProperty(EngineStore, "LastCreatedEngine", {
  33144. /**
  33145. * Gets the latest created engine
  33146. */
  33147. get: function () {
  33148. if (this.Instances.length === 0) {
  33149. return null;
  33150. }
  33151. return this.Instances[this.Instances.length - 1];
  33152. },
  33153. enumerable: true,
  33154. configurable: true
  33155. });
  33156. Object.defineProperty(EngineStore, "LastCreatedScene", {
  33157. /**
  33158. * Gets the latest created scene
  33159. */
  33160. get: function () {
  33161. var lastCreatedEngine = this.LastCreatedEngine;
  33162. if (!lastCreatedEngine) {
  33163. return null;
  33164. }
  33165. if (lastCreatedEngine.scenes.length === 0) {
  33166. return null;
  33167. }
  33168. return lastCreatedEngine.scenes[lastCreatedEngine.scenes.length - 1];
  33169. },
  33170. enumerable: true,
  33171. configurable: true
  33172. });
  33173. /** Gets the list of created engines */
  33174. EngineStore.Instances = new Array();
  33175. return EngineStore;
  33176. }());
  33177. /***/ }),
  33178. /***/ "./Engines/index.ts":
  33179. /*!**************************!*\
  33180. !*** ./Engines/index.ts ***!
  33181. \**************************/
  33182. /*! exports provided: Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  33183. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33184. "use strict";
  33185. __webpack_require__.r(__webpack_exports__);
  33186. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  33187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _constants__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  33188. /* harmony import */ var _engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine */ "./Engines/engine.ts");
  33189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["InstancingAttributeInfo"]; });
  33190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["DepthTextureCreationOptions"]; });
  33191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["EngineCapabilities"]; });
  33192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]; });
  33193. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  33194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"]; });
  33195. /* harmony import */ var _nullEngine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nullEngine */ "./Engines/nullEngine.ts");
  33196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngineOptions"]; });
  33197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngine"]; });
  33198. /* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Extensions/index */ "./Engines/Extensions/index.ts");
  33199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_OcclusionDataStorage"]; });
  33200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_forceTransformFeedbackToBundle"]; });
  33201. /***/ }),
  33202. /***/ "./Engines/nullEngine.ts":
  33203. /*!*******************************!*\
  33204. !*** ./Engines/nullEngine.ts ***!
  33205. \*******************************/
  33206. /*! exports provided: NullEngineOptions, NullEngine */
  33207. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33208. "use strict";
  33209. __webpack_require__.r(__webpack_exports__);
  33210. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return NullEngineOptions; });
  33211. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return NullEngine; });
  33212. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  33213. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  33214. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  33215. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  33216. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  33217. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  33218. /**
  33219. * Options to create the null engine
  33220. */
  33221. var NullEngineOptions = /** @class */ (function () {
  33222. function NullEngineOptions() {
  33223. /**
  33224. * Render width (Default: 512)
  33225. */
  33226. this.renderWidth = 512;
  33227. /**
  33228. * Render height (Default: 256)
  33229. */
  33230. this.renderHeight = 256;
  33231. /**
  33232. * Texture size (Default: 512)
  33233. */
  33234. this.textureSize = 512;
  33235. /**
  33236. * If delta time between frames should be constant
  33237. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33238. */
  33239. this.deterministicLockstep = false;
  33240. /**
  33241. * Maximum about of steps between frames (Default: 4)
  33242. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33243. */
  33244. this.lockstepMaxSteps = 4;
  33245. }
  33246. return NullEngineOptions;
  33247. }());
  33248. /**
  33249. * The null engine class provides support for headless version of babylon.js.
  33250. * This can be used in server side scenario or for testing purposes
  33251. */
  33252. var NullEngine = /** @class */ (function (_super) {
  33253. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NullEngine, _super);
  33254. function NullEngine(options) {
  33255. if (options === void 0) { options = new NullEngineOptions(); }
  33256. var _this = _super.call(this, null) || this;
  33257. if (options.deterministicLockstep === undefined) {
  33258. options.deterministicLockstep = false;
  33259. }
  33260. if (options.lockstepMaxSteps === undefined) {
  33261. options.lockstepMaxSteps = 4;
  33262. }
  33263. _this._options = options;
  33264. // Init caps
  33265. // We consider we are on a webgl1 capable device
  33266. _this._caps = new _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["EngineCapabilities"]();
  33267. _this._caps.maxTexturesImageUnits = 16;
  33268. _this._caps.maxVertexTextureImageUnits = 16;
  33269. _this._caps.maxTextureSize = 512;
  33270. _this._caps.maxCubemapTextureSize = 512;
  33271. _this._caps.maxRenderTextureSize = 512;
  33272. _this._caps.maxVertexAttribs = 16;
  33273. _this._caps.maxVaryingVectors = 16;
  33274. _this._caps.maxFragmentUniformVectors = 16;
  33275. _this._caps.maxVertexUniformVectors = 16;
  33276. // Extensions
  33277. _this._caps.standardDerivatives = false;
  33278. _this._caps.astc = null;
  33279. _this._caps.s3tc = null;
  33280. _this._caps.pvrtc = null;
  33281. _this._caps.etc1 = null;
  33282. _this._caps.etc2 = null;
  33283. _this._caps.textureAnisotropicFilterExtension = null;
  33284. _this._caps.maxAnisotropy = 0;
  33285. _this._caps.uintIndices = false;
  33286. _this._caps.fragmentDepthSupported = false;
  33287. _this._caps.highPrecisionShaderSupported = true;
  33288. _this._caps.colorBufferFloat = false;
  33289. _this._caps.textureFloat = false;
  33290. _this._caps.textureFloatLinearFiltering = false;
  33291. _this._caps.textureFloatRender = false;
  33292. _this._caps.textureHalfFloat = false;
  33293. _this._caps.textureHalfFloatLinearFiltering = false;
  33294. _this._caps.textureHalfFloatRender = false;
  33295. _this._caps.textureLOD = false;
  33296. _this._caps.drawBuffersExtension = false;
  33297. _this._caps.depthTextureExtension = false;
  33298. _this._caps.vertexArrayObject = false;
  33299. _this._caps.instancedArrays = false;
  33300. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("Babylon.js v" + _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].Version + " - Null engine");
  33301. // Wrappers
  33302. if (typeof URL === "undefined") {
  33303. URL = {
  33304. createObjectURL: function () { },
  33305. revokeObjectURL: function () { }
  33306. };
  33307. }
  33308. if (typeof Blob === "undefined") {
  33309. Blob = function () { };
  33310. }
  33311. return _this;
  33312. }
  33313. /**
  33314. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33315. */
  33316. NullEngine.prototype.isDeterministicLockStep = function () {
  33317. return this._options.deterministicLockstep;
  33318. };
  33319. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  33320. NullEngine.prototype.getLockstepMaxSteps = function () {
  33321. return this._options.lockstepMaxSteps;
  33322. };
  33323. /**
  33324. * Sets hardware scaling, used to save performance if needed
  33325. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  33326. */
  33327. NullEngine.prototype.getHardwareScalingLevel = function () {
  33328. return 1.0;
  33329. };
  33330. NullEngine.prototype.createVertexBuffer = function (vertices) {
  33331. return {
  33332. capacity: 0,
  33333. references: 1,
  33334. is32Bits: false
  33335. };
  33336. };
  33337. NullEngine.prototype.createIndexBuffer = function (indices) {
  33338. return {
  33339. capacity: 0,
  33340. references: 1,
  33341. is32Bits: false
  33342. };
  33343. };
  33344. NullEngine.prototype.clear = function (color, backBuffer, depth, stencil) {
  33345. if (stencil === void 0) { stencil = false; }
  33346. };
  33347. NullEngine.prototype.getRenderWidth = function (useScreen) {
  33348. if (useScreen === void 0) { useScreen = false; }
  33349. if (!useScreen && this._currentRenderTarget) {
  33350. return this._currentRenderTarget.width;
  33351. }
  33352. return this._options.renderWidth;
  33353. };
  33354. NullEngine.prototype.getRenderHeight = function (useScreen) {
  33355. if (useScreen === void 0) { useScreen = false; }
  33356. if (!useScreen && this._currentRenderTarget) {
  33357. return this._currentRenderTarget.height;
  33358. }
  33359. return this._options.renderHeight;
  33360. };
  33361. NullEngine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  33362. this._cachedViewport = viewport;
  33363. };
  33364. NullEngine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context) {
  33365. return {
  33366. transformFeedback: null,
  33367. __SPECTOR_rebuildProgram: null,
  33368. isParallelCompiled: false
  33369. };
  33370. };
  33371. NullEngine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  33372. return [];
  33373. };
  33374. NullEngine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  33375. return [];
  33376. };
  33377. NullEngine.prototype.bindSamplers = function (effect) {
  33378. this._currentEffect = null;
  33379. };
  33380. NullEngine.prototype.enableEffect = function (effect) {
  33381. this._currentEffect = effect;
  33382. if (effect.onBind) {
  33383. effect.onBind(effect);
  33384. }
  33385. if (effect._onBindObservable) {
  33386. effect._onBindObservable.notifyObservers(effect);
  33387. }
  33388. };
  33389. NullEngine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  33390. if (zOffset === void 0) { zOffset = 0; }
  33391. if (reverseSide === void 0) { reverseSide = false; }
  33392. };
  33393. NullEngine.prototype.setIntArray = function (uniform, array) {
  33394. };
  33395. NullEngine.prototype.setIntArray2 = function (uniform, array) {
  33396. };
  33397. NullEngine.prototype.setIntArray3 = function (uniform, array) {
  33398. };
  33399. NullEngine.prototype.setIntArray4 = function (uniform, array) {
  33400. };
  33401. NullEngine.prototype.setFloatArray = function (uniform, array) {
  33402. };
  33403. NullEngine.prototype.setFloatArray2 = function (uniform, array) {
  33404. };
  33405. NullEngine.prototype.setFloatArray3 = function (uniform, array) {
  33406. };
  33407. NullEngine.prototype.setFloatArray4 = function (uniform, array) {
  33408. };
  33409. NullEngine.prototype.setArray = function (uniform, array) {
  33410. };
  33411. NullEngine.prototype.setArray2 = function (uniform, array) {
  33412. };
  33413. NullEngine.prototype.setArray3 = function (uniform, array) {
  33414. };
  33415. NullEngine.prototype.setArray4 = function (uniform, array) {
  33416. };
  33417. NullEngine.prototype.setMatrices = function (uniform, matrices) {
  33418. };
  33419. NullEngine.prototype.setMatrix = function (uniform, matrix) {
  33420. };
  33421. NullEngine.prototype.setMatrix3x3 = function (uniform, matrix) {
  33422. };
  33423. NullEngine.prototype.setMatrix2x2 = function (uniform, matrix) {
  33424. };
  33425. NullEngine.prototype.setFloat = function (uniform, value) {
  33426. };
  33427. NullEngine.prototype.setFloat2 = function (uniform, x, y) {
  33428. };
  33429. NullEngine.prototype.setFloat3 = function (uniform, x, y, z) {
  33430. };
  33431. NullEngine.prototype.setBool = function (uniform, bool) {
  33432. };
  33433. NullEngine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  33434. };
  33435. NullEngine.prototype.setColor3 = function (uniform, color3) {
  33436. };
  33437. NullEngine.prototype.setColor4 = function (uniform, color3, alpha) {
  33438. };
  33439. NullEngine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  33440. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  33441. if (this._alphaMode === mode) {
  33442. return;
  33443. }
  33444. this._alphaState.alphaBlend = (mode !== _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  33445. if (!noDepthWriteChange) {
  33446. this.setDepthWrite(mode === _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  33447. }
  33448. this._alphaMode = mode;
  33449. };
  33450. NullEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  33451. };
  33452. NullEngine.prototype.wipeCaches = function (bruteForce) {
  33453. if (this.preventCacheWipeBetweenFrames) {
  33454. return;
  33455. }
  33456. this.resetTextureCache();
  33457. this._currentEffect = null;
  33458. if (bruteForce) {
  33459. this._currentProgram = null;
  33460. this._stencilState.reset();
  33461. this._depthCullingState.reset();
  33462. this._alphaState.reset();
  33463. }
  33464. this._cachedVertexBuffers = null;
  33465. this._cachedIndexBuffer = null;
  33466. this._cachedEffectForVertexBuffers = null;
  33467. };
  33468. NullEngine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  33469. };
  33470. NullEngine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  33471. };
  33472. NullEngine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  33473. };
  33474. /** @hidden */
  33475. NullEngine.prototype._createTexture = function () {
  33476. return {};
  33477. };
  33478. /** @hidden */
  33479. NullEngine.prototype._releaseTexture = function (texture) {
  33480. };
  33481. NullEngine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallBack, format) {
  33482. if (samplingMode === void 0) { samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  33483. if (onLoad === void 0) { onLoad = null; }
  33484. if (onError === void 0) { onError = null; }
  33485. if (buffer === void 0) { buffer = null; }
  33486. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_URL);
  33487. var url = String(urlArg);
  33488. texture.url = url;
  33489. texture.generateMipMaps = !noMipmap;
  33490. texture.samplingMode = samplingMode;
  33491. texture.invertY = invertY;
  33492. texture.baseWidth = this._options.textureSize;
  33493. texture.baseHeight = this._options.textureSize;
  33494. texture.width = this._options.textureSize;
  33495. texture.height = this._options.textureSize;
  33496. if (format) {
  33497. texture.format = format;
  33498. }
  33499. texture.isReady = true;
  33500. if (onLoad) {
  33501. onLoad();
  33502. }
  33503. this._internalTexturesCache.push(texture);
  33504. return texture;
  33505. };
  33506. NullEngine.prototype.createRenderTargetTexture = function (size, options) {
  33507. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__["RenderTargetCreationOptions"]();
  33508. if (options !== undefined && typeof options === "object") {
  33509. fullOptions.generateMipMaps = options.generateMipMaps;
  33510. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  33511. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  33512. fullOptions.type = options.type === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT : options.type;
  33513. fullOptions.samplingMode = options.samplingMode === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  33514. }
  33515. else {
  33516. fullOptions.generateMipMaps = options;
  33517. fullOptions.generateDepthBuffer = true;
  33518. fullOptions.generateStencilBuffer = false;
  33519. fullOptions.type = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  33520. fullOptions.samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  33521. }
  33522. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_RENDERTARGET);
  33523. var width = size.width || size;
  33524. var height = size.height || size;
  33525. texture._depthStencilBuffer = {};
  33526. texture._framebuffer = {};
  33527. texture.baseWidth = width;
  33528. texture.baseHeight = height;
  33529. texture.width = width;
  33530. texture.height = height;
  33531. texture.isReady = true;
  33532. texture.samples = 1;
  33533. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  33534. texture.samplingMode = fullOptions.samplingMode;
  33535. texture.type = fullOptions.type;
  33536. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  33537. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  33538. this._internalTexturesCache.push(texture);
  33539. return texture;
  33540. };
  33541. NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  33542. texture.samplingMode = samplingMode;
  33543. };
  33544. NullEngine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
  33545. if (this._currentRenderTarget) {
  33546. this.unBindFramebuffer(this._currentRenderTarget);
  33547. }
  33548. this._currentRenderTarget = texture;
  33549. this._currentFramebuffer = texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer;
  33550. if (this._cachedViewport && !forceFullscreenViewport) {
  33551. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  33552. }
  33553. };
  33554. NullEngine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  33555. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  33556. this._currentRenderTarget = null;
  33557. if (onBeforeUnbind) {
  33558. if (texture._MSAAFramebuffer) {
  33559. this._currentFramebuffer = texture._framebuffer;
  33560. }
  33561. onBeforeUnbind();
  33562. }
  33563. this._currentFramebuffer = null;
  33564. };
  33565. NullEngine.prototype.createDynamicVertexBuffer = function (vertices) {
  33566. var vbo = {
  33567. capacity: 1,
  33568. references: 1,
  33569. is32Bits: false
  33570. };
  33571. return vbo;
  33572. };
  33573. NullEngine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format) {
  33574. if (premulAlpha === void 0) { premulAlpha = false; }
  33575. };
  33576. NullEngine.prototype.areAllEffectsReady = function () {
  33577. return true;
  33578. };
  33579. /**
  33580. * @hidden
  33581. * Get the current error code of the webGL context
  33582. * @returns the error code
  33583. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33584. */
  33585. NullEngine.prototype.getError = function () {
  33586. return 0;
  33587. };
  33588. /** @hidden */
  33589. NullEngine.prototype._getUnpackAlignement = function () {
  33590. return 1;
  33591. };
  33592. /** @hidden */
  33593. NullEngine.prototype._unpackFlipY = function (value) {
  33594. };
  33595. NullEngine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  33596. if (offset === void 0) { offset = 0; }
  33597. };
  33598. /**
  33599. * Updates a dynamic vertex buffer.
  33600. * @param vertexBuffer the vertex buffer to update
  33601. * @param data the data used to update the vertex buffer
  33602. * @param byteOffset the byte offset of the data (optional)
  33603. * @param byteLength the byte length of the data (optional)
  33604. */
  33605. NullEngine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, vertices, byteOffset, byteLength) {
  33606. };
  33607. NullEngine.prototype._bindTextureDirectly = function (target, texture) {
  33608. if (this._boundTexturesCache[this._activeChannel] !== texture) {
  33609. this._boundTexturesCache[this._activeChannel] = texture;
  33610. return true;
  33611. }
  33612. return false;
  33613. };
  33614. /** @hidden */
  33615. NullEngine.prototype._bindTexture = function (channel, texture) {
  33616. if (channel < 0) {
  33617. return;
  33618. }
  33619. this._bindTextureDirectly(0, texture);
  33620. };
  33621. /** @hidden */
  33622. NullEngine.prototype._releaseBuffer = function (buffer) {
  33623. buffer.references--;
  33624. if (buffer.references === 0) {
  33625. return true;
  33626. }
  33627. return false;
  33628. };
  33629. NullEngine.prototype.releaseEffects = function () {
  33630. };
  33631. NullEngine.prototype.displayLoadingUI = function () {
  33632. };
  33633. NullEngine.prototype.hideLoadingUI = function () {
  33634. };
  33635. /** @hidden */
  33636. NullEngine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  33637. if (faceIndex === void 0) { faceIndex = 0; }
  33638. if (lod === void 0) { lod = 0; }
  33639. };
  33640. /** @hidden */
  33641. NullEngine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  33642. if (faceIndex === void 0) { faceIndex = 0; }
  33643. if (lod === void 0) { lod = 0; }
  33644. };
  33645. /** @hidden */
  33646. NullEngine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  33647. if (faceIndex === void 0) { faceIndex = 0; }
  33648. if (lod === void 0) { lod = 0; }
  33649. };
  33650. /** @hidden */
  33651. NullEngine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  33652. if (faceIndex === void 0) { faceIndex = 0; }
  33653. if (lod === void 0) { lod = 0; }
  33654. };
  33655. return NullEngine;
  33656. }(_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"]));
  33657. /***/ }),
  33658. /***/ "./Events/clipboardEvents.ts":
  33659. /*!***********************************!*\
  33660. !*** ./Events/clipboardEvents.ts ***!
  33661. \***********************************/
  33662. /*! exports provided: ClipboardEventTypes, ClipboardInfo */
  33663. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33664. "use strict";
  33665. __webpack_require__.r(__webpack_exports__);
  33666. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return ClipboardEventTypes; });
  33667. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return ClipboardInfo; });
  33668. /**
  33669. * Gather the list of clipboard event types as constants.
  33670. */
  33671. var ClipboardEventTypes = /** @class */ (function () {
  33672. function ClipboardEventTypes() {
  33673. }
  33674. /**
  33675. * The clipboard event is fired when a copy command is active (pressed).
  33676. */
  33677. ClipboardEventTypes.COPY = 0x01; //
  33678. /**
  33679. * The clipboard event is fired when a cut command is active (pressed).
  33680. */
  33681. ClipboardEventTypes.CUT = 0x02;
  33682. /**
  33683. * The clipboard event is fired when a paste command is active (pressed).
  33684. */
  33685. ClipboardEventTypes.PASTE = 0x03;
  33686. return ClipboardEventTypes;
  33687. }());
  33688. /**
  33689. * This class is used to store clipboard related info for the onClipboardObservable event.
  33690. */
  33691. var ClipboardInfo = /** @class */ (function () {
  33692. /**
  33693. *Creates an instance of ClipboardInfo.
  33694. * @param {number} type
  33695. * @param {ClipboardEvent} event
  33696. */
  33697. function ClipboardInfo(
  33698. /**
  33699. * Defines the type of event (BABYLON.ClipboardEventTypes)
  33700. */
  33701. type,
  33702. /**
  33703. * Defines the related dom event
  33704. */
  33705. event) {
  33706. this.type = type;
  33707. this.event = event;
  33708. }
  33709. /**
  33710. * Get the clipboard event's type from the keycode.
  33711. * @param keyCode Defines the keyCode for the current keyboard event.
  33712. * @return {number}
  33713. */
  33714. ClipboardInfo.GetTypeFromCharacter = function (keyCode) {
  33715. var charCode = keyCode;
  33716. //TODO: add codes for extended ASCII
  33717. switch (charCode) {
  33718. case 67: return ClipboardEventTypes.COPY;
  33719. case 86: return ClipboardEventTypes.PASTE;
  33720. case 88: return ClipboardEventTypes.CUT;
  33721. default: return -1;
  33722. }
  33723. };
  33724. return ClipboardInfo;
  33725. }());
  33726. /***/ }),
  33727. /***/ "./Events/index.ts":
  33728. /*!*************************!*\
  33729. !*** ./Events/index.ts ***!
  33730. \*************************/
  33731. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo */
  33732. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33733. "use strict";
  33734. __webpack_require__.r(__webpack_exports__);
  33735. /* harmony import */ var _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./keyboardEvents */ "./Events/keyboardEvents.ts");
  33736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  33737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  33738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  33739. /* harmony import */ var _pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pointerEvents */ "./Events/pointerEvents.ts");
  33740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"]; });
  33741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoBase"]; });
  33742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoPre"]; });
  33743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfo"]; });
  33744. /* harmony import */ var _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./clipboardEvents */ "./Events/clipboardEvents.ts");
  33745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardEventTypes"]; });
  33746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardInfo"]; });
  33747. /***/ }),
  33748. /***/ "./Events/keyboardEvents.ts":
  33749. /*!**********************************!*\
  33750. !*** ./Events/keyboardEvents.ts ***!
  33751. \**********************************/
  33752. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre */
  33753. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33754. "use strict";
  33755. __webpack_require__.r(__webpack_exports__);
  33756. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return KeyboardEventTypes; });
  33757. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return KeyboardInfo; });
  33758. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return KeyboardInfoPre; });
  33759. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  33760. /**
  33761. * Gather the list of keyboard event types as constants.
  33762. */
  33763. var KeyboardEventTypes = /** @class */ (function () {
  33764. function KeyboardEventTypes() {
  33765. }
  33766. /**
  33767. * The keydown event is fired when a key becomes active (pressed).
  33768. */
  33769. KeyboardEventTypes.KEYDOWN = 0x01;
  33770. /**
  33771. * The keyup event is fired when a key has been released.
  33772. */
  33773. KeyboardEventTypes.KEYUP = 0x02;
  33774. return KeyboardEventTypes;
  33775. }());
  33776. /**
  33777. * This class is used to store keyboard related info for the onKeyboardObservable event.
  33778. */
  33779. var KeyboardInfo = /** @class */ (function () {
  33780. /**
  33781. * Instantiates a new keyboard info.
  33782. * This class is used to store keyboard related info for the onKeyboardObservable event.
  33783. * @param type Defines the type of event (KeyboardEventTypes)
  33784. * @param event Defines the related dom event
  33785. */
  33786. function KeyboardInfo(
  33787. /**
  33788. * Defines the type of event (KeyboardEventTypes)
  33789. */
  33790. type,
  33791. /**
  33792. * Defines the related dom event
  33793. */
  33794. event) {
  33795. this.type = type;
  33796. this.event = event;
  33797. }
  33798. return KeyboardInfo;
  33799. }());
  33800. /**
  33801. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  33802. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  33803. */
  33804. var KeyboardInfoPre = /** @class */ (function (_super) {
  33805. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeyboardInfoPre, _super);
  33806. /**
  33807. * Instantiates a new keyboard pre info.
  33808. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  33809. * @param type Defines the type of event (KeyboardEventTypes)
  33810. * @param event Defines the related dom event
  33811. */
  33812. function KeyboardInfoPre(
  33813. /**
  33814. * Defines the type of event (KeyboardEventTypes)
  33815. */
  33816. type,
  33817. /**
  33818. * Defines the related dom event
  33819. */
  33820. event) {
  33821. var _this = _super.call(this, type, event) || this;
  33822. _this.type = type;
  33823. _this.event = event;
  33824. _this.skipOnPointerObservable = false;
  33825. return _this;
  33826. }
  33827. return KeyboardInfoPre;
  33828. }(KeyboardInfo));
  33829. /***/ }),
  33830. /***/ "./Events/pointerEvents.ts":
  33831. /*!*********************************!*\
  33832. !*** ./Events/pointerEvents.ts ***!
  33833. \*********************************/
  33834. /*! exports provided: PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo */
  33835. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33836. "use strict";
  33837. __webpack_require__.r(__webpack_exports__);
  33838. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return PointerEventTypes; });
  33839. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return PointerInfoBase; });
  33840. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return PointerInfoPre; });
  33841. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return PointerInfo; });
  33842. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  33843. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  33844. /**
  33845. * Gather the list of pointer event types as constants.
  33846. */
  33847. var PointerEventTypes = /** @class */ (function () {
  33848. function PointerEventTypes() {
  33849. }
  33850. /**
  33851. * 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.
  33852. */
  33853. PointerEventTypes.POINTERDOWN = 0x01;
  33854. /**
  33855. * The pointerup event is fired when a pointer is no longer active.
  33856. */
  33857. PointerEventTypes.POINTERUP = 0x02;
  33858. /**
  33859. * The pointermove event is fired when a pointer changes coordinates.
  33860. */
  33861. PointerEventTypes.POINTERMOVE = 0x04;
  33862. /**
  33863. * The pointerwheel event is fired when a mouse wheel has been rotated.
  33864. */
  33865. PointerEventTypes.POINTERWHEEL = 0x08;
  33866. /**
  33867. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  33868. */
  33869. PointerEventTypes.POINTERPICK = 0x10;
  33870. /**
  33871. * The pointertap event is fired when a the object has been touched and released without drag.
  33872. */
  33873. PointerEventTypes.POINTERTAP = 0x20;
  33874. /**
  33875. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  33876. */
  33877. PointerEventTypes.POINTERDOUBLETAP = 0x40;
  33878. return PointerEventTypes;
  33879. }());
  33880. /**
  33881. * Base class of pointer info types.
  33882. */
  33883. var PointerInfoBase = /** @class */ (function () {
  33884. /**
  33885. * Instantiates the base class of pointers info.
  33886. * @param type Defines the type of event (PointerEventTypes)
  33887. * @param event Defines the related dom event
  33888. */
  33889. function PointerInfoBase(
  33890. /**
  33891. * Defines the type of event (PointerEventTypes)
  33892. */
  33893. type,
  33894. /**
  33895. * Defines the related dom event
  33896. */
  33897. event) {
  33898. this.type = type;
  33899. this.event = event;
  33900. }
  33901. return PointerInfoBase;
  33902. }());
  33903. /**
  33904. * This class is used to store pointer related info for the onPrePointerObservable event.
  33905. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  33906. */
  33907. var PointerInfoPre = /** @class */ (function (_super) {
  33908. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfoPre, _super);
  33909. /**
  33910. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  33911. * @param type Defines the type of event (PointerEventTypes)
  33912. * @param event Defines the related dom event
  33913. * @param localX Defines the local x coordinates of the pointer when the event occured
  33914. * @param localY Defines the local y coordinates of the pointer when the event occured
  33915. */
  33916. function PointerInfoPre(type, event, localX, localY) {
  33917. var _this = _super.call(this, type, event) || this;
  33918. /**
  33919. * Ray from a pointer if availible (eg. 6dof controller)
  33920. */
  33921. _this.ray = null;
  33922. _this.skipOnPointerObservable = false;
  33923. _this.localPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](localX, localY);
  33924. return _this;
  33925. }
  33926. return PointerInfoPre;
  33927. }(PointerInfoBase));
  33928. /**
  33929. * This type contains all the data related to a pointer event in Babylon.js.
  33930. * 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.
  33931. */
  33932. var PointerInfo = /** @class */ (function (_super) {
  33933. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfo, _super);
  33934. /**
  33935. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  33936. * @param type Defines the type of event (PointerEventTypes)
  33937. * @param event Defines the related dom event
  33938. * @param pickInfo Defines the picking info associated to the info (if any)\
  33939. */
  33940. function PointerInfo(type, event,
  33941. /**
  33942. * Defines the picking info associated to the info (if any)\
  33943. */
  33944. pickInfo) {
  33945. var _this = _super.call(this, type, event) || this;
  33946. _this.pickInfo = pickInfo;
  33947. return _this;
  33948. }
  33949. return PointerInfo;
  33950. }(PointerInfoBase));
  33951. /***/ }),
  33952. /***/ "./Gamepads/Controllers/daydreamController.ts":
  33953. /*!****************************************************!*\
  33954. !*** ./Gamepads/Controllers/daydreamController.ts ***!
  33955. \****************************************************/
  33956. /*! exports provided: DaydreamController */
  33957. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33958. "use strict";
  33959. __webpack_require__.r(__webpack_exports__);
  33960. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return DaydreamController; });
  33961. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  33962. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  33963. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  33964. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  33965. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  33966. /**
  33967. * Google Daydream controller
  33968. */
  33969. var DaydreamController = /** @class */ (function (_super) {
  33970. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DaydreamController, _super);
  33971. /**
  33972. * Creates a new DaydreamController from a gamepad
  33973. * @param vrGamepad the gamepad that the controller should be created from
  33974. */
  33975. function DaydreamController(vrGamepad) {
  33976. var _this = _super.call(this, vrGamepad) || this;
  33977. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].DAYDREAM;
  33978. return _this;
  33979. }
  33980. /**
  33981. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33982. * @param scene scene in which to add meshes
  33983. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33984. */
  33985. DaydreamController.prototype.initControllerMesh = function (scene, meshLoaded) {
  33986. var _this = this;
  33987. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", DaydreamController.MODEL_BASE_URL, DaydreamController.MODEL_FILENAME, scene, function (newMeshes) {
  33988. _this._defaultModel = newMeshes[1];
  33989. _this.attachToMesh(_this._defaultModel);
  33990. if (meshLoaded) {
  33991. meshLoaded(_this._defaultModel);
  33992. }
  33993. });
  33994. };
  33995. /**
  33996. * Called once for each button that changed state since the last frame
  33997. * @param buttonIdx Which button index changed
  33998. * @param state New state of the button
  33999. * @param changes Which properties on the state changed since last frame
  34000. */
  34001. DaydreamController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34002. // Daydream controller only has 1 GamepadButton (on the trackpad).
  34003. if (buttonIdx === 0) {
  34004. var observable = this.onTriggerStateChangedObservable;
  34005. if (observable) {
  34006. observable.notifyObservers(state);
  34007. }
  34008. }
  34009. else {
  34010. // If the app or home buttons are ever made available
  34011. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Unrecognized Daydream button index: " + buttonIdx);
  34012. }
  34013. };
  34014. /**
  34015. * Base Url for the controller model.
  34016. */
  34017. DaydreamController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  34018. /**
  34019. * File name for the controller model.
  34020. */
  34021. DaydreamController.MODEL_FILENAME = 'generic.babylon';
  34022. /**
  34023. * Gamepad Id prefix used to identify Daydream Controller.
  34024. */
  34025. DaydreamController.GAMEPAD_ID_PREFIX = 'Daydream'; // id is 'Daydream Controller'
  34026. return DaydreamController;
  34027. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  34028. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  34029. canCreate: function (gamepadInfo) {
  34030. return gamepadInfo.id.indexOf(DaydreamController.GAMEPAD_ID_PREFIX) === 0;
  34031. },
  34032. create: function (gamepadInfo) {
  34033. return new DaydreamController(gamepadInfo);
  34034. }
  34035. });
  34036. /***/ }),
  34037. /***/ "./Gamepads/Controllers/gearVRController.ts":
  34038. /*!**************************************************!*\
  34039. !*** ./Gamepads/Controllers/gearVRController.ts ***!
  34040. \**************************************************/
  34041. /*! exports provided: GearVRController */
  34042. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34043. "use strict";
  34044. __webpack_require__.r(__webpack_exports__);
  34045. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return GearVRController; });
  34046. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34047. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  34048. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  34049. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34050. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34051. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34052. /**
  34053. * Gear VR Controller
  34054. */
  34055. var GearVRController = /** @class */ (function (_super) {
  34056. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GearVRController, _super);
  34057. /**
  34058. * Creates a new GearVRController from a gamepad
  34059. * @param vrGamepad the gamepad that the controller should be created from
  34060. */
  34061. function GearVRController(vrGamepad) {
  34062. var _this = _super.call(this, vrGamepad) || this;
  34063. _this._buttonIndexToObservableNameMap = [
  34064. 'onTrackpadChangedObservable',
  34065. 'onTriggerStateChangedObservable' // Trigger
  34066. ];
  34067. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerType"].GEAR_VR;
  34068. // Initial starting position defaults to where hand would be (incase of only 3dof controller)
  34069. _this._calculatedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](_this.hand == "left" ? -0.15 : 0.15, -0.5, 0.25);
  34070. _this._disableTrackPosition(_this._calculatedPosition);
  34071. return _this;
  34072. }
  34073. /**
  34074. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34075. * @param scene scene in which to add meshes
  34076. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34077. */
  34078. GearVRController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34079. var _this = this;
  34080. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__["SceneLoader"].ImportMesh("", GearVRController.MODEL_BASE_URL, GearVRController.MODEL_FILENAME, scene, function (newMeshes) {
  34081. // Offset the controller so it will rotate around the users wrist
  34082. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", scene);
  34083. newMeshes[1].parent = mesh;
  34084. newMeshes[1].position.z = -0.15;
  34085. _this._defaultModel = mesh;
  34086. _this.attachToMesh(_this._defaultModel);
  34087. if (meshLoaded) {
  34088. meshLoaded(_this._defaultModel);
  34089. }
  34090. });
  34091. };
  34092. /**
  34093. * Called once for each button that changed state since the last frame
  34094. * @param buttonIdx Which button index changed
  34095. * @param state New state of the button
  34096. * @param changes Which properties on the state changed since last frame
  34097. */
  34098. GearVRController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34099. if (buttonIdx < this._buttonIndexToObservableNameMap.length) {
  34100. var observableName = this._buttonIndexToObservableNameMap[buttonIdx];
  34101. // Only emit events for buttons that we know how to map from index to observable
  34102. var observable = this[observableName];
  34103. if (observable) {
  34104. observable.notifyObservers(state);
  34105. }
  34106. }
  34107. };
  34108. /**
  34109. * Base Url for the controller model.
  34110. */
  34111. GearVRController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  34112. /**
  34113. * File name for the controller model.
  34114. */
  34115. GearVRController.MODEL_FILENAME = 'generic.babylon';
  34116. /**
  34117. * Gamepad Id prefix used to identify this controller.
  34118. */
  34119. GearVRController.GAMEPAD_ID_PREFIX = 'Gear VR'; // id is 'Gear VR Controller'
  34120. return GearVRController;
  34121. }(_webVRController__WEBPACK_IMPORTED_MODULE_4__["WebVRController"]));
  34122. _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  34123. canCreate: function (gamepadInfo) {
  34124. return gamepadInfo.id.indexOf(GearVRController.GAMEPAD_ID_PREFIX) === 0 ||
  34125. gamepadInfo.id.indexOf('Oculus Go') !== -1;
  34126. },
  34127. create: function (gamepadInfo) {
  34128. return new GearVRController(gamepadInfo);
  34129. }
  34130. });
  34131. /***/ }),
  34132. /***/ "./Gamepads/Controllers/genericController.ts":
  34133. /*!***************************************************!*\
  34134. !*** ./Gamepads/Controllers/genericController.ts ***!
  34135. \***************************************************/
  34136. /*! exports provided: GenericController */
  34137. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34138. "use strict";
  34139. __webpack_require__.r(__webpack_exports__);
  34140. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return GenericController; });
  34141. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34142. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34143. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34144. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34145. /**
  34146. * Generic Controller
  34147. */
  34148. var GenericController = /** @class */ (function (_super) {
  34149. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericController, _super);
  34150. /**
  34151. * Creates a new GenericController from a gamepad
  34152. * @param vrGamepad the gamepad that the controller should be created from
  34153. */
  34154. function GenericController(vrGamepad) {
  34155. return _super.call(this, vrGamepad) || this;
  34156. }
  34157. /**
  34158. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34159. * @param scene scene in which to add meshes
  34160. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34161. */
  34162. GenericController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34163. var _this = this;
  34164. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", GenericController.MODEL_BASE_URL, GenericController.MODEL_FILENAME, scene, function (newMeshes) {
  34165. _this._defaultModel = newMeshes[1];
  34166. _this.attachToMesh(_this._defaultModel);
  34167. if (meshLoaded) {
  34168. meshLoaded(_this._defaultModel);
  34169. }
  34170. });
  34171. };
  34172. /**
  34173. * Called once for each button that changed state since the last frame
  34174. * @param buttonIdx Which button index changed
  34175. * @param state New state of the button
  34176. * @param changes Which properties on the state changed since last frame
  34177. */
  34178. GenericController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34179. console.log("Button id: " + buttonIdx + "state: ");
  34180. console.dir(state);
  34181. };
  34182. /**
  34183. * Base Url for the controller model.
  34184. */
  34185. GenericController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  34186. /**
  34187. * File name for the controller model.
  34188. */
  34189. GenericController.MODEL_FILENAME = 'generic.babylon';
  34190. return GenericController;
  34191. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  34192. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._DefaultControllerFactory = function (gamepadInfo) { return new GenericController(gamepadInfo); };
  34193. /***/ }),
  34194. /***/ "./Gamepads/Controllers/index.ts":
  34195. /*!***************************************!*\
  34196. !*** ./Gamepads/Controllers/index.ts ***!
  34197. \***************************************/
  34198. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController */
  34199. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34200. "use strict";
  34201. __webpack_require__.r(__webpack_exports__);
  34202. /* harmony import */ var _daydreamController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./daydreamController */ "./Gamepads/Controllers/daydreamController.ts");
  34203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _daydreamController__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  34204. /* harmony import */ var _gearVRController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gearVRController */ "./Gamepads/Controllers/gearVRController.ts");
  34205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _gearVRController__WEBPACK_IMPORTED_MODULE_1__["GearVRController"]; });
  34206. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  34207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _genericController__WEBPACK_IMPORTED_MODULE_2__["GenericController"]; });
  34208. /* harmony import */ var _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./oculusTouchController */ "./Gamepads/Controllers/oculusTouchController.ts");
  34209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__["OculusTouchController"]; });
  34210. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"]; });
  34212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]; });
  34213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledController"]; });
  34214. /* harmony import */ var _viveController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./viveController */ "./Gamepads/Controllers/viveController.ts");
  34215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _viveController__WEBPACK_IMPORTED_MODULE_5__["ViveController"]; });
  34216. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _webVRController__WEBPACK_IMPORTED_MODULE_6__["WebVRController"]; });
  34218. /* harmony import */ var _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./windowsMotionController */ "./Gamepads/Controllers/windowsMotionController.ts");
  34219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__["WindowsMotionController"]; });
  34220. /***/ }),
  34221. /***/ "./Gamepads/Controllers/oculusTouchController.ts":
  34222. /*!*******************************************************!*\
  34223. !*** ./Gamepads/Controllers/oculusTouchController.ts ***!
  34224. \*******************************************************/
  34225. /*! exports provided: OculusTouchController */
  34226. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34227. "use strict";
  34228. __webpack_require__.r(__webpack_exports__);
  34229. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return OculusTouchController; });
  34230. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34231. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  34232. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34233. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34234. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34235. /**
  34236. * Oculus Touch Controller
  34237. */
  34238. var OculusTouchController = /** @class */ (function (_super) {
  34239. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](OculusTouchController, _super);
  34240. /**
  34241. * Creates a new OculusTouchController from a gamepad
  34242. * @param vrGamepad the gamepad that the controller should be created from
  34243. */
  34244. function OculusTouchController(vrGamepad) {
  34245. var _this = _super.call(this, vrGamepad) || this;
  34246. /**
  34247. * Fired when the secondary trigger on this controller is modified
  34248. */
  34249. _this.onSecondaryTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34250. /**
  34251. * Fired when the thumb rest on this controller is modified
  34252. */
  34253. _this.onThumbRestChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34254. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].OCULUS;
  34255. return _this;
  34256. }
  34257. /**
  34258. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34259. * @param scene scene in which to add meshes
  34260. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34261. */
  34262. OculusTouchController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34263. var _this = this;
  34264. var meshName;
  34265. // Hand
  34266. if (this.hand === 'left') {
  34267. meshName = OculusTouchController.MODEL_LEFT_FILENAME;
  34268. }
  34269. else { // Right is the default if no hand is specified
  34270. meshName = OculusTouchController.MODEL_RIGHT_FILENAME;
  34271. }
  34272. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", OculusTouchController.MODEL_BASE_URL, meshName, scene, function (newMeshes) {
  34273. /*
  34274. Parent Mesh name: oculus_touch_left
  34275. - body
  34276. - trigger
  34277. - thumbstick
  34278. - grip
  34279. - button_y
  34280. - button_x
  34281. - button_enter
  34282. */
  34283. _this._defaultModel = newMeshes[1];
  34284. _this.attachToMesh(_this._defaultModel);
  34285. if (meshLoaded) {
  34286. meshLoaded(_this._defaultModel);
  34287. }
  34288. });
  34289. };
  34290. Object.defineProperty(OculusTouchController.prototype, "onAButtonStateChangedObservable", {
  34291. /**
  34292. * Fired when the A button on this controller is modified
  34293. */
  34294. get: function () {
  34295. if (this.hand === 'right') {
  34296. return this.onMainButtonStateChangedObservable;
  34297. }
  34298. else {
  34299. throw new Error('No A button on left hand');
  34300. }
  34301. },
  34302. enumerable: true,
  34303. configurable: true
  34304. });
  34305. Object.defineProperty(OculusTouchController.prototype, "onBButtonStateChangedObservable", {
  34306. /**
  34307. * Fired when the B button on this controller is modified
  34308. */
  34309. get: function () {
  34310. if (this.hand === 'right') {
  34311. return this.onSecondaryButtonStateChangedObservable;
  34312. }
  34313. else {
  34314. throw new Error('No B button on left hand');
  34315. }
  34316. },
  34317. enumerable: true,
  34318. configurable: true
  34319. });
  34320. Object.defineProperty(OculusTouchController.prototype, "onXButtonStateChangedObservable", {
  34321. /**
  34322. * Fired when the X button on this controller is modified
  34323. */
  34324. get: function () {
  34325. if (this.hand === 'left') {
  34326. return this.onMainButtonStateChangedObservable;
  34327. }
  34328. else {
  34329. throw new Error('No X button on right hand');
  34330. }
  34331. },
  34332. enumerable: true,
  34333. configurable: true
  34334. });
  34335. Object.defineProperty(OculusTouchController.prototype, "onYButtonStateChangedObservable", {
  34336. /**
  34337. * Fired when the Y button on this controller is modified
  34338. */
  34339. get: function () {
  34340. if (this.hand === 'left') {
  34341. return this.onSecondaryButtonStateChangedObservable;
  34342. }
  34343. else {
  34344. throw new Error('No Y button on right hand');
  34345. }
  34346. },
  34347. enumerable: true,
  34348. configurable: true
  34349. });
  34350. /**
  34351. * Called once for each button that changed state since the last frame
  34352. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  34353. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  34354. * 2) secondary trigger (same)
  34355. * 3) A (right) X (left), touch, pressed = value
  34356. * 4) B / Y
  34357. * 5) thumb rest
  34358. * @param buttonIdx Which button index changed
  34359. * @param state New state of the button
  34360. * @param changes Which properties on the state changed since last frame
  34361. */
  34362. OculusTouchController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34363. var notifyObject = state; //{ state: state, changes: changes };
  34364. var triggerDirection = this.hand === 'right' ? -1 : 1;
  34365. switch (buttonIdx) {
  34366. case 0:
  34367. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  34368. return;
  34369. case 1: // index trigger
  34370. if (this._defaultModel) {
  34371. (this._defaultModel.getChildren()[3]).rotation.x = -notifyObject.value * 0.20;
  34372. (this._defaultModel.getChildren()[3]).position.y = -notifyObject.value * 0.005;
  34373. (this._defaultModel.getChildren()[3]).position.z = -notifyObject.value * 0.005;
  34374. }
  34375. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  34376. return;
  34377. case 2: // secondary trigger
  34378. if (this._defaultModel) {
  34379. (this._defaultModel.getChildren()[4]).position.x = triggerDirection * notifyObject.value * 0.0035;
  34380. }
  34381. this.onSecondaryTriggerStateChangedObservable.notifyObservers(notifyObject);
  34382. return;
  34383. case 3:
  34384. if (this._defaultModel) {
  34385. if (notifyObject.pressed) {
  34386. (this._defaultModel.getChildren()[1]).position.y = -0.001;
  34387. }
  34388. else {
  34389. (this._defaultModel.getChildren()[1]).position.y = 0;
  34390. }
  34391. }
  34392. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  34393. return;
  34394. case 4:
  34395. if (this._defaultModel) {
  34396. if (notifyObject.pressed) {
  34397. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  34398. }
  34399. else {
  34400. (this._defaultModel.getChildren()[2]).position.y = 0;
  34401. }
  34402. }
  34403. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  34404. return;
  34405. case 5:
  34406. this.onThumbRestChangedObservable.notifyObservers(notifyObject);
  34407. return;
  34408. }
  34409. };
  34410. /**
  34411. * Base Url for the controller model.
  34412. */
  34413. OculusTouchController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/oculus/';
  34414. /**
  34415. * File name for the left controller model.
  34416. */
  34417. OculusTouchController.MODEL_LEFT_FILENAME = 'left.babylon';
  34418. /**
  34419. * File name for the right controller model.
  34420. */
  34421. OculusTouchController.MODEL_RIGHT_FILENAME = 'right.babylon';
  34422. return OculusTouchController;
  34423. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  34424. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  34425. canCreate: function (gamepadInfo) {
  34426. return gamepadInfo.id.indexOf('Oculus Touch') !== -1;
  34427. },
  34428. create: function (gamepadInfo) {
  34429. return new OculusTouchController(gamepadInfo);
  34430. }
  34431. });
  34432. /***/ }),
  34433. /***/ "./Gamepads/Controllers/poseEnabledController.ts":
  34434. /*!*******************************************************!*\
  34435. !*** ./Gamepads/Controllers/poseEnabledController.ts ***!
  34436. \*******************************************************/
  34437. /*! exports provided: PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController */
  34438. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34439. "use strict";
  34440. __webpack_require__.r(__webpack_exports__);
  34441. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return PoseEnabledControllerType; });
  34442. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return PoseEnabledControllerHelper; });
  34443. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return PoseEnabledController; });
  34444. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34445. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  34446. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  34447. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  34448. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  34449. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  34450. /**
  34451. * Defines the types of pose enabled controllers that are supported
  34452. */
  34453. var PoseEnabledControllerType;
  34454. (function (PoseEnabledControllerType) {
  34455. /**
  34456. * HTC Vive
  34457. */
  34458. PoseEnabledControllerType[PoseEnabledControllerType["VIVE"] = 0] = "VIVE";
  34459. /**
  34460. * Oculus Rift
  34461. */
  34462. PoseEnabledControllerType[PoseEnabledControllerType["OCULUS"] = 1] = "OCULUS";
  34463. /**
  34464. * Windows mixed reality
  34465. */
  34466. PoseEnabledControllerType[PoseEnabledControllerType["WINDOWS"] = 2] = "WINDOWS";
  34467. /**
  34468. * Samsung gear VR
  34469. */
  34470. PoseEnabledControllerType[PoseEnabledControllerType["GEAR_VR"] = 3] = "GEAR_VR";
  34471. /**
  34472. * Google Daydream
  34473. */
  34474. PoseEnabledControllerType[PoseEnabledControllerType["DAYDREAM"] = 4] = "DAYDREAM";
  34475. /**
  34476. * Generic
  34477. */
  34478. PoseEnabledControllerType[PoseEnabledControllerType["GENERIC"] = 5] = "GENERIC";
  34479. })(PoseEnabledControllerType || (PoseEnabledControllerType = {}));
  34480. /**
  34481. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  34482. */
  34483. var PoseEnabledControllerHelper = /** @class */ (function () {
  34484. function PoseEnabledControllerHelper() {
  34485. }
  34486. /**
  34487. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  34488. * @param vrGamepad the gamepad to initialized
  34489. * @returns a vr controller of the type the gamepad identified as
  34490. */
  34491. PoseEnabledControllerHelper.InitiateController = function (vrGamepad) {
  34492. for (var _i = 0, _a = this._ControllerFactories; _i < _a.length; _i++) {
  34493. var factory = _a[_i];
  34494. if (factory.canCreate(vrGamepad)) {
  34495. return factory.create(vrGamepad);
  34496. }
  34497. }
  34498. if (this._DefaultControllerFactory) {
  34499. return this._DefaultControllerFactory(vrGamepad);
  34500. }
  34501. throw "The type of gamepad you are trying to load needs to be imported first or is not supported.";
  34502. };
  34503. /** @hidden */
  34504. PoseEnabledControllerHelper._ControllerFactories = [];
  34505. /** @hidden */
  34506. PoseEnabledControllerHelper._DefaultControllerFactory = null;
  34507. return PoseEnabledControllerHelper;
  34508. }());
  34509. /**
  34510. * Defines the PoseEnabledController object that contains state of a vr capable controller
  34511. */
  34512. var PoseEnabledController = /** @class */ (function (_super) {
  34513. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PoseEnabledController, _super);
  34514. /**
  34515. * Creates a new PoseEnabledController from a gamepad
  34516. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  34517. */
  34518. function PoseEnabledController(browserGamepad) {
  34519. var _this = _super.call(this, browserGamepad.id, browserGamepad.index, browserGamepad) || this;
  34520. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  34521. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  34522. _this._deviceRoomRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  34523. /**
  34524. * The device position in babylon space
  34525. */
  34526. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  34527. /**
  34528. * The device rotation in babylon space
  34529. */
  34530. _this.deviceRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  34531. /**
  34532. * The scale factor of the device in babylon space
  34533. */
  34534. _this.deviceScaleFactor = 1;
  34535. // Used to convert 6dof controllers to 3dof
  34536. _this._trackPosition = true;
  34537. _this._maxRotationDistFromHeadset = Math.PI / 5;
  34538. _this._draggedRoomRotation = 0;
  34539. _this._leftHandSystemQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  34540. /**
  34541. * Internal, matrix used to convert room space to babylon space
  34542. * @hidden
  34543. */
  34544. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  34545. /**
  34546. * Node to be used when casting a ray from the controller
  34547. * @hidden
  34548. */
  34549. _this._pointingPoseNode = null;
  34550. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  34551. /**
  34552. * @hidden
  34553. */
  34554. _this._meshAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34555. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED;
  34556. _this.controllerType = PoseEnabledControllerType.GENERIC;
  34557. _this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  34558. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  34559. _this._calculatedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  34560. _this._calculatedRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  34561. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(Math.PI, 0, 0, _this._leftHandSystemQuaternion);
  34562. return _this;
  34563. }
  34564. /**
  34565. * @hidden
  34566. */
  34567. PoseEnabledController.prototype._disableTrackPosition = function (fixedPosition) {
  34568. if (this._trackPosition) {
  34569. this._calculatedPosition.copyFrom(fixedPosition);
  34570. this._trackPosition = false;
  34571. }
  34572. };
  34573. /**
  34574. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  34575. */
  34576. PoseEnabledController.prototype.update = function () {
  34577. _super.prototype.update.call(this);
  34578. this._updatePoseAndMesh();
  34579. };
  34580. /**
  34581. * Updates only the pose device and mesh without doing any button event checking
  34582. */
  34583. PoseEnabledController.prototype._updatePoseAndMesh = function () {
  34584. var pose = this.browserGamepad.pose;
  34585. this.updateFromDevice(pose);
  34586. 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) {
  34587. var camera = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene.activeCamera;
  34588. camera._computeDevicePosition();
  34589. this._deviceToWorld.setTranslation(camera.devicePosition);
  34590. if (camera.deviceRotationQuaternion) {
  34591. var camera = camera;
  34592. camera._deviceRoomRotationQuaternion.toEulerAnglesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0]);
  34593. // Find the radian distance away that the headset is from the controllers rotation
  34594. 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));
  34595. if (Math.abs(distanceAway) > this._maxRotationDistFromHeadset) {
  34596. // Only rotate enouph to be within the _maxRotationDistFromHeadset
  34597. var rotationAmount = distanceAway - (distanceAway < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
  34598. this._draggedRoomRotation += rotationAmount;
  34599. // Rotate controller around headset
  34600. var sin = Math.sin(-rotationAmount);
  34601. var cos = Math.cos(-rotationAmount);
  34602. this._calculatedPosition.x = this._calculatedPosition.x * cos - this._calculatedPosition.z * sin;
  34603. this._calculatedPosition.z = this._calculatedPosition.x * sin + this._calculatedPosition.z * cos;
  34604. }
  34605. }
  34606. }
  34607. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition);
  34608. this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix);
  34609. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  34610. this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation);
  34611. if (this._mesh) {
  34612. this._mesh.position.copyFrom(this.devicePosition);
  34613. if (this._mesh.rotationQuaternion) {
  34614. this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion);
  34615. }
  34616. }
  34617. };
  34618. /**
  34619. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  34620. * @param poseData raw pose fromthe device
  34621. */
  34622. PoseEnabledController.prototype.updateFromDevice = function (poseData) {
  34623. if (poseData) {
  34624. this.rawPose = poseData;
  34625. if (poseData.position) {
  34626. this._deviceRoomPosition.copyFromFloats(poseData.position[0], poseData.position[1], -poseData.position[2]);
  34627. if (this._mesh && this._mesh.getScene().useRightHandedSystem) {
  34628. this._deviceRoomPosition.z *= -1;
  34629. }
  34630. if (this._trackPosition) {
  34631. this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition);
  34632. }
  34633. this._calculatedPosition.addInPlace(this.position);
  34634. }
  34635. var pose = this.rawPose;
  34636. if (poseData.orientation && pose.orientation) {
  34637. this._deviceRoomRotationQuaternion.copyFromFloats(pose.orientation[0], pose.orientation[1], -pose.orientation[2], -pose.orientation[3]);
  34638. if (this._mesh) {
  34639. if (this._mesh.getScene().useRightHandedSystem) {
  34640. this._deviceRoomRotationQuaternion.z *= -1;
  34641. this._deviceRoomRotationQuaternion.w *= -1;
  34642. }
  34643. else {
  34644. this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion);
  34645. }
  34646. }
  34647. // if the camera is set, rotate to the camera's rotation
  34648. this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation);
  34649. }
  34650. }
  34651. };
  34652. /**
  34653. * Attaches a mesh to the controller
  34654. * @param mesh the mesh to be attached
  34655. */
  34656. PoseEnabledController.prototype.attachToMesh = function (mesh) {
  34657. if (this._mesh) {
  34658. this._mesh.parent = null;
  34659. }
  34660. this._mesh = mesh;
  34661. if (this._poseControlledCamera) {
  34662. this._mesh.parent = this._poseControlledCamera;
  34663. }
  34664. if (!this._mesh.rotationQuaternion) {
  34665. this._mesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  34666. }
  34667. // 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
  34668. this._updatePoseAndMesh();
  34669. if (this._pointingPoseNode) {
  34670. var parents = [];
  34671. var obj = this._pointingPoseNode;
  34672. while (obj.parent) {
  34673. parents.push(obj.parent);
  34674. obj = obj.parent;
  34675. }
  34676. parents.reverse().forEach(function (p) { p.computeWorldMatrix(true); });
  34677. }
  34678. this._meshAttachedObservable.notifyObservers(mesh);
  34679. };
  34680. /**
  34681. * Attaches the controllers mesh to a camera
  34682. * @param camera the camera the mesh should be attached to
  34683. */
  34684. PoseEnabledController.prototype.attachToPoseControlledCamera = function (camera) {
  34685. this._poseControlledCamera = camera;
  34686. if (this._mesh) {
  34687. this._mesh.parent = this._poseControlledCamera;
  34688. }
  34689. };
  34690. /**
  34691. * Disposes of the controller
  34692. */
  34693. PoseEnabledController.prototype.dispose = function () {
  34694. if (this._mesh) {
  34695. this._mesh.dispose();
  34696. }
  34697. this._mesh = null;
  34698. _super.prototype.dispose.call(this);
  34699. };
  34700. Object.defineProperty(PoseEnabledController.prototype, "mesh", {
  34701. /**
  34702. * The mesh that is attached to the controller
  34703. */
  34704. get: function () {
  34705. return this._mesh;
  34706. },
  34707. enumerable: true,
  34708. configurable: true
  34709. });
  34710. /**
  34711. * Gets the ray of the controller in the direction the controller is pointing
  34712. * @param length the length the resulting ray should be
  34713. * @returns a ray in the direction the controller is pointing
  34714. */
  34715. PoseEnabledController.prototype.getForwardRay = function (length) {
  34716. if (length === void 0) { length = 100; }
  34717. if (!this.mesh) {
  34718. 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);
  34719. }
  34720. var m = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix();
  34721. var origin = m.getTranslation();
  34722. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, -1);
  34723. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(forward, m);
  34724. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(forwardWorld);
  34725. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](origin, direction, length);
  34726. };
  34727. /**
  34728. * Name of the child mesh that can be used to cast a ray from the controller
  34729. */
  34730. PoseEnabledController.POINTING_POSE = "POINTING_POSE";
  34731. return PoseEnabledController;
  34732. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"]));
  34733. /***/ }),
  34734. /***/ "./Gamepads/Controllers/viveController.ts":
  34735. /*!************************************************!*\
  34736. !*** ./Gamepads/Controllers/viveController.ts ***!
  34737. \************************************************/
  34738. /*! exports provided: ViveController */
  34739. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34740. "use strict";
  34741. __webpack_require__.r(__webpack_exports__);
  34742. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return ViveController; });
  34743. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34744. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34745. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34746. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34747. /**
  34748. * Vive Controller
  34749. */
  34750. var ViveController = /** @class */ (function (_super) {
  34751. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ViveController, _super);
  34752. /**
  34753. * Creates a new ViveController from a gamepad
  34754. * @param vrGamepad the gamepad that the controller should be created from
  34755. */
  34756. function ViveController(vrGamepad) {
  34757. var _this = _super.call(this, vrGamepad) || this;
  34758. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerType"].VIVE;
  34759. _this._invertLeftStickY = true;
  34760. return _this;
  34761. }
  34762. /**
  34763. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34764. * @param scene scene in which to add meshes
  34765. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34766. */
  34767. ViveController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34768. var _this = this;
  34769. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", ViveController.MODEL_BASE_URL, ViveController.MODEL_FILENAME, scene, function (newMeshes) {
  34770. /*
  34771. Parent Mesh name: ViveWand
  34772. - body
  34773. - r_gripper
  34774. - l_gripper
  34775. - menu_button
  34776. - system_button
  34777. - trackpad
  34778. - trigger
  34779. - LED
  34780. */
  34781. _this._defaultModel = newMeshes[1];
  34782. _this.attachToMesh(_this._defaultModel);
  34783. if (meshLoaded) {
  34784. meshLoaded(_this._defaultModel);
  34785. }
  34786. });
  34787. };
  34788. Object.defineProperty(ViveController.prototype, "onLeftButtonStateChangedObservable", {
  34789. /**
  34790. * Fired when the left button on this controller is modified
  34791. */
  34792. get: function () {
  34793. return this.onMainButtonStateChangedObservable;
  34794. },
  34795. enumerable: true,
  34796. configurable: true
  34797. });
  34798. Object.defineProperty(ViveController.prototype, "onRightButtonStateChangedObservable", {
  34799. /**
  34800. * Fired when the right button on this controller is modified
  34801. */
  34802. get: function () {
  34803. return this.onMainButtonStateChangedObservable;
  34804. },
  34805. enumerable: true,
  34806. configurable: true
  34807. });
  34808. Object.defineProperty(ViveController.prototype, "onMenuButtonStateChangedObservable", {
  34809. /**
  34810. * Fired when the menu button on this controller is modified
  34811. */
  34812. get: function () {
  34813. return this.onSecondaryButtonStateChangedObservable;
  34814. },
  34815. enumerable: true,
  34816. configurable: true
  34817. });
  34818. /**
  34819. * Called once for each button that changed state since the last frame
  34820. * Vive mapping:
  34821. * 0: touchpad
  34822. * 1: trigger
  34823. * 2: left AND right buttons
  34824. * 3: menu button
  34825. * @param buttonIdx Which button index changed
  34826. * @param state New state of the button
  34827. * @param changes Which properties on the state changed since last frame
  34828. */
  34829. ViveController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34830. var notifyObject = state; //{ state: state, changes: changes };
  34831. switch (buttonIdx) {
  34832. case 0:
  34833. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  34834. return;
  34835. case 1: // index trigger
  34836. if (this._defaultModel) {
  34837. (this._defaultModel.getChildren()[6]).rotation.x = -notifyObject.value * 0.15;
  34838. }
  34839. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  34840. return;
  34841. case 2: // left AND right button
  34842. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  34843. return;
  34844. case 3:
  34845. if (this._defaultModel) {
  34846. if (notifyObject.pressed) {
  34847. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  34848. }
  34849. else {
  34850. (this._defaultModel.getChildren()[2]).position.y = 0;
  34851. }
  34852. }
  34853. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  34854. return;
  34855. }
  34856. };
  34857. /**
  34858. * Base Url for the controller model.
  34859. */
  34860. ViveController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/vive/';
  34861. /**
  34862. * File name for the controller model.
  34863. */
  34864. ViveController.MODEL_FILENAME = 'wand.babylon';
  34865. return ViveController;
  34866. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  34867. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  34868. canCreate: function (gamepadInfo) {
  34869. return gamepadInfo.id.toLowerCase().indexOf('openvr') !== -1;
  34870. },
  34871. create: function (gamepadInfo) {
  34872. return new ViveController(gamepadInfo);
  34873. }
  34874. });
  34875. /***/ }),
  34876. /***/ "./Gamepads/Controllers/webVRController.ts":
  34877. /*!*************************************************!*\
  34878. !*** ./Gamepads/Controllers/webVRController.ts ***!
  34879. \*************************************************/
  34880. /*! exports provided: WebVRController */
  34881. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34882. "use strict";
  34883. __webpack_require__.r(__webpack_exports__);
  34884. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return WebVRController; });
  34885. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34886. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  34887. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34888. /**
  34889. * Defines the WebVRController object that represents controllers tracked in 3D space
  34890. */
  34891. var WebVRController = /** @class */ (function (_super) {
  34892. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRController, _super);
  34893. /**
  34894. * Creates a new WebVRController from a gamepad
  34895. * @param vrGamepad the gamepad that the WebVRController should be created from
  34896. */
  34897. function WebVRController(vrGamepad) {
  34898. var _this = _super.call(this, vrGamepad) || this;
  34899. // Observables
  34900. /**
  34901. * Fired when the trigger state has changed
  34902. */
  34903. _this.onTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34904. /**
  34905. * Fired when the main button state has changed
  34906. */
  34907. _this.onMainButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34908. /**
  34909. * Fired when the secondary button state has changed
  34910. */
  34911. _this.onSecondaryButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34912. /**
  34913. * Fired when the pad state has changed
  34914. */
  34915. _this.onPadStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34916. /**
  34917. * Fired when controllers stick values have changed
  34918. */
  34919. _this.onPadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34920. /**
  34921. * X and Y axis corrisponding to the controllers joystick
  34922. */
  34923. _this.pad = { x: 0, y: 0 };
  34924. // avoid GC, store state in a tmp object
  34925. _this._changes = {
  34926. pressChanged: false,
  34927. touchChanged: false,
  34928. valueChanged: false,
  34929. changed: false
  34930. };
  34931. _this._buttons = new Array(vrGamepad.buttons.length);
  34932. _this.hand = vrGamepad.hand;
  34933. return _this;
  34934. }
  34935. /**
  34936. * Fired when a controller button's state has changed
  34937. * @param callback the callback containing the button that was modified
  34938. */
  34939. WebVRController.prototype.onButtonStateChange = function (callback) {
  34940. this._onButtonStateChange = callback;
  34941. };
  34942. Object.defineProperty(WebVRController.prototype, "defaultModel", {
  34943. /**
  34944. * The default controller model for the controller
  34945. */
  34946. get: function () {
  34947. return this._defaultModel;
  34948. },
  34949. enumerable: true,
  34950. configurable: true
  34951. });
  34952. /**
  34953. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  34954. */
  34955. WebVRController.prototype.update = function () {
  34956. _super.prototype.update.call(this);
  34957. for (var index = 0; index < this._buttons.length; index++) {
  34958. this._setButtonValue(this.browserGamepad.buttons[index], this._buttons[index], index);
  34959. }
  34960. if (this.leftStick.x !== this.pad.x || this.leftStick.y !== this.pad.y) {
  34961. this.pad.x = this.leftStick.x;
  34962. this.pad.y = this.leftStick.y;
  34963. this.onPadValuesChangedObservable.notifyObservers(this.pad);
  34964. }
  34965. };
  34966. WebVRController.prototype._setButtonValue = function (newState, currentState, buttonIndex) {
  34967. if (!newState) {
  34968. newState = {
  34969. pressed: false,
  34970. touched: false,
  34971. value: 0
  34972. };
  34973. }
  34974. if (!currentState) {
  34975. this._buttons[buttonIndex] = {
  34976. pressed: newState.pressed,
  34977. touched: newState.touched,
  34978. value: newState.value
  34979. };
  34980. return;
  34981. }
  34982. this._checkChanges(newState, currentState);
  34983. if (this._changes.changed) {
  34984. this._onButtonStateChange && this._onButtonStateChange(this.index, buttonIndex, newState);
  34985. this._handleButtonChange(buttonIndex, newState, this._changes);
  34986. }
  34987. this._buttons[buttonIndex].pressed = newState.pressed;
  34988. this._buttons[buttonIndex].touched = newState.touched;
  34989. // oculus triggers are never 0, thou not touched.
  34990. this._buttons[buttonIndex].value = newState.value < 0.00000001 ? 0 : newState.value;
  34991. };
  34992. WebVRController.prototype._checkChanges = function (newState, currentState) {
  34993. this._changes.pressChanged = newState.pressed !== currentState.pressed;
  34994. this._changes.touchChanged = newState.touched !== currentState.touched;
  34995. this._changes.valueChanged = newState.value !== currentState.value;
  34996. this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
  34997. return this._changes;
  34998. };
  34999. /**
  35000. * Disposes of th webVRCOntroller
  35001. */
  35002. WebVRController.prototype.dispose = function () {
  35003. _super.prototype.dispose.call(this);
  35004. this.onTriggerStateChangedObservable.clear();
  35005. this.onMainButtonStateChangedObservable.clear();
  35006. this.onSecondaryButtonStateChangedObservable.clear();
  35007. this.onPadStateChangedObservable.clear();
  35008. this.onPadValuesChangedObservable.clear();
  35009. };
  35010. return WebVRController;
  35011. }(_poseEnabledController__WEBPACK_IMPORTED_MODULE_2__["PoseEnabledController"]));
  35012. /***/ }),
  35013. /***/ "./Gamepads/Controllers/windowsMotionController.ts":
  35014. /*!*********************************************************!*\
  35015. !*** ./Gamepads/Controllers/windowsMotionController.ts ***!
  35016. \*********************************************************/
  35017. /*! exports provided: WindowsMotionController */
  35018. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35019. "use strict";
  35020. __webpack_require__.r(__webpack_exports__);
  35021. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return WindowsMotionController; });
  35022. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35023. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  35024. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35025. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35026. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  35027. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  35028. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35029. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35030. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  35031. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35032. /**
  35033. * Defines the LoadedMeshInfo object that describes information about the loaded webVR controller mesh
  35034. */
  35035. var LoadedMeshInfo = /** @class */ (function () {
  35036. function LoadedMeshInfo() {
  35037. /**
  35038. * Map of the button meshes contained in the controller
  35039. */
  35040. this.buttonMeshes = {};
  35041. /**
  35042. * Map of the axis meshes contained in the controller
  35043. */
  35044. this.axisMeshes = {};
  35045. }
  35046. return LoadedMeshInfo;
  35047. }());
  35048. /**
  35049. * Defines the WindowsMotionController object that the state of the windows motion controller
  35050. */
  35051. var WindowsMotionController = /** @class */ (function (_super) {
  35052. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WindowsMotionController, _super);
  35053. /**
  35054. * Creates a new WindowsMotionController from a gamepad
  35055. * @param vrGamepad the gamepad that the controller should be created from
  35056. */
  35057. function WindowsMotionController(vrGamepad) {
  35058. var _this = _super.call(this, vrGamepad) || this;
  35059. _this._mapping = {
  35060. // Semantic button names
  35061. buttons: ['thumbstick', 'trigger', 'grip', 'menu', 'trackpad'],
  35062. // A mapping of the button name to glTF model node name
  35063. // that should be transformed by button value.
  35064. buttonMeshNames: {
  35065. 'trigger': 'SELECT',
  35066. 'menu': 'MENU',
  35067. 'grip': 'GRASP',
  35068. 'thumbstick': 'THUMBSTICK_PRESS',
  35069. 'trackpad': 'TOUCHPAD_PRESS'
  35070. },
  35071. // This mapping is used to translate from the Motion Controller to Babylon semantics
  35072. buttonObservableNames: {
  35073. 'trigger': 'onTriggerStateChangedObservable',
  35074. 'menu': 'onSecondaryButtonStateChangedObservable',
  35075. 'grip': 'onMainButtonStateChangedObservable',
  35076. 'thumbstick': 'onPadStateChangedObservable',
  35077. 'trackpad': 'onTrackpadChangedObservable'
  35078. },
  35079. // A mapping of the axis name to glTF model node name
  35080. // that should be transformed by axis value.
  35081. // This array mirrors the browserGamepad.axes array, such that
  35082. // the mesh corresponding to axis 0 is in this array index 0.
  35083. axisMeshNames: [
  35084. 'THUMBSTICK_X',
  35085. 'THUMBSTICK_Y',
  35086. 'TOUCHPAD_TOUCH_X',
  35087. 'TOUCHPAD_TOUCH_Y'
  35088. ],
  35089. pointingPoseMeshName: _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledController"].POINTING_POSE
  35090. };
  35091. /**
  35092. * Fired when the trackpad on this controller is clicked
  35093. */
  35094. _this.onTrackpadChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  35095. /**
  35096. * Fired when the trackpad on this controller is modified
  35097. */
  35098. _this.onTrackpadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  35099. /**
  35100. * The current x and y values of this controller's trackpad
  35101. */
  35102. _this.trackpad = { x: 0, y: 0 };
  35103. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerType"].WINDOWS;
  35104. _this._loadedMeshInfo = null;
  35105. return _this;
  35106. }
  35107. Object.defineProperty(WindowsMotionController.prototype, "onTriggerButtonStateChangedObservable", {
  35108. /**
  35109. * Fired when the trigger on this controller is modified
  35110. */
  35111. get: function () {
  35112. return this.onTriggerStateChangedObservable;
  35113. },
  35114. enumerable: true,
  35115. configurable: true
  35116. });
  35117. Object.defineProperty(WindowsMotionController.prototype, "onMenuButtonStateChangedObservable", {
  35118. /**
  35119. * Fired when the menu button on this controller is modified
  35120. */
  35121. get: function () {
  35122. return this.onSecondaryButtonStateChangedObservable;
  35123. },
  35124. enumerable: true,
  35125. configurable: true
  35126. });
  35127. Object.defineProperty(WindowsMotionController.prototype, "onGripButtonStateChangedObservable", {
  35128. /**
  35129. * Fired when the grip button on this controller is modified
  35130. */
  35131. get: function () {
  35132. return this.onMainButtonStateChangedObservable;
  35133. },
  35134. enumerable: true,
  35135. configurable: true
  35136. });
  35137. Object.defineProperty(WindowsMotionController.prototype, "onThumbstickButtonStateChangedObservable", {
  35138. /**
  35139. * Fired when the thumbstick button on this controller is modified
  35140. */
  35141. get: function () {
  35142. return this.onPadStateChangedObservable;
  35143. },
  35144. enumerable: true,
  35145. configurable: true
  35146. });
  35147. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadButtonStateChangedObservable", {
  35148. /**
  35149. * Fired when the touchpad button on this controller is modified
  35150. */
  35151. get: function () {
  35152. return this.onTrackpadChangedObservable;
  35153. },
  35154. enumerable: true,
  35155. configurable: true
  35156. });
  35157. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadValuesChangedObservable", {
  35158. /**
  35159. * Fired when the touchpad values on this controller are modified
  35160. */
  35161. get: function () {
  35162. return this.onTrackpadValuesChangedObservable;
  35163. },
  35164. enumerable: true,
  35165. configurable: true
  35166. });
  35167. WindowsMotionController.prototype._updateTrackpad = function () {
  35168. if (this.browserGamepad.axes && (this.browserGamepad.axes[2] != this.trackpad.x || this.browserGamepad.axes[3] != this.trackpad.y)) {
  35169. this.trackpad.x = this.browserGamepad["axes"][2];
  35170. this.trackpad.y = this.browserGamepad["axes"][3];
  35171. this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad);
  35172. }
  35173. };
  35174. /**
  35175. * Called once per frame by the engine.
  35176. */
  35177. WindowsMotionController.prototype.update = function () {
  35178. _super.prototype.update.call(this);
  35179. if (this.browserGamepad.axes) {
  35180. this._updateTrackpad();
  35181. // Only need to animate axes if there is a loaded mesh
  35182. if (this._loadedMeshInfo) {
  35183. for (var axis = 0; axis < this._mapping.axisMeshNames.length; axis++) {
  35184. this._lerpAxisTransform(axis, this.browserGamepad.axes[axis]);
  35185. }
  35186. }
  35187. }
  35188. };
  35189. /**
  35190. * Called once for each button that changed state since the last frame
  35191. * @param buttonIdx Which button index changed
  35192. * @param state New state of the button
  35193. * @param changes Which properties on the state changed since last frame
  35194. */
  35195. WindowsMotionController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35196. var buttonName = this._mapping.buttons[buttonIdx];
  35197. if (!buttonName) {
  35198. return;
  35199. }
  35200. // Update the trackpad to ensure trackpad.x/y are accurate during button events between frames
  35201. this._updateTrackpad();
  35202. // Only emit events for buttons that we know how to map from index to name
  35203. var observable = this[(this._mapping.buttonObservableNames)[buttonName]];
  35204. if (observable) {
  35205. observable.notifyObservers(state);
  35206. }
  35207. this._lerpButtonTransform(buttonName, state.value);
  35208. };
  35209. /**
  35210. * Moves the buttons on the controller mesh based on their current state
  35211. * @param buttonName the name of the button to move
  35212. * @param buttonValue the value of the button which determines the buttons new position
  35213. */
  35214. WindowsMotionController.prototype._lerpButtonTransform = function (buttonName, buttonValue) {
  35215. // If there is no loaded mesh, there is nothing to transform.
  35216. if (!this._loadedMeshInfo) {
  35217. return;
  35218. }
  35219. var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
  35220. if (!meshInfo.unpressed.rotationQuaternion || !meshInfo.pressed.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  35221. return;
  35222. }
  35223. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
  35224. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
  35225. };
  35226. /**
  35227. * Moves the axis on the controller mesh based on its current state
  35228. * @param axis the index of the axis
  35229. * @param axisValue the value of the axis which determines the meshes new position
  35230. * @hidden
  35231. */
  35232. WindowsMotionController.prototype._lerpAxisTransform = function (axis, axisValue) {
  35233. if (!this._loadedMeshInfo) {
  35234. return;
  35235. }
  35236. var meshInfo = this._loadedMeshInfo.axisMeshes[axis];
  35237. if (!meshInfo) {
  35238. return;
  35239. }
  35240. if (!meshInfo.min.rotationQuaternion || !meshInfo.max.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  35241. return;
  35242. }
  35243. // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
  35244. var lerpValue = axisValue * 0.5 + 0.5;
  35245. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
  35246. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.min.position, meshInfo.max.position, lerpValue, meshInfo.value.position);
  35247. };
  35248. /**
  35249. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35250. * @param scene scene in which to add meshes
  35251. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35252. */
  35253. WindowsMotionController.prototype.initControllerMesh = function (scene, meshLoaded, forceDefault) {
  35254. var _this = this;
  35255. if (forceDefault === void 0) { forceDefault = false; }
  35256. var path;
  35257. var filename;
  35258. // Checking if GLB loader is present
  35259. if (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].IsPluginForExtensionAvailable(".glb")) {
  35260. // Determine the device specific folder based on the ID suffix
  35261. var device = 'default';
  35262. if (this.id && !forceDefault) {
  35263. var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
  35264. device = ((match && match[0]) || device);
  35265. }
  35266. // Hand
  35267. if (this.hand === 'left') {
  35268. filename = WindowsMotionController.MODEL_LEFT_FILENAME;
  35269. }
  35270. else { // Right is the default if no hand is specified
  35271. filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
  35272. }
  35273. path = WindowsMotionController.MODEL_BASE_URL + device + '/';
  35274. }
  35275. else {
  35276. _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");
  35277. path = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_BASE_URL;
  35278. filename = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_FILENAME;
  35279. }
  35280. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].ImportMesh("", path, filename, scene, function (meshes) {
  35281. // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
  35282. _this._loadedMeshInfo = _this.processModel(scene, meshes);
  35283. if (!_this._loadedMeshInfo) {
  35284. return;
  35285. }
  35286. _this._defaultModel = _this._loadedMeshInfo.rootNode;
  35287. _this.attachToMesh(_this._defaultModel);
  35288. if (meshLoaded) {
  35289. meshLoaded(_this._defaultModel);
  35290. }
  35291. }, null, function (scene, message) {
  35292. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log(message);
  35293. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
  35294. if (!forceDefault) {
  35295. _this.initControllerMesh(scene, meshLoaded, true);
  35296. }
  35297. });
  35298. };
  35299. /**
  35300. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  35301. * can be transformed by button presses and axes values, based on this._mapping.
  35302. *
  35303. * @param scene scene in which the meshes exist
  35304. * @param meshes list of meshes that make up the controller model to process
  35305. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  35306. */
  35307. WindowsMotionController.prototype.processModel = function (scene, meshes) {
  35308. var loadedMeshInfo = null;
  35309. // Create a new mesh to contain the glTF hierarchy
  35310. var parentMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this.id + " " + this.hand, scene);
  35311. // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
  35312. var childMesh = null;
  35313. for (var i = 0; i < meshes.length; i++) {
  35314. var mesh = meshes[i];
  35315. if (!mesh.parent) {
  35316. // Exclude controller meshes from picking results
  35317. mesh.isPickable = false;
  35318. // Handle root node, attach to the new parentMesh
  35319. childMesh = mesh;
  35320. break;
  35321. }
  35322. }
  35323. if (childMesh) {
  35324. childMesh.setParent(parentMesh);
  35325. // Create our mesh info. Note that this method will always return non-null.
  35326. loadedMeshInfo = this.createMeshInfo(parentMesh);
  35327. }
  35328. else {
  35329. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Could not find root node in model file.');
  35330. }
  35331. return loadedMeshInfo;
  35332. };
  35333. WindowsMotionController.prototype.createMeshInfo = function (rootNode) {
  35334. var loadedMeshInfo = new LoadedMeshInfo();
  35335. var i;
  35336. loadedMeshInfo.rootNode = rootNode;
  35337. // Reset the caches
  35338. loadedMeshInfo.buttonMeshes = {};
  35339. loadedMeshInfo.axisMeshes = {};
  35340. // Button Meshes
  35341. for (i = 0; i < this._mapping.buttons.length; i++) {
  35342. var buttonMeshName = this._mapping.buttonMeshNames[this._mapping.buttons[i]];
  35343. if (!buttonMeshName) {
  35344. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown button at index: ' + i + ' with mapped name: ' + this._mapping.buttons[i]);
  35345. continue;
  35346. }
  35347. var buttonMesh = getChildByName(rootNode, buttonMeshName);
  35348. if (!buttonMesh) {
  35349. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button mesh with name: ' + buttonMeshName);
  35350. continue;
  35351. }
  35352. var buttonMeshInfo = {
  35353. index: i,
  35354. value: getImmediateChildByName(buttonMesh, 'VALUE'),
  35355. pressed: getImmediateChildByName(buttonMesh, 'PRESSED'),
  35356. unpressed: getImmediateChildByName(buttonMesh, 'UNPRESSED')
  35357. };
  35358. if (buttonMeshInfo.value && buttonMeshInfo.pressed && buttonMeshInfo.unpressed) {
  35359. loadedMeshInfo.buttonMeshes[this._mapping.buttons[i]] = buttonMeshInfo;
  35360. }
  35361. else {
  35362. // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.
  35363. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button submesh under mesh with name: ' + buttonMeshName +
  35364. '(VALUE: ' + !!buttonMeshInfo.value +
  35365. ', PRESSED: ' + !!buttonMeshInfo.pressed +
  35366. ', UNPRESSED:' + !!buttonMeshInfo.unpressed +
  35367. ')');
  35368. }
  35369. }
  35370. // Axis Meshes
  35371. for (i = 0; i < this._mapping.axisMeshNames.length; i++) {
  35372. var axisMeshName = this._mapping.axisMeshNames[i];
  35373. if (!axisMeshName) {
  35374. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown axis at index: ' + i);
  35375. continue;
  35376. }
  35377. var axisMesh = getChildByName(rootNode, axisMeshName);
  35378. if (!axisMesh) {
  35379. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis mesh with name: ' + axisMeshName);
  35380. continue;
  35381. }
  35382. var axisMeshInfo = {
  35383. index: i,
  35384. value: getImmediateChildByName(axisMesh, 'VALUE'),
  35385. min: getImmediateChildByName(axisMesh, 'MIN'),
  35386. max: getImmediateChildByName(axisMesh, 'MAX')
  35387. };
  35388. if (axisMeshInfo.value && axisMeshInfo.min && axisMeshInfo.max) {
  35389. loadedMeshInfo.axisMeshes[i] = axisMeshInfo;
  35390. }
  35391. else {
  35392. // If we didn't find the mesh, it simply means thit axis won't have transforms applied as mapped axis values change.
  35393. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis submesh under mesh with name: ' + axisMeshName +
  35394. '(VALUE: ' + !!axisMeshInfo.value +
  35395. ', MIN: ' + !!axisMeshInfo.min +
  35396. ', MAX:' + !!axisMeshInfo.max +
  35397. ')');
  35398. }
  35399. }
  35400. // Pointing Ray
  35401. loadedMeshInfo.pointingPoseNode = getChildByName(rootNode, this._mapping.pointingPoseMeshName);
  35402. if (!loadedMeshInfo.pointingPoseNode) {
  35403. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing pointing pose mesh with name: ' + this._mapping.pointingPoseMeshName);
  35404. }
  35405. else {
  35406. this._pointingPoseNode = loadedMeshInfo.pointingPoseNode;
  35407. }
  35408. return loadedMeshInfo;
  35409. // Look through all children recursively. This will return null if no mesh exists with the given name.
  35410. function getChildByName(node, name) {
  35411. return node.getChildren(function (n) { return n.name === name; }, false)[0];
  35412. }
  35413. // Look through only immediate children. This will return null if no mesh exists with the given name.
  35414. function getImmediateChildByName(node, name) {
  35415. return node.getChildren(function (n) { return n.name == name; }, true)[0];
  35416. }
  35417. };
  35418. /**
  35419. * Gets the ray of the controller in the direction the controller is pointing
  35420. * @param length the length the resulting ray should be
  35421. * @returns a ray in the direction the controller is pointing
  35422. */
  35423. WindowsMotionController.prototype.getForwardRay = function (length) {
  35424. if (length === void 0) { length = 100; }
  35425. if (!(this._loadedMeshInfo && this._loadedMeshInfo.pointingPoseNode)) {
  35426. return _super.prototype.getForwardRay.call(this, length);
  35427. }
  35428. var m = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix();
  35429. var origin = m.getTranslation();
  35430. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  35431. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(forward, m);
  35432. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(forwardWorld);
  35433. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, length);
  35434. };
  35435. /**
  35436. * Disposes of the controller
  35437. */
  35438. WindowsMotionController.prototype.dispose = function () {
  35439. _super.prototype.dispose.call(this);
  35440. this.onTrackpadChangedObservable.clear();
  35441. };
  35442. /**
  35443. * The base url used to load the left and right controller models
  35444. */
  35445. WindowsMotionController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/microsoft/';
  35446. /**
  35447. * The name of the left controller model file
  35448. */
  35449. WindowsMotionController.MODEL_LEFT_FILENAME = 'left.glb';
  35450. /**
  35451. * The name of the right controller model file
  35452. */
  35453. WindowsMotionController.MODEL_RIGHT_FILENAME = 'right.glb';
  35454. /**
  35455. * The controller name prefix for this controller type
  35456. */
  35457. WindowsMotionController.GAMEPAD_ID_PREFIX = 'Spatial Controller (Spatial Interaction Source) ';
  35458. /**
  35459. * The controller id pattern for this controller type
  35460. */
  35461. WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
  35462. return WindowsMotionController;
  35463. }(_webVRController__WEBPACK_IMPORTED_MODULE_7__["WebVRController"]));
  35464. _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35465. canCreate: function (gamepadInfo) {
  35466. return gamepadInfo.id.indexOf(WindowsMotionController.GAMEPAD_ID_PREFIX) === 0;
  35467. },
  35468. create: function (gamepadInfo) {
  35469. return new WindowsMotionController(gamepadInfo);
  35470. }
  35471. });
  35472. /***/ }),
  35473. /***/ "./Gamepads/gamepad.ts":
  35474. /*!*****************************!*\
  35475. !*** ./Gamepads/gamepad.ts ***!
  35476. \*****************************/
  35477. /*! exports provided: StickValues, Gamepad, GenericPad */
  35478. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35479. "use strict";
  35480. __webpack_require__.r(__webpack_exports__);
  35481. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return StickValues; });
  35482. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return Gamepad; });
  35483. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return GenericPad; });
  35484. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35485. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  35486. /**
  35487. * Represents a gamepad control stick position
  35488. */
  35489. var StickValues = /** @class */ (function () {
  35490. /**
  35491. * Initializes the gamepad x and y control stick values
  35492. * @param x The x component of the gamepad control stick value
  35493. * @param y The y component of the gamepad control stick value
  35494. */
  35495. function StickValues(
  35496. /**
  35497. * The x component of the control stick
  35498. */
  35499. x,
  35500. /**
  35501. * The y component of the control stick
  35502. */
  35503. y) {
  35504. this.x = x;
  35505. this.y = y;
  35506. }
  35507. return StickValues;
  35508. }());
  35509. /**
  35510. * Represents a gamepad
  35511. */
  35512. var Gamepad = /** @class */ (function () {
  35513. /**
  35514. * Initializes the gamepad
  35515. * @param id The id of the gamepad
  35516. * @param index The index of the gamepad
  35517. * @param browserGamepad The browser gamepad
  35518. * @param leftStickX The x component of the left joystick
  35519. * @param leftStickY The y component of the left joystick
  35520. * @param rightStickX The x component of the right joystick
  35521. * @param rightStickY The y component of the right joystick
  35522. */
  35523. function Gamepad(
  35524. /**
  35525. * The id of the gamepad
  35526. */
  35527. id,
  35528. /**
  35529. * The index of the gamepad
  35530. */
  35531. index,
  35532. /**
  35533. * The browser gamepad
  35534. */
  35535. browserGamepad, leftStickX, leftStickY, rightStickX, rightStickY) {
  35536. if (leftStickX === void 0) { leftStickX = 0; }
  35537. if (leftStickY === void 0) { leftStickY = 1; }
  35538. if (rightStickX === void 0) { rightStickX = 2; }
  35539. if (rightStickY === void 0) { rightStickY = 3; }
  35540. this.id = id;
  35541. this.index = index;
  35542. this.browserGamepad = browserGamepad;
  35543. this._leftStick = { x: 0, y: 0 };
  35544. this._rightStick = { x: 0, y: 0 };
  35545. /** @hidden */
  35546. this._isConnected = true;
  35547. /**
  35548. * Specifies whether the left control stick should be Y-inverted
  35549. */
  35550. this._invertLeftStickY = false;
  35551. this.type = Gamepad.GAMEPAD;
  35552. this._leftStickAxisX = leftStickX;
  35553. this._leftStickAxisY = leftStickY;
  35554. this._rightStickAxisX = rightStickX;
  35555. this._rightStickAxisY = rightStickY;
  35556. if (this.browserGamepad.axes.length >= 2) {
  35557. this._leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  35558. }
  35559. if (this.browserGamepad.axes.length >= 4) {
  35560. this._rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  35561. }
  35562. }
  35563. Object.defineProperty(Gamepad.prototype, "isConnected", {
  35564. /**
  35565. * Specifies if the gamepad has been connected
  35566. */
  35567. get: function () {
  35568. return this._isConnected;
  35569. },
  35570. enumerable: true,
  35571. configurable: true
  35572. });
  35573. /**
  35574. * Callback triggered when the left joystick has changed
  35575. * @param callback
  35576. */
  35577. Gamepad.prototype.onleftstickchanged = function (callback) {
  35578. this._onleftstickchanged = callback;
  35579. };
  35580. /**
  35581. * Callback triggered when the right joystick has changed
  35582. * @param callback
  35583. */
  35584. Gamepad.prototype.onrightstickchanged = function (callback) {
  35585. this._onrightstickchanged = callback;
  35586. };
  35587. Object.defineProperty(Gamepad.prototype, "leftStick", {
  35588. /**
  35589. * Gets the left joystick
  35590. */
  35591. get: function () {
  35592. return this._leftStick;
  35593. },
  35594. /**
  35595. * Sets the left joystick values
  35596. */
  35597. set: function (newValues) {
  35598. if (this._onleftstickchanged && (this._leftStick.x !== newValues.x || this._leftStick.y !== newValues.y)) {
  35599. this._onleftstickchanged(newValues);
  35600. }
  35601. this._leftStick = newValues;
  35602. },
  35603. enumerable: true,
  35604. configurable: true
  35605. });
  35606. Object.defineProperty(Gamepad.prototype, "rightStick", {
  35607. /**
  35608. * Gets the right joystick
  35609. */
  35610. get: function () {
  35611. return this._rightStick;
  35612. },
  35613. /**
  35614. * Sets the right joystick value
  35615. */
  35616. set: function (newValues) {
  35617. if (this._onrightstickchanged && (this._rightStick.x !== newValues.x || this._rightStick.y !== newValues.y)) {
  35618. this._onrightstickchanged(newValues);
  35619. }
  35620. this._rightStick = newValues;
  35621. },
  35622. enumerable: true,
  35623. configurable: true
  35624. });
  35625. /**
  35626. * Updates the gamepad joystick positions
  35627. */
  35628. Gamepad.prototype.update = function () {
  35629. if (this._leftStick) {
  35630. this.leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  35631. if (this._invertLeftStickY) {
  35632. this.leftStick.y *= -1;
  35633. }
  35634. }
  35635. if (this._rightStick) {
  35636. this.rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  35637. }
  35638. };
  35639. /**
  35640. * Disposes the gamepad
  35641. */
  35642. Gamepad.prototype.dispose = function () {
  35643. };
  35644. /**
  35645. * Represents a gamepad controller
  35646. */
  35647. Gamepad.GAMEPAD = 0;
  35648. /**
  35649. * Represents a generic controller
  35650. */
  35651. Gamepad.GENERIC = 1;
  35652. /**
  35653. * Represents an XBox controller
  35654. */
  35655. Gamepad.XBOX = 2;
  35656. /**
  35657. * Represents a pose-enabled controller
  35658. */
  35659. Gamepad.POSE_ENABLED = 3;
  35660. return Gamepad;
  35661. }());
  35662. /**
  35663. * Represents a generic gamepad
  35664. */
  35665. var GenericPad = /** @class */ (function (_super) {
  35666. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericPad, _super);
  35667. /**
  35668. * Initializes the generic gamepad
  35669. * @param id The id of the generic gamepad
  35670. * @param index The index of the generic gamepad
  35671. * @param browserGamepad The browser gamepad
  35672. */
  35673. function GenericPad(id, index, browserGamepad) {
  35674. var _this = _super.call(this, id, index, browserGamepad) || this;
  35675. /**
  35676. * Observable triggered when a button has been pressed
  35677. */
  35678. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35679. /**
  35680. * Observable triggered when a button has been released
  35681. */
  35682. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35683. _this.type = Gamepad.GENERIC;
  35684. _this._buttons = new Array(browserGamepad.buttons.length);
  35685. return _this;
  35686. }
  35687. /**
  35688. * Callback triggered when a button has been pressed
  35689. * @param callback Called when a button has been pressed
  35690. */
  35691. GenericPad.prototype.onbuttondown = function (callback) {
  35692. this._onbuttondown = callback;
  35693. };
  35694. /**
  35695. * Callback triggered when a button has been released
  35696. * @param callback Called when a button has been released
  35697. */
  35698. GenericPad.prototype.onbuttonup = function (callback) {
  35699. this._onbuttonup = callback;
  35700. };
  35701. GenericPad.prototype._setButtonValue = function (newValue, currentValue, buttonIndex) {
  35702. if (newValue !== currentValue) {
  35703. if (newValue === 1) {
  35704. if (this._onbuttondown) {
  35705. this._onbuttondown(buttonIndex);
  35706. }
  35707. this.onButtonDownObservable.notifyObservers(buttonIndex);
  35708. }
  35709. if (newValue === 0) {
  35710. if (this._onbuttonup) {
  35711. this._onbuttonup(buttonIndex);
  35712. }
  35713. this.onButtonUpObservable.notifyObservers(buttonIndex);
  35714. }
  35715. }
  35716. return newValue;
  35717. };
  35718. /**
  35719. * Updates the generic gamepad
  35720. */
  35721. GenericPad.prototype.update = function () {
  35722. _super.prototype.update.call(this);
  35723. for (var index = 0; index < this._buttons.length; index++) {
  35724. this._buttons[index] = this._setButtonValue(this.browserGamepad.buttons[index].value, this._buttons[index], index);
  35725. }
  35726. };
  35727. /**
  35728. * Disposes the generic gamepad
  35729. */
  35730. GenericPad.prototype.dispose = function () {
  35731. _super.prototype.dispose.call(this);
  35732. this.onButtonDownObservable.clear();
  35733. this.onButtonUpObservable.clear();
  35734. };
  35735. return GenericPad;
  35736. }(Gamepad));
  35737. /***/ }),
  35738. /***/ "./Gamepads/gamepadManager.ts":
  35739. /*!************************************!*\
  35740. !*** ./Gamepads/gamepadManager.ts ***!
  35741. \************************************/
  35742. /*! exports provided: GamepadManager */
  35743. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35744. "use strict";
  35745. __webpack_require__.r(__webpack_exports__);
  35746. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return GamepadManager; });
  35747. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  35748. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  35749. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  35750. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35751. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  35752. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  35753. /**
  35754. * Manager for handling gamepads
  35755. */
  35756. var GamepadManager = /** @class */ (function () {
  35757. /**
  35758. * Initializes the gamepad manager
  35759. * @param _scene BabylonJS scene
  35760. */
  35761. function GamepadManager(_scene) {
  35762. var _this = this;
  35763. this._scene = _scene;
  35764. this._babylonGamepads = [];
  35765. this._oneGamepadConnected = false;
  35766. /** @hidden */
  35767. this._isMonitoring = false;
  35768. /**
  35769. * observable to be triggered when the gamepad controller has been disconnected
  35770. */
  35771. this.onGamepadDisconnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35772. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  35773. this._gamepadEventSupported = false;
  35774. }
  35775. else {
  35776. this._gamepadEventSupported = 'GamepadEvent' in window;
  35777. this._gamepadSupport = (navigator.getGamepads ||
  35778. navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
  35779. }
  35780. this.onGamepadConnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"](function (observer) {
  35781. // This will be used to raise the onGamepadConnected for all gamepads ALREADY connected
  35782. for (var i in _this._babylonGamepads) {
  35783. var gamepad = _this._babylonGamepads[i];
  35784. if (gamepad && gamepad._isConnected) {
  35785. _this.onGamepadConnectedObservable.notifyObserver(observer, gamepad);
  35786. }
  35787. }
  35788. });
  35789. this._onGamepadConnectedEvent = function (evt) {
  35790. var gamepad = evt.gamepad;
  35791. if (gamepad.index in _this._babylonGamepads) {
  35792. if (_this._babylonGamepads[gamepad.index].isConnected) {
  35793. return;
  35794. }
  35795. }
  35796. var newGamepad;
  35797. if (_this._babylonGamepads[gamepad.index]) {
  35798. newGamepad = _this._babylonGamepads[gamepad.index];
  35799. newGamepad.browserGamepad = gamepad;
  35800. newGamepad._isConnected = true;
  35801. }
  35802. else {
  35803. newGamepad = _this._addNewGamepad(gamepad);
  35804. }
  35805. _this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  35806. _this._startMonitoringGamepads();
  35807. };
  35808. this._onGamepadDisconnectedEvent = function (evt) {
  35809. var gamepad = evt.gamepad;
  35810. // Remove the gamepad from the list of gamepads to monitor.
  35811. for (var i in _this._babylonGamepads) {
  35812. if (_this._babylonGamepads[i].index === gamepad.index) {
  35813. var disconnectedGamepad = _this._babylonGamepads[i];
  35814. disconnectedGamepad._isConnected = false;
  35815. _this.onGamepadDisconnectedObservable.notifyObservers(disconnectedGamepad);
  35816. break;
  35817. }
  35818. }
  35819. };
  35820. if (this._gamepadSupport) {
  35821. //first add already-connected gamepads
  35822. this._updateGamepadObjects();
  35823. if (this._babylonGamepads.length) {
  35824. this._startMonitoringGamepads();
  35825. }
  35826. // Checking if the gamepad connected event is supported (like in Firefox)
  35827. if (this._gamepadEventSupported) {
  35828. window.addEventListener('gamepadconnected', this._onGamepadConnectedEvent, false);
  35829. window.addEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent, false);
  35830. }
  35831. else {
  35832. this._startMonitoringGamepads();
  35833. }
  35834. }
  35835. }
  35836. Object.defineProperty(GamepadManager.prototype, "gamepads", {
  35837. /**
  35838. * The gamepads in the game pad manager
  35839. */
  35840. get: function () {
  35841. return this._babylonGamepads;
  35842. },
  35843. enumerable: true,
  35844. configurable: true
  35845. });
  35846. /**
  35847. * Get the gamepad controllers based on type
  35848. * @param type The type of gamepad controller
  35849. * @returns Nullable gamepad
  35850. */
  35851. GamepadManager.prototype.getGamepadByType = function (type) {
  35852. if (type === void 0) { type = _gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].XBOX; }
  35853. for (var _i = 0, _a = this._babylonGamepads; _i < _a.length; _i++) {
  35854. var gamepad = _a[_i];
  35855. if (gamepad && gamepad.type === type) {
  35856. return gamepad;
  35857. }
  35858. }
  35859. return null;
  35860. };
  35861. /**
  35862. * Disposes the gamepad manager
  35863. */
  35864. GamepadManager.prototype.dispose = function () {
  35865. if (this._gamepadEventSupported) {
  35866. if (this._onGamepadConnectedEvent) {
  35867. window.removeEventListener('gamepadconnected', this._onGamepadConnectedEvent);
  35868. }
  35869. if (this._onGamepadDisconnectedEvent) {
  35870. window.removeEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent);
  35871. }
  35872. this._onGamepadConnectedEvent = null;
  35873. this._onGamepadDisconnectedEvent = null;
  35874. }
  35875. this._babylonGamepads.forEach(function (gamepad) {
  35876. gamepad.dispose();
  35877. });
  35878. this.onGamepadConnectedObservable.clear();
  35879. this.onGamepadDisconnectedObservable.clear();
  35880. this._oneGamepadConnected = false;
  35881. this._stopMonitoringGamepads();
  35882. this._babylonGamepads = [];
  35883. };
  35884. GamepadManager.prototype._addNewGamepad = function (gamepad) {
  35885. if (!this._oneGamepadConnected) {
  35886. this._oneGamepadConnected = true;
  35887. }
  35888. var newGamepad;
  35889. var xboxOne = (gamepad.id.search("Xbox One") !== -1);
  35890. if (xboxOne || gamepad.id.search("Xbox 360") !== -1 || gamepad.id.search("xinput") !== -1) {
  35891. newGamepad = new _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"](gamepad.id, gamepad.index, gamepad, xboxOne);
  35892. }
  35893. // if pose is supported, use the (WebVR) pose enabled controller
  35894. else if (gamepad.pose) {
  35895. newGamepad = _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"].InitiateController(gamepad);
  35896. }
  35897. else {
  35898. newGamepad = new _gamepad__WEBPACK_IMPORTED_MODULE_5__["GenericPad"](gamepad.id, gamepad.index, gamepad);
  35899. }
  35900. this._babylonGamepads[newGamepad.index] = newGamepad;
  35901. return newGamepad;
  35902. };
  35903. GamepadManager.prototype._startMonitoringGamepads = function () {
  35904. if (!this._isMonitoring) {
  35905. this._isMonitoring = true;
  35906. //back-comp
  35907. if (!this._scene) {
  35908. this._checkGamepadsStatus();
  35909. }
  35910. }
  35911. };
  35912. GamepadManager.prototype._stopMonitoringGamepads = function () {
  35913. this._isMonitoring = false;
  35914. };
  35915. /** @hidden */
  35916. GamepadManager.prototype._checkGamepadsStatus = function () {
  35917. var _this = this;
  35918. // Hack to be compatible Chrome
  35919. this._updateGamepadObjects();
  35920. for (var i in this._babylonGamepads) {
  35921. var gamepad = this._babylonGamepads[i];
  35922. if (!gamepad || !gamepad.isConnected) {
  35923. continue;
  35924. }
  35925. gamepad.update();
  35926. }
  35927. if (this._isMonitoring && !this._scene) {
  35928. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].QueueNewFrame(function () { _this._checkGamepadsStatus(); });
  35929. }
  35930. };
  35931. // This function is called only on Chrome, which does not properly support
  35932. // connection/disconnection events and forces you to recopy again the gamepad object
  35933. GamepadManager.prototype._updateGamepadObjects = function () {
  35934. var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
  35935. for (var i = 0; i < gamepads.length; i++) {
  35936. var gamepad = gamepads[i];
  35937. if (gamepad) {
  35938. if (!this._babylonGamepads[gamepad.index]) {
  35939. var newGamepad = this._addNewGamepad(gamepad);
  35940. this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  35941. }
  35942. else {
  35943. // Forced to copy again this object for Chrome for unknown reason
  35944. this._babylonGamepads[i].browserGamepad = gamepad;
  35945. if (!this._babylonGamepads[i].isConnected) {
  35946. this._babylonGamepads[i]._isConnected = true;
  35947. this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[i]);
  35948. }
  35949. }
  35950. }
  35951. }
  35952. };
  35953. return GamepadManager;
  35954. }());
  35955. /***/ }),
  35956. /***/ "./Gamepads/gamepadSceneComponent.ts":
  35957. /*!*******************************************!*\
  35958. !*** ./Gamepads/gamepadSceneComponent.ts ***!
  35959. \*******************************************/
  35960. /*! exports provided: GamepadSystemSceneComponent */
  35961. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35962. "use strict";
  35963. __webpack_require__.r(__webpack_exports__);
  35964. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return GamepadSystemSceneComponent; });
  35965. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  35966. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  35967. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  35968. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  35969. /* harmony import */ var _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  35970. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  35971. /* harmony import */ var _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  35972. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "gamepadManager", {
  35973. get: function () {
  35974. if (!this._gamepadManager) {
  35975. this._gamepadManager = new _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"](this);
  35976. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD);
  35977. if (!component) {
  35978. component = new GamepadSystemSceneComponent(this);
  35979. this._addComponent(component);
  35980. }
  35981. }
  35982. return this._gamepadManager;
  35983. },
  35984. enumerable: true,
  35985. configurable: true
  35986. });
  35987. /**
  35988. * Adds a gamepad to the free camera inputs manager
  35989. */
  35990. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addGamepad = function () {
  35991. this.add(new _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraGamepadInput"]());
  35992. return this;
  35993. };
  35994. /**
  35995. * Adds a gamepad to the arc rotate camera inputs manager
  35996. */
  35997. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["ArcRotateCameraInputsManager"].prototype.addGamepad = function () {
  35998. this.add(new _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__["ArcRotateCameraGamepadInput"]());
  35999. return this;
  36000. };
  36001. /**
  36002. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  36003. */
  36004. var GamepadSystemSceneComponent = /** @class */ (function () {
  36005. /**
  36006. * Creates a new instance of the component for the given scene
  36007. * @param scene Defines the scene to register the component in
  36008. */
  36009. function GamepadSystemSceneComponent(scene) {
  36010. /**
  36011. * The component name helpfull to identify the component in the list of scene components.
  36012. */
  36013. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD;
  36014. this.scene = scene;
  36015. }
  36016. /**
  36017. * Registers the component in a given scene
  36018. */
  36019. GamepadSystemSceneComponent.prototype.register = function () {
  36020. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate);
  36021. };
  36022. /**
  36023. * Rebuilds the elements related to this component in case of
  36024. * context lost for instance.
  36025. */
  36026. GamepadSystemSceneComponent.prototype.rebuild = function () {
  36027. // Nothing to do for gamepads
  36028. };
  36029. /**
  36030. * Disposes the component and the associated ressources
  36031. */
  36032. GamepadSystemSceneComponent.prototype.dispose = function () {
  36033. var gamepadManager = this.scene._gamepadManager;
  36034. if (gamepadManager) {
  36035. gamepadManager.dispose();
  36036. this.scene._gamepadManager = null;
  36037. }
  36038. };
  36039. GamepadSystemSceneComponent.prototype._beforeCameraUpdate = function () {
  36040. var gamepadManager = this.scene._gamepadManager;
  36041. if (gamepadManager && gamepadManager._isMonitoring) {
  36042. gamepadManager._checkGamepadsStatus();
  36043. }
  36044. };
  36045. return GamepadSystemSceneComponent;
  36046. }());
  36047. /***/ }),
  36048. /***/ "./Gamepads/index.ts":
  36049. /*!***************************!*\
  36050. !*** ./Gamepads/index.ts ***!
  36051. \***************************/
  36052. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad */
  36053. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36054. "use strict";
  36055. __webpack_require__.r(__webpack_exports__);
  36056. /* harmony import */ var _Controllers_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Controllers/index */ "./Gamepads/Controllers/index.ts");
  36057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  36058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  36059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  36060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  36061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  36062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  36063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  36064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  36065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  36066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  36067. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  36068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["StickValues"]; });
  36069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["Gamepad"]; });
  36070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["GenericPad"]; });
  36071. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  36072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"]; });
  36073. /* harmony import */ var _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  36074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__["GamepadSystemSceneComponent"]; });
  36075. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  36076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Button"]; });
  36077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Dpad"]; });
  36078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"]; });
  36079. /***/ }),
  36080. /***/ "./Gamepads/xboxGamepad.ts":
  36081. /*!*********************************!*\
  36082. !*** ./Gamepads/xboxGamepad.ts ***!
  36083. \*********************************/
  36084. /*! exports provided: Xbox360Button, Xbox360Dpad, Xbox360Pad */
  36085. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36086. "use strict";
  36087. __webpack_require__.r(__webpack_exports__);
  36088. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return Xbox360Button; });
  36089. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return Xbox360Dpad; });
  36090. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return Xbox360Pad; });
  36091. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36092. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36093. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  36094. /**
  36095. * Defines supported buttons for XBox360 compatible gamepads
  36096. */
  36097. var Xbox360Button;
  36098. (function (Xbox360Button) {
  36099. /** A */
  36100. Xbox360Button[Xbox360Button["A"] = 0] = "A";
  36101. /** B */
  36102. Xbox360Button[Xbox360Button["B"] = 1] = "B";
  36103. /** X */
  36104. Xbox360Button[Xbox360Button["X"] = 2] = "X";
  36105. /** Y */
  36106. Xbox360Button[Xbox360Button["Y"] = 3] = "Y";
  36107. /** Start */
  36108. Xbox360Button[Xbox360Button["Start"] = 4] = "Start";
  36109. /** Back */
  36110. Xbox360Button[Xbox360Button["Back"] = 5] = "Back";
  36111. /** Left button */
  36112. Xbox360Button[Xbox360Button["LB"] = 6] = "LB";
  36113. /** Right button */
  36114. Xbox360Button[Xbox360Button["RB"] = 7] = "RB";
  36115. /** Left stick */
  36116. Xbox360Button[Xbox360Button["LeftStick"] = 8] = "LeftStick";
  36117. /** Right stick */
  36118. Xbox360Button[Xbox360Button["RightStick"] = 9] = "RightStick";
  36119. })(Xbox360Button || (Xbox360Button = {}));
  36120. /** Defines values for XBox360 DPad */
  36121. var Xbox360Dpad;
  36122. (function (Xbox360Dpad) {
  36123. /** Up */
  36124. Xbox360Dpad[Xbox360Dpad["Up"] = 0] = "Up";
  36125. /** Down */
  36126. Xbox360Dpad[Xbox360Dpad["Down"] = 1] = "Down";
  36127. /** Left */
  36128. Xbox360Dpad[Xbox360Dpad["Left"] = 2] = "Left";
  36129. /** Right */
  36130. Xbox360Dpad[Xbox360Dpad["Right"] = 3] = "Right";
  36131. })(Xbox360Dpad || (Xbox360Dpad = {}));
  36132. /**
  36133. * Defines a XBox360 gamepad
  36134. */
  36135. var Xbox360Pad = /** @class */ (function (_super) {
  36136. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Xbox360Pad, _super);
  36137. /**
  36138. * Creates a new XBox360 gamepad object
  36139. * @param id defines the id of this gamepad
  36140. * @param index defines its index
  36141. * @param gamepad defines the internal HTML gamepad object
  36142. * @param xboxOne defines if it is a XBox One gamepad
  36143. */
  36144. function Xbox360Pad(id, index, gamepad, xboxOne) {
  36145. if (xboxOne === void 0) { xboxOne = false; }
  36146. var _this = _super.call(this, id, index, gamepad, 0, 1, 2, 3) || this;
  36147. _this._leftTrigger = 0;
  36148. _this._rightTrigger = 0;
  36149. /** Observable raised when a button is pressed */
  36150. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36151. /** Observable raised when a button is released */
  36152. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36153. /** Observable raised when a pad is pressed */
  36154. _this.onPadDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36155. /** Observable raised when a pad is released */
  36156. _this.onPadUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36157. _this._buttonA = 0;
  36158. _this._buttonB = 0;
  36159. _this._buttonX = 0;
  36160. _this._buttonY = 0;
  36161. _this._buttonBack = 0;
  36162. _this._buttonStart = 0;
  36163. _this._buttonLB = 0;
  36164. _this._buttonRB = 0;
  36165. _this._buttonLeftStick = 0;
  36166. _this._buttonRightStick = 0;
  36167. _this._dPadUp = 0;
  36168. _this._dPadDown = 0;
  36169. _this._dPadLeft = 0;
  36170. _this._dPadRight = 0;
  36171. _this._isXboxOnePad = false;
  36172. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"].XBOX;
  36173. _this._isXboxOnePad = xboxOne;
  36174. return _this;
  36175. }
  36176. /**
  36177. * Defines the callback to call when left trigger is pressed
  36178. * @param callback defines the callback to use
  36179. */
  36180. Xbox360Pad.prototype.onlefttriggerchanged = function (callback) {
  36181. this._onlefttriggerchanged = callback;
  36182. };
  36183. /**
  36184. * Defines the callback to call when right trigger is pressed
  36185. * @param callback defines the callback to use
  36186. */
  36187. Xbox360Pad.prototype.onrighttriggerchanged = function (callback) {
  36188. this._onrighttriggerchanged = callback;
  36189. };
  36190. Object.defineProperty(Xbox360Pad.prototype, "leftTrigger", {
  36191. /**
  36192. * Gets the left trigger value
  36193. */
  36194. get: function () {
  36195. return this._leftTrigger;
  36196. },
  36197. /**
  36198. * Sets the left trigger value
  36199. */
  36200. set: function (newValue) {
  36201. if (this._onlefttriggerchanged && this._leftTrigger !== newValue) {
  36202. this._onlefttriggerchanged(newValue);
  36203. }
  36204. this._leftTrigger = newValue;
  36205. },
  36206. enumerable: true,
  36207. configurable: true
  36208. });
  36209. Object.defineProperty(Xbox360Pad.prototype, "rightTrigger", {
  36210. /**
  36211. * Gets the right trigger value
  36212. */
  36213. get: function () {
  36214. return this._rightTrigger;
  36215. },
  36216. /**
  36217. * Sets the right trigger value
  36218. */
  36219. set: function (newValue) {
  36220. if (this._onrighttriggerchanged && this._rightTrigger !== newValue) {
  36221. this._onrighttriggerchanged(newValue);
  36222. }
  36223. this._rightTrigger = newValue;
  36224. },
  36225. enumerable: true,
  36226. configurable: true
  36227. });
  36228. /**
  36229. * Defines the callback to call when a button is pressed
  36230. * @param callback defines the callback to use
  36231. */
  36232. Xbox360Pad.prototype.onbuttondown = function (callback) {
  36233. this._onbuttondown = callback;
  36234. };
  36235. /**
  36236. * Defines the callback to call when a button is released
  36237. * @param callback defines the callback to use
  36238. */
  36239. Xbox360Pad.prototype.onbuttonup = function (callback) {
  36240. this._onbuttonup = callback;
  36241. };
  36242. /**
  36243. * Defines the callback to call when a pad is pressed
  36244. * @param callback defines the callback to use
  36245. */
  36246. Xbox360Pad.prototype.ondpaddown = function (callback) {
  36247. this._ondpaddown = callback;
  36248. };
  36249. /**
  36250. * Defines the callback to call when a pad is released
  36251. * @param callback defines the callback to use
  36252. */
  36253. Xbox360Pad.prototype.ondpadup = function (callback) {
  36254. this._ondpadup = callback;
  36255. };
  36256. Xbox360Pad.prototype._setButtonValue = function (newValue, currentValue, buttonType) {
  36257. if (newValue !== currentValue) {
  36258. if (newValue === 1) {
  36259. if (this._onbuttondown) {
  36260. this._onbuttondown(buttonType);
  36261. }
  36262. this.onButtonDownObservable.notifyObservers(buttonType);
  36263. }
  36264. if (newValue === 0) {
  36265. if (this._onbuttonup) {
  36266. this._onbuttonup(buttonType);
  36267. }
  36268. this.onButtonUpObservable.notifyObservers(buttonType);
  36269. }
  36270. }
  36271. return newValue;
  36272. };
  36273. Xbox360Pad.prototype._setDPadValue = function (newValue, currentValue, buttonType) {
  36274. if (newValue !== currentValue) {
  36275. if (newValue === 1) {
  36276. if (this._ondpaddown) {
  36277. this._ondpaddown(buttonType);
  36278. }
  36279. this.onPadDownObservable.notifyObservers(buttonType);
  36280. }
  36281. if (newValue === 0) {
  36282. if (this._ondpadup) {
  36283. this._ondpadup(buttonType);
  36284. }
  36285. this.onPadUpObservable.notifyObservers(buttonType);
  36286. }
  36287. }
  36288. return newValue;
  36289. };
  36290. Object.defineProperty(Xbox360Pad.prototype, "buttonA", {
  36291. /**
  36292. * Gets the value of the `A` button
  36293. */
  36294. get: function () {
  36295. return this._buttonA;
  36296. },
  36297. /**
  36298. * Sets the value of the `A` button
  36299. */
  36300. set: function (value) {
  36301. this._buttonA = this._setButtonValue(value, this._buttonA, Xbox360Button.A);
  36302. },
  36303. enumerable: true,
  36304. configurable: true
  36305. });
  36306. Object.defineProperty(Xbox360Pad.prototype, "buttonB", {
  36307. /**
  36308. * Gets the value of the `B` button
  36309. */
  36310. get: function () {
  36311. return this._buttonB;
  36312. },
  36313. /**
  36314. * Sets the value of the `B` button
  36315. */
  36316. set: function (value) {
  36317. this._buttonB = this._setButtonValue(value, this._buttonB, Xbox360Button.B);
  36318. },
  36319. enumerable: true,
  36320. configurable: true
  36321. });
  36322. Object.defineProperty(Xbox360Pad.prototype, "buttonX", {
  36323. /**
  36324. * Gets the value of the `X` button
  36325. */
  36326. get: function () {
  36327. return this._buttonX;
  36328. },
  36329. /**
  36330. * Sets the value of the `X` button
  36331. */
  36332. set: function (value) {
  36333. this._buttonX = this._setButtonValue(value, this._buttonX, Xbox360Button.X);
  36334. },
  36335. enumerable: true,
  36336. configurable: true
  36337. });
  36338. Object.defineProperty(Xbox360Pad.prototype, "buttonY", {
  36339. /**
  36340. * Gets the value of the `Y` button
  36341. */
  36342. get: function () {
  36343. return this._buttonY;
  36344. },
  36345. /**
  36346. * Sets the value of the `Y` button
  36347. */
  36348. set: function (value) {
  36349. this._buttonY = this._setButtonValue(value, this._buttonY, Xbox360Button.Y);
  36350. },
  36351. enumerable: true,
  36352. configurable: true
  36353. });
  36354. Object.defineProperty(Xbox360Pad.prototype, "buttonStart", {
  36355. /**
  36356. * Gets the value of the `Start` button
  36357. */
  36358. get: function () {
  36359. return this._buttonStart;
  36360. },
  36361. /**
  36362. * Sets the value of the `Start` button
  36363. */
  36364. set: function (value) {
  36365. this._buttonStart = this._setButtonValue(value, this._buttonStart, Xbox360Button.Start);
  36366. },
  36367. enumerable: true,
  36368. configurable: true
  36369. });
  36370. Object.defineProperty(Xbox360Pad.prototype, "buttonBack", {
  36371. /**
  36372. * Gets the value of the `Back` button
  36373. */
  36374. get: function () {
  36375. return this._buttonBack;
  36376. },
  36377. /**
  36378. * Sets the value of the `Back` button
  36379. */
  36380. set: function (value) {
  36381. this._buttonBack = this._setButtonValue(value, this._buttonBack, Xbox360Button.Back);
  36382. },
  36383. enumerable: true,
  36384. configurable: true
  36385. });
  36386. Object.defineProperty(Xbox360Pad.prototype, "buttonLB", {
  36387. /**
  36388. * Gets the value of the `Left` button
  36389. */
  36390. get: function () {
  36391. return this._buttonLB;
  36392. },
  36393. /**
  36394. * Sets the value of the `Left` button
  36395. */
  36396. set: function (value) {
  36397. this._buttonLB = this._setButtonValue(value, this._buttonLB, Xbox360Button.LB);
  36398. },
  36399. enumerable: true,
  36400. configurable: true
  36401. });
  36402. Object.defineProperty(Xbox360Pad.prototype, "buttonRB", {
  36403. /**
  36404. * Gets the value of the `Right` button
  36405. */
  36406. get: function () {
  36407. return this._buttonRB;
  36408. },
  36409. /**
  36410. * Sets the value of the `Right` button
  36411. */
  36412. set: function (value) {
  36413. this._buttonRB = this._setButtonValue(value, this._buttonRB, Xbox360Button.RB);
  36414. },
  36415. enumerable: true,
  36416. configurable: true
  36417. });
  36418. Object.defineProperty(Xbox360Pad.prototype, "buttonLeftStick", {
  36419. /**
  36420. * Gets the value of the Left joystick
  36421. */
  36422. get: function () {
  36423. return this._buttonLeftStick;
  36424. },
  36425. /**
  36426. * Sets the value of the Left joystick
  36427. */
  36428. set: function (value) {
  36429. this._buttonLeftStick = this._setButtonValue(value, this._buttonLeftStick, Xbox360Button.LeftStick);
  36430. },
  36431. enumerable: true,
  36432. configurable: true
  36433. });
  36434. Object.defineProperty(Xbox360Pad.prototype, "buttonRightStick", {
  36435. /**
  36436. * Gets the value of the Right joystick
  36437. */
  36438. get: function () {
  36439. return this._buttonRightStick;
  36440. },
  36441. /**
  36442. * Sets the value of the Right joystick
  36443. */
  36444. set: function (value) {
  36445. this._buttonRightStick = this._setButtonValue(value, this._buttonRightStick, Xbox360Button.RightStick);
  36446. },
  36447. enumerable: true,
  36448. configurable: true
  36449. });
  36450. Object.defineProperty(Xbox360Pad.prototype, "dPadUp", {
  36451. /**
  36452. * Gets the value of D-pad up
  36453. */
  36454. get: function () {
  36455. return this._dPadUp;
  36456. },
  36457. /**
  36458. * Sets the value of D-pad up
  36459. */
  36460. set: function (value) {
  36461. this._dPadUp = this._setDPadValue(value, this._dPadUp, Xbox360Dpad.Up);
  36462. },
  36463. enumerable: true,
  36464. configurable: true
  36465. });
  36466. Object.defineProperty(Xbox360Pad.prototype, "dPadDown", {
  36467. /**
  36468. * Gets the value of D-pad down
  36469. */
  36470. get: function () {
  36471. return this._dPadDown;
  36472. },
  36473. /**
  36474. * Sets the value of D-pad down
  36475. */
  36476. set: function (value) {
  36477. this._dPadDown = this._setDPadValue(value, this._dPadDown, Xbox360Dpad.Down);
  36478. },
  36479. enumerable: true,
  36480. configurable: true
  36481. });
  36482. Object.defineProperty(Xbox360Pad.prototype, "dPadLeft", {
  36483. /**
  36484. * Gets the value of D-pad left
  36485. */
  36486. get: function () {
  36487. return this._dPadLeft;
  36488. },
  36489. /**
  36490. * Sets the value of D-pad left
  36491. */
  36492. set: function (value) {
  36493. this._dPadLeft = this._setDPadValue(value, this._dPadLeft, Xbox360Dpad.Left);
  36494. },
  36495. enumerable: true,
  36496. configurable: true
  36497. });
  36498. Object.defineProperty(Xbox360Pad.prototype, "dPadRight", {
  36499. /**
  36500. * Gets the value of D-pad right
  36501. */
  36502. get: function () {
  36503. return this._dPadRight;
  36504. },
  36505. /**
  36506. * Sets the value of D-pad right
  36507. */
  36508. set: function (value) {
  36509. this._dPadRight = this._setDPadValue(value, this._dPadRight, Xbox360Dpad.Right);
  36510. },
  36511. enumerable: true,
  36512. configurable: true
  36513. });
  36514. /**
  36515. * Force the gamepad to synchronize with device values
  36516. */
  36517. Xbox360Pad.prototype.update = function () {
  36518. _super.prototype.update.call(this);
  36519. if (this._isXboxOnePad) {
  36520. this.buttonA = this.browserGamepad.buttons[0].value;
  36521. this.buttonB = this.browserGamepad.buttons[1].value;
  36522. this.buttonX = this.browserGamepad.buttons[2].value;
  36523. this.buttonY = this.browserGamepad.buttons[3].value;
  36524. this.buttonLB = this.browserGamepad.buttons[4].value;
  36525. this.buttonRB = this.browserGamepad.buttons[5].value;
  36526. this.leftTrigger = this.browserGamepad.axes[2];
  36527. this.rightTrigger = this.browserGamepad.axes[5];
  36528. this.buttonBack = this.browserGamepad.buttons[9].value;
  36529. this.buttonStart = this.browserGamepad.buttons[8].value;
  36530. this.buttonLeftStick = this.browserGamepad.buttons[6].value;
  36531. this.buttonRightStick = this.browserGamepad.buttons[7].value;
  36532. this.dPadUp = this.browserGamepad.buttons[11].value;
  36533. this.dPadDown = this.browserGamepad.buttons[12].value;
  36534. this.dPadLeft = this.browserGamepad.buttons[13].value;
  36535. this.dPadRight = this.browserGamepad.buttons[14].value;
  36536. }
  36537. else {
  36538. this.buttonA = this.browserGamepad.buttons[0].value;
  36539. this.buttonB = this.browserGamepad.buttons[1].value;
  36540. this.buttonX = this.browserGamepad.buttons[2].value;
  36541. this.buttonY = this.browserGamepad.buttons[3].value;
  36542. this.buttonLB = this.browserGamepad.buttons[4].value;
  36543. this.buttonRB = this.browserGamepad.buttons[5].value;
  36544. this.leftTrigger = this.browserGamepad.buttons[6].value;
  36545. this.rightTrigger = this.browserGamepad.buttons[7].value;
  36546. this.buttonBack = this.browserGamepad.buttons[8].value;
  36547. this.buttonStart = this.browserGamepad.buttons[9].value;
  36548. this.buttonLeftStick = this.browserGamepad.buttons[10].value;
  36549. this.buttonRightStick = this.browserGamepad.buttons[11].value;
  36550. this.dPadUp = this.browserGamepad.buttons[12].value;
  36551. this.dPadDown = this.browserGamepad.buttons[13].value;
  36552. this.dPadLeft = this.browserGamepad.buttons[14].value;
  36553. this.dPadRight = this.browserGamepad.buttons[15].value;
  36554. }
  36555. };
  36556. /**
  36557. * Disposes the gamepad
  36558. */
  36559. Xbox360Pad.prototype.dispose = function () {
  36560. _super.prototype.dispose.call(this);
  36561. this.onButtonDownObservable.clear();
  36562. this.onButtonUpObservable.clear();
  36563. this.onPadDownObservable.clear();
  36564. this.onPadUpObservable.clear();
  36565. };
  36566. return Xbox360Pad;
  36567. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"]));
  36568. /***/ }),
  36569. /***/ "./Gizmos/axisDragGizmo.ts":
  36570. /*!*********************************!*\
  36571. !*** ./Gizmos/axisDragGizmo.ts ***!
  36572. \*********************************/
  36573. /*! exports provided: AxisDragGizmo */
  36574. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36575. "use strict";
  36576. __webpack_require__.r(__webpack_exports__);
  36577. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return AxisDragGizmo; });
  36578. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36579. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36580. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  36581. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  36582. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  36583. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  36584. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  36585. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  36586. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  36587. /**
  36588. * Single axis drag gizmo
  36589. */
  36590. var AxisDragGizmo = /** @class */ (function (_super) {
  36591. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisDragGizmo, _super);
  36592. /**
  36593. * Creates an AxisDragGizmo
  36594. * @param gizmoLayer The utility layer the gizmo will be added to
  36595. * @param dragAxis The axis which the gizmo will be able to drag on
  36596. * @param color The color of the gizmo
  36597. */
  36598. function AxisDragGizmo(dragAxis, color, gizmoLayer) {
  36599. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  36600. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  36601. var _this = _super.call(this, gizmoLayer) || this;
  36602. _this._pointerObserver = null;
  36603. /**
  36604. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  36605. */
  36606. _this.snapDistance = 0;
  36607. /**
  36608. * Event that fires each time the gizmo snaps to a new location.
  36609. * * snapDistance is the the change in distance
  36610. */
  36611. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36612. // Create Material
  36613. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  36614. coloredMaterial.disableLighting = true;
  36615. coloredMaterial.emissiveColor = color;
  36616. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  36617. hoverMaterial.disableLighting = true;
  36618. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  36619. // Build mesh on root node
  36620. var arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, coloredMaterial);
  36621. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  36622. arrow.scaling.scaleInPlace(1 / 3);
  36623. arrow.parent = _this._rootMesh;
  36624. var currentSnapDragDistance = 0;
  36625. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  36626. var tmpSnapEvent = { snapDistance: 0 };
  36627. // Add drag behavior to handle events when the gizmo is dragged
  36628. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragAxis: dragAxis });
  36629. _this.dragBehavior.moveAttached = false;
  36630. _this._rootMesh.addBehavior(_this.dragBehavior);
  36631. var localDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  36632. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  36633. _this.dragBehavior.onDragObservable.add(function (event) {
  36634. if (_this.attachedMesh) {
  36635. // Convert delta to local translation if it has a parent
  36636. if (_this.attachedMesh.parent) {
  36637. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  36638. tmpMatrix.setTranslationFromFloats(0, 0, 0);
  36639. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(event.delta, tmpMatrix, localDelta);
  36640. }
  36641. else {
  36642. localDelta.copyFrom(event.delta);
  36643. }
  36644. // Snapping logic
  36645. if (_this.snapDistance == 0) {
  36646. _this.attachedMesh.position.addInPlace(localDelta);
  36647. }
  36648. else {
  36649. currentSnapDragDistance += event.dragDistance;
  36650. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  36651. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  36652. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  36653. localDelta.normalizeToRef(tmpVector);
  36654. tmpVector.scaleInPlace(_this.snapDistance * dragSteps);
  36655. _this.attachedMesh.position.addInPlace(tmpVector);
  36656. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  36657. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  36658. }
  36659. }
  36660. }
  36661. });
  36662. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  36663. if (_this._customMeshSet) {
  36664. return;
  36665. }
  36666. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  36667. var material = isHovered ? hoverMaterial : coloredMaterial;
  36668. _this._rootMesh.getChildMeshes().forEach(function (m) {
  36669. m.material = material;
  36670. if (m.color) {
  36671. m.color = material.emissiveColor;
  36672. }
  36673. });
  36674. });
  36675. return _this;
  36676. }
  36677. /** @hidden */
  36678. AxisDragGizmo._CreateArrow = function (scene, material) {
  36679. var arrow = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  36680. var cylinder = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_4__["MeshBuilder"].CreateCylinder("cylinder", { diameterTop: 0, height: 1.5, diameterBottom: 0.75, tessellation: 96 }, scene);
  36681. 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);
  36682. line.color = material.emissiveColor;
  36683. cylinder.parent = arrow;
  36684. line.parent = arrow;
  36685. // Position arrow pointing in its drag axis
  36686. cylinder.scaling.scaleInPlace(0.05);
  36687. cylinder.material = material;
  36688. cylinder.rotation.x = Math.PI / 2;
  36689. cylinder.position.z += 0.3;
  36690. line.scaling.scaleInPlace(0.26);
  36691. line.rotation.x = Math.PI / 2;
  36692. line.material = material;
  36693. return arrow;
  36694. };
  36695. /** @hidden */
  36696. AxisDragGizmo._CreateArrowInstance = function (scene, arrow) {
  36697. var instance = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  36698. for (var _i = 0, _a = arrow.getChildMeshes(); _i < _a.length; _i++) {
  36699. var mesh = _a[_i];
  36700. var childInstance = mesh.createInstance(mesh.name);
  36701. childInstance.parent = instance;
  36702. }
  36703. return instance;
  36704. };
  36705. AxisDragGizmo.prototype._attachedMeshChanged = function (value) {
  36706. if (this.dragBehavior) {
  36707. this.dragBehavior.enabled = value ? true : false;
  36708. }
  36709. };
  36710. /**
  36711. * Disposes of the gizmo
  36712. */
  36713. AxisDragGizmo.prototype.dispose = function () {
  36714. this.onSnapObservable.clear();
  36715. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  36716. this.dragBehavior.detach();
  36717. _super.prototype.dispose.call(this);
  36718. };
  36719. return AxisDragGizmo;
  36720. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  36721. /***/ }),
  36722. /***/ "./Gizmos/axisScaleGizmo.ts":
  36723. /*!**********************************!*\
  36724. !*** ./Gizmos/axisScaleGizmo.ts ***!
  36725. \**********************************/
  36726. /*! exports provided: AxisScaleGizmo */
  36727. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36728. "use strict";
  36729. __webpack_require__.r(__webpack_exports__);
  36730. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return AxisScaleGizmo; });
  36731. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36732. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36733. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  36734. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  36735. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  36736. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  36737. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  36738. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  36739. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  36740. /**
  36741. * Single axis scale gizmo
  36742. */
  36743. var AxisScaleGizmo = /** @class */ (function (_super) {
  36744. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisScaleGizmo, _super);
  36745. /**
  36746. * Creates an AxisScaleGizmo
  36747. * @param gizmoLayer The utility layer the gizmo will be added to
  36748. * @param dragAxis The axis which the gizmo will be able to scale on
  36749. * @param color The color of the gizmo
  36750. */
  36751. function AxisScaleGizmo(dragAxis, color, gizmoLayer) {
  36752. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  36753. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  36754. var _this = _super.call(this, gizmoLayer) || this;
  36755. _this._pointerObserver = null;
  36756. /**
  36757. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  36758. */
  36759. _this.snapDistance = 0;
  36760. /**
  36761. * Event that fires each time the gizmo snaps to a new location.
  36762. * * snapDistance is the the change in distance
  36763. */
  36764. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36765. /**
  36766. * If the scaling operation should be done on all axis (default: false)
  36767. */
  36768. _this.uniformScaling = false;
  36769. // Create Material
  36770. _this._coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  36771. _this._coloredMaterial.disableLighting = true;
  36772. _this._coloredMaterial.emissiveColor = color;
  36773. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  36774. hoverMaterial.disableLighting = true;
  36775. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  36776. // Build mesh on root node
  36777. var arrow = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  36778. var arrowMesh = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_4__["MeshBuilder"].CreateBox("yPosMesh", { size: 0.4 }, gizmoLayer.utilityLayerScene);
  36779. 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);
  36780. arrowTail.color = _this._coloredMaterial.emissiveColor;
  36781. arrow.addChild(arrowMesh);
  36782. arrow.addChild(arrowTail);
  36783. // Position arrow pointing in its drag axis
  36784. arrowMesh.scaling.scaleInPlace(0.1);
  36785. arrowMesh.material = _this._coloredMaterial;
  36786. arrowMesh.rotation.x = Math.PI / 2;
  36787. arrowMesh.position.z += 0.3;
  36788. arrowTail.scaling.scaleInPlace(0.26);
  36789. arrowTail.rotation.x = Math.PI / 2;
  36790. arrowTail.material = _this._coloredMaterial;
  36791. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  36792. _this._rootMesh.addChild(arrow);
  36793. arrow.scaling.scaleInPlace(1 / 3);
  36794. // Add drag behavior to handle events when the gizmo is dragged
  36795. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__["PointerDragBehavior"]({ dragAxis: dragAxis });
  36796. _this.dragBehavior.moveAttached = false;
  36797. _this._rootMesh.addBehavior(_this.dragBehavior);
  36798. var currentSnapDragDistance = 0;
  36799. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  36800. var tmpSnapEvent = { snapDistance: 0 };
  36801. _this.dragBehavior.onDragObservable.add(function (event) {
  36802. if (_this.attachedMesh) {
  36803. // Snapping logic
  36804. var snapped = false;
  36805. var dragSteps = 0;
  36806. if (_this.uniformScaling) {
  36807. _this.attachedMesh.scaling.normalizeToRef(tmpVector);
  36808. if (tmpVector.y < 0) {
  36809. tmpVector.scaleInPlace(-1);
  36810. }
  36811. }
  36812. else {
  36813. tmpVector.copyFrom(dragAxis);
  36814. }
  36815. if (_this.snapDistance == 0) {
  36816. tmpVector.scaleToRef(event.dragDistance, tmpVector);
  36817. }
  36818. else {
  36819. currentSnapDragDistance += event.dragDistance;
  36820. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  36821. dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  36822. if (currentSnapDragDistance < 0) {
  36823. dragSteps *= -1;
  36824. }
  36825. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  36826. tmpVector.scaleToRef(_this.snapDistance * dragSteps, tmpVector);
  36827. snapped = true;
  36828. }
  36829. else {
  36830. tmpVector.scaleInPlace(0);
  36831. }
  36832. }
  36833. _this.attachedMesh.scaling.addInPlace(tmpVector);
  36834. if (snapped) {
  36835. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  36836. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  36837. }
  36838. }
  36839. });
  36840. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  36841. if (_this._customMeshSet) {
  36842. return;
  36843. }
  36844. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  36845. var material = isHovered ? hoverMaterial : _this._coloredMaterial;
  36846. _this._rootMesh.getChildMeshes().forEach(function (m) {
  36847. m.material = material;
  36848. if (m.color) {
  36849. m.color = material.emissiveColor;
  36850. }
  36851. });
  36852. });
  36853. return _this;
  36854. }
  36855. AxisScaleGizmo.prototype._attachedMeshChanged = function (value) {
  36856. if (this.dragBehavior) {
  36857. this.dragBehavior.enabled = value ? true : false;
  36858. }
  36859. };
  36860. /**
  36861. * Disposes of the gizmo
  36862. */
  36863. AxisScaleGizmo.prototype.dispose = function () {
  36864. this.onSnapObservable.clear();
  36865. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  36866. this.dragBehavior.detach();
  36867. _super.prototype.dispose.call(this);
  36868. };
  36869. /**
  36870. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  36871. * @param mesh The mesh to replace the default mesh of the gizmo
  36872. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  36873. */
  36874. AxisScaleGizmo.prototype.setCustomMesh = function (mesh, useGizmoMaterial) {
  36875. var _this = this;
  36876. if (useGizmoMaterial === void 0) { useGizmoMaterial = false; }
  36877. _super.prototype.setCustomMesh.call(this, mesh);
  36878. if (useGizmoMaterial) {
  36879. this._rootMesh.getChildMeshes().forEach(function (m) {
  36880. m.material = _this._coloredMaterial;
  36881. if (m.color) {
  36882. m.color = _this._coloredMaterial.emissiveColor;
  36883. }
  36884. });
  36885. this._customMeshSet = false;
  36886. }
  36887. };
  36888. return AxisScaleGizmo;
  36889. }(_gizmo__WEBPACK_IMPORTED_MODULE_7__["Gizmo"]));
  36890. /***/ }),
  36891. /***/ "./Gizmos/boundingBoxGizmo.ts":
  36892. /*!************************************!*\
  36893. !*** ./Gizmos/boundingBoxGizmo.ts ***!
  36894. \************************************/
  36895. /*! exports provided: BoundingBoxGizmo */
  36896. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36897. "use strict";
  36898. __webpack_require__.r(__webpack_exports__);
  36899. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return BoundingBoxGizmo; });
  36900. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36901. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36902. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  36903. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  36904. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  36905. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  36906. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  36907. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  36908. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  36909. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  36910. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  36911. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Misc/pivotTools */ "./Misc/pivotTools.ts");
  36912. /**
  36913. * Bounding box gizmo
  36914. */
  36915. var BoundingBoxGizmo = /** @class */ (function (_super) {
  36916. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoundingBoxGizmo, _super);
  36917. /**
  36918. * Creates an BoundingBoxGizmo
  36919. * @param gizmoLayer The utility layer the gizmo will be added to
  36920. * @param color The color of the gizmo
  36921. */
  36922. function BoundingBoxGizmo(color, gizmoLayer) {
  36923. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Gray(); }
  36924. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"].DefaultKeepDepthUtilityLayer; }
  36925. var _this = _super.call(this, gizmoLayer) || this;
  36926. _this._boundingDimensions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 1);
  36927. _this._renderObserver = null;
  36928. _this._pointerObserver = null;
  36929. _this._scaleDragSpeed = 0.2;
  36930. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  36931. _this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  36932. _this._tmpRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  36933. /**
  36934. * 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)
  36935. */
  36936. _this.ignoreChildren = false;
  36937. /**
  36938. * 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)
  36939. */
  36940. _this.includeChildPredicate = null;
  36941. /**
  36942. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  36943. */
  36944. _this.rotationSphereSize = 0.1;
  36945. /**
  36946. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  36947. */
  36948. _this.scaleBoxSize = 0.1;
  36949. /**
  36950. * 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)
  36951. */
  36952. _this.fixedDragMeshScreenSize = false;
  36953. /**
  36954. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  36955. */
  36956. _this.fixedDragMeshScreenSizeDistanceFactor = 10;
  36957. /**
  36958. * Fired when a rotation sphere or scale box is dragged
  36959. */
  36960. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36961. /**
  36962. * Fired when a scale box is dragged
  36963. */
  36964. _this.onScaleBoxDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36965. /**
  36966. * Fired when a scale box drag is ended
  36967. */
  36968. _this.onScaleBoxDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36969. /**
  36970. * Fired when a rotation sphere is dragged
  36971. */
  36972. _this.onRotationSphereDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36973. /**
  36974. * Fired when a rotation sphere drag is ended
  36975. */
  36976. _this.onRotationSphereDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36977. /**
  36978. * 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)
  36979. */
  36980. _this.scalePivot = null;
  36981. _this._existingMeshScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  36982. // Dragging
  36983. _this._dragMesh = null;
  36984. _this.pointerDragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]();
  36985. // Do not update the gizmo's scale so it has a fixed size to the object its attached to
  36986. _this._updateScale = false;
  36987. _this._anchorMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("anchor", gizmoLayer.utilityLayerScene);
  36988. // Create Materials
  36989. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_10__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  36990. coloredMaterial.disableLighting = true;
  36991. coloredMaterial.emissiveColor = color;
  36992. var hoverColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_10__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  36993. hoverColoredMaterial.disableLighting = true;
  36994. hoverColoredMaterial.emissiveColor = color.clone().add(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.3, 0.3, 0.3));
  36995. // Build bounding box out of lines
  36996. _this._lineBoundingBox = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  36997. _this._lineBoundingBox.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  36998. var lines = [];
  36999. 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));
  37000. 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));
  37001. 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));
  37002. 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));
  37003. 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));
  37004. 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));
  37005. 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));
  37006. 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));
  37007. 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));
  37008. 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));
  37009. 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));
  37010. 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));
  37011. lines.forEach(function (l) {
  37012. l.color = color;
  37013. l.position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-_this._boundingDimensions.x / 2, -_this._boundingDimensions.y / 2, -_this._boundingDimensions.z / 2));
  37014. l.isPickable = false;
  37015. _this._lineBoundingBox.addChild(l);
  37016. });
  37017. _this._rootMesh.addChild(_this._lineBoundingBox);
  37018. // Create rotation spheres
  37019. _this._rotateSpheresParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37020. _this._rotateSpheresParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37021. var _loop_1 = function (i_1) {
  37022. var sphere = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].CreateSphere("", { diameter: 1 }, gizmoLayer.utilityLayerScene);
  37023. sphere.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37024. sphere.material = coloredMaterial;
  37025. // Drag behavior
  37026. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]({});
  37027. _dragBehavior.moveAttached = false;
  37028. _dragBehavior.updateDragPlane = false;
  37029. sphere.addBehavior(_dragBehavior);
  37030. var startingTurnDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  37031. var totalTurnAmountOfDrag = 0;
  37032. _dragBehavior.onDragStartObservable.add(function () {
  37033. startingTurnDirection.copyFrom(sphere.forward);
  37034. totalTurnAmountOfDrag = 0;
  37035. });
  37036. _dragBehavior.onDragObservable.add(function (event) {
  37037. _this.onRotationSphereDragObservable.notifyObservers({});
  37038. if (_this.attachedMesh) {
  37039. var originalParent = _this.attachedMesh.parent;
  37040. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  37041. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  37042. return;
  37043. }
  37044. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  37045. var worldDragDirection = startingTurnDirection;
  37046. // Project the world right on to the drag plane
  37047. var toSub = event.dragPlaneNormal.scale(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(event.dragPlaneNormal, worldDragDirection));
  37048. var dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();
  37049. // project drag delta on to the resulting drag axis and rotate based on that
  37050. var projectDist = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());
  37051. // Make rotation relative to size of mesh.
  37052. projectDist = (projectDist / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  37053. // Rotate based on axis
  37054. if (!_this.attachedMesh.rotationQuaternion) {
  37055. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  37056. }
  37057. if (!_this._anchorMesh.rotationQuaternion) {
  37058. _this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this._anchorMesh.rotation.y, _this._anchorMesh.rotation.x, _this._anchorMesh.rotation.z);
  37059. }
  37060. // Do not allow the object to turn more than a full circle
  37061. totalTurnAmountOfDrag += projectDist;
  37062. if (Math.abs(totalTurnAmountOfDrag) <= 2 * Math.PI) {
  37063. if (i_1 >= 8) {
  37064. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, 0, projectDist, _this._tmpQuaternion);
  37065. }
  37066. else if (i_1 >= 4) {
  37067. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(projectDist, 0, 0, _this._tmpQuaternion);
  37068. }
  37069. else {
  37070. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, projectDist, 0, _this._tmpQuaternion);
  37071. }
  37072. // Rotate around center of bounding box
  37073. _this._anchorMesh.addChild(_this.attachedMesh);
  37074. _this._anchorMesh.rotationQuaternion.multiplyToRef(_this._tmpQuaternion, _this._anchorMesh.rotationQuaternion);
  37075. _this._anchorMesh.removeChild(_this.attachedMesh);
  37076. _this.attachedMesh.setParent(originalParent);
  37077. }
  37078. _this.updateBoundingBox();
  37079. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  37080. }
  37081. _this._updateDummy();
  37082. });
  37083. // Selection/deselection
  37084. _dragBehavior.onDragStartObservable.add(function () {
  37085. _this.onDragStartObservable.notifyObservers({});
  37086. _this._selectNode(sphere);
  37087. });
  37088. _dragBehavior.onDragEndObservable.add(function () {
  37089. _this.onRotationSphereDragEndObservable.notifyObservers({});
  37090. _this._selectNode(null);
  37091. _this._updateDummy();
  37092. });
  37093. this_1._rotateSpheresParent.addChild(sphere);
  37094. };
  37095. var this_1 = this, _dragBehavior;
  37096. for (var i_1 = 0; i_1 < 12; i_1++) {
  37097. _loop_1(i_1);
  37098. }
  37099. _this._rootMesh.addChild(_this._rotateSpheresParent);
  37100. // Create scale cubes
  37101. _this._scaleBoxesParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37102. _this._scaleBoxesParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37103. for (var i = 0; i < 2; i++) {
  37104. for (var j = 0; j < 2; j++) {
  37105. var _loop_2 = function () {
  37106. var box = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].CreateBox("", { size: 1 }, gizmoLayer.utilityLayerScene);
  37107. box.material = coloredMaterial;
  37108. // Dragging logic
  37109. var dragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](i == 0 ? -1 : 1, j == 0 ? -1 : 1, k == 0 ? -1 : 1);
  37110. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37111. _dragBehavior.moveAttached = false;
  37112. box.addBehavior(_dragBehavior);
  37113. _dragBehavior.onDragObservable.add(function (event) {
  37114. _this.onScaleBoxDragObservable.notifyObservers({});
  37115. if (_this.attachedMesh) {
  37116. var originalParent = _this.attachedMesh.parent;
  37117. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  37118. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  37119. return;
  37120. }
  37121. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  37122. var relativeDragDistance = (event.dragDistance / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  37123. var deltaScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](relativeDragDistance, relativeDragDistance, relativeDragDistance);
  37124. deltaScale.scaleInPlace(_this._scaleDragSpeed);
  37125. _this.updateBoundingBox();
  37126. if (_this.scalePivot) {
  37127. _this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(_this._tmpRotationMatrix);
  37128. // Move anchor to desired pivot point (Bottom left corner + dimension/2)
  37129. _this._boundingDimensions.scaleToRef(0.5, _this._tmpVector);
  37130. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  37131. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  37132. _this._boundingDimensions.multiplyToRef(_this.scalePivot, _this._tmpVector);
  37133. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  37134. _this._anchorMesh.position.addInPlace(_this._tmpVector);
  37135. }
  37136. else {
  37137. // Scale from the position of the opposite corner
  37138. box.absolutePosition.subtractToRef(_this._anchorMesh.position, _this._tmpVector);
  37139. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  37140. }
  37141. _this._anchorMesh.addChild(_this.attachedMesh);
  37142. _this._anchorMesh.scaling.addInPlace(deltaScale);
  37143. if (_this._anchorMesh.scaling.x < 0 || _this._anchorMesh.scaling.y < 0 || _this._anchorMesh.scaling.z < 0) {
  37144. _this._anchorMesh.scaling.subtractInPlace(deltaScale);
  37145. }
  37146. _this._anchorMesh.removeChild(_this.attachedMesh);
  37147. _this.attachedMesh.setParent(originalParent);
  37148. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  37149. }
  37150. _this._updateDummy();
  37151. });
  37152. // Selection/deselection
  37153. _dragBehavior.onDragStartObservable.add(function () {
  37154. _this.onDragStartObservable.notifyObservers({});
  37155. _this._selectNode(box);
  37156. });
  37157. _dragBehavior.onDragEndObservable.add(function () {
  37158. _this.onScaleBoxDragEndObservable.notifyObservers({});
  37159. _this._selectNode(null);
  37160. _this._updateDummy();
  37161. });
  37162. this_2._scaleBoxesParent.addChild(box);
  37163. };
  37164. var this_2 = this, _dragBehavior;
  37165. for (var k = 0; k < 2; k++) {
  37166. _loop_2();
  37167. }
  37168. }
  37169. }
  37170. _this._rootMesh.addChild(_this._scaleBoxesParent);
  37171. // Hover color change
  37172. var pointerIds = new Array();
  37173. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37174. if (!pointerIds[pointerInfo.event.pointerId]) {
  37175. _this._rotateSpheresParent.getChildMeshes().concat(_this._scaleBoxesParent.getChildMeshes()).forEach(function (mesh) {
  37176. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {
  37177. pointerIds[pointerInfo.event.pointerId] = mesh;
  37178. mesh.material = hoverColoredMaterial;
  37179. }
  37180. });
  37181. }
  37182. else {
  37183. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[pointerInfo.event.pointerId]) {
  37184. pointerIds[pointerInfo.event.pointerId].material = coloredMaterial;
  37185. delete pointerIds[pointerInfo.event.pointerId];
  37186. }
  37187. }
  37188. });
  37189. // Update bounding box positions
  37190. _this._renderObserver = _this.gizmoLayer.originalScene.onBeforeRenderObservable.add(function () {
  37191. // Only update the bouding box if scaling has changed
  37192. if (_this.attachedMesh && !_this._existingMeshScale.equals(_this.attachedMesh.scaling)) {
  37193. _this.updateBoundingBox();
  37194. }
  37195. else if (_this.fixedDragMeshScreenSize) {
  37196. _this._updateRotationSpheres();
  37197. _this._updateScaleBoxes();
  37198. }
  37199. // If dragg mesh is enabled and dragging, update the attached mesh pose to match the drag mesh
  37200. if (_this._dragMesh && _this.attachedMesh && _this.pointerDragBehavior.dragging) {
  37201. _this._lineBoundingBox.position.rotateByQuaternionToRef(_this._rootMesh.rotationQuaternion, _this._tmpVector);
  37202. _this.attachedMesh.setAbsolutePosition(_this._dragMesh.position.add(_this._tmpVector.scale(-1)));
  37203. }
  37204. });
  37205. _this.updateBoundingBox();
  37206. return _this;
  37207. }
  37208. BoundingBoxGizmo.prototype._attachedMeshChanged = function (value) {
  37209. var _this = this;
  37210. if (value) {
  37211. // Reset anchor mesh to match attached mesh's scale
  37212. // This is needed to avoid invalid box/sphere position on first drag
  37213. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RemoveAndStorePivotPoint(value);
  37214. var originalParent = value.parent;
  37215. this._anchorMesh.addChild(value);
  37216. this._anchorMesh.removeChild(value);
  37217. value.setParent(originalParent);
  37218. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RestorePivotPoint(value);
  37219. this.updateBoundingBox();
  37220. value.getChildMeshes(false).forEach(function (m) {
  37221. m.markAsDirty("scaling");
  37222. });
  37223. this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function () {
  37224. _this._updateDummy();
  37225. });
  37226. }
  37227. };
  37228. BoundingBoxGizmo.prototype._selectNode = function (selectedMesh) {
  37229. this._rotateSpheresParent.getChildMeshes()
  37230. .concat(this._scaleBoxesParent.getChildMeshes()).forEach(function (m) {
  37231. m.isVisible = (!selectedMesh || m == selectedMesh);
  37232. });
  37233. };
  37234. /**
  37235. * Updates the bounding box information for the Gizmo
  37236. */
  37237. BoundingBoxGizmo.prototype.updateBoundingBox = function () {
  37238. if (this.attachedMesh) {
  37239. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RemoveAndStorePivotPoint(this.attachedMesh);
  37240. var originalParent = this.attachedMesh.parent;
  37241. this.attachedMesh.setParent(null);
  37242. this._update();
  37243. // Rotate based on axis
  37244. if (!this.attachedMesh.rotationQuaternion) {
  37245. this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
  37246. }
  37247. if (!this._anchorMesh.rotationQuaternion) {
  37248. this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);
  37249. }
  37250. this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  37251. // Store original position and reset mesh to origin before computing the bounding box
  37252. this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  37253. this._tmpVector.copyFrom(this.attachedMesh.position);
  37254. this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1);
  37255. this.attachedMesh.position.set(0, 0, 0);
  37256. // Update bounding dimensions/positions
  37257. var boundingMinMax = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
  37258. boundingMinMax.max.subtractToRef(boundingMinMax.min, this._boundingDimensions);
  37259. // Update gizmo to match bounding box scaling and rotation
  37260. this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);
  37261. 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);
  37262. this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position);
  37263. this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position);
  37264. this._lineBoundingBox.computeWorldMatrix();
  37265. this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition);
  37266. // restore position/rotation values
  37267. this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);
  37268. this.attachedMesh.position.copyFrom(this._tmpVector);
  37269. this.attachedMesh.setParent(originalParent);
  37270. }
  37271. this._updateRotationSpheres();
  37272. this._updateScaleBoxes();
  37273. if (this.attachedMesh) {
  37274. this._existingMeshScale.copyFrom(this.attachedMesh.scaling);
  37275. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RestorePivotPoint(this.attachedMesh);
  37276. }
  37277. };
  37278. BoundingBoxGizmo.prototype._updateRotationSpheres = function () {
  37279. var rotateSpheres = this._rotateSpheresParent.getChildMeshes();
  37280. for (var i = 0; i < 3; i++) {
  37281. for (var j = 0; j < 2; j++) {
  37282. for (var k = 0; k < 2; k++) {
  37283. var index = ((i * 4) + (j * 2)) + k;
  37284. if (i == 0) {
  37285. rotateSpheres[index].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  37286. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37287. 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));
  37288. }
  37289. if (i == 1) {
  37290. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y / 2, this._boundingDimensions.z * k);
  37291. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37292. 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));
  37293. }
  37294. if (i == 2) {
  37295. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y * k, this._boundingDimensions.z / 2);
  37296. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37297. 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));
  37298. }
  37299. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  37300. rotateSpheres[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  37301. var distanceFromCamera = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  37302. rotateSpheres[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  37303. }
  37304. else {
  37305. rotateSpheres[index].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);
  37306. }
  37307. }
  37308. }
  37309. }
  37310. };
  37311. BoundingBoxGizmo.prototype._updateScaleBoxes = function () {
  37312. var scaleBoxes = this._scaleBoxesParent.getChildMeshes();
  37313. for (var i = 0; i < 2; i++) {
  37314. for (var j = 0; j < 2; j++) {
  37315. for (var k = 0; k < 2; k++) {
  37316. var index = ((i * 4) + (j * 2)) + k;
  37317. if (scaleBoxes[index]) {
  37318. scaleBoxes[index].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  37319. scaleBoxes[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37320. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  37321. scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  37322. var distanceFromCamera = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  37323. scaleBoxes[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  37324. }
  37325. else {
  37326. scaleBoxes[index].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
  37327. }
  37328. }
  37329. }
  37330. }
  37331. }
  37332. };
  37333. /**
  37334. * Enables rotation on the specified axis and disables rotation on the others
  37335. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  37336. */
  37337. BoundingBoxGizmo.prototype.setEnabledRotationAxis = function (axis) {
  37338. this._rotateSpheresParent.getChildMeshes().forEach(function (m, i) {
  37339. if (i < 4) {
  37340. m.setEnabled(axis.indexOf("x") != -1);
  37341. }
  37342. else if (i < 8) {
  37343. m.setEnabled(axis.indexOf("y") != -1);
  37344. }
  37345. else {
  37346. m.setEnabled(axis.indexOf("z") != -1);
  37347. }
  37348. });
  37349. };
  37350. /**
  37351. * Enables/disables scaling
  37352. * @param enable if scaling should be enabled
  37353. */
  37354. BoundingBoxGizmo.prototype.setEnabledScaling = function (enable) {
  37355. this._scaleBoxesParent.getChildMeshes().forEach(function (m, i) {
  37356. m.setEnabled(enable);
  37357. });
  37358. };
  37359. BoundingBoxGizmo.prototype._updateDummy = function () {
  37360. if (this._dragMesh) {
  37361. this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());
  37362. this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling);
  37363. this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion);
  37364. }
  37365. };
  37366. /**
  37367. * Enables a pointer drag behavior on the bounding box of the gizmo
  37368. */
  37369. BoundingBoxGizmo.prototype.enableDragBehavior = function () {
  37370. this._dragMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].CreateBox("dummy", 1, this.gizmoLayer.utilityLayerScene);
  37371. this._dragMesh.visibility = 0;
  37372. this._dragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37373. this.pointerDragBehavior.useObjectOrienationForDragging = false;
  37374. this._dragMesh.addBehavior(this.pointerDragBehavior);
  37375. };
  37376. /**
  37377. * Disposes of the gizmo
  37378. */
  37379. BoundingBoxGizmo.prototype.dispose = function () {
  37380. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  37381. this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver);
  37382. this._lineBoundingBox.dispose();
  37383. this._rotateSpheresParent.dispose();
  37384. this._scaleBoxesParent.dispose();
  37385. if (this._dragMesh) {
  37386. this._dragMesh.dispose();
  37387. }
  37388. _super.prototype.dispose.call(this);
  37389. };
  37390. /**
  37391. * 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)
  37392. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  37393. * @returns the bounding box mesh with the passed in mesh as a child
  37394. */
  37395. BoundingBoxGizmo.MakeNotPickableAndWrapInBoundingBox = function (mesh) {
  37396. var makeNotPickable = function (root) {
  37397. root.isPickable = false;
  37398. root.getChildMeshes().forEach(function (c) {
  37399. makeNotPickable(c);
  37400. });
  37401. };
  37402. makeNotPickable(mesh);
  37403. // Reset position to get boudning box from origin with no rotation
  37404. if (!mesh.rotationQuaternion) {
  37405. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);
  37406. }
  37407. var oldPos = mesh.position.clone();
  37408. var oldRot = mesh.rotationQuaternion.clone();
  37409. mesh.rotationQuaternion.set(0, 0, 0, 1);
  37410. mesh.position.set(0, 0, 0);
  37411. // Update bounding dimensions/positions
  37412. var box = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].CreateBox("box", { size: 1 }, mesh.getScene());
  37413. var boundingMinMax = mesh.getHierarchyBoundingVectors();
  37414. boundingMinMax.max.subtractToRef(boundingMinMax.min, box.scaling);
  37415. // Adjust scale to avoid undefined behavior when adding child
  37416. if (box.scaling.y === 0) {
  37417. box.scaling.y = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  37418. }
  37419. if (box.scaling.x === 0) {
  37420. box.scaling.x = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  37421. }
  37422. if (box.scaling.z === 0) {
  37423. box.scaling.z = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  37424. }
  37425. box.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);
  37426. // Restore original positions
  37427. mesh.addChild(box);
  37428. mesh.rotationQuaternion.copyFrom(oldRot);
  37429. mesh.position.copyFrom(oldPos);
  37430. // Reverse parenting
  37431. mesh.removeChild(box);
  37432. box.addChild(mesh);
  37433. box.visibility = 0;
  37434. return box;
  37435. };
  37436. /**
  37437. * CustomMeshes are not supported by this gizmo
  37438. * @param mesh The mesh to replace the default mesh of the gizmo
  37439. */
  37440. BoundingBoxGizmo.prototype.setCustomMesh = function (mesh) {
  37441. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("Custom meshes are not supported on this gizmo");
  37442. };
  37443. return BoundingBoxGizmo;
  37444. }(_gizmo__WEBPACK_IMPORTED_MODULE_8__["Gizmo"]));
  37445. /***/ }),
  37446. /***/ "./Gizmos/gizmo.ts":
  37447. /*!*************************!*\
  37448. !*** ./Gizmos/gizmo.ts ***!
  37449. \*************************/
  37450. /*! exports provided: Gizmo */
  37451. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37452. "use strict";
  37453. __webpack_require__.r(__webpack_exports__);
  37454. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return Gizmo; });
  37455. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37456. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  37457. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37458. /**
  37459. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  37460. */
  37461. var Gizmo = /** @class */ (function () {
  37462. /**
  37463. * Creates a gizmo
  37464. * @param gizmoLayer The utility layer the gizmo will be added to
  37465. */
  37466. function Gizmo(
  37467. /** The utility layer the gizmo will be added to */
  37468. gizmoLayer) {
  37469. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37470. var _this = this;
  37471. this.gizmoLayer = gizmoLayer;
  37472. /**
  37473. * Ratio for the scale of the gizmo (Default: 1)
  37474. */
  37475. this.scaleRatio = 1;
  37476. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  37477. /**
  37478. * If a custom mesh has been set (Default: false)
  37479. */
  37480. this._customMeshSet = false;
  37481. /**
  37482. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  37483. */
  37484. this.updateGizmoRotationToMatchAttachedMesh = true;
  37485. /**
  37486. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  37487. */
  37488. this.updateGizmoPositionToMatchAttachedMesh = true;
  37489. /**
  37490. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  37491. */
  37492. this._updateScale = true;
  37493. this._interactionsEnabled = true;
  37494. this._tempVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  37495. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]("gizmoRootNode", gizmoLayer.utilityLayerScene);
  37496. this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function () {
  37497. _this._update();
  37498. });
  37499. this.attachedMesh = null;
  37500. }
  37501. Object.defineProperty(Gizmo.prototype, "attachedMesh", {
  37502. /**
  37503. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  37504. * * When set, interactions will be enabled
  37505. */
  37506. get: function () {
  37507. return this._attachedMesh;
  37508. },
  37509. set: function (value) {
  37510. this._attachedMesh = value;
  37511. this._rootMesh.setEnabled(value ? true : false);
  37512. this._attachedMeshChanged(value);
  37513. },
  37514. enumerable: true,
  37515. configurable: true
  37516. });
  37517. /**
  37518. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  37519. * @param mesh The mesh to replace the default mesh of the gizmo
  37520. */
  37521. Gizmo.prototype.setCustomMesh = function (mesh) {
  37522. if (mesh.getScene() != this.gizmoLayer.utilityLayerScene) {
  37523. throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
  37524. }
  37525. this._rootMesh.getChildMeshes().forEach(function (c) {
  37526. c.dispose();
  37527. });
  37528. mesh.parent = this._rootMesh;
  37529. this._customMeshSet = true;
  37530. };
  37531. Gizmo.prototype._attachedMeshChanged = function (value) {
  37532. };
  37533. /**
  37534. * @hidden
  37535. * Updates the gizmo to match the attached mesh's position/rotation
  37536. */
  37537. Gizmo.prototype._update = function () {
  37538. if (this.attachedMesh) {
  37539. if (this.updateGizmoRotationToMatchAttachedMesh) {
  37540. if (!this._rootMesh.rotationQuaternion) {
  37541. this._rootMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(this._rootMesh.rotation.y, this._rootMesh.rotation.x, this._rootMesh.rotation.z);
  37542. }
  37543. // Remove scaling before getting rotation matrix to get rotation matrix unmodified by scale
  37544. this._tempVector.copyFrom(this.attachedMesh.scaling);
  37545. if (this.attachedMesh.scaling.x < 0) {
  37546. this.attachedMesh.scaling.x *= -1;
  37547. }
  37548. if (this.attachedMesh.scaling.y < 0) {
  37549. this.attachedMesh.scaling.y *= -1;
  37550. }
  37551. if (this.attachedMesh.scaling.z < 0) {
  37552. this.attachedMesh.scaling.z *= -1;
  37553. }
  37554. this.attachedMesh.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix);
  37555. this.attachedMesh.scaling.copyFrom(this._tempVector);
  37556. this.attachedMesh.computeWorldMatrix();
  37557. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._tmpMatrix, this._rootMesh.rotationQuaternion);
  37558. }
  37559. else if (this._rootMesh.rotationQuaternion) {
  37560. this._rootMesh.rotationQuaternion.set(0, 0, 0, 1);
  37561. }
  37562. if (this.updateGizmoPositionToMatchAttachedMesh) {
  37563. this._rootMesh.position.copyFrom(this.attachedMesh.absolutePosition);
  37564. }
  37565. if (this._updateScale && this.gizmoLayer.utilityLayerScene.activeCamera && this.attachedMesh) {
  37566. var cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.globalPosition;
  37567. if (this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition) {
  37568. cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition;
  37569. }
  37570. this._rootMesh.position.subtractToRef(cameraPosition, this._tempVector);
  37571. var dist = this._tempVector.length() * this.scaleRatio;
  37572. this._rootMesh.scaling.set(dist, dist, dist);
  37573. }
  37574. }
  37575. };
  37576. /**
  37577. * Disposes of the gizmo
  37578. */
  37579. Gizmo.prototype.dispose = function () {
  37580. this._rootMesh.dispose();
  37581. if (this._beforeRenderObserver) {
  37582. this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  37583. }
  37584. };
  37585. return Gizmo;
  37586. }());
  37587. /***/ }),
  37588. /***/ "./Gizmos/gizmoManager.ts":
  37589. /*!********************************!*\
  37590. !*** ./Gizmos/gizmoManager.ts ***!
  37591. \********************************/
  37592. /*! exports provided: GizmoManager */
  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__, "GizmoManager", function() { return GizmoManager; });
  37597. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37598. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  37599. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  37600. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37601. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37602. /* harmony import */ var _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  37603. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  37604. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  37605. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  37606. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  37607. /**
  37608. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  37609. */
  37610. var GizmoManager = /** @class */ (function () {
  37611. /**
  37612. * Instatiates a gizmo manager
  37613. * @param scene the scene to overlay the gizmos on top of
  37614. */
  37615. function GizmoManager(scene) {
  37616. var _this = this;
  37617. this.scene = scene;
  37618. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  37619. this.clearGizmoOnEmptyPointerEvent = false;
  37620. /** Fires an event when the manager is attached to a mesh */
  37621. this.onAttachedToMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  37622. this._gizmosEnabled = { positionGizmo: false, rotationGizmo: false, scaleGizmo: false, boundingBoxGizmo: false };
  37623. this._pointerObserver = null;
  37624. this._attachedMesh = null;
  37625. this._boundingBoxColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromHexString("#0984e3");
  37626. /**
  37627. * When bounding box gizmo is enabled, this can be used to track drag/end events
  37628. */
  37629. this.boundingBoxDragBehavior = new _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]();
  37630. /**
  37631. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  37632. */
  37633. this.attachableMeshes = null;
  37634. /**
  37635. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  37636. */
  37637. this.usePointerToAttachGizmos = true;
  37638. this._defaultKeepDepthUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  37639. this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  37640. this._defaultUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  37641. this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
  37642. // Instatiate/dispose gizmos based on pointer actions
  37643. this._pointerObserver = scene.onPointerObservable.add(function (pointerInfo) {
  37644. if (!_this.usePointerToAttachGizmos) {
  37645. return;
  37646. }
  37647. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  37648. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh) {
  37649. var node = pointerInfo.pickInfo.pickedMesh;
  37650. if (_this.attachableMeshes == null) {
  37651. // Attach to the most parent node
  37652. while (node && node.parent != null) {
  37653. node = node.parent;
  37654. }
  37655. }
  37656. else {
  37657. // Attach to the parent node that is an attachableMesh
  37658. var found = false;
  37659. _this.attachableMeshes.forEach(function (mesh) {
  37660. if (node && (node == mesh || node.isDescendantOf(mesh))) {
  37661. node = mesh;
  37662. found = true;
  37663. }
  37664. });
  37665. if (!found) {
  37666. node = null;
  37667. }
  37668. }
  37669. if (node instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]) {
  37670. if (_this._attachedMesh != node) {
  37671. _this.attachToMesh(node);
  37672. }
  37673. }
  37674. else {
  37675. if (_this.clearGizmoOnEmptyPointerEvent) {
  37676. _this.attachToMesh(null);
  37677. }
  37678. }
  37679. }
  37680. else {
  37681. if (_this.clearGizmoOnEmptyPointerEvent) {
  37682. _this.attachToMesh(null);
  37683. }
  37684. }
  37685. }
  37686. });
  37687. }
  37688. /**
  37689. * Attaches a set of gizmos to the specified mesh
  37690. * @param mesh The mesh the gizmo's should be attached to
  37691. */
  37692. GizmoManager.prototype.attachToMesh = function (mesh) {
  37693. if (this._attachedMesh) {
  37694. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  37695. }
  37696. this._attachedMesh = mesh;
  37697. for (var key in this.gizmos) {
  37698. var gizmo = (this.gizmos[key]);
  37699. if (gizmo && this._gizmosEnabled[key]) {
  37700. gizmo.attachedMesh = mesh;
  37701. }
  37702. }
  37703. if (this.boundingBoxGizmoEnabled && this._attachedMesh) {
  37704. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  37705. }
  37706. this.onAttachedToMeshObservable.notifyObservers(mesh);
  37707. };
  37708. Object.defineProperty(GizmoManager.prototype, "positionGizmoEnabled", {
  37709. get: function () {
  37710. return this._gizmosEnabled.positionGizmo;
  37711. },
  37712. /**
  37713. * If the position gizmo is enabled
  37714. */
  37715. set: function (value) {
  37716. if (value) {
  37717. if (!this.gizmos.positionGizmo) {
  37718. this.gizmos.positionGizmo = new _positionGizmo__WEBPACK_IMPORTED_MODULE_7__["PositionGizmo"](this._defaultUtilityLayer);
  37719. }
  37720. this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;
  37721. }
  37722. else if (this.gizmos.positionGizmo) {
  37723. this.gizmos.positionGizmo.attachedMesh = null;
  37724. }
  37725. this._gizmosEnabled.positionGizmo = value;
  37726. },
  37727. enumerable: true,
  37728. configurable: true
  37729. });
  37730. Object.defineProperty(GizmoManager.prototype, "rotationGizmoEnabled", {
  37731. get: function () {
  37732. return this._gizmosEnabled.rotationGizmo;
  37733. },
  37734. /**
  37735. * If the rotation gizmo is enabled
  37736. */
  37737. set: function (value) {
  37738. if (value) {
  37739. if (!this.gizmos.rotationGizmo) {
  37740. this.gizmos.rotationGizmo = new _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__["RotationGizmo"](this._defaultUtilityLayer);
  37741. }
  37742. this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;
  37743. }
  37744. else if (this.gizmos.rotationGizmo) {
  37745. this.gizmos.rotationGizmo.attachedMesh = null;
  37746. }
  37747. this._gizmosEnabled.rotationGizmo = value;
  37748. },
  37749. enumerable: true,
  37750. configurable: true
  37751. });
  37752. Object.defineProperty(GizmoManager.prototype, "scaleGizmoEnabled", {
  37753. get: function () {
  37754. return this._gizmosEnabled.scaleGizmo;
  37755. },
  37756. /**
  37757. * If the scale gizmo is enabled
  37758. */
  37759. set: function (value) {
  37760. if (value) {
  37761. this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"](this._defaultUtilityLayer);
  37762. this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;
  37763. }
  37764. else if (this.gizmos.scaleGizmo) {
  37765. this.gizmos.scaleGizmo.attachedMesh = null;
  37766. }
  37767. this._gizmosEnabled.scaleGizmo = value;
  37768. },
  37769. enumerable: true,
  37770. configurable: true
  37771. });
  37772. Object.defineProperty(GizmoManager.prototype, "boundingBoxGizmoEnabled", {
  37773. get: function () {
  37774. return this._gizmosEnabled.boundingBoxGizmo;
  37775. },
  37776. /**
  37777. * If the boundingBox gizmo is enabled
  37778. */
  37779. set: function (value) {
  37780. if (value) {
  37781. this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__["BoundingBoxGizmo"](this._boundingBoxColor, this._defaultKeepDepthUtilityLayer);
  37782. this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh;
  37783. if (this._attachedMesh) {
  37784. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  37785. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  37786. }
  37787. }
  37788. else if (this.gizmos.boundingBoxGizmo) {
  37789. this.gizmos.boundingBoxGizmo.attachedMesh = null;
  37790. }
  37791. this._gizmosEnabled.boundingBoxGizmo = value;
  37792. },
  37793. enumerable: true,
  37794. configurable: true
  37795. });
  37796. /**
  37797. * Disposes of the gizmo manager
  37798. */
  37799. GizmoManager.prototype.dispose = function () {
  37800. this.scene.onPointerObservable.remove(this._pointerObserver);
  37801. for (var key in this.gizmos) {
  37802. var gizmo = (this.gizmos[key]);
  37803. if (gizmo) {
  37804. gizmo.dispose();
  37805. }
  37806. }
  37807. this._defaultKeepDepthUtilityLayer.dispose();
  37808. this._defaultUtilityLayer.dispose();
  37809. this.boundingBoxDragBehavior.detach();
  37810. this.onAttachedToMeshObservable.clear();
  37811. };
  37812. return GizmoManager;
  37813. }());
  37814. /***/ }),
  37815. /***/ "./Gizmos/index.ts":
  37816. /*!*************************!*\
  37817. !*** ./Gizmos/index.ts ***!
  37818. \*************************/
  37819. /*! exports provided: AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo */
  37820. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37821. "use strict";
  37822. __webpack_require__.r(__webpack_exports__);
  37823. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  37824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  37825. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  37826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__["AxisScaleGizmo"]; });
  37827. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  37828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__["BoundingBoxGizmo"]; });
  37829. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _gizmo__WEBPACK_IMPORTED_MODULE_3__["Gizmo"]; });
  37831. /* harmony import */ var _gizmoManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmoManager */ "./Gizmos/gizmoManager.ts");
  37832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _gizmoManager__WEBPACK_IMPORTED_MODULE_4__["GizmoManager"]; });
  37833. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  37834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"]; });
  37835. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  37836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _positionGizmo__WEBPACK_IMPORTED_MODULE_6__["PositionGizmo"]; });
  37837. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  37838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__["RotationGizmo"]; });
  37839. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  37840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"]; });
  37841. /***/ }),
  37842. /***/ "./Gizmos/planeRotationGizmo.ts":
  37843. /*!**************************************!*\
  37844. !*** ./Gizmos/planeRotationGizmo.ts ***!
  37845. \**************************************/
  37846. /*! exports provided: PlaneRotationGizmo */
  37847. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37848. "use strict";
  37849. __webpack_require__.r(__webpack_exports__);
  37850. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return PlaneRotationGizmo; });
  37851. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37852. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37853. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37854. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  37855. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  37856. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37857. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37858. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37859. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37860. /**
  37861. * Single plane rotation gizmo
  37862. */
  37863. var PlaneRotationGizmo = /** @class */ (function (_super) {
  37864. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaneRotationGizmo, _super);
  37865. /**
  37866. * Creates a PlaneRotationGizmo
  37867. * @param gizmoLayer The utility layer the gizmo will be added to
  37868. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  37869. * @param color The color of the gizmo
  37870. * @param tessellation Amount of tessellation to be used when creating rotation circles
  37871. */
  37872. function PlaneRotationGizmo(planeNormal, color, gizmoLayer, tessellation) {
  37873. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  37874. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37875. if (tessellation === void 0) { tessellation = 32; }
  37876. var _this = _super.call(this, gizmoLayer) || this;
  37877. _this._pointerObserver = null;
  37878. /**
  37879. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  37880. */
  37881. _this.snapDistance = 0;
  37882. /**
  37883. * Event that fires each time the gizmo snaps to a new location.
  37884. * * snapDistance is the the change in distance
  37885. */
  37886. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37887. // Create Material
  37888. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37889. coloredMaterial.disableLighting = true;
  37890. coloredMaterial.emissiveColor = color;
  37891. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37892. hoverMaterial.disableLighting = true;
  37893. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  37894. // Build mesh on root node
  37895. var parentMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37896. // Create circle out of lines
  37897. var radius = 0.8;
  37898. var points = new Array();
  37899. for (var i = 0; i < tessellation; i++) {
  37900. var radian = (2 * Math.PI) * (i / (tessellation - 1));
  37901. points.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](radius * Math.sin(radian), 0, radius * Math.cos(radian)));
  37902. }
  37903. var rotationMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateLines("", points, gizmoLayer.utilityLayerScene);
  37904. rotationMesh.color = coloredMaterial.emissiveColor;
  37905. // Position arrow pointing in its drag axis
  37906. rotationMesh.scaling.scaleInPlace(0.26);
  37907. rotationMesh.material = coloredMaterial;
  37908. rotationMesh.rotation.x = Math.PI / 2;
  37909. parentMesh.addChild(rotationMesh);
  37910. parentMesh.lookAt(_this._rootMesh.position.add(planeNormal));
  37911. _this._rootMesh.addChild(parentMesh);
  37912. parentMesh.scaling.scaleInPlace(1 / 3);
  37913. // Add drag behavior to handle events when the gizmo is dragged
  37914. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragPlaneNormal: planeNormal });
  37915. _this.dragBehavior.moveAttached = false;
  37916. _this.dragBehavior.maxDragAngle = Math.PI * 9 / 20;
  37917. _this.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = true;
  37918. _this._rootMesh.addBehavior(_this.dragBehavior);
  37919. var lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37920. _this.dragBehavior.onDragStartObservable.add(function (e) {
  37921. if (_this.attachedMesh) {
  37922. lastDragPosition.copyFrom(e.dragPlanePoint);
  37923. }
  37924. });
  37925. var rotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  37926. var planeNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37927. var localPlaneNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37928. var tmpSnapEvent = { snapDistance: 0 };
  37929. var currentSnapDragDistance = 0;
  37930. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  37931. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37932. var amountToRotate = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  37933. _this.dragBehavior.onDragObservable.add(function (event) {
  37934. if (_this.attachedMesh) {
  37935. if (!_this.attachedMesh.rotationQuaternion) {
  37936. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  37937. }
  37938. // Calc angle over full 360 degree (https://stackoverflow.com/questions/43493711/the-angle-between-two-3d-vectors-with-a-result-range-0-360)
  37939. var newVector = event.dragPlanePoint.subtract(_this.attachedMesh.absolutePosition).normalize();
  37940. var originalVector = lastDragPosition.subtract(_this.attachedMesh.absolutePosition).normalize();
  37941. var cross = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(newVector, originalVector);
  37942. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(newVector, originalVector);
  37943. var angle = Math.atan2(cross.length(), dot);
  37944. planeNormalTowardsCamera.copyFrom(planeNormal);
  37945. localPlaneNormalTowardsCamera.copyFrom(planeNormal);
  37946. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  37947. _this.attachedMesh.rotationQuaternion.toRotationMatrix(rotationMatrix);
  37948. localPlaneNormalTowardsCamera = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(planeNormalTowardsCamera, rotationMatrix);
  37949. }
  37950. // Flip up vector depending on which side the camera is on
  37951. if (gizmoLayer.utilityLayerScene.activeCamera) {
  37952. var camVec = gizmoLayer.utilityLayerScene.activeCamera.position.subtract(_this.attachedMesh.position);
  37953. if (_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(camVec, localPlaneNormalTowardsCamera) > 0) {
  37954. planeNormalTowardsCamera.scaleInPlace(-1);
  37955. localPlaneNormalTowardsCamera.scaleInPlace(-1);
  37956. }
  37957. }
  37958. var halfCircleSide = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(localPlaneNormalTowardsCamera, cross) > 0.0;
  37959. if (halfCircleSide) {
  37960. angle = -angle;
  37961. }
  37962. // Snapping logic
  37963. var snapped = false;
  37964. if (_this.snapDistance != 0) {
  37965. currentSnapDragDistance += angle;
  37966. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  37967. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  37968. if (currentSnapDragDistance < 0) {
  37969. dragSteps *= -1;
  37970. }
  37971. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  37972. angle = _this.snapDistance * dragSteps;
  37973. snapped = true;
  37974. }
  37975. else {
  37976. angle = 0;
  37977. }
  37978. }
  37979. // If the mesh has a parent, convert needed world rotation to local rotation
  37980. tmpMatrix.reset();
  37981. if (_this.attachedMesh.parent) {
  37982. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  37983. tmpMatrix.getRotationMatrixToRef(tmpMatrix);
  37984. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(planeNormalTowardsCamera, tmpMatrix, planeNormalTowardsCamera);
  37985. }
  37986. // Convert angle and axis to quaternion (http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm)
  37987. var quaternionCoefficient = Math.sin(angle / 2);
  37988. amountToRotate.set(planeNormalTowardsCamera.x * quaternionCoefficient, planeNormalTowardsCamera.y * quaternionCoefficient, planeNormalTowardsCamera.z * quaternionCoefficient, Math.cos(angle / 2));
  37989. // 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
  37990. if (tmpMatrix.determinant() > 0) {
  37991. amountToRotate.toEulerAnglesToRef(tmpVector);
  37992. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(tmpVector.y, -tmpVector.x, -tmpVector.z, amountToRotate);
  37993. }
  37994. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  37995. // Rotate selected mesh quaternion over fixed axis
  37996. _this.attachedMesh.rotationQuaternion.multiplyToRef(amountToRotate, _this.attachedMesh.rotationQuaternion);
  37997. }
  37998. else {
  37999. // Rotate selected mesh quaternion over rotated axis
  38000. amountToRotate.multiplyToRef(_this.attachedMesh.rotationQuaternion, _this.attachedMesh.rotationQuaternion);
  38001. }
  38002. lastDragPosition.copyFrom(event.dragPlanePoint);
  38003. if (snapped) {
  38004. tmpSnapEvent.snapDistance = angle;
  38005. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  38006. }
  38007. }
  38008. });
  38009. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38010. if (_this._customMeshSet) {
  38011. return;
  38012. }
  38013. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  38014. var material = isHovered ? hoverMaterial : coloredMaterial;
  38015. _this._rootMesh.getChildMeshes().forEach(function (m) {
  38016. m.material = material;
  38017. if (m.color) {
  38018. m.color = material.emissiveColor;
  38019. }
  38020. });
  38021. });
  38022. return _this;
  38023. }
  38024. PlaneRotationGizmo.prototype._attachedMeshChanged = function (value) {
  38025. if (this.dragBehavior) {
  38026. this.dragBehavior.enabled = value ? true : false;
  38027. }
  38028. };
  38029. /**
  38030. * Disposes of the gizmo
  38031. */
  38032. PlaneRotationGizmo.prototype.dispose = function () {
  38033. this.onSnapObservable.clear();
  38034. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38035. this.dragBehavior.detach();
  38036. _super.prototype.dispose.call(this);
  38037. };
  38038. return PlaneRotationGizmo;
  38039. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  38040. /***/ }),
  38041. /***/ "./Gizmos/positionGizmo.ts":
  38042. /*!*********************************!*\
  38043. !*** ./Gizmos/positionGizmo.ts ***!
  38044. \*********************************/
  38045. /*! exports provided: PositionGizmo */
  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__, "PositionGizmo", function() { return PositionGizmo; });
  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 _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38055. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  38056. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38057. /**
  38058. * Gizmo that enables dragging a mesh along 3 axis
  38059. */
  38060. var PositionGizmo = /** @class */ (function (_super) {
  38061. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PositionGizmo, _super);
  38062. /**
  38063. * Creates a PositionGizmo
  38064. * @param gizmoLayer The utility layer the gizmo will be added to
  38065. */
  38066. function PositionGizmo(gizmoLayer) {
  38067. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38068. var _this = _super.call(this, gizmoLayer) || this;
  38069. /** Fires an event when any of it's sub gizmos are dragged */
  38070. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38071. /** Fires an event when any of it's sub gizmos are released from dragging */
  38072. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38073. _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);
  38074. _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);
  38075. _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);
  38076. // Relay drag events
  38077. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  38078. gizmo.dragBehavior.onDragStartObservable.add(function () {
  38079. _this.onDragStartObservable.notifyObservers({});
  38080. });
  38081. gizmo.dragBehavior.onDragEndObservable.add(function () {
  38082. _this.onDragEndObservable.notifyObservers({});
  38083. });
  38084. });
  38085. _this.attachedMesh = null;
  38086. return _this;
  38087. }
  38088. Object.defineProperty(PositionGizmo.prototype, "attachedMesh", {
  38089. set: function (mesh) {
  38090. if (this.xGizmo) {
  38091. this.xGizmo.attachedMesh = mesh;
  38092. this.yGizmo.attachedMesh = mesh;
  38093. this.zGizmo.attachedMesh = mesh;
  38094. }
  38095. },
  38096. enumerable: true,
  38097. configurable: true
  38098. });
  38099. Object.defineProperty(PositionGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  38100. get: function () {
  38101. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  38102. },
  38103. set: function (value) {
  38104. if (this.xGizmo) {
  38105. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38106. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38107. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38108. }
  38109. },
  38110. enumerable: true,
  38111. configurable: true
  38112. });
  38113. Object.defineProperty(PositionGizmo.prototype, "snapDistance", {
  38114. get: function () {
  38115. return this.xGizmo.snapDistance;
  38116. },
  38117. /**
  38118. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38119. */
  38120. set: function (value) {
  38121. if (this.xGizmo) {
  38122. this.xGizmo.snapDistance = value;
  38123. this.yGizmo.snapDistance = value;
  38124. this.zGizmo.snapDistance = value;
  38125. }
  38126. },
  38127. enumerable: true,
  38128. configurable: true
  38129. });
  38130. Object.defineProperty(PositionGizmo.prototype, "scaleRatio", {
  38131. get: function () {
  38132. return this.xGizmo.scaleRatio;
  38133. },
  38134. /**
  38135. * Ratio for the scale of the gizmo (Default: 1)
  38136. */
  38137. set: function (value) {
  38138. if (this.xGizmo) {
  38139. this.xGizmo.scaleRatio = value;
  38140. this.yGizmo.scaleRatio = value;
  38141. this.zGizmo.scaleRatio = value;
  38142. }
  38143. },
  38144. enumerable: true,
  38145. configurable: true
  38146. });
  38147. /**
  38148. * Disposes of the gizmo
  38149. */
  38150. PositionGizmo.prototype.dispose = function () {
  38151. this.xGizmo.dispose();
  38152. this.yGizmo.dispose();
  38153. this.zGizmo.dispose();
  38154. this.onDragStartObservable.clear();
  38155. this.onDragEndObservable.clear();
  38156. };
  38157. /**
  38158. * CustomMeshes are not supported by this gizmo
  38159. * @param mesh The mesh to replace the default mesh of the gizmo
  38160. */
  38161. PositionGizmo.prototype.setCustomMesh = function (mesh) {
  38162. _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)");
  38163. };
  38164. return PositionGizmo;
  38165. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  38166. /***/ }),
  38167. /***/ "./Gizmos/rotationGizmo.ts":
  38168. /*!*********************************!*\
  38169. !*** ./Gizmos/rotationGizmo.ts ***!
  38170. \*********************************/
  38171. /*! exports provided: RotationGizmo */
  38172. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38173. "use strict";
  38174. __webpack_require__.r(__webpack_exports__);
  38175. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return RotationGizmo; });
  38176. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38177. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38178. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38179. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38180. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38181. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  38182. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38183. /**
  38184. * Gizmo that enables rotating a mesh along 3 axis
  38185. */
  38186. var RotationGizmo = /** @class */ (function (_super) {
  38187. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RotationGizmo, _super);
  38188. /**
  38189. * Creates a RotationGizmo
  38190. * @param gizmoLayer The utility layer the gizmo will be added to
  38191. * @param tessellation Amount of tessellation to be used when creating rotation circles
  38192. */
  38193. function RotationGizmo(gizmoLayer, tessellation) {
  38194. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38195. if (tessellation === void 0) { tessellation = 32; }
  38196. var _this = _super.call(this, gizmoLayer) || this;
  38197. /** Fires an event when any of it's sub gizmos are dragged */
  38198. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38199. /** Fires an event when any of it's sub gizmos are released from dragging */
  38200. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38201. _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);
  38202. _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);
  38203. _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);
  38204. // Relay drag events
  38205. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  38206. gizmo.dragBehavior.onDragStartObservable.add(function () {
  38207. _this.onDragStartObservable.notifyObservers({});
  38208. });
  38209. gizmo.dragBehavior.onDragEndObservable.add(function () {
  38210. _this.onDragEndObservable.notifyObservers({});
  38211. });
  38212. });
  38213. _this.attachedMesh = null;
  38214. return _this;
  38215. }
  38216. Object.defineProperty(RotationGizmo.prototype, "attachedMesh", {
  38217. set: function (mesh) {
  38218. if (this.xGizmo) {
  38219. this.xGizmo.attachedMesh = mesh;
  38220. this.yGizmo.attachedMesh = mesh;
  38221. this.zGizmo.attachedMesh = mesh;
  38222. }
  38223. },
  38224. enumerable: true,
  38225. configurable: true
  38226. });
  38227. Object.defineProperty(RotationGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  38228. get: function () {
  38229. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  38230. },
  38231. set: function (value) {
  38232. if (this.xGizmo) {
  38233. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38234. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38235. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38236. }
  38237. },
  38238. enumerable: true,
  38239. configurable: true
  38240. });
  38241. Object.defineProperty(RotationGizmo.prototype, "snapDistance", {
  38242. get: function () {
  38243. return this.xGizmo.snapDistance;
  38244. },
  38245. /**
  38246. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38247. */
  38248. set: function (value) {
  38249. if (this.xGizmo) {
  38250. this.xGizmo.snapDistance = value;
  38251. this.yGizmo.snapDistance = value;
  38252. this.zGizmo.snapDistance = value;
  38253. }
  38254. },
  38255. enumerable: true,
  38256. configurable: true
  38257. });
  38258. Object.defineProperty(RotationGizmo.prototype, "scaleRatio", {
  38259. get: function () {
  38260. return this.xGizmo.scaleRatio;
  38261. },
  38262. /**
  38263. * Ratio for the scale of the gizmo (Default: 1)
  38264. */
  38265. set: function (value) {
  38266. if (this.xGizmo) {
  38267. this.xGizmo.scaleRatio = value;
  38268. this.yGizmo.scaleRatio = value;
  38269. this.zGizmo.scaleRatio = value;
  38270. }
  38271. },
  38272. enumerable: true,
  38273. configurable: true
  38274. });
  38275. /**
  38276. * Disposes of the gizmo
  38277. */
  38278. RotationGizmo.prototype.dispose = function () {
  38279. this.xGizmo.dispose();
  38280. this.yGizmo.dispose();
  38281. this.zGizmo.dispose();
  38282. this.onDragStartObservable.clear();
  38283. this.onDragEndObservable.clear();
  38284. };
  38285. /**
  38286. * CustomMeshes are not supported by this gizmo
  38287. * @param mesh The mesh to replace the default mesh of the gizmo
  38288. */
  38289. RotationGizmo.prototype.setCustomMesh = function (mesh) {
  38290. _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)");
  38291. };
  38292. return RotationGizmo;
  38293. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  38294. /***/ }),
  38295. /***/ "./Gizmos/scaleGizmo.ts":
  38296. /*!******************************!*\
  38297. !*** ./Gizmos/scaleGizmo.ts ***!
  38298. \******************************/
  38299. /*! exports provided: ScaleGizmo */
  38300. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38301. "use strict";
  38302. __webpack_require__.r(__webpack_exports__);
  38303. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return ScaleGizmo; });
  38304. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38305. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38306. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38307. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38308. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38309. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38310. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  38311. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38312. /**
  38313. * Gizmo that enables scaling a mesh along 3 axis
  38314. */
  38315. var ScaleGizmo = /** @class */ (function (_super) {
  38316. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScaleGizmo, _super);
  38317. /**
  38318. * Creates a ScaleGizmo
  38319. * @param gizmoLayer The utility layer the gizmo will be added to
  38320. */
  38321. function ScaleGizmo(gizmoLayer) {
  38322. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38323. var _this = _super.call(this, gizmoLayer) || this;
  38324. /** Fires an event when any of it's sub gizmos are dragged */
  38325. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38326. /** Fires an event when any of it's sub gizmos are released from dragging */
  38327. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38328. _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);
  38329. _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);
  38330. _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);
  38331. // Create uniform scale gizmo
  38332. _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);
  38333. _this.uniformScaleGizmo.updateGizmoRotationToMatchAttachedMesh = false;
  38334. _this.uniformScaleGizmo.uniformScaling = true;
  38335. var uniformScalingMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  38336. uniformScalingMesh.scaling.scaleInPlace(0.02);
  38337. uniformScalingMesh.visibility = 0;
  38338. var octahedron = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  38339. octahedron.scaling.scaleInPlace(0.007);
  38340. uniformScalingMesh.addChild(octahedron);
  38341. _this.uniformScaleGizmo.setCustomMesh(uniformScalingMesh, true);
  38342. // Relay drag events
  38343. [_this.xGizmo, _this.yGizmo, _this.zGizmo, _this.uniformScaleGizmo].forEach(function (gizmo) {
  38344. gizmo.dragBehavior.onDragStartObservable.add(function () {
  38345. _this.onDragStartObservable.notifyObservers({});
  38346. });
  38347. gizmo.dragBehavior.onDragEndObservable.add(function () {
  38348. _this.onDragEndObservable.notifyObservers({});
  38349. });
  38350. });
  38351. _this.attachedMesh = null;
  38352. return _this;
  38353. }
  38354. Object.defineProperty(ScaleGizmo.prototype, "attachedMesh", {
  38355. set: function (mesh) {
  38356. if (this.xGizmo) {
  38357. this.xGizmo.attachedMesh = mesh;
  38358. this.yGizmo.attachedMesh = mesh;
  38359. this.zGizmo.attachedMesh = mesh;
  38360. this.uniformScaleGizmo.attachedMesh = mesh;
  38361. }
  38362. },
  38363. enumerable: true,
  38364. configurable: true
  38365. });
  38366. Object.defineProperty(ScaleGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  38367. get: function () {
  38368. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  38369. },
  38370. set: function (value) {
  38371. if (!value) {
  38372. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
  38373. }
  38374. if (this.xGizmo) {
  38375. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38376. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38377. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38378. }
  38379. },
  38380. enumerable: true,
  38381. configurable: true
  38382. });
  38383. Object.defineProperty(ScaleGizmo.prototype, "snapDistance", {
  38384. get: function () {
  38385. return this.xGizmo.snapDistance;
  38386. },
  38387. /**
  38388. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38389. */
  38390. set: function (value) {
  38391. if (this.xGizmo) {
  38392. this.xGizmo.snapDistance = value;
  38393. this.yGizmo.snapDistance = value;
  38394. this.zGizmo.snapDistance = value;
  38395. this.uniformScaleGizmo.snapDistance = value;
  38396. }
  38397. },
  38398. enumerable: true,
  38399. configurable: true
  38400. });
  38401. Object.defineProperty(ScaleGizmo.prototype, "scaleRatio", {
  38402. get: function () {
  38403. return this.xGizmo.scaleRatio;
  38404. },
  38405. /**
  38406. * Ratio for the scale of the gizmo (Default: 1)
  38407. */
  38408. set: function (value) {
  38409. if (this.xGizmo) {
  38410. this.xGizmo.scaleRatio = value;
  38411. this.yGizmo.scaleRatio = value;
  38412. this.zGizmo.scaleRatio = value;
  38413. this.uniformScaleGizmo.scaleRatio = value;
  38414. }
  38415. },
  38416. enumerable: true,
  38417. configurable: true
  38418. });
  38419. /**
  38420. * Disposes of the gizmo
  38421. */
  38422. ScaleGizmo.prototype.dispose = function () {
  38423. this.xGizmo.dispose();
  38424. this.yGizmo.dispose();
  38425. this.zGizmo.dispose();
  38426. this.uniformScaleGizmo.dispose();
  38427. this.onDragStartObservable.clear();
  38428. this.onDragEndObservable.clear();
  38429. };
  38430. return ScaleGizmo;
  38431. }(_gizmo__WEBPACK_IMPORTED_MODULE_5__["Gizmo"]));
  38432. /***/ }),
  38433. /***/ "./Helpers/environmentHelper.ts":
  38434. /*!**************************************!*\
  38435. !*** ./Helpers/environmentHelper.ts ***!
  38436. \**************************************/
  38437. /*! exports provided: EnvironmentHelper */
  38438. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38439. "use strict";
  38440. __webpack_require__.r(__webpack_exports__);
  38441. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return EnvironmentHelper; });
  38442. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38443. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38444. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  38445. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38446. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38447. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  38448. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  38449. /* harmony import */ var _Materials_Textures_mirrorTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  38450. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  38451. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  38452. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  38453. /**
  38454. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  38455. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  38456. * It also helps with the default setup of your imageProcessing configuration.
  38457. */
  38458. var EnvironmentHelper = /** @class */ (function () {
  38459. /**
  38460. * constructor
  38461. * @param options
  38462. * @param scene The scene to add the material to
  38463. */
  38464. function EnvironmentHelper(options, scene) {
  38465. var _this = this;
  38466. this._errorHandler = function (message, exception) {
  38467. _this.onErrorObservable.notifyObservers({ message: message, exception: exception });
  38468. };
  38469. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, EnvironmentHelper._getDefaultOptions(), options);
  38470. this._scene = scene;
  38471. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38472. this._setupBackground();
  38473. this._setupImageProcessing();
  38474. }
  38475. /**
  38476. * Creates the default options for the helper.
  38477. */
  38478. EnvironmentHelper._getDefaultOptions = function () {
  38479. return {
  38480. createGround: true,
  38481. groundSize: 15,
  38482. groundTexture: this._groundTextureCDNUrl,
  38483. groundColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  38484. groundOpacity: 0.9,
  38485. enableGroundShadow: true,
  38486. groundShadowLevel: 0.5,
  38487. enableGroundMirror: false,
  38488. groundMirrorSizeRatio: 0.3,
  38489. groundMirrorBlurKernel: 64,
  38490. groundMirrorAmount: 1,
  38491. groundMirrorFresnelWeight: 1,
  38492. groundMirrorFallOffDistance: 0,
  38493. groundMirrorTextureType: _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT,
  38494. groundYBias: 0.00001,
  38495. createSkybox: true,
  38496. skyboxSize: 20,
  38497. skyboxTexture: this._skyboxTextureCDNUrl,
  38498. skyboxColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  38499. backgroundYRotation: 0,
  38500. sizeAuto: true,
  38501. rootPosition: _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(),
  38502. setupImageProcessing: true,
  38503. environmentTexture: this._environmentTextureCDNUrl,
  38504. cameraExposure: 0.8,
  38505. cameraContrast: 1.2,
  38506. toneMappingEnabled: true,
  38507. };
  38508. };
  38509. Object.defineProperty(EnvironmentHelper.prototype, "rootMesh", {
  38510. /**
  38511. * Gets the root mesh created by the helper.
  38512. */
  38513. get: function () {
  38514. return this._rootMesh;
  38515. },
  38516. enumerable: true,
  38517. configurable: true
  38518. });
  38519. Object.defineProperty(EnvironmentHelper.prototype, "skybox", {
  38520. /**
  38521. * Gets the skybox created by the helper.
  38522. */
  38523. get: function () {
  38524. return this._skybox;
  38525. },
  38526. enumerable: true,
  38527. configurable: true
  38528. });
  38529. Object.defineProperty(EnvironmentHelper.prototype, "skyboxTexture", {
  38530. /**
  38531. * Gets the skybox texture created by the helper.
  38532. */
  38533. get: function () {
  38534. return this._skyboxTexture;
  38535. },
  38536. enumerable: true,
  38537. configurable: true
  38538. });
  38539. Object.defineProperty(EnvironmentHelper.prototype, "skyboxMaterial", {
  38540. /**
  38541. * Gets the skybox material created by the helper.
  38542. */
  38543. get: function () {
  38544. return this._skyboxMaterial;
  38545. },
  38546. enumerable: true,
  38547. configurable: true
  38548. });
  38549. Object.defineProperty(EnvironmentHelper.prototype, "ground", {
  38550. /**
  38551. * Gets the ground mesh created by the helper.
  38552. */
  38553. get: function () {
  38554. return this._ground;
  38555. },
  38556. enumerable: true,
  38557. configurable: true
  38558. });
  38559. Object.defineProperty(EnvironmentHelper.prototype, "groundTexture", {
  38560. /**
  38561. * Gets the ground texture created by the helper.
  38562. */
  38563. get: function () {
  38564. return this._groundTexture;
  38565. },
  38566. enumerable: true,
  38567. configurable: true
  38568. });
  38569. Object.defineProperty(EnvironmentHelper.prototype, "groundMirror", {
  38570. /**
  38571. * Gets the ground mirror created by the helper.
  38572. */
  38573. get: function () {
  38574. return this._groundMirror;
  38575. },
  38576. enumerable: true,
  38577. configurable: true
  38578. });
  38579. Object.defineProperty(EnvironmentHelper.prototype, "groundMirrorRenderList", {
  38580. /**
  38581. * Gets the ground mirror render list to helps pushing the meshes
  38582. * you wish in the ground reflection.
  38583. */
  38584. get: function () {
  38585. if (this._groundMirror) {
  38586. return this._groundMirror.renderList;
  38587. }
  38588. return null;
  38589. },
  38590. enumerable: true,
  38591. configurable: true
  38592. });
  38593. Object.defineProperty(EnvironmentHelper.prototype, "groundMaterial", {
  38594. /**
  38595. * Gets the ground material created by the helper.
  38596. */
  38597. get: function () {
  38598. return this._groundMaterial;
  38599. },
  38600. enumerable: true,
  38601. configurable: true
  38602. });
  38603. /**
  38604. * Updates the background according to the new options
  38605. * @param options
  38606. */
  38607. EnvironmentHelper.prototype.updateOptions = function (options) {
  38608. var newOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, this._options, options);
  38609. if (this._ground && !newOptions.createGround) {
  38610. this._ground.dispose();
  38611. this._ground = null;
  38612. }
  38613. if (this._groundMaterial && !newOptions.createGround) {
  38614. this._groundMaterial.dispose();
  38615. this._groundMaterial = null;
  38616. }
  38617. if (this._groundTexture) {
  38618. if (this._options.groundTexture != newOptions.groundTexture) {
  38619. this._groundTexture.dispose();
  38620. this._groundTexture = null;
  38621. }
  38622. }
  38623. if (this._skybox && !newOptions.createSkybox) {
  38624. this._skybox.dispose();
  38625. this._skybox = null;
  38626. }
  38627. if (this._skyboxMaterial && !newOptions.createSkybox) {
  38628. this._skyboxMaterial.dispose();
  38629. this._skyboxMaterial = null;
  38630. }
  38631. if (this._skyboxTexture) {
  38632. if (this._options.skyboxTexture != newOptions.skyboxTexture) {
  38633. this._skyboxTexture.dispose();
  38634. this._skyboxTexture = null;
  38635. }
  38636. }
  38637. if (this._groundMirror && !newOptions.enableGroundMirror) {
  38638. this._groundMirror.dispose();
  38639. this._groundMirror = null;
  38640. }
  38641. if (this._scene.environmentTexture) {
  38642. if (this._options.environmentTexture != newOptions.environmentTexture) {
  38643. this._scene.environmentTexture.dispose();
  38644. }
  38645. }
  38646. this._options = newOptions;
  38647. this._setupBackground();
  38648. this._setupImageProcessing();
  38649. };
  38650. /**
  38651. * Sets the primary color of all the available elements.
  38652. * @param color the main color to affect to the ground and the background
  38653. */
  38654. EnvironmentHelper.prototype.setMainColor = function (color) {
  38655. if (this.groundMaterial) {
  38656. this.groundMaterial.primaryColor = color;
  38657. }
  38658. if (this.skyboxMaterial) {
  38659. this.skyboxMaterial.primaryColor = color;
  38660. }
  38661. if (this.groundMirror) {
  38662. this.groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](color.r, color.g, color.b, 1.0);
  38663. }
  38664. };
  38665. /**
  38666. * Setup the image processing according to the specified options.
  38667. */
  38668. EnvironmentHelper.prototype._setupImageProcessing = function () {
  38669. if (this._options.setupImageProcessing) {
  38670. this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast;
  38671. this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure;
  38672. this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled;
  38673. this._setupEnvironmentTexture();
  38674. }
  38675. };
  38676. /**
  38677. * Setup the environment texture according to the specified options.
  38678. */
  38679. EnvironmentHelper.prototype._setupEnvironmentTexture = function () {
  38680. if (this._scene.environmentTexture) {
  38681. return;
  38682. }
  38683. if (this._options.environmentTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  38684. this._scene.environmentTexture = this._options.environmentTexture;
  38685. return;
  38686. }
  38687. var environmentTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
  38688. this._scene.environmentTexture = environmentTexture;
  38689. };
  38690. /**
  38691. * Setup the background according to the specified options.
  38692. */
  38693. EnvironmentHelper.prototype._setupBackground = function () {
  38694. if (!this._rootMesh) {
  38695. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("BackgroundHelper", this._scene);
  38696. }
  38697. this._rootMesh.rotation.y = this._options.backgroundYRotation;
  38698. var sceneSize = this._getSceneSize();
  38699. if (this._options.createGround) {
  38700. this._setupGround(sceneSize);
  38701. this._setupGroundMaterial();
  38702. this._setupGroundDiffuseTexture();
  38703. if (this._options.enableGroundMirror) {
  38704. this._setupGroundMirrorTexture(sceneSize);
  38705. }
  38706. this._setupMirrorInGroundMaterial();
  38707. }
  38708. if (this._options.createSkybox) {
  38709. this._setupSkybox(sceneSize);
  38710. this._setupSkyboxMaterial();
  38711. this._setupSkyboxReflectionTexture();
  38712. }
  38713. this._rootMesh.position.x = sceneSize.rootPosition.x;
  38714. this._rootMesh.position.z = sceneSize.rootPosition.z;
  38715. this._rootMesh.position.y = sceneSize.rootPosition.y;
  38716. };
  38717. /**
  38718. * Get the scene sizes according to the setup.
  38719. */
  38720. EnvironmentHelper.prototype._getSceneSize = function () {
  38721. var _this = this;
  38722. var groundSize = this._options.groundSize;
  38723. var skyboxSize = this._options.skyboxSize;
  38724. var rootPosition = this._options.rootPosition;
  38725. if (!this._scene.meshes || this._scene.meshes.length === 1) { // 1 only means the root of the helper.
  38726. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  38727. }
  38728. var sceneExtends = this._scene.getWorldExtends(function (mesh) {
  38729. return (mesh !== _this._ground && mesh !== _this._rootMesh && mesh !== _this._skybox);
  38730. });
  38731. var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
  38732. if (this._options.sizeAuto) {
  38733. if (this._scene.activeCamera instanceof _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"] &&
  38734. this._scene.activeCamera.upperRadiusLimit) {
  38735. groundSize = this._scene.activeCamera.upperRadiusLimit * 2;
  38736. skyboxSize = groundSize;
  38737. }
  38738. var sceneDiagonalLenght = sceneDiagonal.length();
  38739. if (sceneDiagonalLenght > groundSize) {
  38740. groundSize = sceneDiagonalLenght * 2;
  38741. skyboxSize = groundSize;
  38742. }
  38743. // 10 % bigger.
  38744. groundSize *= 1.1;
  38745. skyboxSize *= 1.5;
  38746. rootPosition = sceneExtends.min.add(sceneDiagonal.scale(0.5));
  38747. rootPosition.y = sceneExtends.min.y - this._options.groundYBias;
  38748. }
  38749. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  38750. };
  38751. /**
  38752. * Setup the ground according to the specified options.
  38753. */
  38754. EnvironmentHelper.prototype._setupGround = function (sceneSize) {
  38755. var _this = this;
  38756. if (!this._ground || this._ground.isDisposed()) {
  38757. this._ground = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePlane("BackgroundPlane", sceneSize.groundSize, this._scene);
  38758. this._ground.rotation.x = Math.PI / 2; // Face up by default.
  38759. this._ground.parent = this._rootMesh;
  38760. this._ground.onDisposeObservable.add(function () { _this._ground = null; });
  38761. }
  38762. this._ground.receiveShadows = this._options.enableGroundShadow;
  38763. };
  38764. /**
  38765. * Setup the ground material according to the specified options.
  38766. */
  38767. EnvironmentHelper.prototype._setupGroundMaterial = function () {
  38768. if (!this._groundMaterial) {
  38769. this._groundMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundPlaneMaterial", this._scene);
  38770. }
  38771. this._groundMaterial.alpha = this._options.groundOpacity;
  38772. this._groundMaterial.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  38773. this._groundMaterial.shadowLevel = this._options.groundShadowLevel;
  38774. this._groundMaterial.primaryColor = this._options.groundColor;
  38775. this._groundMaterial.useRGBColor = false;
  38776. this._groundMaterial.enableNoise = true;
  38777. if (this._ground) {
  38778. this._ground.material = this._groundMaterial;
  38779. }
  38780. };
  38781. /**
  38782. * Setup the ground diffuse texture according to the specified options.
  38783. */
  38784. EnvironmentHelper.prototype._setupGroundDiffuseTexture = function () {
  38785. if (!this._groundMaterial) {
  38786. return;
  38787. }
  38788. if (this._groundTexture) {
  38789. return;
  38790. }
  38791. if (this._options.groundTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  38792. this._groundMaterial.diffuseTexture = this._options.groundTexture;
  38793. return;
  38794. }
  38795. var diffuseTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](this._options.groundTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  38796. diffuseTexture.gammaSpace = false;
  38797. diffuseTexture.hasAlpha = true;
  38798. this._groundMaterial.diffuseTexture = diffuseTexture;
  38799. };
  38800. /**
  38801. * Setup the ground mirror texture according to the specified options.
  38802. */
  38803. EnvironmentHelper.prototype._setupGroundMirrorTexture = function (sceneSize) {
  38804. var wrapping = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  38805. if (!this._groundMirror) {
  38806. 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);
  38807. this._groundMirror.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Plane"](0, -1, 0, sceneSize.rootPosition.y);
  38808. this._groundMirror.anisotropicFilteringLevel = 1;
  38809. this._groundMirror.wrapU = wrapping;
  38810. this._groundMirror.wrapV = wrapping;
  38811. this._groundMirror.gammaSpace = false;
  38812. if (this._groundMirror.renderList) {
  38813. for (var i = 0; i < this._scene.meshes.length; i++) {
  38814. var mesh = this._scene.meshes[i];
  38815. if (mesh !== this._ground &&
  38816. mesh !== this._skybox &&
  38817. mesh !== this._rootMesh) {
  38818. this._groundMirror.renderList.push(mesh);
  38819. }
  38820. }
  38821. }
  38822. }
  38823. this._groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](this._options.groundColor.r, this._options.groundColor.g, this._options.groundColor.b, 1);
  38824. this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel;
  38825. };
  38826. /**
  38827. * Setup the ground to receive the mirror texture.
  38828. */
  38829. EnvironmentHelper.prototype._setupMirrorInGroundMaterial = function () {
  38830. if (this._groundMaterial) {
  38831. this._groundMaterial.reflectionTexture = this._groundMirror;
  38832. this._groundMaterial.reflectionFresnel = true;
  38833. this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount;
  38834. this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight;
  38835. this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance;
  38836. }
  38837. };
  38838. /**
  38839. * Setup the skybox according to the specified options.
  38840. */
  38841. EnvironmentHelper.prototype._setupSkybox = function (sceneSize) {
  38842. var _this = this;
  38843. if (!this._skybox || this._skybox.isDisposed()) {
  38844. this._skybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateBox("BackgroundSkybox", sceneSize.skyboxSize, this._scene, undefined, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].BACKSIDE);
  38845. this._skybox.onDisposeObservable.add(function () { _this._skybox = null; });
  38846. }
  38847. this._skybox.parent = this._rootMesh;
  38848. };
  38849. /**
  38850. * Setup the skybox material according to the specified options.
  38851. */
  38852. EnvironmentHelper.prototype._setupSkyboxMaterial = function () {
  38853. if (!this._skybox) {
  38854. return;
  38855. }
  38856. if (!this._skyboxMaterial) {
  38857. this._skyboxMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundSkyboxMaterial", this._scene);
  38858. }
  38859. this._skyboxMaterial.useRGBColor = false;
  38860. this._skyboxMaterial.primaryColor = this._options.skyboxColor;
  38861. this._skyboxMaterial.enableNoise = true;
  38862. this._skybox.material = this._skyboxMaterial;
  38863. };
  38864. /**
  38865. * Setup the skybox reflection texture according to the specified options.
  38866. */
  38867. EnvironmentHelper.prototype._setupSkyboxReflectionTexture = function () {
  38868. if (!this._skyboxMaterial) {
  38869. return;
  38870. }
  38871. if (this._skyboxTexture) {
  38872. return;
  38873. }
  38874. if (this._options.skyboxTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  38875. this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture;
  38876. return;
  38877. }
  38878. this._skyboxTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"](this._options.skyboxTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  38879. this._skyboxTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].SKYBOX_MODE;
  38880. this._skyboxTexture.gammaSpace = false;
  38881. this._skyboxMaterial.reflectionTexture = this._skyboxTexture;
  38882. };
  38883. /**
  38884. * Dispose all the elements created by the Helper.
  38885. */
  38886. EnvironmentHelper.prototype.dispose = function () {
  38887. if (this._groundMaterial) {
  38888. this._groundMaterial.dispose(true, true);
  38889. }
  38890. if (this._skyboxMaterial) {
  38891. this._skyboxMaterial.dispose(true, true);
  38892. }
  38893. this._rootMesh.dispose(false);
  38894. };
  38895. /**
  38896. * Default ground texture URL.
  38897. */
  38898. EnvironmentHelper._groundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png";
  38899. /**
  38900. * Default skybox texture URL.
  38901. */
  38902. EnvironmentHelper._skyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds";
  38903. /**
  38904. * Default environment texture URL.
  38905. */
  38906. EnvironmentHelper._environmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env";
  38907. return EnvironmentHelper;
  38908. }());
  38909. /***/ }),
  38910. /***/ "./Helpers/index.ts":
  38911. /*!**************************!*\
  38912. !*** ./Helpers/index.ts ***!
  38913. \**************************/
  38914. /*! exports provided: EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome */
  38915. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38916. "use strict";
  38917. __webpack_require__.r(__webpack_exports__);
  38918. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  38919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _environmentHelper__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  38920. /* harmony import */ var _photoDome__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./photoDome */ "./Helpers/photoDome.ts");
  38921. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _photoDome__WEBPACK_IMPORTED_MODULE_1__["PhotoDome"]; });
  38922. /* harmony import */ var _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneHelpers */ "./Helpers/sceneHelpers.ts");
  38923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__["_forceSceneHelpersToBundle"]; });
  38924. /* harmony import */ var _videoDome__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./videoDome */ "./Helpers/videoDome.ts");
  38925. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _videoDome__WEBPACK_IMPORTED_MODULE_3__["VideoDome"]; });
  38926. /***/ }),
  38927. /***/ "./Helpers/photoDome.ts":
  38928. /*!******************************!*\
  38929. !*** ./Helpers/photoDome.ts ***!
  38930. \******************************/
  38931. /*! exports provided: PhotoDome */
  38932. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38933. "use strict";
  38934. __webpack_require__.r(__webpack_exports__);
  38935. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return PhotoDome; });
  38936. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38937. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38938. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  38939. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38940. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  38941. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  38942. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  38943. /**
  38944. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  38945. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  38946. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  38947. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  38948. */
  38949. var PhotoDome = /** @class */ (function (_super) {
  38950. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PhotoDome, _super);
  38951. /**
  38952. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  38953. * @param name Element's name, child elements will append suffixes for their own names.
  38954. * @param urlsOfPhoto defines the url of the photo to display
  38955. * @param options defines an object containing optional or exposed sub element properties
  38956. * @param onError defines a callback called when an error occured while loading the texture
  38957. */
  38958. function PhotoDome(name, urlOfPhoto, options, scene, onError) {
  38959. if (onError === void 0) { onError = null; }
  38960. var _this = _super.call(this, name, scene) || this;
  38961. _this._useDirectMapping = false;
  38962. /**
  38963. * Observable raised when an error occured while loading the 360 image
  38964. */
  38965. _this.onLoadErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38966. // set defaults and manage values
  38967. name = name || "photoDome";
  38968. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  38969. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  38970. if (options.useDirectMapping === undefined) {
  38971. _this._useDirectMapping = true;
  38972. }
  38973. else {
  38974. _this._useDirectMapping = options.useDirectMapping;
  38975. }
  38976. _this._setReady(false);
  38977. // create
  38978. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  38979. _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);
  38980. // configure material
  38981. material.opacityFresnel = false;
  38982. material.useEquirectangularFOV = true;
  38983. material.fovMultiplier = 1.0;
  38984. _this.photoTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](urlOfPhoto, scene, true, !_this._useDirectMapping, undefined, undefined, function (message, exception) {
  38985. _this.onLoadErrorObservable.notifyObservers(message || "Unknown error occured");
  38986. if (onError) {
  38987. onError(message, exception);
  38988. }
  38989. });
  38990. _this.photoTexture.onLoadObservable.addOnce(function () {
  38991. _this._setReady(true);
  38992. });
  38993. // configure mesh
  38994. _this._mesh.material = material;
  38995. _this._mesh.parent = _this;
  38996. return _this;
  38997. }
  38998. Object.defineProperty(PhotoDome.prototype, "photoTexture", {
  38999. /**
  39000. * Gets or sets the texture being displayed on the sphere
  39001. */
  39002. get: function () {
  39003. return this._photoTexture;
  39004. },
  39005. set: function (value) {
  39006. if (this._photoTexture === value) {
  39007. return;
  39008. }
  39009. this._photoTexture = value;
  39010. if (this._useDirectMapping) {
  39011. this._photoTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  39012. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  39013. this._material.diffuseTexture = this._photoTexture;
  39014. }
  39015. else {
  39016. this._photoTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  39017. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  39018. this._material.reflectionTexture = this._photoTexture;
  39019. }
  39020. },
  39021. enumerable: true,
  39022. configurable: true
  39023. });
  39024. Object.defineProperty(PhotoDome.prototype, "fovMultiplier", {
  39025. /**
  39026. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  39027. * Also see the options.resolution property.
  39028. */
  39029. get: function () {
  39030. return this._material.fovMultiplier;
  39031. },
  39032. set: function (value) {
  39033. this._material.fovMultiplier = value;
  39034. },
  39035. enumerable: true,
  39036. configurable: true
  39037. });
  39038. /**
  39039. * Releases resources associated with this node.
  39040. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  39041. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  39042. */
  39043. PhotoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  39044. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  39045. this._photoTexture.dispose();
  39046. this._mesh.dispose();
  39047. this._material.dispose();
  39048. this.onLoadErrorObservable.clear();
  39049. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  39050. };
  39051. return PhotoDome;
  39052. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__["TransformNode"]));
  39053. /***/ }),
  39054. /***/ "./Helpers/sceneHelpers.ts":
  39055. /*!*********************************!*\
  39056. !*** ./Helpers/sceneHelpers.ts ***!
  39057. \*********************************/
  39058. /*! exports provided: _forceSceneHelpersToBundle */
  39059. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39060. "use strict";
  39061. __webpack_require__.r(__webpack_exports__);
  39062. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _forceSceneHelpersToBundle; });
  39063. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39064. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  39065. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39066. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39067. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39068. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39069. /* harmony import */ var _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/PBR/pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  39070. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  39071. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  39072. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  39073. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  39074. /* harmony import */ var _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/XR/webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  39075. /* harmony import */ var _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Cameras/XR/webXRInput */ "./Cameras/XR/webXRInput.ts");
  39076. /* harmony import */ var _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Cameras/XR/webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  39077. /* harmony import */ var _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Cameras/XR/webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  39078. /* harmony import */ var _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Cameras/VR/vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  39079. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  39080. /** @hidden */
  39081. var _forceSceneHelpersToBundle = true;
  39082. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultLight = function (replace) {
  39083. if (replace === void 0) { replace = false; }
  39084. // Dispose existing light in replace mode.
  39085. if (replace) {
  39086. if (this.lights) {
  39087. for (var i = 0; i < this.lights.length; i++) {
  39088. this.lights[i].dispose();
  39089. }
  39090. }
  39091. }
  39092. // Light
  39093. if (this.lights.length === 0) {
  39094. new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__["HemisphericLight"]("default light", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up(), this);
  39095. }
  39096. };
  39097. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCamera = function (createArcRotateCamera, replace, attachCameraControls) {
  39098. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  39099. if (replace === void 0) { replace = false; }
  39100. if (attachCameraControls === void 0) { attachCameraControls = false; }
  39101. // Dispose existing camera in replace mode.
  39102. if (replace) {
  39103. if (this.activeCamera) {
  39104. this.activeCamera.dispose();
  39105. this.activeCamera = null;
  39106. }
  39107. }
  39108. // Camera
  39109. if (!this.activeCamera) {
  39110. var worldExtends = this.getWorldExtends();
  39111. var worldSize = worldExtends.max.subtract(worldExtends.min);
  39112. var worldCenter = worldExtends.min.add(worldSize.scale(0.5));
  39113. var camera;
  39114. var radius = worldSize.length() * 1.5;
  39115. // empty scene scenario!
  39116. if (!isFinite(radius)) {
  39117. radius = 1;
  39118. worldCenter.copyFromFloats(0, 0, 0);
  39119. }
  39120. if (createArcRotateCamera) {
  39121. var arcRotateCamera = new _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__["ArcRotateCamera"]("default camera", -(Math.PI / 2), Math.PI / 2, radius, worldCenter, this);
  39122. arcRotateCamera.lowerRadiusLimit = radius * 0.01;
  39123. arcRotateCamera.wheelPrecision = 100 / radius;
  39124. camera = arcRotateCamera;
  39125. }
  39126. else {
  39127. 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);
  39128. freeCamera.setTarget(worldCenter);
  39129. camera = freeCamera;
  39130. }
  39131. camera.minZ = radius * 0.01;
  39132. camera.maxZ = radius * 1000;
  39133. camera.speed = radius * 0.2;
  39134. this.activeCamera = camera;
  39135. var canvas = this.getEngine().getRenderingCanvas();
  39136. if (attachCameraControls && canvas) {
  39137. camera.attachControl(canvas);
  39138. }
  39139. }
  39140. };
  39141. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCameraOrLight = function (createArcRotateCamera, replace, attachCameraControls) {
  39142. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  39143. if (replace === void 0) { replace = false; }
  39144. if (attachCameraControls === void 0) { attachCameraControls = false; }
  39145. this.createDefaultLight(replace);
  39146. this.createDefaultCamera(createArcRotateCamera, replace, attachCameraControls);
  39147. };
  39148. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultSkybox = function (environmentTexture, pbr, scale, blur, setGlobalEnvTexture) {
  39149. if (pbr === void 0) { pbr = false; }
  39150. if (scale === void 0) { scale = 1000; }
  39151. if (blur === void 0) { blur = 0; }
  39152. if (setGlobalEnvTexture === void 0) { setGlobalEnvTexture = true; }
  39153. if (!environmentTexture) {
  39154. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Can not create default skybox without environment texture.");
  39155. return null;
  39156. }
  39157. if (setGlobalEnvTexture) {
  39158. if (environmentTexture) {
  39159. this.environmentTexture = environmentTexture;
  39160. }
  39161. }
  39162. // Skybox
  39163. var hdrSkybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateBox("hdrSkyBox", scale, this);
  39164. if (pbr) {
  39165. var hdrSkyboxMaterial = new _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__["PBRMaterial"]("skyBox", this);
  39166. hdrSkyboxMaterial.backFaceCulling = false;
  39167. hdrSkyboxMaterial.reflectionTexture = environmentTexture.clone();
  39168. if (hdrSkyboxMaterial.reflectionTexture) {
  39169. hdrSkyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  39170. }
  39171. hdrSkyboxMaterial.microSurface = 1.0 - blur;
  39172. hdrSkyboxMaterial.disableLighting = true;
  39173. hdrSkyboxMaterial.twoSidedLighting = true;
  39174. hdrSkybox.infiniteDistance = true;
  39175. hdrSkybox.material = hdrSkyboxMaterial;
  39176. }
  39177. else {
  39178. var skyboxMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("skyBox", this);
  39179. skyboxMaterial.backFaceCulling = false;
  39180. skyboxMaterial.reflectionTexture = environmentTexture.clone();
  39181. if (skyboxMaterial.reflectionTexture) {
  39182. skyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  39183. }
  39184. skyboxMaterial.disableLighting = true;
  39185. hdrSkybox.infiniteDistance = true;
  39186. hdrSkybox.material = skyboxMaterial;
  39187. }
  39188. hdrSkybox.isPickable = false;
  39189. return hdrSkybox;
  39190. };
  39191. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultEnvironment = function (options) {
  39192. if (_environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"]) {
  39193. return new _environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"](options, this);
  39194. }
  39195. return null;
  39196. };
  39197. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultVRExperience = function (webVROptions) {
  39198. if (webVROptions === void 0) { webVROptions = {}; }
  39199. return new _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__["VRExperienceHelper"](this, webVROptions);
  39200. };
  39201. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultXRExperienceAsync = function () {
  39202. var _this = this;
  39203. return _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__["WebXRExperienceHelper"].CreateAsync(this).then(function (helper) {
  39204. var outputCanvas = new _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__["WebXRManagedOutputCanvas"](helper);
  39205. return _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__["WebXREnterExitUI"].CreateAsync(_this, helper, { outputCanvasContext: outputCanvas.canvasContext })
  39206. .then(function (ui) {
  39207. new _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__["WebXRInput"](helper);
  39208. return helper;
  39209. });
  39210. });
  39211. };
  39212. /***/ }),
  39213. /***/ "./Helpers/videoDome.ts":
  39214. /*!******************************!*\
  39215. !*** ./Helpers/videoDome.ts ***!
  39216. \******************************/
  39217. /*! exports provided: VideoDome */
  39218. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39219. "use strict";
  39220. __webpack_require__.r(__webpack_exports__);
  39221. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return VideoDome; });
  39222. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39223. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  39224. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39225. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39226. /* harmony import */ var _Materials_Textures_videoTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/videoTexture */ "./Materials/Textures/videoTexture.ts");
  39227. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  39228. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  39229. /**
  39230. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  39231. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  39232. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  39233. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  39234. */
  39235. var VideoDome = /** @class */ (function (_super) {
  39236. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoDome, _super);
  39237. /**
  39238. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  39239. * @param name Element's name, child elements will append suffixes for their own names.
  39240. * @param urlsOrVideo defines the url(s) or the video element to use
  39241. * @param options An object containing optional or exposed sub element properties
  39242. */
  39243. function VideoDome(name, urlsOrVideo, options, scene) {
  39244. var _this = _super.call(this, name, scene) || this;
  39245. _this._useDirectMapping = false;
  39246. // set defaults and manage values
  39247. name = name || "videoDome";
  39248. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  39249. options.clickToPlay = Boolean(options.clickToPlay);
  39250. options.autoPlay = options.autoPlay === undefined ? true : Boolean(options.autoPlay);
  39251. options.loop = options.loop === undefined ? true : Boolean(options.loop);
  39252. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  39253. if (options.useDirectMapping === undefined) {
  39254. _this._useDirectMapping = true;
  39255. }
  39256. else {
  39257. _this._useDirectMapping = options.useDirectMapping;
  39258. }
  39259. _this._setReady(false);
  39260. // create
  39261. var tempOptions = { loop: options.loop, autoPlay: options.autoPlay, autoUpdateTexture: true, poster: options.poster };
  39262. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  39263. 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);
  39264. _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);
  39265. texture.onLoadObservable.addOnce(function () {
  39266. _this._setReady(true);
  39267. });
  39268. // configure material
  39269. material.useEquirectangularFOV = true;
  39270. material.fovMultiplier = 1.0;
  39271. material.opacityFresnel = false;
  39272. if (_this._useDirectMapping) {
  39273. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  39274. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  39275. material.diffuseTexture = texture;
  39276. }
  39277. else {
  39278. texture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  39279. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  39280. material.reflectionTexture = texture;
  39281. }
  39282. // configure mesh
  39283. _this._mesh.material = material;
  39284. _this._mesh.parent = _this;
  39285. // optional configuration
  39286. if (options.clickToPlay) {
  39287. scene.onPointerUp = function () {
  39288. _this._videoTexture.video.play();
  39289. };
  39290. }
  39291. return _this;
  39292. }
  39293. Object.defineProperty(VideoDome.prototype, "videoTexture", {
  39294. /**
  39295. * Gets the video texture being displayed on the sphere
  39296. */
  39297. get: function () {
  39298. return this._videoTexture;
  39299. },
  39300. enumerable: true,
  39301. configurable: true
  39302. });
  39303. Object.defineProperty(VideoDome.prototype, "fovMultiplier", {
  39304. /**
  39305. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  39306. * Also see the options.resolution property.
  39307. */
  39308. get: function () {
  39309. return this._material.fovMultiplier;
  39310. },
  39311. set: function (value) {
  39312. this._material.fovMultiplier = value;
  39313. },
  39314. enumerable: true,
  39315. configurable: true
  39316. });
  39317. /**
  39318. * Releases resources associated with this node.
  39319. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  39320. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  39321. */
  39322. VideoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  39323. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  39324. this._videoTexture.dispose();
  39325. this._mesh.dispose();
  39326. this._material.dispose();
  39327. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  39328. };
  39329. return VideoDome;
  39330. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]));
  39331. /***/ }),
  39332. /***/ "./Instrumentation/engineInstrumentation.ts":
  39333. /*!**************************************************!*\
  39334. !*** ./Instrumentation/engineInstrumentation.ts ***!
  39335. \**************************************************/
  39336. /*! exports provided: EngineInstrumentation */
  39337. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39338. "use strict";
  39339. __webpack_require__.r(__webpack_exports__);
  39340. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return EngineInstrumentation; });
  39341. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  39342. /**
  39343. * This class can be used to get instrumentation data from a Babylon engine
  39344. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  39345. */
  39346. var EngineInstrumentation = /** @class */ (function () {
  39347. /**
  39348. * Instantiates a new engine instrumentation.
  39349. * This class can be used to get instrumentation data from a Babylon engine
  39350. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  39351. * @param engine Defines the engine to instrument
  39352. */
  39353. function EngineInstrumentation(
  39354. /**
  39355. * Define the instrumented engine.
  39356. */
  39357. engine) {
  39358. this.engine = engine;
  39359. this._captureGPUFrameTime = false;
  39360. this._gpuFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39361. this._captureShaderCompilationTime = false;
  39362. this._shaderCompilationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39363. // Observers
  39364. this._onBeginFrameObserver = null;
  39365. this._onEndFrameObserver = null;
  39366. this._onBeforeShaderCompilationObserver = null;
  39367. this._onAfterShaderCompilationObserver = null;
  39368. }
  39369. Object.defineProperty(EngineInstrumentation.prototype, "gpuFrameTimeCounter", {
  39370. // Properties
  39371. /**
  39372. * Gets the perf counter used for GPU frame time
  39373. */
  39374. get: function () {
  39375. return this._gpuFrameTime;
  39376. },
  39377. enumerable: true,
  39378. configurable: true
  39379. });
  39380. Object.defineProperty(EngineInstrumentation.prototype, "captureGPUFrameTime", {
  39381. /**
  39382. * Gets the GPU frame time capture status
  39383. */
  39384. get: function () {
  39385. return this._captureGPUFrameTime;
  39386. },
  39387. /**
  39388. * Enable or disable the GPU frame time capture
  39389. */
  39390. set: function (value) {
  39391. var _this = this;
  39392. if (value === this._captureGPUFrameTime) {
  39393. return;
  39394. }
  39395. this._captureGPUFrameTime = value;
  39396. if (value) {
  39397. this._onBeginFrameObserver = this.engine.onBeginFrameObservable.add(function () {
  39398. if (!_this._gpuFrameTimeToken) {
  39399. _this._gpuFrameTimeToken = _this.engine.startTimeQuery();
  39400. }
  39401. });
  39402. this._onEndFrameObserver = this.engine.onEndFrameObservable.add(function () {
  39403. if (!_this._gpuFrameTimeToken) {
  39404. return;
  39405. }
  39406. var time = _this.engine.endTimeQuery(_this._gpuFrameTimeToken);
  39407. if (time > -1) {
  39408. _this._gpuFrameTimeToken = null;
  39409. _this._gpuFrameTime.fetchNewFrame();
  39410. _this._gpuFrameTime.addCount(time, true);
  39411. }
  39412. });
  39413. }
  39414. else {
  39415. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  39416. this._onBeginFrameObserver = null;
  39417. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  39418. this._onEndFrameObserver = null;
  39419. }
  39420. },
  39421. enumerable: true,
  39422. configurable: true
  39423. });
  39424. Object.defineProperty(EngineInstrumentation.prototype, "shaderCompilationTimeCounter", {
  39425. /**
  39426. * Gets the perf counter used for shader compilation time
  39427. */
  39428. get: function () {
  39429. return this._shaderCompilationTime;
  39430. },
  39431. enumerable: true,
  39432. configurable: true
  39433. });
  39434. Object.defineProperty(EngineInstrumentation.prototype, "captureShaderCompilationTime", {
  39435. /**
  39436. * Gets the shader compilation time capture status
  39437. */
  39438. get: function () {
  39439. return this._captureShaderCompilationTime;
  39440. },
  39441. /**
  39442. * Enable or disable the shader compilation time capture
  39443. */
  39444. set: function (value) {
  39445. var _this = this;
  39446. if (value === this._captureShaderCompilationTime) {
  39447. return;
  39448. }
  39449. this._captureShaderCompilationTime = value;
  39450. if (value) {
  39451. this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add(function () {
  39452. _this._shaderCompilationTime.fetchNewFrame();
  39453. _this._shaderCompilationTime.beginMonitoring();
  39454. });
  39455. this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add(function () {
  39456. _this._shaderCompilationTime.endMonitoring();
  39457. });
  39458. }
  39459. else {
  39460. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  39461. this._onBeforeShaderCompilationObserver = null;
  39462. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  39463. this._onAfterShaderCompilationObserver = null;
  39464. }
  39465. },
  39466. enumerable: true,
  39467. configurable: true
  39468. });
  39469. /**
  39470. * Dispose and release associated resources.
  39471. */
  39472. EngineInstrumentation.prototype.dispose = function () {
  39473. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  39474. this._onBeginFrameObserver = null;
  39475. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  39476. this._onEndFrameObserver = null;
  39477. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  39478. this._onBeforeShaderCompilationObserver = null;
  39479. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  39480. this._onAfterShaderCompilationObserver = null;
  39481. this.engine = null;
  39482. };
  39483. return EngineInstrumentation;
  39484. }());
  39485. /***/ }),
  39486. /***/ "./Instrumentation/index.ts":
  39487. /*!**********************************!*\
  39488. !*** ./Instrumentation/index.ts ***!
  39489. \**********************************/
  39490. /*! exports provided: EngineInstrumentation, SceneInstrumentation, _TimeToken */
  39491. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39492. "use strict";
  39493. __webpack_require__.r(__webpack_exports__);
  39494. /* harmony import */ var _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engineInstrumentation */ "./Instrumentation/engineInstrumentation.ts");
  39495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  39496. /* harmony import */ var _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sceneInstrumentation */ "./Instrumentation/sceneInstrumentation.ts");
  39497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__["SceneInstrumentation"]; });
  39498. /* harmony import */ var _timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./timeToken */ "./Instrumentation/timeToken.ts");
  39499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]; });
  39500. /***/ }),
  39501. /***/ "./Instrumentation/sceneInstrumentation.ts":
  39502. /*!*************************************************!*\
  39503. !*** ./Instrumentation/sceneInstrumentation.ts ***!
  39504. \*************************************************/
  39505. /*! exports provided: SceneInstrumentation */
  39506. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39507. "use strict";
  39508. __webpack_require__.r(__webpack_exports__);
  39509. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return SceneInstrumentation; });
  39510. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  39511. /**
  39512. * This class can be used to get instrumentation data from a Babylon engine
  39513. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  39514. */
  39515. var SceneInstrumentation = /** @class */ (function () {
  39516. /**
  39517. * Instantiates a new scene instrumentation.
  39518. * This class can be used to get instrumentation data from a Babylon engine
  39519. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  39520. * @param scene Defines the scene to instrument
  39521. */
  39522. function SceneInstrumentation(
  39523. /**
  39524. * Defines the scene to instrument
  39525. */
  39526. scene) {
  39527. var _this = this;
  39528. this.scene = scene;
  39529. this._captureActiveMeshesEvaluationTime = false;
  39530. this._activeMeshesEvaluationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39531. this._captureRenderTargetsRenderTime = false;
  39532. this._renderTargetsRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39533. this._captureFrameTime = false;
  39534. this._frameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39535. this._captureRenderTime = false;
  39536. this._renderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39537. this._captureInterFrameTime = false;
  39538. this._interFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39539. this._captureParticlesRenderTime = false;
  39540. this._particlesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39541. this._captureSpritesRenderTime = false;
  39542. this._spritesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39543. this._capturePhysicsTime = false;
  39544. this._physicsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39545. this._captureAnimationsTime = false;
  39546. this._animationsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39547. this._captureCameraRenderTime = false;
  39548. this._cameraRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39549. // Observers
  39550. this._onBeforeActiveMeshesEvaluationObserver = null;
  39551. this._onAfterActiveMeshesEvaluationObserver = null;
  39552. this._onBeforeRenderTargetsRenderObserver = null;
  39553. this._onAfterRenderTargetsRenderObserver = null;
  39554. this._onAfterRenderObserver = null;
  39555. this._onBeforeDrawPhaseObserver = null;
  39556. this._onAfterDrawPhaseObserver = null;
  39557. this._onBeforeAnimationsObserver = null;
  39558. this._onBeforeParticlesRenderingObserver = null;
  39559. this._onAfterParticlesRenderingObserver = null;
  39560. this._onBeforeSpritesRenderingObserver = null;
  39561. this._onAfterSpritesRenderingObserver = null;
  39562. this._onBeforePhysicsObserver = null;
  39563. this._onAfterPhysicsObserver = null;
  39564. this._onAfterAnimationsObserver = null;
  39565. this._onBeforeCameraRenderObserver = null;
  39566. this._onAfterCameraRenderObserver = null;
  39567. // Before render
  39568. this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(function () {
  39569. if (_this._captureActiveMeshesEvaluationTime) {
  39570. _this._activeMeshesEvaluationTime.fetchNewFrame();
  39571. }
  39572. if (_this._captureRenderTargetsRenderTime) {
  39573. _this._renderTargetsRenderTime.fetchNewFrame();
  39574. }
  39575. if (_this._captureFrameTime) {
  39576. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Scene rendering");
  39577. _this._frameTime.beginMonitoring();
  39578. }
  39579. if (_this._captureInterFrameTime) {
  39580. _this._interFrameTime.endMonitoring();
  39581. }
  39582. if (_this._captureParticlesRenderTime) {
  39583. _this._particlesRenderTime.fetchNewFrame();
  39584. }
  39585. if (_this._captureSpritesRenderTime) {
  39586. _this._spritesRenderTime.fetchNewFrame();
  39587. }
  39588. if (_this._captureAnimationsTime) {
  39589. _this._animationsTime.beginMonitoring();
  39590. }
  39591. _this.scene.getEngine()._drawCalls.fetchNewFrame();
  39592. _this.scene.getEngine()._textureCollisions.fetchNewFrame();
  39593. });
  39594. // After render
  39595. this._onAfterRenderObserver = scene.onAfterRenderObservable.add(function () {
  39596. if (_this._captureFrameTime) {
  39597. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Scene rendering");
  39598. _this._frameTime.endMonitoring();
  39599. }
  39600. if (_this._captureRenderTime) {
  39601. _this._renderTime.endMonitoring(false);
  39602. }
  39603. if (_this._captureInterFrameTime) {
  39604. _this._interFrameTime.beginMonitoring();
  39605. }
  39606. });
  39607. }
  39608. Object.defineProperty(SceneInstrumentation.prototype, "activeMeshesEvaluationTimeCounter", {
  39609. // Properties
  39610. /**
  39611. * Gets the perf counter used for active meshes evaluation time
  39612. */
  39613. get: function () {
  39614. return this._activeMeshesEvaluationTime;
  39615. },
  39616. enumerable: true,
  39617. configurable: true
  39618. });
  39619. Object.defineProperty(SceneInstrumentation.prototype, "captureActiveMeshesEvaluationTime", {
  39620. /**
  39621. * Gets the active meshes evaluation time capture status
  39622. */
  39623. get: function () {
  39624. return this._captureActiveMeshesEvaluationTime;
  39625. },
  39626. /**
  39627. * Enable or disable the active meshes evaluation time capture
  39628. */
  39629. set: function (value) {
  39630. var _this = this;
  39631. if (value === this._captureActiveMeshesEvaluationTime) {
  39632. return;
  39633. }
  39634. this._captureActiveMeshesEvaluationTime = value;
  39635. if (value) {
  39636. this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add(function () {
  39637. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Active meshes evaluation");
  39638. _this._activeMeshesEvaluationTime.beginMonitoring();
  39639. });
  39640. this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add(function () {
  39641. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Active meshes evaluation");
  39642. _this._activeMeshesEvaluationTime.endMonitoring();
  39643. });
  39644. }
  39645. else {
  39646. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  39647. this._onBeforeActiveMeshesEvaluationObserver = null;
  39648. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  39649. this._onAfterActiveMeshesEvaluationObserver = null;
  39650. }
  39651. },
  39652. enumerable: true,
  39653. configurable: true
  39654. });
  39655. Object.defineProperty(SceneInstrumentation.prototype, "renderTargetsRenderTimeCounter", {
  39656. /**
  39657. * Gets the perf counter used for render targets render time
  39658. */
  39659. get: function () {
  39660. return this._renderTargetsRenderTime;
  39661. },
  39662. enumerable: true,
  39663. configurable: true
  39664. });
  39665. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTargetsRenderTime", {
  39666. /**
  39667. * Gets the render targets render time capture status
  39668. */
  39669. get: function () {
  39670. return this._captureRenderTargetsRenderTime;
  39671. },
  39672. /**
  39673. * Enable or disable the render targets render time capture
  39674. */
  39675. set: function (value) {
  39676. var _this = this;
  39677. if (value === this._captureRenderTargetsRenderTime) {
  39678. return;
  39679. }
  39680. this._captureRenderTargetsRenderTime = value;
  39681. if (value) {
  39682. this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add(function () {
  39683. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Render targets rendering");
  39684. _this._renderTargetsRenderTime.beginMonitoring();
  39685. });
  39686. this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add(function () {
  39687. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Render targets rendering");
  39688. _this._renderTargetsRenderTime.endMonitoring(false);
  39689. });
  39690. }
  39691. else {
  39692. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  39693. this._onBeforeRenderTargetsRenderObserver = null;
  39694. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  39695. this._onAfterRenderTargetsRenderObserver = null;
  39696. }
  39697. },
  39698. enumerable: true,
  39699. configurable: true
  39700. });
  39701. Object.defineProperty(SceneInstrumentation.prototype, "particlesRenderTimeCounter", {
  39702. /**
  39703. * Gets the perf counter used for particles render time
  39704. */
  39705. get: function () {
  39706. return this._particlesRenderTime;
  39707. },
  39708. enumerable: true,
  39709. configurable: true
  39710. });
  39711. Object.defineProperty(SceneInstrumentation.prototype, "captureParticlesRenderTime", {
  39712. /**
  39713. * Gets the particles render time capture status
  39714. */
  39715. get: function () {
  39716. return this._captureParticlesRenderTime;
  39717. },
  39718. /**
  39719. * Enable or disable the particles render time capture
  39720. */
  39721. set: function (value) {
  39722. var _this = this;
  39723. if (value === this._captureParticlesRenderTime) {
  39724. return;
  39725. }
  39726. this._captureParticlesRenderTime = value;
  39727. if (value) {
  39728. this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add(function () {
  39729. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Particles");
  39730. _this._particlesRenderTime.beginMonitoring();
  39731. });
  39732. this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add(function () {
  39733. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Particles");
  39734. _this._particlesRenderTime.endMonitoring(false);
  39735. });
  39736. }
  39737. else {
  39738. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  39739. this._onBeforeParticlesRenderingObserver = null;
  39740. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  39741. this._onAfterParticlesRenderingObserver = null;
  39742. }
  39743. },
  39744. enumerable: true,
  39745. configurable: true
  39746. });
  39747. Object.defineProperty(SceneInstrumentation.prototype, "spritesRenderTimeCounter", {
  39748. /**
  39749. * Gets the perf counter used for sprites render time
  39750. */
  39751. get: function () {
  39752. return this._spritesRenderTime;
  39753. },
  39754. enumerable: true,
  39755. configurable: true
  39756. });
  39757. Object.defineProperty(SceneInstrumentation.prototype, "captureSpritesRenderTime", {
  39758. /**
  39759. * Gets the sprites render time capture status
  39760. */
  39761. get: function () {
  39762. return this._captureSpritesRenderTime;
  39763. },
  39764. /**
  39765. * Enable or disable the sprites render time capture
  39766. */
  39767. set: function (value) {
  39768. var _this = this;
  39769. if (value === this._captureSpritesRenderTime) {
  39770. return;
  39771. }
  39772. this._captureSpritesRenderTime = value;
  39773. if (!this.scene.spriteManagers) {
  39774. return;
  39775. }
  39776. if (value) {
  39777. this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add(function () {
  39778. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Sprites");
  39779. _this._spritesRenderTime.beginMonitoring();
  39780. });
  39781. this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add(function () {
  39782. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Sprites");
  39783. _this._spritesRenderTime.endMonitoring(false);
  39784. });
  39785. }
  39786. else {
  39787. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  39788. this._onBeforeSpritesRenderingObserver = null;
  39789. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  39790. this._onAfterSpritesRenderingObserver = null;
  39791. }
  39792. },
  39793. enumerable: true,
  39794. configurable: true
  39795. });
  39796. Object.defineProperty(SceneInstrumentation.prototype, "physicsTimeCounter", {
  39797. /**
  39798. * Gets the perf counter used for physics time
  39799. */
  39800. get: function () {
  39801. return this._physicsTime;
  39802. },
  39803. enumerable: true,
  39804. configurable: true
  39805. });
  39806. Object.defineProperty(SceneInstrumentation.prototype, "capturePhysicsTime", {
  39807. /**
  39808. * Gets the physics time capture status
  39809. */
  39810. get: function () {
  39811. return this._capturePhysicsTime;
  39812. },
  39813. /**
  39814. * Enable or disable the physics time capture
  39815. */
  39816. set: function (value) {
  39817. var _this = this;
  39818. if (value === this._capturePhysicsTime) {
  39819. return;
  39820. }
  39821. if (!this.scene.onBeforePhysicsObservable) {
  39822. return;
  39823. }
  39824. this._capturePhysicsTime = value;
  39825. if (value) {
  39826. this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add(function () {
  39827. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Physics");
  39828. _this._physicsTime.beginMonitoring();
  39829. });
  39830. this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add(function () {
  39831. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Physics");
  39832. _this._physicsTime.endMonitoring();
  39833. });
  39834. }
  39835. else {
  39836. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  39837. this._onBeforePhysicsObserver = null;
  39838. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  39839. this._onAfterPhysicsObserver = null;
  39840. }
  39841. },
  39842. enumerable: true,
  39843. configurable: true
  39844. });
  39845. Object.defineProperty(SceneInstrumentation.prototype, "animationsTimeCounter", {
  39846. /**
  39847. * Gets the perf counter used for animations time
  39848. */
  39849. get: function () {
  39850. return this._animationsTime;
  39851. },
  39852. enumerable: true,
  39853. configurable: true
  39854. });
  39855. Object.defineProperty(SceneInstrumentation.prototype, "captureAnimationsTime", {
  39856. /**
  39857. * Gets the animations time capture status
  39858. */
  39859. get: function () {
  39860. return this._captureAnimationsTime;
  39861. },
  39862. /**
  39863. * Enable or disable the animations time capture
  39864. */
  39865. set: function (value) {
  39866. var _this = this;
  39867. if (value === this._captureAnimationsTime) {
  39868. return;
  39869. }
  39870. this._captureAnimationsTime = value;
  39871. if (value) {
  39872. this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add(function () {
  39873. _this._animationsTime.endMonitoring();
  39874. });
  39875. }
  39876. else {
  39877. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  39878. this._onAfterAnimationsObserver = null;
  39879. }
  39880. },
  39881. enumerable: true,
  39882. configurable: true
  39883. });
  39884. Object.defineProperty(SceneInstrumentation.prototype, "frameTimeCounter", {
  39885. /**
  39886. * Gets the perf counter used for frame time capture
  39887. */
  39888. get: function () {
  39889. return this._frameTime;
  39890. },
  39891. enumerable: true,
  39892. configurable: true
  39893. });
  39894. Object.defineProperty(SceneInstrumentation.prototype, "captureFrameTime", {
  39895. /**
  39896. * Gets the frame time capture status
  39897. */
  39898. get: function () {
  39899. return this._captureFrameTime;
  39900. },
  39901. /**
  39902. * Enable or disable the frame time capture
  39903. */
  39904. set: function (value) {
  39905. this._captureFrameTime = value;
  39906. },
  39907. enumerable: true,
  39908. configurable: true
  39909. });
  39910. Object.defineProperty(SceneInstrumentation.prototype, "interFrameTimeCounter", {
  39911. /**
  39912. * Gets the perf counter used for inter-frames time capture
  39913. */
  39914. get: function () {
  39915. return this._interFrameTime;
  39916. },
  39917. enumerable: true,
  39918. configurable: true
  39919. });
  39920. Object.defineProperty(SceneInstrumentation.prototype, "captureInterFrameTime", {
  39921. /**
  39922. * Gets the inter-frames time capture status
  39923. */
  39924. get: function () {
  39925. return this._captureInterFrameTime;
  39926. },
  39927. /**
  39928. * Enable or disable the inter-frames time capture
  39929. */
  39930. set: function (value) {
  39931. this._captureInterFrameTime = value;
  39932. },
  39933. enumerable: true,
  39934. configurable: true
  39935. });
  39936. Object.defineProperty(SceneInstrumentation.prototype, "renderTimeCounter", {
  39937. /**
  39938. * Gets the perf counter used for render time capture
  39939. */
  39940. get: function () {
  39941. return this._renderTime;
  39942. },
  39943. enumerable: true,
  39944. configurable: true
  39945. });
  39946. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTime", {
  39947. /**
  39948. * Gets the render time capture status
  39949. */
  39950. get: function () {
  39951. return this._captureRenderTime;
  39952. },
  39953. /**
  39954. * Enable or disable the render time capture
  39955. */
  39956. set: function (value) {
  39957. var _this = this;
  39958. if (value === this._captureRenderTime) {
  39959. return;
  39960. }
  39961. this._captureRenderTime = value;
  39962. if (value) {
  39963. this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add(function () {
  39964. _this._renderTime.beginMonitoring();
  39965. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Main render");
  39966. });
  39967. this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add(function () {
  39968. _this._renderTime.endMonitoring(false);
  39969. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Main render");
  39970. });
  39971. }
  39972. else {
  39973. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  39974. this._onBeforeDrawPhaseObserver = null;
  39975. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  39976. this._onAfterDrawPhaseObserver = null;
  39977. }
  39978. },
  39979. enumerable: true,
  39980. configurable: true
  39981. });
  39982. Object.defineProperty(SceneInstrumentation.prototype, "cameraRenderTimeCounter", {
  39983. /**
  39984. * Gets the perf counter used for camera render time capture
  39985. */
  39986. get: function () {
  39987. return this._cameraRenderTime;
  39988. },
  39989. enumerable: true,
  39990. configurable: true
  39991. });
  39992. Object.defineProperty(SceneInstrumentation.prototype, "captureCameraRenderTime", {
  39993. /**
  39994. * Gets the camera render time capture status
  39995. */
  39996. get: function () {
  39997. return this._captureCameraRenderTime;
  39998. },
  39999. /**
  40000. * Enable or disable the camera render time capture
  40001. */
  40002. set: function (value) {
  40003. var _this = this;
  40004. if (value === this._captureCameraRenderTime) {
  40005. return;
  40006. }
  40007. this._captureCameraRenderTime = value;
  40008. if (value) {
  40009. this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function (camera) {
  40010. _this._cameraRenderTime.beginMonitoring();
  40011. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Rendering camera " + camera.name);
  40012. });
  40013. this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function (camera) {
  40014. _this._cameraRenderTime.endMonitoring(false);
  40015. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Rendering camera " + camera.name);
  40016. });
  40017. }
  40018. else {
  40019. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  40020. this._onBeforeCameraRenderObserver = null;
  40021. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  40022. this._onAfterCameraRenderObserver = null;
  40023. }
  40024. },
  40025. enumerable: true,
  40026. configurable: true
  40027. });
  40028. Object.defineProperty(SceneInstrumentation.prototype, "drawCallsCounter", {
  40029. /**
  40030. * Gets the perf counter used for draw calls
  40031. */
  40032. get: function () {
  40033. return this.scene.getEngine()._drawCalls;
  40034. },
  40035. enumerable: true,
  40036. configurable: true
  40037. });
  40038. Object.defineProperty(SceneInstrumentation.prototype, "textureCollisionsCounter", {
  40039. /**
  40040. * Gets the perf counter used for texture collisions
  40041. */
  40042. get: function () {
  40043. return this.scene.getEngine()._textureCollisions;
  40044. },
  40045. enumerable: true,
  40046. configurable: true
  40047. });
  40048. /**
  40049. * Dispose and release associated resources.
  40050. */
  40051. SceneInstrumentation.prototype.dispose = function () {
  40052. this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  40053. this._onAfterRenderObserver = null;
  40054. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  40055. this._onBeforeActiveMeshesEvaluationObserver = null;
  40056. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  40057. this._onAfterActiveMeshesEvaluationObserver = null;
  40058. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  40059. this._onBeforeRenderTargetsRenderObserver = null;
  40060. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  40061. this._onAfterRenderTargetsRenderObserver = null;
  40062. this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);
  40063. this._onBeforeAnimationsObserver = null;
  40064. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  40065. this._onBeforeParticlesRenderingObserver = null;
  40066. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  40067. this._onAfterParticlesRenderingObserver = null;
  40068. if (this._onBeforeSpritesRenderingObserver) {
  40069. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  40070. this._onBeforeSpritesRenderingObserver = null;
  40071. }
  40072. if (this._onAfterSpritesRenderingObserver) {
  40073. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  40074. this._onAfterSpritesRenderingObserver = null;
  40075. }
  40076. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  40077. this._onBeforeDrawPhaseObserver = null;
  40078. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  40079. this._onAfterDrawPhaseObserver = null;
  40080. if (this._onBeforePhysicsObserver) {
  40081. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  40082. this._onBeforePhysicsObserver = null;
  40083. }
  40084. if (this._onAfterPhysicsObserver) {
  40085. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  40086. this._onAfterPhysicsObserver = null;
  40087. }
  40088. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  40089. this._onAfterAnimationsObserver = null;
  40090. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  40091. this._onBeforeCameraRenderObserver = null;
  40092. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  40093. this._onAfterCameraRenderObserver = null;
  40094. this.scene = null;
  40095. };
  40096. return SceneInstrumentation;
  40097. }());
  40098. /***/ }),
  40099. /***/ "./Instrumentation/timeToken.ts":
  40100. /*!**************************************!*\
  40101. !*** ./Instrumentation/timeToken.ts ***!
  40102. \**************************************/
  40103. /*! exports provided: _TimeToken */
  40104. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40105. "use strict";
  40106. __webpack_require__.r(__webpack_exports__);
  40107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _TimeToken; });
  40108. /**
  40109. * @hidden
  40110. **/
  40111. var _TimeToken = /** @class */ (function () {
  40112. function _TimeToken() {
  40113. this._timeElapsedQueryEnded = false;
  40114. }
  40115. return _TimeToken;
  40116. }());
  40117. /***/ }),
  40118. /***/ "./Layers/effectLayer.ts":
  40119. /*!*******************************!*\
  40120. !*** ./Layers/effectLayer.ts ***!
  40121. \*******************************/
  40122. /*! exports provided: EffectLayer */
  40123. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40124. "use strict";
  40125. __webpack_require__.r(__webpack_exports__);
  40126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return EffectLayer; });
  40127. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40128. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  40129. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40130. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40131. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40132. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  40133. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  40134. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40135. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  40136. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  40137. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  40138. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  40139. /* harmony import */ var _Shaders_glowMapGeneration_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.fragment */ "./Shaders/glowMapGeneration.fragment.ts");
  40140. /* harmony import */ var _Shaders_glowMapGeneration_vertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.vertex */ "./Shaders/glowMapGeneration.vertex.ts");
  40141. /**
  40142. * The effect layer Helps adding post process effect blended with the main pass.
  40143. *
  40144. * This can be for instance use to generate glow or higlight effects on the scene.
  40145. *
  40146. * The effect layer class can not be used directly and is intented to inherited from to be
  40147. * customized per effects.
  40148. */
  40149. var EffectLayer = /** @class */ (function () {
  40150. /**
  40151. * Instantiates a new effect Layer and references it in the scene.
  40152. * @param name The name of the layer
  40153. * @param scene The scene to use the layer in
  40154. */
  40155. function EffectLayer(
  40156. /** The Friendly of the effect in the scene */
  40157. name, scene) {
  40158. this._vertexBuffers = {};
  40159. this._maxSize = 0;
  40160. this._mainTextureDesiredSize = { width: 0, height: 0 };
  40161. this._shouldRender = true;
  40162. this._postProcesses = [];
  40163. this._textures = [];
  40164. this._emissiveTextureAndColor = { texture: null, color: new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]() };
  40165. /**
  40166. * The clear color of the texture used to generate the glow map.
  40167. */
  40168. this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]();
  40169. /**
  40170. * Specifies wether the highlight layer is enabled or not.
  40171. */
  40172. this.isEnabled = true;
  40173. /**
  40174. * An event triggered when the effect layer has been disposed.
  40175. */
  40176. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40177. /**
  40178. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  40179. */
  40180. this.onBeforeRenderMainTextureObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40181. /**
  40182. * An event triggered when the generated texture is being merged in the scene.
  40183. */
  40184. this.onBeforeComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40185. /**
  40186. * An event triggered when the generated texture has been merged in the scene.
  40187. */
  40188. this.onAfterComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40189. /**
  40190. * An event triggered when the efffect layer changes its size.
  40191. */
  40192. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40193. this.name = name;
  40194. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  40195. EffectLayer._SceneComponentInitialization(this._scene);
  40196. this._engine = this._scene.getEngine();
  40197. this._maxSize = this._engine.getCaps().maxTextureSize;
  40198. this._scene.effectLayers.push(this);
  40199. // Generate Buffers
  40200. this._generateIndexBuffer();
  40201. this._genrateVertexBuffer();
  40202. }
  40203. Object.defineProperty(EffectLayer.prototype, "camera", {
  40204. /**
  40205. * Gets the camera attached to the layer.
  40206. */
  40207. get: function () {
  40208. return this._effectLayerOptions.camera;
  40209. },
  40210. enumerable: true,
  40211. configurable: true
  40212. });
  40213. Object.defineProperty(EffectLayer.prototype, "renderingGroupId", {
  40214. /**
  40215. * Gets the rendering group id the layer should render in.
  40216. */
  40217. get: function () {
  40218. return this._effectLayerOptions.renderingGroupId;
  40219. },
  40220. enumerable: true,
  40221. configurable: true
  40222. });
  40223. /**
  40224. * Initializes the effect layer with the required options.
  40225. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  40226. */
  40227. EffectLayer.prototype._init = function (options) {
  40228. // Adapt options
  40229. 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);
  40230. this._setMainTextureSize();
  40231. this._createMainTexture();
  40232. this._createTextureAndPostProcesses();
  40233. this._mergeEffect = this._createMergeEffect();
  40234. };
  40235. /**
  40236. * Generates the index buffer of the full screen quad blending to the main canvas.
  40237. */
  40238. EffectLayer.prototype._generateIndexBuffer = function () {
  40239. // Indices
  40240. var indices = [];
  40241. indices.push(0);
  40242. indices.push(1);
  40243. indices.push(2);
  40244. indices.push(0);
  40245. indices.push(2);
  40246. indices.push(3);
  40247. this._indexBuffer = this._engine.createIndexBuffer(indices);
  40248. };
  40249. /**
  40250. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  40251. */
  40252. EffectLayer.prototype._genrateVertexBuffer = function () {
  40253. // VBO
  40254. var vertices = [];
  40255. vertices.push(1, 1);
  40256. vertices.push(-1, 1);
  40257. vertices.push(-1, -1);
  40258. vertices.push(1, -1);
  40259. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"](this._engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind, false, false, 2);
  40260. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = vertexBuffer;
  40261. };
  40262. /**
  40263. * Sets the main texture desired size which is the closest power of two
  40264. * of the engine canvas size.
  40265. */
  40266. EffectLayer.prototype._setMainTextureSize = function () {
  40267. if (this._effectLayerOptions.mainTextureFixedSize) {
  40268. this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize;
  40269. this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize;
  40270. }
  40271. else {
  40272. this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio;
  40273. this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio;
  40274. this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width;
  40275. this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height;
  40276. }
  40277. this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width);
  40278. this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height);
  40279. };
  40280. /**
  40281. * Creates the main texture for the effect layer.
  40282. */
  40283. EffectLayer.prototype._createMainTexture = function () {
  40284. var _this = this;
  40285. this._mainTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerMainRTT", {
  40286. width: this._mainTextureDesiredSize.width,
  40287. height: this._mainTextureDesiredSize.height
  40288. }, this._scene, false, true, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  40289. this._mainTexture.activeCamera = this._effectLayerOptions.camera;
  40290. this._mainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  40291. this._mainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  40292. this._mainTexture.anisotropicFilteringLevel = 1;
  40293. this._mainTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE);
  40294. this._mainTexture.renderParticles = false;
  40295. this._mainTexture.renderList = null;
  40296. this._mainTexture.ignoreCameraViewport = true;
  40297. // Custom render function
  40298. this._mainTexture.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  40299. _this.onBeforeRenderMainTextureObservable.notifyObservers(_this);
  40300. var index;
  40301. var engine = _this._scene.getEngine();
  40302. if (depthOnlySubMeshes.length) {
  40303. engine.setColorWrite(false);
  40304. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  40305. _this._renderSubMesh(depthOnlySubMeshes.data[index]);
  40306. }
  40307. engine.setColorWrite(true);
  40308. }
  40309. for (index = 0; index < opaqueSubMeshes.length; index++) {
  40310. _this._renderSubMesh(opaqueSubMeshes.data[index]);
  40311. }
  40312. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  40313. _this._renderSubMesh(alphaTestSubMeshes.data[index]);
  40314. }
  40315. for (index = 0; index < transparentSubMeshes.length; index++) {
  40316. _this._renderSubMesh(transparentSubMeshes.data[index]);
  40317. }
  40318. };
  40319. this._mainTexture.onClearObservable.add(function (engine) {
  40320. engine.clear(_this.neutralColor, true, true, true);
  40321. });
  40322. };
  40323. /**
  40324. * Adds specific effects defines.
  40325. * @param defines The defines to add specifics to.
  40326. */
  40327. EffectLayer.prototype._addCustomEffectDefines = function (defines) {
  40328. // Nothing to add by default.
  40329. };
  40330. /**
  40331. * Checks for the readiness of the element composing the layer.
  40332. * @param subMesh the mesh to check for
  40333. * @param useInstances specify wether or not to use instances to render the mesh
  40334. * @param emissiveTexture the associated emissive texture used to generate the glow
  40335. * @return true if ready otherwise, false
  40336. */
  40337. EffectLayer.prototype._isReady = function (subMesh, useInstances, emissiveTexture) {
  40338. var material = subMesh.getMaterial();
  40339. if (!material) {
  40340. return false;
  40341. }
  40342. if (!material.isReadyForSubMesh(subMesh.getMesh(), subMesh, useInstances)) {
  40343. return false;
  40344. }
  40345. var defines = [];
  40346. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  40347. var mesh = subMesh.getMesh();
  40348. var uv1 = false;
  40349. var uv2 = false;
  40350. // Diffuse
  40351. if (material) {
  40352. var needAlphaTest = material.needAlphaTesting();
  40353. var diffuseTexture = material.getAlphaTestTexture();
  40354. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  40355. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  40356. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  40357. defines.push("#define DIFFUSE");
  40358. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  40359. diffuseTexture.coordinatesIndex === 1) {
  40360. defines.push("#define DIFFUSEUV2");
  40361. uv2 = true;
  40362. }
  40363. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  40364. defines.push("#define DIFFUSEUV1");
  40365. uv1 = true;
  40366. }
  40367. if (needAlphaTest) {
  40368. defines.push("#define ALPHATEST");
  40369. defines.push("#define ALPHATESTVALUE 0.4");
  40370. }
  40371. }
  40372. var opacityTexture = material.opacityTexture;
  40373. if (opacityTexture) {
  40374. defines.push("#define OPACITY");
  40375. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  40376. opacityTexture.coordinatesIndex === 1) {
  40377. defines.push("#define OPACITYUV2");
  40378. uv2 = true;
  40379. }
  40380. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  40381. defines.push("#define OPACITYUV1");
  40382. uv1 = true;
  40383. }
  40384. }
  40385. }
  40386. // Emissive
  40387. if (emissiveTexture) {
  40388. defines.push("#define EMISSIVE");
  40389. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  40390. emissiveTexture.coordinatesIndex === 1) {
  40391. defines.push("#define EMISSIVEUV2");
  40392. uv2 = true;
  40393. }
  40394. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  40395. defines.push("#define EMISSIVEUV1");
  40396. uv1 = true;
  40397. }
  40398. }
  40399. // Vertex
  40400. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind) && mesh.hasVertexAlpha) {
  40401. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind);
  40402. defines.push("#define VERTEXALPHA");
  40403. }
  40404. if (uv1) {
  40405. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind);
  40406. defines.push("#define UV1");
  40407. }
  40408. if (uv2) {
  40409. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind);
  40410. defines.push("#define UV2");
  40411. }
  40412. // Bones
  40413. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  40414. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesKind);
  40415. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsKind);
  40416. if (mesh.numBoneInfluencers > 4) {
  40417. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesExtraKind);
  40418. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsExtraKind);
  40419. }
  40420. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  40421. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  40422. }
  40423. else {
  40424. defines.push("#define NUM_BONE_INFLUENCERS 0");
  40425. }
  40426. // Morph targets
  40427. var manager = mesh.morphTargetManager;
  40428. var morphInfluencers = 0;
  40429. if (manager) {
  40430. if (manager.numInfluencers > 0) {
  40431. defines.push("#define MORPHTARGETS");
  40432. morphInfluencers = manager.numInfluencers;
  40433. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  40434. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  40435. }
  40436. }
  40437. // Instances
  40438. if (useInstances) {
  40439. defines.push("#define INSTANCES");
  40440. attribs.push("world0");
  40441. attribs.push("world1");
  40442. attribs.push("world2");
  40443. attribs.push("world3");
  40444. }
  40445. this._addCustomEffectDefines(defines);
  40446. // Get correct effect
  40447. var join = defines.join("\n");
  40448. if (this._cachedDefines !== join) {
  40449. this._cachedDefines = join;
  40450. this._effectLayerMapGenerationEffect = this._scene.getEngine().createEffect("glowMapGeneration", attribs, ["world", "mBones", "viewProjection",
  40451. "color", "morphTargetInfluences",
  40452. "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity"], ["diffuseSampler", "emissiveSampler", "opacitySampler"], join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  40453. }
  40454. return this._effectLayerMapGenerationEffect.isReady();
  40455. };
  40456. /**
  40457. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  40458. */
  40459. EffectLayer.prototype.render = function () {
  40460. var currentEffect = this._mergeEffect;
  40461. // Check
  40462. if (!currentEffect.isReady()) {
  40463. return;
  40464. }
  40465. for (var i = 0; i < this._postProcesses.length; i++) {
  40466. if (!this._postProcesses[i].isReady()) {
  40467. return;
  40468. }
  40469. }
  40470. var engine = this._scene.getEngine();
  40471. this.onBeforeComposeObservable.notifyObservers(this);
  40472. // Render
  40473. engine.enableEffect(currentEffect);
  40474. engine.setState(false);
  40475. // VBOs
  40476. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  40477. // Cache
  40478. var previousAlphaMode = engine.getAlphaMode();
  40479. // Go Blend.
  40480. engine.setAlphaMode(this._effectLayerOptions.alphaBlendingMode);
  40481. // Blends the map on the main canvas.
  40482. this._internalRender(currentEffect);
  40483. // Restore Alpha
  40484. engine.setAlphaMode(previousAlphaMode);
  40485. this.onAfterComposeObservable.notifyObservers(this);
  40486. // Handle size changes.
  40487. var size = this._mainTexture.getSize();
  40488. this._setMainTextureSize();
  40489. if (size.width !== this._mainTextureDesiredSize.width || size.height !== this._mainTextureDesiredSize.height) {
  40490. // Recreate RTT and post processes on size change.
  40491. this.onSizeChangedObservable.notifyObservers(this);
  40492. this._disposeTextureAndPostProcesses();
  40493. this._createMainTexture();
  40494. this._createTextureAndPostProcesses();
  40495. }
  40496. };
  40497. /**
  40498. * Determine if a given mesh will be used in the current effect.
  40499. * @param mesh mesh to test
  40500. * @returns true if the mesh will be used
  40501. */
  40502. EffectLayer.prototype.hasMesh = function (mesh) {
  40503. if (this.renderingGroupId === -1 || mesh.renderingGroupId === this.renderingGroupId) {
  40504. return true;
  40505. }
  40506. return false;
  40507. };
  40508. /**
  40509. * Returns true if the layer contains information to display, otherwise false.
  40510. * @returns true if the glow layer should be rendered
  40511. */
  40512. EffectLayer.prototype.shouldRender = function () {
  40513. return this.isEnabled && this._shouldRender;
  40514. };
  40515. /**
  40516. * Returns true if the mesh should render, otherwise false.
  40517. * @param mesh The mesh to render
  40518. * @returns true if it should render otherwise false
  40519. */
  40520. EffectLayer.prototype._shouldRenderMesh = function (mesh) {
  40521. return true;
  40522. };
  40523. /**
  40524. * Returns true if the mesh can be rendered, otherwise false.
  40525. * @param mesh The mesh to render
  40526. * @param material The material used on the mesh
  40527. * @returns true if it can be rendered otherwise false
  40528. */
  40529. EffectLayer.prototype._canRenderMesh = function (mesh, material) {
  40530. return !material.needAlphaBlendingForMesh(mesh);
  40531. };
  40532. /**
  40533. * Returns true if the mesh should render, otherwise false.
  40534. * @param mesh The mesh to render
  40535. * @returns true if it should render otherwise false
  40536. */
  40537. EffectLayer.prototype._shouldRenderEmissiveTextureForMesh = function () {
  40538. return true;
  40539. };
  40540. /**
  40541. * Renders the submesh passed in parameter to the generation map.
  40542. */
  40543. EffectLayer.prototype._renderSubMesh = function (subMesh) {
  40544. var _this = this;
  40545. if (!this.shouldRender()) {
  40546. return;
  40547. }
  40548. var material = subMesh.getMaterial();
  40549. var mesh = subMesh.getRenderingMesh();
  40550. var scene = this._scene;
  40551. var engine = scene.getEngine();
  40552. if (!material) {
  40553. return;
  40554. }
  40555. // Do not block in blend mode.
  40556. if (!this._canRenderMesh(mesh, material)) {
  40557. return;
  40558. }
  40559. // Culling
  40560. engine.setState(material.backFaceCulling);
  40561. // Managing instances
  40562. var batch = mesh._getInstancesRenderList(subMesh._id);
  40563. if (batch.mustReturn) {
  40564. return;
  40565. }
  40566. // Early Exit per mesh
  40567. if (!this._shouldRenderMesh(mesh)) {
  40568. return;
  40569. }
  40570. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  40571. this._setEmissiveTextureAndColor(mesh, subMesh, material);
  40572. if (this._isReady(subMesh, hardwareInstancedRendering, this._emissiveTextureAndColor.texture)) {
  40573. engine.enableEffect(this._effectLayerMapGenerationEffect);
  40574. mesh._bind(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode);
  40575. this._effectLayerMapGenerationEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  40576. this._effectLayerMapGenerationEffect.setFloat4("color", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a);
  40577. var needAlphaTest = material.needAlphaTesting();
  40578. var diffuseTexture = material.getAlphaTestTexture();
  40579. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  40580. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  40581. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  40582. this._effectLayerMapGenerationEffect.setTexture("diffuseSampler", diffuseTexture);
  40583. var textureMatrix = diffuseTexture.getTextureMatrix();
  40584. if (textureMatrix) {
  40585. this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix", textureMatrix);
  40586. }
  40587. }
  40588. var opacityTexture = material.opacityTexture;
  40589. if (opacityTexture) {
  40590. this._effectLayerMapGenerationEffect.setTexture("opacitySampler", opacityTexture);
  40591. this._effectLayerMapGenerationEffect.setFloat("opacityIntensity", opacityTexture.level);
  40592. var textureMatrix = opacityTexture.getTextureMatrix();
  40593. if (textureMatrix) {
  40594. this._effectLayerMapGenerationEffect.setMatrix("opacityMatrix", textureMatrix);
  40595. }
  40596. }
  40597. // Glow emissive only
  40598. if (this._emissiveTextureAndColor.texture) {
  40599. this._effectLayerMapGenerationEffect.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture);
  40600. this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix());
  40601. }
  40602. // Bones
  40603. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  40604. this._effectLayerMapGenerationEffect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  40605. }
  40606. // Morph targets
  40607. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effectLayerMapGenerationEffect);
  40608. // Draw
  40609. mesh._processRendering(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effectLayerMapGenerationEffect.setMatrix("world", world); });
  40610. }
  40611. else {
  40612. // Need to reset refresh rate of the main map
  40613. this._mainTexture.resetRefreshCounter();
  40614. }
  40615. };
  40616. /**
  40617. * Rebuild the required buffers.
  40618. * @hidden Internal use only.
  40619. */
  40620. EffectLayer.prototype._rebuild = function () {
  40621. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  40622. if (vb) {
  40623. vb._rebuild();
  40624. }
  40625. this._generateIndexBuffer();
  40626. };
  40627. /**
  40628. * Dispose only the render target textures and post process.
  40629. */
  40630. EffectLayer.prototype._disposeTextureAndPostProcesses = function () {
  40631. this._mainTexture.dispose();
  40632. for (var i = 0; i < this._postProcesses.length; i++) {
  40633. if (this._postProcesses[i]) {
  40634. this._postProcesses[i].dispose();
  40635. }
  40636. }
  40637. this._postProcesses = [];
  40638. for (var i = 0; i < this._textures.length; i++) {
  40639. if (this._textures[i]) {
  40640. this._textures[i].dispose();
  40641. }
  40642. }
  40643. this._textures = [];
  40644. };
  40645. /**
  40646. * Dispose the highlight layer and free resources.
  40647. */
  40648. EffectLayer.prototype.dispose = function () {
  40649. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  40650. if (vertexBuffer) {
  40651. vertexBuffer.dispose();
  40652. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = null;
  40653. }
  40654. if (this._indexBuffer) {
  40655. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  40656. this._indexBuffer = null;
  40657. }
  40658. // Clean textures and post processes
  40659. this._disposeTextureAndPostProcesses();
  40660. // Remove from scene
  40661. var index = this._scene.effectLayers.indexOf(this, 0);
  40662. if (index > -1) {
  40663. this._scene.effectLayers.splice(index, 1);
  40664. }
  40665. // Callback
  40666. this.onDisposeObservable.notifyObservers(this);
  40667. this.onDisposeObservable.clear();
  40668. this.onBeforeRenderMainTextureObservable.clear();
  40669. this.onBeforeComposeObservable.clear();
  40670. this.onAfterComposeObservable.clear();
  40671. this.onSizeChangedObservable.clear();
  40672. };
  40673. /**
  40674. * Gets the class name of the effect layer
  40675. * @returns the string with the class name of the effect layer
  40676. */
  40677. EffectLayer.prototype.getClassName = function () {
  40678. return "EffectLayer";
  40679. };
  40680. /**
  40681. * Creates an effect layer from parsed effect layer data
  40682. * @param parsedEffectLayer defines effect layer data
  40683. * @param scene defines the current scene
  40684. * @param rootUrl defines the root URL containing the effect layer information
  40685. * @returns a parsed effect Layer
  40686. */
  40687. EffectLayer.Parse = function (parsedEffectLayer, scene, rootUrl) {
  40688. var effectLayerType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedEffectLayer.customType);
  40689. return effectLayerType.Parse(parsedEffectLayer, scene, rootUrl);
  40690. };
  40691. /** @hidden */
  40692. EffectLayer._SceneComponentInitialization = function (_) {
  40693. throw "Import EffectLayerSceneComponent before creating EffectLayer.";
  40694. };
  40695. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  40696. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  40697. ], EffectLayer.prototype, "name", void 0);
  40698. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  40699. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  40700. ], EffectLayer.prototype, "neutralColor", void 0);
  40701. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  40702. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  40703. ], EffectLayer.prototype, "isEnabled", void 0);
  40704. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  40705. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsCameraReference"])()
  40706. ], EffectLayer.prototype, "camera", null);
  40707. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  40708. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  40709. ], EffectLayer.prototype, "renderingGroupId", null);
  40710. return EffectLayer;
  40711. }());
  40712. /***/ }),
  40713. /***/ "./Layers/effectLayerSceneComponent.ts":
  40714. /*!*********************************************!*\
  40715. !*** ./Layers/effectLayerSceneComponent.ts ***!
  40716. \*********************************************/
  40717. /*! exports provided: EffectLayerSceneComponent */
  40718. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40719. "use strict";
  40720. __webpack_require__.r(__webpack_exports__);
  40721. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return EffectLayerSceneComponent; });
  40722. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  40723. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  40724. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  40725. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  40726. // Adds the parser to the scene parsers.
  40727. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER, function (parsedData, scene, container, rootUrl) {
  40728. if (parsedData.effectLayers) {
  40729. if (!container.effectLayers) {
  40730. container.effectLayers = new Array();
  40731. }
  40732. for (var index = 0; index < parsedData.effectLayers.length; index++) {
  40733. var effectLayer = _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"].Parse(parsedData.effectLayers[index], scene, rootUrl);
  40734. container.effectLayers.push(effectLayer);
  40735. }
  40736. }
  40737. });
  40738. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.removeEffectLayer = function (toRemove) {
  40739. var index = this.effectLayers.indexOf(toRemove);
  40740. if (index !== -1) {
  40741. this.effectLayers.splice(index, 1);
  40742. }
  40743. return index;
  40744. };
  40745. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.addEffectLayer = function (newEffectLayer) {
  40746. this.effectLayers.push(newEffectLayer);
  40747. };
  40748. /**
  40749. * Defines the layer scene component responsible to manage any effect layers
  40750. * in a given scene.
  40751. */
  40752. var EffectLayerSceneComponent = /** @class */ (function () {
  40753. /**
  40754. * Creates a new instance of the component for the given scene
  40755. * @param scene Defines the scene to register the component in
  40756. */
  40757. function EffectLayerSceneComponent(scene) {
  40758. /**
  40759. * The component name helpfull to identify the component in the list of scene components.
  40760. */
  40761. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER;
  40762. this._renderEffects = false;
  40763. this._needStencil = false;
  40764. this._previousStencilState = false;
  40765. this.scene = scene;
  40766. this._engine = scene.getEngine();
  40767. scene.effectLayers = new Array();
  40768. }
  40769. /**
  40770. * Registers the component in a given scene
  40771. */
  40772. EffectLayerSceneComponent.prototype.register = function () {
  40773. this.scene._isReadyForMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh);
  40774. this.scene._cameraDrawRenderTargetStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture);
  40775. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil);
  40776. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup);
  40777. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack);
  40778. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera);
  40779. };
  40780. /**
  40781. * Rebuilds the elements related to this component in case of
  40782. * context lost for instance.
  40783. */
  40784. EffectLayerSceneComponent.prototype.rebuild = function () {
  40785. var layers = this.scene.effectLayers;
  40786. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  40787. var effectLayer = layers_1[_i];
  40788. effectLayer._rebuild();
  40789. }
  40790. };
  40791. /**
  40792. * Serializes the component data to the specified json object
  40793. * @param serializationObject The object to serialize to
  40794. */
  40795. EffectLayerSceneComponent.prototype.serialize = function (serializationObject) {
  40796. // Effect layers
  40797. serializationObject.effectLayers = [];
  40798. var layers = this.scene.effectLayers;
  40799. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  40800. var effectLayer = layers_2[_i];
  40801. if (effectLayer.serialize) {
  40802. serializationObject.effectLayers.push(effectLayer.serialize());
  40803. }
  40804. }
  40805. };
  40806. /**
  40807. * Adds all the element from the container to the scene
  40808. * @param container the container holding the elements
  40809. */
  40810. EffectLayerSceneComponent.prototype.addFromContainer = function (container) {
  40811. var _this = this;
  40812. if (!container.effectLayers) {
  40813. return;
  40814. }
  40815. container.effectLayers.forEach(function (o) {
  40816. _this.scene.addEffectLayer(o);
  40817. });
  40818. };
  40819. /**
  40820. * Removes all the elements in the container from the scene
  40821. * @param container contains the elements to remove
  40822. */
  40823. EffectLayerSceneComponent.prototype.removeFromContainer = function (container) {
  40824. var _this = this;
  40825. if (!container.effectLayers) {
  40826. return;
  40827. }
  40828. container.effectLayers.forEach(function (o) {
  40829. _this.scene.removeEffectLayer(o);
  40830. });
  40831. };
  40832. /**
  40833. * Disposes the component and the associated ressources.
  40834. */
  40835. EffectLayerSceneComponent.prototype.dispose = function () {
  40836. var layers = this.scene.effectLayers;
  40837. while (layers.length) {
  40838. layers[0].dispose();
  40839. }
  40840. };
  40841. EffectLayerSceneComponent.prototype._isReadyForMesh = function (mesh, hardwareInstancedRendering) {
  40842. var layers = this.scene.effectLayers;
  40843. for (var _i = 0, layers_3 = layers; _i < layers_3.length; _i++) {
  40844. var layer = layers_3[_i];
  40845. if (!layer.hasMesh(mesh)) {
  40846. continue;
  40847. }
  40848. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  40849. var subMesh = _b[_a];
  40850. if (!layer.isReady(subMesh, hardwareInstancedRendering)) {
  40851. return false;
  40852. }
  40853. }
  40854. }
  40855. return true;
  40856. };
  40857. EffectLayerSceneComponent.prototype._renderMainTexture = function (camera) {
  40858. this._renderEffects = false;
  40859. this._needStencil = false;
  40860. var layers = this.scene.effectLayers;
  40861. if (layers && layers.length > 0) {
  40862. this._previousStencilState = this._engine.getStencilBuffer();
  40863. for (var _i = 0, layers_4 = layers; _i < layers_4.length; _i++) {
  40864. var effectLayer = layers_4[_i];
  40865. if (effectLayer.shouldRender() &&
  40866. (!effectLayer.camera ||
  40867. (effectLayer.camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && camera === effectLayer.camera) ||
  40868. (effectLayer.camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && effectLayer.camera._rigCameras.indexOf(camera) > -1))) {
  40869. this._renderEffects = true;
  40870. this._needStencil = this._needStencil || effectLayer.needStencil();
  40871. var renderTarget = effectLayer._mainTexture;
  40872. if (renderTarget._shouldRender()) {
  40873. this.scene.incrementRenderId();
  40874. renderTarget.render(false, false);
  40875. }
  40876. }
  40877. }
  40878. this.scene.incrementRenderId();
  40879. }
  40880. };
  40881. EffectLayerSceneComponent.prototype._setStencil = function () {
  40882. // Activate effect Layer stencil
  40883. if (this._needStencil) {
  40884. this._engine.setStencilBuffer(true);
  40885. }
  40886. };
  40887. EffectLayerSceneComponent.prototype._setStencilBack = function () {
  40888. // Restore effect Layer stencil
  40889. if (this._needStencil) {
  40890. this._engine.setStencilBuffer(this._previousStencilState);
  40891. }
  40892. };
  40893. EffectLayerSceneComponent.prototype._draw = function (renderingGroupId) {
  40894. if (this._renderEffects) {
  40895. this._engine.setDepthBuffer(false);
  40896. var layers = this.scene.effectLayers;
  40897. for (var i = 0; i < layers.length; i++) {
  40898. var effectLayer = layers[i];
  40899. if (effectLayer.renderingGroupId === renderingGroupId) {
  40900. if (effectLayer.shouldRender()) {
  40901. effectLayer.render();
  40902. }
  40903. }
  40904. }
  40905. this._engine.setDepthBuffer(true);
  40906. }
  40907. };
  40908. EffectLayerSceneComponent.prototype._drawCamera = function () {
  40909. if (this._renderEffects) {
  40910. this._draw(-1);
  40911. }
  40912. };
  40913. EffectLayerSceneComponent.prototype._drawRenderingGroup = function (index) {
  40914. if (!this.scene._isInIntermediateRendering() && this._renderEffects) {
  40915. this._draw(index);
  40916. }
  40917. };
  40918. return EffectLayerSceneComponent;
  40919. }());
  40920. _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"]._SceneComponentInitialization = function (scene) {
  40921. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER);
  40922. if (!component) {
  40923. component = new EffectLayerSceneComponent(scene);
  40924. scene._addComponent(component);
  40925. }
  40926. };
  40927. /***/ }),
  40928. /***/ "./Layers/glowLayer.ts":
  40929. /*!*****************************!*\
  40930. !*** ./Layers/glowLayer.ts ***!
  40931. \*****************************/
  40932. /*! exports provided: GlowLayer */
  40933. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40934. "use strict";
  40935. __webpack_require__.r(__webpack_exports__);
  40936. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return GlowLayer; });
  40937. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40938. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  40939. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40940. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40941. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  40942. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40943. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  40944. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  40945. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  40946. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  40947. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  40948. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  40949. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  40950. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  40951. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  40952. _abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"].prototype.getGlowLayerByName = function (name) {
  40953. for (var index = 0; index < this.effectLayers.length; index++) {
  40954. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === GlowLayer.EffectName) {
  40955. return this.effectLayers[index];
  40956. }
  40957. }
  40958. return null;
  40959. };
  40960. /**
  40961. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  40962. *
  40963. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  40964. * glowy meshes to your scene.
  40965. *
  40966. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  40967. */
  40968. var GlowLayer = /** @class */ (function (_super) {
  40969. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowLayer, _super);
  40970. /**
  40971. * Instantiates a new glow Layer and references it to the scene.
  40972. * @param name The name of the layer
  40973. * @param scene The scene to use the layer in
  40974. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  40975. */
  40976. function GlowLayer(name, scene, options) {
  40977. var _this = _super.call(this, name, scene) || this;
  40978. _this._intensity = 1.0;
  40979. _this._includedOnlyMeshes = [];
  40980. _this._excludedMeshes = [];
  40981. _this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 1);
  40982. // Adapt options
  40983. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ mainTextureRatio: GlowLayer.DefaultTextureRatio, blurKernelSize: 32, mainTextureFixedSize: undefined, camera: null, mainTextureSamples: 1, renderingGroupId: -1 }, options);
  40984. // Initialize the layer
  40985. _this._init({
  40986. alphaBlendingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ALPHA_ADD,
  40987. camera: _this._options.camera,
  40988. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  40989. mainTextureRatio: _this._options.mainTextureRatio,
  40990. renderingGroupId: _this._options.renderingGroupId
  40991. });
  40992. return _this;
  40993. }
  40994. Object.defineProperty(GlowLayer.prototype, "blurKernelSize", {
  40995. /**
  40996. * Gets the kernel size of the blur.
  40997. */
  40998. get: function () {
  40999. return this._horizontalBlurPostprocess1.kernel;
  41000. },
  41001. /**
  41002. * Sets the kernel size of the blur.
  41003. */
  41004. set: function (value) {
  41005. this._horizontalBlurPostprocess1.kernel = value;
  41006. this._verticalBlurPostprocess1.kernel = value;
  41007. this._horizontalBlurPostprocess2.kernel = value;
  41008. this._verticalBlurPostprocess2.kernel = value;
  41009. },
  41010. enumerable: true,
  41011. configurable: true
  41012. });
  41013. Object.defineProperty(GlowLayer.prototype, "intensity", {
  41014. /**
  41015. * Gets the glow intensity.
  41016. */
  41017. get: function () {
  41018. return this._intensity;
  41019. },
  41020. /**
  41021. * Sets the glow intensity.
  41022. */
  41023. set: function (value) {
  41024. this._intensity = value;
  41025. },
  41026. enumerable: true,
  41027. configurable: true
  41028. });
  41029. /**
  41030. * Get the effect name of the layer.
  41031. * @return The effect name
  41032. */
  41033. GlowLayer.prototype.getEffectName = function () {
  41034. return GlowLayer.EffectName;
  41035. };
  41036. /**
  41037. * Create the merge effect. This is the shader use to blit the information back
  41038. * to the main canvas at the end of the scene rendering.
  41039. */
  41040. GlowLayer.prototype._createMergeEffect = function () {
  41041. // Effect
  41042. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler", "textureSampler2"], "#define EMISSIVE \n");
  41043. };
  41044. /**
  41045. * Creates the render target textures and post processes used in the glow layer.
  41046. */
  41047. GlowLayer.prototype._createTextureAndPostProcesses = function () {
  41048. var _this = this;
  41049. var blurTextureWidth = this._mainTextureDesiredSize.width;
  41050. var blurTextureHeight = this._mainTextureDesiredSize.height;
  41051. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  41052. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  41053. var textureType = 0;
  41054. if (this._engine.getCaps().textureHalfFloatRender) {
  41055. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_HALF_FLOAT;
  41056. }
  41057. else {
  41058. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  41059. }
  41060. this._blurTexture1 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT", {
  41061. width: blurTextureWidth,
  41062. height: blurTextureHeight
  41063. }, this._scene, false, true, textureType);
  41064. this._blurTexture1.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41065. this._blurTexture1.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41066. this._blurTexture1.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  41067. this._blurTexture1.renderParticles = false;
  41068. this._blurTexture1.ignoreCameraViewport = true;
  41069. var blurTextureWidth2 = Math.floor(blurTextureWidth / 2);
  41070. var blurTextureHeight2 = Math.floor(blurTextureHeight / 2);
  41071. this._blurTexture2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT2", {
  41072. width: blurTextureWidth2,
  41073. height: blurTextureHeight2
  41074. }, this._scene, false, true, textureType);
  41075. this._blurTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41076. this._blurTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41077. this._blurTexture2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  41078. this._blurTexture2.renderParticles = false;
  41079. this._blurTexture2.ignoreCameraViewport = true;
  41080. this._textures = [this._blurTexture1, this._blurTexture2];
  41081. 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, {
  41082. width: blurTextureWidth,
  41083. height: blurTextureHeight
  41084. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41085. this._horizontalBlurPostprocess1.width = blurTextureWidth;
  41086. this._horizontalBlurPostprocess1.height = blurTextureHeight;
  41087. this._horizontalBlurPostprocess1.onApplyObservable.add(function (effect) {
  41088. effect.setTexture("textureSampler", _this._mainTexture);
  41089. });
  41090. 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, {
  41091. width: blurTextureWidth,
  41092. height: blurTextureHeight
  41093. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41094. 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, {
  41095. width: blurTextureWidth2,
  41096. height: blurTextureHeight2
  41097. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41098. this._horizontalBlurPostprocess2.width = blurTextureWidth2;
  41099. this._horizontalBlurPostprocess2.height = blurTextureHeight2;
  41100. this._horizontalBlurPostprocess2.onApplyObservable.add(function (effect) {
  41101. effect.setTexture("textureSampler", _this._blurTexture1);
  41102. });
  41103. 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, {
  41104. width: blurTextureWidth2,
  41105. height: blurTextureHeight2
  41106. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41107. this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  41108. this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1];
  41109. this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  41110. this._mainTexture.samples = this._options.mainTextureSamples;
  41111. this._mainTexture.onAfterUnbindObservable.add(function () {
  41112. var internalTexture = _this._blurTexture1.getInternalTexture();
  41113. if (internalTexture) {
  41114. _this._scene.postProcessManager.directRender(_this._postProcesses1, internalTexture, true);
  41115. internalTexture = _this._blurTexture2.getInternalTexture();
  41116. if (internalTexture) {
  41117. _this._scene.postProcessManager.directRender(_this._postProcesses2, internalTexture, true);
  41118. }
  41119. }
  41120. });
  41121. // Prevent autoClear.
  41122. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  41123. };
  41124. /**
  41125. * Checks for the readiness of the element composing the layer.
  41126. * @param subMesh the mesh to check for
  41127. * @param useInstances specify wether or not to use instances to render the mesh
  41128. * @param emissiveTexture the associated emissive texture used to generate the glow
  41129. * @return true if ready otherwise, false
  41130. */
  41131. GlowLayer.prototype.isReady = function (subMesh, useInstances) {
  41132. var material = subMesh.getMaterial();
  41133. var mesh = subMesh.getRenderingMesh();
  41134. if (!material || !mesh) {
  41135. return false;
  41136. }
  41137. var emissiveTexture = material.emissiveTexture;
  41138. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  41139. };
  41140. /**
  41141. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  41142. */
  41143. GlowLayer.prototype.needStencil = function () {
  41144. return false;
  41145. };
  41146. /**
  41147. * Returns true if the mesh can be rendered, otherwise false.
  41148. * @param mesh The mesh to render
  41149. * @param material The material used on the mesh
  41150. * @returns true if it can be rendered otherwise false
  41151. */
  41152. GlowLayer.prototype._canRenderMesh = function (mesh, material) {
  41153. return true;
  41154. };
  41155. /**
  41156. * Implementation specific of rendering the generating effect on the main canvas.
  41157. * @param effect The effect used to render through
  41158. */
  41159. GlowLayer.prototype._internalRender = function (effect) {
  41160. // Texture
  41161. effect.setTexture("textureSampler", this._blurTexture1);
  41162. effect.setTexture("textureSampler2", this._blurTexture2);
  41163. effect.setFloat("offset", this._intensity);
  41164. // Cache
  41165. var engine = this._engine;
  41166. var previousStencilBuffer = engine.getStencilBuffer();
  41167. // Draw order
  41168. engine.setStencilBuffer(false);
  41169. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, 6);
  41170. // Draw order
  41171. engine.setStencilBuffer(previousStencilBuffer);
  41172. };
  41173. /**
  41174. * Sets the required values for both the emissive texture and and the main color.
  41175. */
  41176. GlowLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  41177. var textureLevel = 1.0;
  41178. if (this.customEmissiveTextureSelector) {
  41179. this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
  41180. }
  41181. else {
  41182. if (material) {
  41183. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  41184. if (this._emissiveTextureAndColor.texture) {
  41185. textureLevel = this._emissiveTextureAndColor.texture.level;
  41186. }
  41187. }
  41188. else {
  41189. this._emissiveTextureAndColor.texture = null;
  41190. }
  41191. }
  41192. if (this.customEmissiveColorSelector) {
  41193. this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
  41194. }
  41195. else {
  41196. if (material.emissiveColor) {
  41197. this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, material.alpha);
  41198. }
  41199. else {
  41200. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  41201. }
  41202. }
  41203. };
  41204. /**
  41205. * Returns true if the mesh should render, otherwise false.
  41206. * @param mesh The mesh to render
  41207. * @returns true if it should render otherwise false
  41208. */
  41209. GlowLayer.prototype._shouldRenderMesh = function (mesh) {
  41210. return this.hasMesh(mesh);
  41211. };
  41212. /**
  41213. * Adds specific effects defines.
  41214. * @param defines The defines to add specifics to.
  41215. */
  41216. GlowLayer.prototype._addCustomEffectDefines = function (defines) {
  41217. defines.push("#define GLOW");
  41218. };
  41219. /**
  41220. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  41221. * @param mesh The mesh to exclude from the glow layer
  41222. */
  41223. GlowLayer.prototype.addExcludedMesh = function (mesh) {
  41224. if (this._excludedMeshes.indexOf(mesh.uniqueId) === -1) {
  41225. this._excludedMeshes.push(mesh.uniqueId);
  41226. }
  41227. };
  41228. /**
  41229. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  41230. * @param mesh The mesh to remove
  41231. */
  41232. GlowLayer.prototype.removeExcludedMesh = function (mesh) {
  41233. var index = this._excludedMeshes.indexOf(mesh.uniqueId);
  41234. if (index !== -1) {
  41235. this._excludedMeshes.splice(index, 1);
  41236. }
  41237. };
  41238. /**
  41239. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  41240. * @param mesh The mesh to include in the glow layer
  41241. */
  41242. GlowLayer.prototype.addIncludedOnlyMesh = function (mesh) {
  41243. if (this._includedOnlyMeshes.indexOf(mesh.uniqueId) === -1) {
  41244. this._includedOnlyMeshes.push(mesh.uniqueId);
  41245. }
  41246. };
  41247. /**
  41248. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  41249. * @param mesh The mesh to remove
  41250. */
  41251. GlowLayer.prototype.removeIncludedOnlyMesh = function (mesh) {
  41252. var index = this._includedOnlyMeshes.indexOf(mesh.uniqueId);
  41253. if (index !== -1) {
  41254. this._includedOnlyMeshes.splice(index, 1);
  41255. }
  41256. };
  41257. /**
  41258. * Determine if a given mesh will be used in the glow layer
  41259. * @param mesh The mesh to test
  41260. * @returns true if the mesh will be highlighted by the current glow layer
  41261. */
  41262. GlowLayer.prototype.hasMesh = function (mesh) {
  41263. if (!_super.prototype.hasMesh.call(this, mesh)) {
  41264. return false;
  41265. }
  41266. // Included Mesh
  41267. if (this._includedOnlyMeshes.length) {
  41268. return this._includedOnlyMeshes.indexOf(mesh.uniqueId) !== -1;
  41269. }
  41270. // Excluded Mesh
  41271. if (this._excludedMeshes.length) {
  41272. return this._excludedMeshes.indexOf(mesh.uniqueId) === -1;
  41273. }
  41274. return true;
  41275. };
  41276. /**
  41277. * Free any resources and references associated to a mesh.
  41278. * Internal use
  41279. * @param mesh The mesh to free.
  41280. * @hidden
  41281. */
  41282. GlowLayer.prototype._disposeMesh = function (mesh) {
  41283. this.removeIncludedOnlyMesh(mesh);
  41284. this.removeExcludedMesh(mesh);
  41285. };
  41286. /**
  41287. * Gets the class name of the effect layer
  41288. * @returns the string with the class name of the effect layer
  41289. */
  41290. GlowLayer.prototype.getClassName = function () {
  41291. return "GlowLayer";
  41292. };
  41293. /**
  41294. * Serializes this glow layer
  41295. * @returns a serialized glow layer object
  41296. */
  41297. GlowLayer.prototype.serialize = function () {
  41298. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  41299. serializationObject.customType = "BABYLON.GlowLayer";
  41300. var index;
  41301. // Included meshes
  41302. serializationObject.includedMeshes = [];
  41303. if (this._includedOnlyMeshes.length) {
  41304. for (index = 0; index < this._includedOnlyMeshes.length; index++) {
  41305. var mesh = this._scene.getMeshByUniqueID(this._includedOnlyMeshes[index]);
  41306. if (mesh) {
  41307. serializationObject.includedMeshes.push(mesh.id);
  41308. }
  41309. }
  41310. }
  41311. // Excluded meshes
  41312. serializationObject.excludedMeshes = [];
  41313. if (this._excludedMeshes.length) {
  41314. for (index = 0; index < this._excludedMeshes.length; index++) {
  41315. var mesh = this._scene.getMeshByUniqueID(this._excludedMeshes[index]);
  41316. if (mesh) {
  41317. serializationObject.excludedMeshes.push(mesh.id);
  41318. }
  41319. }
  41320. }
  41321. return serializationObject;
  41322. };
  41323. /**
  41324. * Creates a Glow Layer from parsed glow layer data
  41325. * @param parsedGlowLayer defines glow layer data
  41326. * @param scene defines the current scene
  41327. * @param rootUrl defines the root URL containing the glow layer information
  41328. * @returns a parsed Glow Layer
  41329. */
  41330. GlowLayer.Parse = function (parsedGlowLayer, scene, rootUrl) {
  41331. var gl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new GlowLayer(parsedGlowLayer.name, scene, parsedGlowLayer.options); }, parsedGlowLayer, scene, rootUrl);
  41332. var index;
  41333. // Excluded meshes
  41334. for (index = 0; index < parsedGlowLayer.excludedMeshes.length; index++) {
  41335. var mesh = scene.getMeshByID(parsedGlowLayer.excludedMeshes[index]);
  41336. if (mesh) {
  41337. gl.addExcludedMesh(mesh);
  41338. }
  41339. }
  41340. // Included meshes
  41341. for (index = 0; index < parsedGlowLayer.includedMeshes.length; index++) {
  41342. var mesh = scene.getMeshByID(parsedGlowLayer.includedMeshes[index]);
  41343. if (mesh) {
  41344. gl.addIncludedOnlyMesh(mesh);
  41345. }
  41346. }
  41347. return gl;
  41348. };
  41349. /**
  41350. * Effect Name of the layer.
  41351. */
  41352. GlowLayer.EffectName = "GlowLayer";
  41353. /**
  41354. * The default blur kernel size used for the glow.
  41355. */
  41356. GlowLayer.DefaultBlurKernelSize = 32;
  41357. /**
  41358. * The default texture size ratio used for the glow.
  41359. */
  41360. GlowLayer.DefaultTextureRatio = 0.5;
  41361. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41362. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41363. ], GlowLayer.prototype, "blurKernelSize", null);
  41364. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41365. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41366. ], GlowLayer.prototype, "intensity", null);
  41367. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41368. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  41369. ], GlowLayer.prototype, "_options", void 0);
  41370. return GlowLayer;
  41371. }(_effectLayer__WEBPACK_IMPORTED_MODULE_9__["EffectLayer"]));
  41372. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.GlowLayer"] = GlowLayer;
  41373. /***/ }),
  41374. /***/ "./Layers/highlightLayer.ts":
  41375. /*!**********************************!*\
  41376. !*** ./Layers/highlightLayer.ts ***!
  41377. \**********************************/
  41378. /*! exports provided: HighlightLayer */
  41379. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41380. "use strict";
  41381. __webpack_require__.r(__webpack_exports__);
  41382. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return HighlightLayer; });
  41383. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  41384. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  41385. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  41386. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41387. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41388. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  41389. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  41390. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  41391. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  41392. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  41393. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  41394. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  41395. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  41396. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  41397. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  41398. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  41399. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  41400. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  41401. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  41402. /* harmony import */ var _Shaders_glowBlurPostProcess_fragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/glowBlurPostProcess.fragment */ "./Shaders/glowBlurPostProcess.fragment.ts");
  41403. _abstractScene__WEBPACK_IMPORTED_MODULE_13__["AbstractScene"].prototype.getHighlightLayerByName = function (name) {
  41404. for (var index = 0; index < this.effectLayers.length; index++) {
  41405. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === HighlightLayer.EffectName) {
  41406. return this.effectLayers[index];
  41407. }
  41408. }
  41409. return null;
  41410. };
  41411. /**
  41412. * Special Glow Blur post process only blurring the alpha channel
  41413. * It enforces keeping the most luminous color in the color channel.
  41414. */
  41415. var GlowBlurPostProcess = /** @class */ (function (_super) {
  41416. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowBlurPostProcess, _super);
  41417. function GlowBlurPostProcess(name, direction, kernel, options, camera, samplingMode, engine, reusable) {
  41418. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE; }
  41419. var _this = _super.call(this, name, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, options, camera, samplingMode, engine, reusable) || this;
  41420. _this.direction = direction;
  41421. _this.kernel = kernel;
  41422. _this.onApplyObservable.add(function (effect) {
  41423. effect.setFloat2("screenSize", _this.width, _this.height);
  41424. effect.setVector2("direction", _this.direction);
  41425. effect.setFloat("blurWidth", _this.kernel);
  41426. });
  41427. return _this;
  41428. }
  41429. return GlowBlurPostProcess;
  41430. }(_PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__["PostProcess"]));
  41431. /**
  41432. * The highlight layer Helps adding a glow effect around a mesh.
  41433. *
  41434. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  41435. * glowy meshes to your scene.
  41436. *
  41437. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  41438. */
  41439. var HighlightLayer = /** @class */ (function (_super) {
  41440. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightLayer, _super);
  41441. /**
  41442. * Instantiates a new highlight Layer and references it to the scene..
  41443. * @param name The name of the layer
  41444. * @param scene The scene to use the layer in
  41445. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  41446. */
  41447. function HighlightLayer(name, scene, options) {
  41448. var _this = _super.call(this, name, scene) || this;
  41449. _this.name = name;
  41450. /**
  41451. * Specifies whether or not the inner glow is ACTIVE in the layer.
  41452. */
  41453. _this.innerGlow = true;
  41454. /**
  41455. * Specifies whether or not the outer glow is ACTIVE in the layer.
  41456. */
  41457. _this.outerGlow = true;
  41458. /**
  41459. * An event triggered when the highlight layer is being blurred.
  41460. */
  41461. _this.onBeforeBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  41462. /**
  41463. * An event triggered when the highlight layer has been blurred.
  41464. */
  41465. _this.onAfterBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  41466. _this._instanceGlowingMeshStencilReference = HighlightLayer.GlowingMeshStencilReference++;
  41467. _this._meshes = {};
  41468. _this._excludedMeshes = {};
  41469. _this.neutralColor = HighlightLayer.NeutralColor;
  41470. // Warn on stencil
  41471. if (!_this._engine.isStencilEnable) {
  41472. _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 }");
  41473. }
  41474. // Adapt options
  41475. _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);
  41476. // Initialize the layer
  41477. _this._init({
  41478. alphaBlendingMode: _this._options.alphaBlendingMode,
  41479. camera: _this._options.camera,
  41480. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  41481. mainTextureRatio: _this._options.mainTextureRatio,
  41482. renderingGroupId: _this._options.renderingGroupId
  41483. });
  41484. // Do not render as long as no meshes have been added
  41485. _this._shouldRender = false;
  41486. return _this;
  41487. }
  41488. Object.defineProperty(HighlightLayer.prototype, "blurHorizontalSize", {
  41489. /**
  41490. * Gets the horizontal size of the blur.
  41491. */
  41492. get: function () {
  41493. return this._horizontalBlurPostprocess.kernel;
  41494. },
  41495. /**
  41496. * Specifies the horizontal size of the blur.
  41497. */
  41498. set: function (value) {
  41499. this._horizontalBlurPostprocess.kernel = value;
  41500. },
  41501. enumerable: true,
  41502. configurable: true
  41503. });
  41504. Object.defineProperty(HighlightLayer.prototype, "blurVerticalSize", {
  41505. /**
  41506. * Gets the vertical size of the blur.
  41507. */
  41508. get: function () {
  41509. return this._verticalBlurPostprocess.kernel;
  41510. },
  41511. /**
  41512. * Specifies the vertical size of the blur.
  41513. */
  41514. set: function (value) {
  41515. this._verticalBlurPostprocess.kernel = value;
  41516. },
  41517. enumerable: true,
  41518. configurable: true
  41519. });
  41520. /**
  41521. * Get the effect name of the layer.
  41522. * @return The effect name
  41523. */
  41524. HighlightLayer.prototype.getEffectName = function () {
  41525. return HighlightLayer.EffectName;
  41526. };
  41527. /**
  41528. * Create the merge effect. This is the shader use to blit the information back
  41529. * to the main canvas at the end of the scene rendering.
  41530. */
  41531. HighlightLayer.prototype._createMergeEffect = function () {
  41532. // Effect
  41533. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : undefined);
  41534. };
  41535. /**
  41536. * Creates the render target textures and post processes used in the highlight layer.
  41537. */
  41538. HighlightLayer.prototype._createTextureAndPostProcesses = function () {
  41539. var _this = this;
  41540. var blurTextureWidth = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio;
  41541. var blurTextureHeight = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
  41542. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  41543. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  41544. var textureType = 0;
  41545. if (this._engine.getCaps().textureHalfFloatRender) {
  41546. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_HALF_FLOAT;
  41547. }
  41548. else {
  41549. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  41550. }
  41551. this._blurTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerBlurRTT", {
  41552. width: blurTextureWidth,
  41553. height: blurTextureHeight
  41554. }, this._scene, false, true, textureType);
  41555. this._blurTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  41556. this._blurTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  41557. this._blurTexture.anisotropicFilteringLevel = 16;
  41558. this._blurTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].TRILINEAR_SAMPLINGMODE);
  41559. this._blurTexture.renderParticles = false;
  41560. this._blurTexture.ignoreCameraViewport = true;
  41561. this._textures = [this._blurTexture];
  41562. if (this._options.alphaBlendingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].ALPHA_COMBINE) {
  41563. 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());
  41564. this._downSamplePostprocess.onApplyObservable.add(function (effect) {
  41565. effect.setTexture("textureSampler", _this._mainTexture);
  41566. });
  41567. 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());
  41568. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  41569. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  41570. });
  41571. 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());
  41572. this._verticalBlurPostprocess.onApplyObservable.add(function (effect) {
  41573. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  41574. });
  41575. this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  41576. }
  41577. else {
  41578. 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, {
  41579. width: blurTextureWidth,
  41580. height: blurTextureHeight
  41581. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41582. this._horizontalBlurPostprocess.width = blurTextureWidth;
  41583. this._horizontalBlurPostprocess.height = blurTextureHeight;
  41584. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  41585. effect.setTexture("textureSampler", _this._mainTexture);
  41586. });
  41587. 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, {
  41588. width: blurTextureWidth,
  41589. height: blurTextureHeight
  41590. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41591. this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  41592. }
  41593. this._mainTexture.onAfterUnbindObservable.add(function () {
  41594. _this.onBeforeBlurObservable.notifyObservers(_this);
  41595. var internalTexture = _this._blurTexture.getInternalTexture();
  41596. if (internalTexture) {
  41597. _this._scene.postProcessManager.directRender(_this._postProcesses, internalTexture, true);
  41598. }
  41599. _this.onAfterBlurObservable.notifyObservers(_this);
  41600. });
  41601. // Prevent autoClear.
  41602. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  41603. };
  41604. /**
  41605. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  41606. */
  41607. HighlightLayer.prototype.needStencil = function () {
  41608. return true;
  41609. };
  41610. /**
  41611. * Checks for the readiness of the element composing the layer.
  41612. * @param subMesh the mesh to check for
  41613. * @param useInstances specify wether or not to use instances to render the mesh
  41614. * @param emissiveTexture the associated emissive texture used to generate the glow
  41615. * @return true if ready otherwise, false
  41616. */
  41617. HighlightLayer.prototype.isReady = function (subMesh, useInstances) {
  41618. var material = subMesh.getMaterial();
  41619. var mesh = subMesh.getRenderingMesh();
  41620. if (!material || !mesh || !this._meshes) {
  41621. return false;
  41622. }
  41623. var emissiveTexture = null;
  41624. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  41625. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  41626. emissiveTexture = material.emissiveTexture;
  41627. }
  41628. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  41629. };
  41630. /**
  41631. * Implementation specific of rendering the generating effect on the main canvas.
  41632. * @param effect The effect used to render through
  41633. */
  41634. HighlightLayer.prototype._internalRender = function (effect) {
  41635. // Texture
  41636. effect.setTexture("textureSampler", this._blurTexture);
  41637. // Cache
  41638. var engine = this._engine;
  41639. var previousStencilBuffer = engine.getStencilBuffer();
  41640. var previousStencilFunction = engine.getStencilFunction();
  41641. var previousStencilMask = engine.getStencilMask();
  41642. var previousStencilOperationPass = engine.getStencilOperationPass();
  41643. var previousStencilOperationFail = engine.getStencilOperationFail();
  41644. var previousStencilOperationDepthFail = engine.getStencilOperationDepthFail();
  41645. var previousStencilReference = engine.getStencilFunctionReference();
  41646. // Stencil operations
  41647. engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].REPLACE);
  41648. engine.setStencilOperationFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  41649. engine.setStencilOperationDepthFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  41650. // Draw order
  41651. engine.setStencilMask(0x00);
  41652. engine.setStencilBuffer(true);
  41653. engine.setStencilFunctionReference(this._instanceGlowingMeshStencilReference);
  41654. // 2 passes inner outer
  41655. if (this.outerGlow) {
  41656. effect.setFloat("offset", 0);
  41657. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].NOTEQUAL);
  41658. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  41659. }
  41660. if (this.innerGlow) {
  41661. effect.setFloat("offset", 1);
  41662. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].EQUAL);
  41663. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  41664. }
  41665. // Restore Cache
  41666. engine.setStencilFunction(previousStencilFunction);
  41667. engine.setStencilMask(previousStencilMask);
  41668. engine.setStencilBuffer(previousStencilBuffer);
  41669. engine.setStencilOperationPass(previousStencilOperationPass);
  41670. engine.setStencilOperationFail(previousStencilOperationFail);
  41671. engine.setStencilOperationDepthFail(previousStencilOperationDepthFail);
  41672. engine.setStencilFunctionReference(previousStencilReference);
  41673. };
  41674. /**
  41675. * Returns true if the layer contains information to display, otherwise false.
  41676. */
  41677. HighlightLayer.prototype.shouldRender = function () {
  41678. if (_super.prototype.shouldRender.call(this)) {
  41679. return this._meshes ? true : false;
  41680. }
  41681. return false;
  41682. };
  41683. /**
  41684. * Returns true if the mesh should render, otherwise false.
  41685. * @param mesh The mesh to render
  41686. * @returns true if it should render otherwise false
  41687. */
  41688. HighlightLayer.prototype._shouldRenderMesh = function (mesh) {
  41689. // Excluded Mesh
  41690. if (this._excludedMeshes && this._excludedMeshes[mesh.uniqueId]) {
  41691. return false;
  41692. }
  41693. if (!_super.prototype.hasMesh.call(this, mesh)) {
  41694. return false;
  41695. }
  41696. return true;
  41697. };
  41698. /**
  41699. * Sets the required values for both the emissive texture and and the main color.
  41700. */
  41701. HighlightLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  41702. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  41703. if (highlightLayerMesh) {
  41704. this._emissiveTextureAndColor.color.set(highlightLayerMesh.color.r, highlightLayerMesh.color.g, highlightLayerMesh.color.b, 1.0);
  41705. }
  41706. else {
  41707. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  41708. }
  41709. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  41710. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  41711. this._emissiveTextureAndColor.color.set(1.0, 1.0, 1.0, 1.0);
  41712. }
  41713. else {
  41714. this._emissiveTextureAndColor.texture = null;
  41715. }
  41716. };
  41717. /**
  41718. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  41719. * @param mesh The mesh to exclude from the highlight layer
  41720. */
  41721. HighlightLayer.prototype.addExcludedMesh = function (mesh) {
  41722. if (!this._excludedMeshes) {
  41723. return;
  41724. }
  41725. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  41726. if (!meshExcluded) {
  41727. this._excludedMeshes[mesh.uniqueId] = {
  41728. mesh: mesh,
  41729. beforeBind: mesh.onBeforeBindObservable.add(function (mesh) {
  41730. mesh.getEngine().setStencilBuffer(false);
  41731. }),
  41732. afterRender: mesh.onAfterRenderObservable.add(function (mesh) {
  41733. mesh.getEngine().setStencilBuffer(true);
  41734. }),
  41735. };
  41736. }
  41737. };
  41738. /**
  41739. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  41740. * @param mesh The mesh to highlight
  41741. */
  41742. HighlightLayer.prototype.removeExcludedMesh = function (mesh) {
  41743. if (!this._excludedMeshes) {
  41744. return;
  41745. }
  41746. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  41747. if (meshExcluded) {
  41748. if (meshExcluded.beforeBind) {
  41749. mesh.onBeforeBindObservable.remove(meshExcluded.beforeBind);
  41750. }
  41751. if (meshExcluded.afterRender) {
  41752. mesh.onAfterRenderObservable.remove(meshExcluded.afterRender);
  41753. }
  41754. }
  41755. this._excludedMeshes[mesh.uniqueId] = null;
  41756. };
  41757. /**
  41758. * Determine if a given mesh will be highlighted by the current HighlightLayer
  41759. * @param mesh mesh to test
  41760. * @returns true if the mesh will be highlighted by the current HighlightLayer
  41761. */
  41762. HighlightLayer.prototype.hasMesh = function (mesh) {
  41763. if (!this._meshes) {
  41764. return false;
  41765. }
  41766. if (!_super.prototype.hasMesh.call(this, mesh)) {
  41767. return false;
  41768. }
  41769. return this._meshes[mesh.uniqueId] !== undefined && this._meshes[mesh.uniqueId] !== null;
  41770. };
  41771. /**
  41772. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  41773. * @param mesh The mesh to highlight
  41774. * @param color The color of the highlight
  41775. * @param glowEmissiveOnly Extract the glow from the emissive texture
  41776. */
  41777. HighlightLayer.prototype.addMesh = function (mesh, color, glowEmissiveOnly) {
  41778. var _this = this;
  41779. if (glowEmissiveOnly === void 0) { glowEmissiveOnly = false; }
  41780. if (!this._meshes) {
  41781. return;
  41782. }
  41783. var meshHighlight = this._meshes[mesh.uniqueId];
  41784. if (meshHighlight) {
  41785. meshHighlight.color = color;
  41786. }
  41787. else {
  41788. this._meshes[mesh.uniqueId] = {
  41789. mesh: mesh,
  41790. color: color,
  41791. // Lambda required for capture due to Observable this context
  41792. observerHighlight: mesh.onBeforeBindObservable.add(function (mesh) {
  41793. if (_this._excludedMeshes && _this._excludedMeshes[mesh.uniqueId]) {
  41794. _this._defaultStencilReference(mesh);
  41795. }
  41796. else {
  41797. mesh.getScene().getEngine().setStencilFunctionReference(_this._instanceGlowingMeshStencilReference);
  41798. }
  41799. }),
  41800. observerDefault: mesh.onAfterRenderObservable.add(this._defaultStencilReference),
  41801. glowEmissiveOnly: glowEmissiveOnly
  41802. };
  41803. mesh.onDisposeObservable.add(function () {
  41804. _this._disposeMesh(mesh);
  41805. });
  41806. }
  41807. this._shouldRender = true;
  41808. };
  41809. /**
  41810. * Remove a mesh from the highlight layer in order to make it stop glowing.
  41811. * @param mesh The mesh to highlight
  41812. */
  41813. HighlightLayer.prototype.removeMesh = function (mesh) {
  41814. if (!this._meshes) {
  41815. return;
  41816. }
  41817. var meshHighlight = this._meshes[mesh.uniqueId];
  41818. if (meshHighlight) {
  41819. if (meshHighlight.observerHighlight) {
  41820. mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  41821. }
  41822. if (meshHighlight.observerDefault) {
  41823. mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  41824. }
  41825. delete this._meshes[mesh.uniqueId];
  41826. }
  41827. this._shouldRender = false;
  41828. for (var meshHighlightToCheck in this._meshes) {
  41829. if (this._meshes[meshHighlightToCheck]) {
  41830. this._shouldRender = true;
  41831. break;
  41832. }
  41833. }
  41834. };
  41835. /**
  41836. * Force the stencil to the normal expected value for none glowing parts
  41837. */
  41838. HighlightLayer.prototype._defaultStencilReference = function (mesh) {
  41839. mesh.getScene().getEngine().setStencilFunctionReference(HighlightLayer.NormalMeshStencilReference);
  41840. };
  41841. /**
  41842. * Free any resources and references associated to a mesh.
  41843. * Internal use
  41844. * @param mesh The mesh to free.
  41845. * @hidden
  41846. */
  41847. HighlightLayer.prototype._disposeMesh = function (mesh) {
  41848. this.removeMesh(mesh);
  41849. this.removeExcludedMesh(mesh);
  41850. };
  41851. /**
  41852. * Dispose the highlight layer and free resources.
  41853. */
  41854. HighlightLayer.prototype.dispose = function () {
  41855. if (this._meshes) {
  41856. // Clean mesh references
  41857. for (var id in this._meshes) {
  41858. var meshHighlight = this._meshes[id];
  41859. if (meshHighlight && meshHighlight.mesh) {
  41860. if (meshHighlight.observerHighlight) {
  41861. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  41862. }
  41863. if (meshHighlight.observerDefault) {
  41864. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  41865. }
  41866. }
  41867. }
  41868. this._meshes = null;
  41869. }
  41870. if (this._excludedMeshes) {
  41871. for (var id in this._excludedMeshes) {
  41872. var meshHighlight = this._excludedMeshes[id];
  41873. if (meshHighlight) {
  41874. if (meshHighlight.beforeBind) {
  41875. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.beforeBind);
  41876. }
  41877. if (meshHighlight.afterRender) {
  41878. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.afterRender);
  41879. }
  41880. }
  41881. }
  41882. this._excludedMeshes = null;
  41883. }
  41884. _super.prototype.dispose.call(this);
  41885. };
  41886. /**
  41887. * Gets the class name of the effect layer
  41888. * @returns the string with the class name of the effect layer
  41889. */
  41890. HighlightLayer.prototype.getClassName = function () {
  41891. return "HighlightLayer";
  41892. };
  41893. /**
  41894. * Serializes this Highlight layer
  41895. * @returns a serialized Highlight layer object
  41896. */
  41897. HighlightLayer.prototype.serialize = function () {
  41898. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  41899. serializationObject.customType = "BABYLON.HighlightLayer";
  41900. // Highlighted meshes
  41901. serializationObject.meshes = [];
  41902. if (this._meshes) {
  41903. for (var m in this._meshes) {
  41904. var mesh = this._meshes[m];
  41905. if (mesh) {
  41906. serializationObject.meshes.push({
  41907. glowEmissiveOnly: mesh.glowEmissiveOnly,
  41908. color: mesh.color.asArray(),
  41909. meshId: mesh.mesh.id
  41910. });
  41911. }
  41912. }
  41913. }
  41914. // Excluded meshes
  41915. serializationObject.excludedMeshes = [];
  41916. if (this._excludedMeshes) {
  41917. for (var e in this._excludedMeshes) {
  41918. var excludedMesh = this._excludedMeshes[e];
  41919. if (excludedMesh) {
  41920. serializationObject.excludedMeshes.push(excludedMesh.mesh.id);
  41921. }
  41922. }
  41923. }
  41924. return serializationObject;
  41925. };
  41926. /**
  41927. * Creates a Highlight layer from parsed Highlight layer data
  41928. * @param parsedHightlightLayer defines the Highlight layer data
  41929. * @param scene defines the current scene
  41930. * @param rootUrl defines the root URL containing the Highlight layer information
  41931. * @returns a parsed Highlight layer
  41932. */
  41933. HighlightLayer.Parse = function (parsedHightlightLayer, scene, rootUrl) {
  41934. var hl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new HighlightLayer(parsedHightlightLayer.name, scene, parsedHightlightLayer.options); }, parsedHightlightLayer, scene, rootUrl);
  41935. var index;
  41936. // Excluded meshes
  41937. for (index = 0; index < parsedHightlightLayer.excludedMeshes.length; index++) {
  41938. var mesh = scene.getMeshByID(parsedHightlightLayer.excludedMeshes[index]);
  41939. if (mesh) {
  41940. hl.addExcludedMesh(mesh);
  41941. }
  41942. }
  41943. // Included meshes
  41944. for (index = 0; index < parsedHightlightLayer.meshes.length; index++) {
  41945. var highlightedMesh = parsedHightlightLayer.meshes[index];
  41946. var mesh = scene.getMeshByID(highlightedMesh.meshId);
  41947. if (mesh) {
  41948. hl.addMesh(mesh, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromArray(highlightedMesh.color), highlightedMesh.glowEmissiveOnly);
  41949. }
  41950. }
  41951. return hl;
  41952. };
  41953. /**
  41954. * Effect Name of the highlight layer.
  41955. */
  41956. HighlightLayer.EffectName = "HighlightLayer";
  41957. /**
  41958. * The neutral color used during the preparation of the glow effect.
  41959. * This is black by default as the blend operation is a blend operation.
  41960. */
  41961. HighlightLayer.NeutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  41962. /**
  41963. * Stencil value used for glowing meshes.
  41964. */
  41965. HighlightLayer.GlowingMeshStencilReference = 0x02;
  41966. /**
  41967. * Stencil value used for the other meshes in the scene.
  41968. */
  41969. HighlightLayer.NormalMeshStencilReference = 0x01;
  41970. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41971. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41972. ], HighlightLayer.prototype, "innerGlow", void 0);
  41973. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41974. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41975. ], HighlightLayer.prototype, "outerGlow", void 0);
  41976. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41977. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41978. ], HighlightLayer.prototype, "blurHorizontalSize", null);
  41979. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41980. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41981. ], HighlightLayer.prototype, "blurVerticalSize", null);
  41982. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41983. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  41984. ], HighlightLayer.prototype, "_options", void 0);
  41985. return HighlightLayer;
  41986. }(_effectLayer__WEBPACK_IMPORTED_MODULE_12__["EffectLayer"]));
  41987. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__["_TypeStore"].RegisteredTypes["BABYLON.HighlightLayer"] = HighlightLayer;
  41988. /***/ }),
  41989. /***/ "./Layers/index.ts":
  41990. /*!*************************!*\
  41991. !*** ./Layers/index.ts ***!
  41992. \*************************/
  41993. /*! exports provided: EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent */
  41994. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41995. "use strict";
  41996. __webpack_require__.r(__webpack_exports__);
  41997. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  41998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _effectLayer__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  41999. /* harmony import */ var _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  42000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__["EffectLayerSceneComponent"]; });
  42001. /* harmony import */ var _glowLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glowLayer */ "./Layers/glowLayer.ts");
  42002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _glowLayer__WEBPACK_IMPORTED_MODULE_2__["GlowLayer"]; });
  42003. /* harmony import */ var _highlightLayer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./highlightLayer */ "./Layers/highlightLayer.ts");
  42004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _highlightLayer__WEBPACK_IMPORTED_MODULE_3__["HighlightLayer"]; });
  42005. /* harmony import */ var _layer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./layer */ "./Layers/layer.ts");
  42006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _layer__WEBPACK_IMPORTED_MODULE_4__["Layer"]; });
  42007. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  42008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__["LayerSceneComponent"]; });
  42009. /***/ }),
  42010. /***/ "./Layers/layer.ts":
  42011. /*!*************************!*\
  42012. !*** ./Layers/layer.ts ***!
  42013. \*************************/
  42014. /*! exports provided: Layer */
  42015. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42016. "use strict";
  42017. __webpack_require__.r(__webpack_exports__);
  42018. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return Layer; });
  42019. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42020. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42021. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  42022. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42023. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42024. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42025. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  42026. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  42027. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42028. /* harmony import */ var _Shaders_layer_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/layer.fragment */ "./Shaders/layer.fragment.ts");
  42029. /* harmony import */ var _Shaders_layer_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/layer.vertex */ "./Shaders/layer.vertex.ts");
  42030. /**
  42031. * This represents a full screen 2d layer.
  42032. * This can be useful to display a picture in the background of your scene for instance.
  42033. * @see https://www.babylonjs-playground.com/#08A2BS#1
  42034. */
  42035. var Layer = /** @class */ (function () {
  42036. /**
  42037. * Instantiates a new layer.
  42038. * This represents a full screen 2d layer.
  42039. * This can be useful to display a picture in the background of your scene for instance.
  42040. * @see https://www.babylonjs-playground.com/#08A2BS#1
  42041. * @param name Define the name of the layer in the scene
  42042. * @param imgUrl Define the url of the texture to display in the layer
  42043. * @param scene Define the scene the layer belongs to
  42044. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  42045. * @param color Defines a color for the layer
  42046. */
  42047. function Layer(
  42048. /**
  42049. * Define the name of the layer.
  42050. */
  42051. name, imgUrl, scene, isBackground, color) {
  42052. this.name = name;
  42053. /**
  42054. * Define the scale of the layer in order to zoom in out of the texture.
  42055. */
  42056. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 1);
  42057. /**
  42058. * Define an offset for the layer in order to shift the texture.
  42059. */
  42060. this.offset = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 0);
  42061. /**
  42062. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  42063. */
  42064. this.alphaBlendingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  42065. /**
  42066. * Define a mask to restrict the layer to only some of the scene cameras.
  42067. */
  42068. this.layerMask = 0x0FFFFFFF;
  42069. /**
  42070. * Define the list of render target the layer is visible into.
  42071. */
  42072. this.renderTargetTextures = [];
  42073. /**
  42074. * Define if the layer is only used in renderTarget or if it also
  42075. * renders in the main frame buffer of the canvas.
  42076. */
  42077. this.renderOnlyInRenderTargetTextures = false;
  42078. this._vertexBuffers = {};
  42079. /**
  42080. * An event triggered when the layer is disposed.
  42081. */
  42082. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  42083. /**
  42084. * An event triggered before rendering the scene
  42085. */
  42086. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  42087. /**
  42088. * An event triggered after rendering the scene
  42089. */
  42090. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  42091. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"](imgUrl, scene, true) : null;
  42092. this.isBackground = isBackground === undefined ? true : isBackground;
  42093. this.color = color === undefined ? new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1, 1, 1, 1) : color;
  42094. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene);
  42095. var layerComponent = this._scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_LAYER);
  42096. if (!layerComponent) {
  42097. layerComponent = new _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__["LayerSceneComponent"](this._scene);
  42098. this._scene._addComponent(layerComponent);
  42099. }
  42100. this._scene.layers.push(this);
  42101. var engine = this._scene.getEngine();
  42102. // VBO
  42103. var vertices = [];
  42104. vertices.push(1, 1);
  42105. vertices.push(-1, 1);
  42106. vertices.push(-1, -1);
  42107. vertices.push(1, -1);
  42108. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"](engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, false, false, 2);
  42109. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = vertexBuffer;
  42110. this._createIndexBuffer();
  42111. // Effects
  42112. this._effect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "");
  42113. this._alphaTestEffect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "#define ALPHATEST");
  42114. }
  42115. Object.defineProperty(Layer.prototype, "onDispose", {
  42116. /**
  42117. * Back compatibility with callback before the onDisposeObservable existed.
  42118. * The set callback will be triggered when the layer has been disposed.
  42119. */
  42120. set: function (callback) {
  42121. if (this._onDisposeObserver) {
  42122. this.onDisposeObservable.remove(this._onDisposeObserver);
  42123. }
  42124. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  42125. },
  42126. enumerable: true,
  42127. configurable: true
  42128. });
  42129. Object.defineProperty(Layer.prototype, "onBeforeRender", {
  42130. /**
  42131. * Back compatibility with callback before the onBeforeRenderObservable existed.
  42132. * The set callback will be triggered just before rendering the layer.
  42133. */
  42134. set: function (callback) {
  42135. if (this._onBeforeRenderObserver) {
  42136. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  42137. }
  42138. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  42139. },
  42140. enumerable: true,
  42141. configurable: true
  42142. });
  42143. Object.defineProperty(Layer.prototype, "onAfterRender", {
  42144. /**
  42145. * Back compatibility with callback before the onAfterRenderObservable existed.
  42146. * The set callback will be triggered just after rendering the layer.
  42147. */
  42148. set: function (callback) {
  42149. if (this._onAfterRenderObserver) {
  42150. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  42151. }
  42152. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  42153. },
  42154. enumerable: true,
  42155. configurable: true
  42156. });
  42157. Layer.prototype._createIndexBuffer = function () {
  42158. var engine = this._scene.getEngine();
  42159. // Indices
  42160. var indices = [];
  42161. indices.push(0);
  42162. indices.push(1);
  42163. indices.push(2);
  42164. indices.push(0);
  42165. indices.push(2);
  42166. indices.push(3);
  42167. this._indexBuffer = engine.createIndexBuffer(indices);
  42168. };
  42169. /** @hidden */
  42170. Layer.prototype._rebuild = function () {
  42171. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  42172. if (vb) {
  42173. vb._rebuild();
  42174. }
  42175. this._createIndexBuffer();
  42176. };
  42177. /**
  42178. * Renders the layer in the scene.
  42179. */
  42180. Layer.prototype.render = function () {
  42181. var currentEffect = this.alphaTest ? this._alphaTestEffect : this._effect;
  42182. // Check
  42183. if (!currentEffect.isReady() || !this.texture || !this.texture.isReady()) {
  42184. return;
  42185. }
  42186. var engine = this._scene.getEngine();
  42187. this.onBeforeRenderObservable.notifyObservers(this);
  42188. // Render
  42189. engine.enableEffect(currentEffect);
  42190. engine.setState(false);
  42191. // Texture
  42192. currentEffect.setTexture("textureSampler", this.texture);
  42193. currentEffect.setMatrix("textureMatrix", this.texture.getTextureMatrix());
  42194. // Color
  42195. currentEffect.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a);
  42196. // Scale / offset
  42197. currentEffect.setVector2("offset", this.offset);
  42198. currentEffect.setVector2("scale", this.scale);
  42199. // VBOs
  42200. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  42201. // Draw order
  42202. if (!this.alphaTest) {
  42203. engine.setAlphaMode(this.alphaBlendingMode);
  42204. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  42205. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  42206. }
  42207. else {
  42208. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  42209. }
  42210. this.onAfterRenderObservable.notifyObservers(this);
  42211. };
  42212. /**
  42213. * Disposes and releases the associated ressources.
  42214. */
  42215. Layer.prototype.dispose = function () {
  42216. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  42217. if (vertexBuffer) {
  42218. vertexBuffer.dispose();
  42219. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  42220. }
  42221. if (this._indexBuffer) {
  42222. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  42223. this._indexBuffer = null;
  42224. }
  42225. if (this.texture) {
  42226. this.texture.dispose();
  42227. this.texture = null;
  42228. }
  42229. // Clean RTT list
  42230. this.renderTargetTextures = [];
  42231. // Remove from scene
  42232. var index = this._scene.layers.indexOf(this);
  42233. this._scene.layers.splice(index, 1);
  42234. // Callback
  42235. this.onDisposeObservable.notifyObservers(this);
  42236. this.onDisposeObservable.clear();
  42237. this.onAfterRenderObservable.clear();
  42238. this.onBeforeRenderObservable.clear();
  42239. };
  42240. return Layer;
  42241. }());
  42242. /***/ }),
  42243. /***/ "./Layers/layerSceneComponent.ts":
  42244. /*!***************************************!*\
  42245. !*** ./Layers/layerSceneComponent.ts ***!
  42246. \***************************************/
  42247. /*! exports provided: LayerSceneComponent */
  42248. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42249. "use strict";
  42250. __webpack_require__.r(__webpack_exports__);
  42251. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return LayerSceneComponent; });
  42252. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  42253. /**
  42254. * Defines the layer scene component responsible to manage any layers
  42255. * in a given scene.
  42256. */
  42257. var LayerSceneComponent = /** @class */ (function () {
  42258. /**
  42259. * Creates a new instance of the component for the given scene
  42260. * @param scene Defines the scene to register the component in
  42261. */
  42262. function LayerSceneComponent(scene) {
  42263. /**
  42264. * The component name helpfull to identify the component in the list of scene components.
  42265. */
  42266. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_LAYER;
  42267. this.scene = scene;
  42268. this._engine = scene.getEngine();
  42269. scene.layers = new Array();
  42270. }
  42271. /**
  42272. * Registers the component in a given scene
  42273. */
  42274. LayerSceneComponent.prototype.register = function () {
  42275. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground);
  42276. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground);
  42277. this.scene._beforeRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground);
  42278. this.scene._afterRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground);
  42279. };
  42280. /**
  42281. * Rebuilds the elements related to this component in case of
  42282. * context lost for instance.
  42283. */
  42284. LayerSceneComponent.prototype.rebuild = function () {
  42285. var layers = this.scene.layers;
  42286. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  42287. var layer = layers_1[_i];
  42288. layer._rebuild();
  42289. }
  42290. };
  42291. /**
  42292. * Disposes the component and the associated ressources.
  42293. */
  42294. LayerSceneComponent.prototype.dispose = function () {
  42295. var layers = this.scene.layers;
  42296. while (layers.length) {
  42297. layers[0].dispose();
  42298. }
  42299. };
  42300. LayerSceneComponent.prototype._draw = function (predicate) {
  42301. var layers = this.scene.layers;
  42302. if (layers.length) {
  42303. this._engine.setDepthBuffer(false);
  42304. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  42305. var layer = layers_2[_i];
  42306. if (predicate(layer)) {
  42307. layer.render();
  42308. }
  42309. }
  42310. this._engine.setDepthBuffer(true);
  42311. }
  42312. };
  42313. LayerSceneComponent.prototype._drawCameraPredicate = function (layer, isBackground, cameraLayerMask) {
  42314. return !layer.renderOnlyInRenderTargetTextures &&
  42315. layer.isBackground === isBackground &&
  42316. ((layer.layerMask & cameraLayerMask) !== 0);
  42317. };
  42318. LayerSceneComponent.prototype._drawCameraBackground = function (camera) {
  42319. var _this = this;
  42320. this._draw(function (layer) {
  42321. return _this._drawCameraPredicate(layer, true, camera.layerMask);
  42322. });
  42323. };
  42324. LayerSceneComponent.prototype._drawCameraForeground = function (camera) {
  42325. var _this = this;
  42326. this._draw(function (layer) {
  42327. return _this._drawCameraPredicate(layer, false, camera.layerMask);
  42328. });
  42329. };
  42330. LayerSceneComponent.prototype._drawRenderTargetPredicate = function (layer, isBackground, cameraLayerMask, renderTargetTexture) {
  42331. return (layer.renderTargetTextures.length > 0) &&
  42332. layer.isBackground === isBackground &&
  42333. (layer.renderTargetTextures.indexOf(renderTargetTexture) > -1) &&
  42334. ((layer.layerMask & cameraLayerMask) !== 0);
  42335. };
  42336. LayerSceneComponent.prototype._drawRenderTargetBackground = function (renderTarget) {
  42337. var _this = this;
  42338. this._draw(function (layer) {
  42339. return _this._drawRenderTargetPredicate(layer, true, _this.scene.activeCamera.layerMask, renderTarget);
  42340. });
  42341. };
  42342. LayerSceneComponent.prototype._drawRenderTargetForeground = function (renderTarget) {
  42343. var _this = this;
  42344. this._draw(function (layer) {
  42345. return _this._drawRenderTargetPredicate(layer, false, _this.scene.activeCamera.layerMask, renderTarget);
  42346. });
  42347. };
  42348. return LayerSceneComponent;
  42349. }());
  42350. /***/ }),
  42351. /***/ "./Legacy/legacy.ts":
  42352. /*!**************************!*\
  42353. !*** ./Legacy/legacy.ts ***!
  42354. \**************************/
  42355. /*! exports provided: AbstractScene, KeepAssets, AssetContainer, Node, Scene, SceneComponentConstants, Stage, Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction, Animatable, AnimationRange, AnimationEvent, PathCursor, AnimationKeyInterpolation, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, CollisionCoordinatorLegacy, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, _PrimitiveGeometry, RibbonGeometry, BoxGeometry, SphereGeometry, DiscGeometry, CylinderGeometry, TorusGeometry, GroundGeometry, TiledGroundGeometry, PlaneGeometry, TorusKnotGeometry, GroundMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, MorphTarget, MorphTargetManager, Database, BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, ReflectionProbe, BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer, Sprite, SpriteManager, SpriteSceneComponent, _AlphaState, _DepthCullingState, _StencilState, AndOrNotEvaluator, AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, FilesInput, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  42356. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42357. "use strict";
  42358. __webpack_require__.r(__webpack_exports__);
  42359. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  42360. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/index */ "./Debug/index.ts");
  42361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  42362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeepAssets"]; });
  42363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetContainer"]; });
  42364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Node"]; });
  42365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scene"]; });
  42366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"]; });
  42367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Stage"]; });
  42368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  42369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionEvent"]; });
  42370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionManager"]; });
  42371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Condition"]; });
  42372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueCondition"]; });
  42373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PredicateCondition"]; });
  42374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StateCondition"]; });
  42375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SwitchBooleanAction"]; });
  42376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetStateAction"]; });
  42377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetValueAction"]; });
  42378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IncrementValueAction"]; });
  42379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlayAnimationAction"]; });
  42380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopAnimationAction"]; });
  42381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DoNothingAction"]; });
  42382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CombineAction"]; });
  42383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExecuteCodeAction"]; });
  42384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetParentAction"]; });
  42385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaySoundAction"]; });
  42386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopSoundAction"]; });
  42387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InterpolateValueAction"]; });
  42388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  42389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationRange"]; });
  42390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationEvent"]; });
  42391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PathCursor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PathCursor"]; });
  42392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationKeyInterpolation"]; });
  42393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animation"]; });
  42394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetedAnimation"]; });
  42395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationGroup"]; });
  42396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationPropertiesOverride"]; });
  42397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"]; });
  42398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleEase"]; });
  42399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackEase"]; });
  42400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BounceEase"]; });
  42401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubicEase"]; });
  42402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ElasticEase"]; });
  42403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]; });
  42404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PowerEase"]; });
  42405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuadraticEase"]; });
  42406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuarticEase"]; });
  42407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuinticEase"]; });
  42408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SineEase"]; });
  42409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurveEase"]; });
  42410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RuntimeAnimation"]; });
  42411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  42412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioEngine"]; });
  42413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioSceneComponent"]; });
  42414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sound"]; });
  42415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SoundTrack"]; });
  42416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WeightedSound"]; });
  42417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  42418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneIKController"]; });
  42419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneLookController"]; });
  42420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Skeleton"]; });
  42421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]; });
  42422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputsManager"]; });
  42423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Camera"]; });
  42424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetCamera"]; });
  42425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCamera"]; });
  42426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraInputsManager"]; });
  42427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TouchCamera"]; });
  42428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCamera"]; });
  42429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraInputsManager"]; });
  42430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeviceOrientationCamera"]; });
  42431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCamera"]; });
  42432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraInputsManager"]; });
  42433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCamera"]; });
  42434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcFollowCamera"]; });
  42435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadCamera"]; });
  42436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniversalCamera"]; });
  42437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoysticksCamera"]; });
  42438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  42439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CollisionCoordinatorLegacy", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CollisionCoordinatorLegacy"]; });
  42440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PickingInfo"]; });
  42441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IntersectionInfo"]; });
  42442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  42443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingInfo"]; });
  42444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingSphere"]; });
  42445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ray"]; });
  42446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  42447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneAxesViewer"]; });
  42448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DebugLayer"]; });
  42449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsViewer"]; });
  42450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RayHelper"]; });
  42451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SkeletonViewer"]; });
  42452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  42453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancingAttributeInfo"]; });
  42454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthTextureCreationOptions"]; });
  42455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineCapabilities"]; });
  42456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Engine"]; });
  42457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineStore"]; });
  42458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngineOptions"]; });
  42459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngine"]; });
  42460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  42461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  42462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  42463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"]; });
  42464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoBase"]; });
  42465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoPre"]; });
  42466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"]; });
  42467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardEventTypes"]; });
  42468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardInfo"]; });
  42469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  42470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  42471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  42472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  42473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  42474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  42475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  42476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  42477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  42478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  42479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StickValues"]; });
  42480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gamepad"]; });
  42481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericPad"]; });
  42482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadManager"]; });
  42483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadSystemSceneComponent"]; });
  42484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Button"]; });
  42485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Dpad"]; });
  42486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Pad"]; });
  42487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  42488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisScaleGizmo"]; });
  42489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxGizmo"]; });
  42490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gizmo"]; });
  42491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GizmoManager"]; });
  42492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneRotationGizmo"]; });
  42493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionGizmo"]; });
  42494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RotationGizmo"]; });
  42495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScaleGizmo"]; });
  42496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  42497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhotoDome"]; });
  42498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceSceneHelpersToBundle"]; });
  42499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoDome"]; });
  42500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  42501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneInstrumentation"]; });
  42502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TimeToken"]; });
  42503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  42504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayerSceneComponent"]; });
  42505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GlowLayer"]; });
  42506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightLayer"]; });
  42507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Layer"]; });
  42508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LayerSceneComponent"]; });
  42509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  42510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystem"]; });
  42511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystemSceneComponent"]; });
  42512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  42513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowLight"]; });
  42514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DirectionalLight"]; });
  42515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]; });
  42516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointLight"]; });
  42517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpotLight"]; });
  42518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  42519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderProgressEvent"]; });
  42520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"]; });
  42521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderFlags"]; });
  42522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCurves"]; });
  42523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectFallbacks"]; });
  42524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectCreationOptions"]; });
  42525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Effect"]; });
  42526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FresnelParameters"]; });
  42527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfigurationDefines"]; });
  42528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfiguration"]; });
  42529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Material"]; });
  42530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialDefines"]; });
  42531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialHelper"]; });
  42532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiMaterial"]; });
  42533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PushMaterial"]; });
  42534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShaderMaterial"]; });
  42535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterialDefines"]; });
  42536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterial"]; });
  42537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  42538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTexture"]; });
  42539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTexture"]; });
  42540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InternalTexture"]; });
  42541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DummyInternalTextureTracker"]; });
  42542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MirrorTexture"]; });
  42543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiRenderTarget"]; });
  42544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture"]; });
  42545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetTexture"]; });
  42546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Texture"]; });
  42547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniformBuffer"]; });
  42548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialFlags"]; });
  42549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  42550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToGammaSpace"]; });
  42551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]; });
  42552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; });
  42553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3"]; });
  42554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color4"]; });
  42555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2"]; });
  42556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3"]; });
  42557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector4"]; });
  42558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Size"]; });
  42559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]; });
  42560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix"]; });
  42561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Plane"]; });
  42562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Viewport"]; });
  42563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Frustum"]; });
  42564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Space"]; });
  42565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Axis"]; });
  42566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurve"]; });
  42567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Orientation"]; });
  42568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Angle"]; });
  42569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Arc2"]; });
  42570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path2"]; });
  42571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path3D"]; });
  42572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Curve3"]; });
  42573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]; });
  42574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalTextureVertex"]; });
  42575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tmp"]; });
  42576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]; });
  42577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalHarmonics"]; });
  42578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  42579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Buffer"]; });
  42580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"]; });
  42581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CSG"]; });
  42582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Geometry"]; });
  42583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_PrimitiveGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_PrimitiveGeometry"]; });
  42584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RibbonGeometry"]; });
  42585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxGeometry"]; });
  42586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereGeometry"]; });
  42587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DiscGeometry"]; });
  42588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderGeometry"]; });
  42589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusGeometry"]; });
  42590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundGeometry"]; });
  42591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TiledGroundGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TiledGroundGeometry"]; });
  42592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneGeometry"]; });
  42593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusKnotGeometry"]; });
  42594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundMesh"]; });
  42595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedMesh"]; });
  42596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesMesh"]; });
  42597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedLinesMesh"]; });
  42598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshLODLevel"]; });
  42599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_CreationDataStorage"]; });
  42600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_InstancesBatch"]; });
  42601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Mesh"]; });
  42602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexData"]; });
  42603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"]; });
  42604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationSettings"]; });
  42605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationQueue"]; });
  42606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationType"]; });
  42607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplicationQueueSceneComponent"]; });
  42608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Polygon"]; });
  42609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonMeshBuilder"]; });
  42610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSubMesh"]; });
  42611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubMesh"]; });
  42612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TransformNode"]; });
  42613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  42614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTargetManager"]; });
  42615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  42616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  42617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GPUParticleSystem"]; });
  42618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Particle"]; });
  42619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleHelper"]; });
  42620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystem"]; });
  42621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_IDoNeedToBeInTheBuild"]; });
  42622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystemSet"]; });
  42623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticle"]; });
  42624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ModelShape"]; });
  42625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthSortedParticle"]; });
  42626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticleSystem"]; });
  42627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitterType"]; });
  42628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitter"]; });
  42629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  42630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngineSceneComponent"]; });
  42631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsHelper"]; });
  42632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialExplosionEvent"]; });
  42633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsGravitationalFieldEvent"]; });
  42634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftEvent"]; });
  42635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsVortexEvent"]; });
  42636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialImpulseFalloff"]; });
  42637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftMode"]; });
  42638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"]; });
  42639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsJoint"]; });
  42640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DistanceJoint"]; });
  42641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotorEnabledJoint"]; });
  42642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HingeJoint"]; });
  42643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Hinge2Joint"]; });
  42644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  42645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlackAndWhitePostProcess"]; });
  42646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomEffect"]; });
  42647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomMergePostProcess"]; });
  42648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlurPostProcess"]; });
  42649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ChromaticAberrationPostProcess"]; });
  42650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleOfConfusionPostProcess"]; });
  42651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCorrectionPostProcess"]; });
  42652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConvolutionPostProcess"]; });
  42653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldBlurPostProcess"]; });
  42654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffectBlurLevel"]; });
  42655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffect"]; });
  42656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcessOptions"]; });
  42657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcess"]; });
  42658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayPassPostProcess"]; });
  42659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExtractHighlightsPostProcess"]; });
  42660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilterPostProcess"]; });
  42661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FxaaPostProcess"]; });
  42662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GrainPostProcess"]; });
  42663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightsPostProcess"]; });
  42664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingPostProcess"]; });
  42665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotionBlurPostProcess"]; });
  42666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassPostProcess"]; });
  42667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassCubePostProcess"]; });
  42668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcess"]; });
  42669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessManager"]; });
  42670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionPostProcess"]; });
  42671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SharpenPostProcess"]; });
  42672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicInterlacePostProcess"]; });
  42673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemappingOperator"]; });
  42674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemapPostProcess"]; });
  42675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumetricLightScatteringPostProcess"]; });
  42676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDistortionCorrectionPostProcess"]; });
  42677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  42678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  42679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRenderer"]; });
  42680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRendererSceneComponent"]; });
  42681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EdgesRenderer"]; });
  42682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LineEdgesRenderer"]; });
  42683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRenderer"]; });
  42684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRendererSceneComponent"]; });
  42685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OutlineRenderer"]; });
  42686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"]; });
  42687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroupInfo"]; });
  42688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingManager"]; });
  42689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"]; });
  42690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  42691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteManager"]; });
  42692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteSceneComponent"]; });
  42693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  42694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DepthCullingState"]; });
  42695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_StencilState"]; });
  42696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  42697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetTaskState"]; });
  42698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractAssetTask"]; });
  42699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsProgressEvent"]; });
  42700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshAssetTask"]; });
  42701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextFileAssetTask"]; });
  42702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BinaryFileAssetTask"]; });
  42703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageAssetTask"]; });
  42704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureAssetTask"]; });
  42705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTextureAssetTask"]; });
  42706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTextureAssetTask"]; });
  42707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsManager"]; });
  42708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DDSTools"]; });
  42709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["expandToProperty"]; });
  42710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serialize"]; });
  42711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsTexture"]; });
  42712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor3"]; });
  42713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsFresnelParameters"]; });
  42714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector2"]; });
  42715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector3"]; });
  42716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMeshReference"]; });
  42717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColorCurves"]; });
  42718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor4"]; });
  42719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsImageProcessingConfiguration"]; });
  42720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsQuaternion"]; });
  42721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsCameraReference"]; });
  42722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SerializationHelper"]; });
  42723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Deferred"]; });
  42724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"]; });
  42725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInput"]; });
  42726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"]; });
  42727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EventState"]; });
  42728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observer"]; });
  42729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiObserver"]; });
  42730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observable"]; });
  42731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerformanceMonitor"]; });
  42732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RollingAverage"]; });
  42733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PromisePolyfill"]; });
  42734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimization"]; });
  42735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureOptimization"]; });
  42736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HardwareScalingOptimization"]; });
  42737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowsOptimization"]; });
  42738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessesOptimization"]; });
  42739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlaresOptimization"]; });
  42740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomOptimization"]; });
  42741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticlesOptimization"]; });
  42742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetsOptimization"]; });
  42743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MergeMeshesOptimization"]; });
  42744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizerOptions"]; });
  42745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizer"]; });
  42746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneSerializer"]; });
  42747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArray"]; });
  42748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"]; });
  42749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StringDictionary"]; });
  42750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tags"]; });
  42751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureTools"]; });
  42752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TGATools"]; });
  42753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradient"]; });
  42754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3Gradient"]; });
  42755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FactorGradient"]; });
  42756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LoadFileError"]; });
  42757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RetryStrategy"]; });
  42758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tools"]; });
  42759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]; });
  42760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["className"]; });
  42761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AsyncLoop"]; });
  42762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoRecorder"]; });
  42763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"]; });
  42764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"]; });
  42765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WorkerPool"]; });
  42766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Logger"]; });
  42767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"]; });
  42768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInputStore"]; });
  42769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"]; });
  42770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PivotTools"]; });
  42771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"]; });
  42772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScreenshotTools"]; });
  42773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  42774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  42775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  42776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  42777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FadeInOutBehavior"]; });
  42778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiPointerScaleBehavior"]; });
  42779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]; });
  42780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SixDofDragBehavior"]; });
  42781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  42782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  42783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  42784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  42785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  42786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  42787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  42788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  42789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  42790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  42791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  42792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  42793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  42794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  42795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphFreeCamera"]; });
  42796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphGamepadCamera"]; });
  42797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphUniversalCamera"]; });
  42798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicArcRotateCamera"]; });
  42799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicFreeCamera"]; });
  42800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicGamepadCamera"]; });
  42801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicUniversalCamera"]; });
  42802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  42803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationArcRotateCamera"]; });
  42804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationFreeCamera"]; });
  42805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationGamepadCamera"]; });
  42806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRExperienceHelper"]; });
  42807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRFreeCamera"]; });
  42808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  42809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIButton"]; });
  42810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIOptions"]; });
  42811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUI"]; });
  42812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRState"]; });
  42813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRExperienceHelper"]; });
  42814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRController"]; });
  42815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRInput"]; });
  42816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRManagedOutputCanvas"]; });
  42817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRSessionManager"]; });
  42818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  42819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeBlock"]; });
  42820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeSceneComponent"]; });
  42821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  42822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceTransformFeedbackToBundle"]; });
  42823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  42824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGeneratorSceneComponent"]; });
  42825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  42826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  42827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  42828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseSimpleMaterial"]; });
  42829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"]; });
  42830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMetallicRoughnessMaterial"]; });
  42831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRSpecularGlossinessMaterial"]; });
  42832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradingTexture"]; });
  42833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DynamicTexture"]; });
  42834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTexture"]; });
  42835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawCubeTexture"]; });
  42836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture3D"]; });
  42837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionTexture"]; });
  42838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoTexture"]; });
  42839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  42840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  42841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConeParticleEmitter"]; });
  42842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderParticleEmitter"]; });
  42843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderDirectedParticleEmitter"]; });
  42844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericParticleEmitter"]; });
  42845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointParticleEmitter"]; });
  42846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereParticleEmitter"]; });
  42847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereDirectedParticleEmitter"]; });
  42848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  42849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AmmoJSPlugin"]; });
  42850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OimoJSPlugin"]; });
  42851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderEffect"]; });
  42852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipeline"]; });
  42853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManager"]; });
  42854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManagerSceneComponent"]; });
  42855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  42856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRTools"]; });
  42857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"]; });
  42858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  42859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_ENVTextureLoader"]; });
  42860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_KTXTextureLoader"]; });
  42861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TGATextureLoader"]; });
  42862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  42863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NoiseProceduralTexture"]; });
  42864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTextureSceneComponent"]; });
  42865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  42866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  42867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  42868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  42869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  42870. /**
  42871. * Legacy support, defining window.BABYLON (global variable).
  42872. *
  42873. * This is the entry point for the UMD module.
  42874. * The entry point for a future ESM package should be index.ts
  42875. */
  42876. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  42877. if (typeof globalObject !== "undefined") {
  42878. globalObject.BABYLON = BABYLON;
  42879. globalObject.BABYLON = globalObject.BABYLON || {};
  42880. var BABYLON = globalObject.BABYLON;
  42881. BABYLON.Debug = BABYLON.Debug || {};
  42882. var keys = [];
  42883. for (var key in _Debug_index__WEBPACK_IMPORTED_MODULE_1__) {
  42884. BABYLON.Debug[key] = _Debug_index__WEBPACK_IMPORTED_MODULE_1__[key];
  42885. keys.push(key);
  42886. }
  42887. for (var key in _index__WEBPACK_IMPORTED_MODULE_0__) {
  42888. // Prevent Reassignment.
  42889. if (keys.indexOf(key) > -1) {
  42890. continue;
  42891. }
  42892. BABYLON[key] = _index__WEBPACK_IMPORTED_MODULE_0__[key];
  42893. }
  42894. }
  42895. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  42896. /***/ }),
  42897. /***/ "./LensFlares/index.ts":
  42898. /*!*****************************!*\
  42899. !*** ./LensFlares/index.ts ***!
  42900. \*****************************/
  42901. /*! exports provided: LensFlare, LensFlareSystem, LensFlareSystemSceneComponent */
  42902. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42903. "use strict";
  42904. __webpack_require__.r(__webpack_exports__);
  42905. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  42906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _lensFlare__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  42907. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  42908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__["LensFlareSystem"]; });
  42909. /* harmony import */ var _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lensFlareSystemSceneComponent */ "./LensFlares/lensFlareSystemSceneComponent.ts");
  42910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__["LensFlareSystemSceneComponent"]; });
  42911. /***/ }),
  42912. /***/ "./LensFlares/lensFlare.ts":
  42913. /*!*********************************!*\
  42914. !*** ./LensFlares/lensFlare.ts ***!
  42915. \*********************************/
  42916. /*! exports provided: LensFlare */
  42917. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42918. "use strict";
  42919. __webpack_require__.r(__webpack_exports__);
  42920. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return LensFlare; });
  42921. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42922. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42923. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42924. /**
  42925. * This represents one of the lens effect in a `lensFlareSystem`.
  42926. * It controls one of the indiviual texture used in the effect.
  42927. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  42928. */
  42929. var LensFlare = /** @class */ (function () {
  42930. /**
  42931. * Instantiates a new Lens Flare.
  42932. * This represents one of the lens effect in a `lensFlareSystem`.
  42933. * It controls one of the indiviual texture used in the effect.
  42934. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  42935. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  42936. * @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.
  42937. * @param color Define the lens color
  42938. * @param imgUrl Define the lens texture url
  42939. * @param system Define the `lensFlareSystem` this flare is part of
  42940. */
  42941. function LensFlare(
  42942. /**
  42943. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  42944. */
  42945. size,
  42946. /**
  42947. * 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.
  42948. */
  42949. position, color, imgUrl, system) {
  42950. this.size = size;
  42951. this.position = position;
  42952. /**
  42953. * Define the alpha mode to render this particular lens.
  42954. */
  42955. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_ONEONE;
  42956. this.color = color || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](1, 1, 1);
  42957. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](imgUrl, system.getScene(), true) : null;
  42958. this._system = system;
  42959. system.lensFlares.push(this);
  42960. }
  42961. /**
  42962. * Creates a new Lens Flare.
  42963. * This represents one of the lens effect in a `lensFlareSystem`.
  42964. * It controls one of the indiviual texture used in the effect.
  42965. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  42966. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  42967. * @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.
  42968. * @param color Define the lens color
  42969. * @param imgUrl Define the lens texture url
  42970. * @param system Define the `lensFlareSystem` this flare is part of
  42971. * @returns The newly created Lens Flare
  42972. */
  42973. LensFlare.AddFlare = function (size, position, color, imgUrl, system) {
  42974. return new LensFlare(size, position, color, imgUrl, system);
  42975. };
  42976. /**
  42977. * Dispose and release the lens flare with its associated resources.
  42978. */
  42979. LensFlare.prototype.dispose = function () {
  42980. if (this.texture) {
  42981. this.texture.dispose();
  42982. }
  42983. // Remove from scene
  42984. var index = this._system.lensFlares.indexOf(this);
  42985. this._system.lensFlares.splice(index, 1);
  42986. };
  42987. return LensFlare;
  42988. }());
  42989. /***/ }),
  42990. /***/ "./LensFlares/lensFlareSystem.ts":
  42991. /*!***************************************!*\
  42992. !*** ./LensFlares/lensFlareSystem.ts ***!
  42993. \***************************************/
  42994. /*! exports provided: LensFlareSystem */
  42995. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42996. "use strict";
  42997. __webpack_require__.r(__webpack_exports__);
  42998. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return LensFlareSystem; });
  42999. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  43000. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43001. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  43002. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  43003. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  43004. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  43005. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  43006. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  43007. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43008. /* harmony import */ var _Shaders_lensFlare_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/lensFlare.fragment */ "./Shaders/lensFlare.fragment.ts");
  43009. /* harmony import */ var _Shaders_lensFlare_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/lensFlare.vertex */ "./Shaders/lensFlare.vertex.ts");
  43010. /**
  43011. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  43012. * It is usually composed of several `lensFlare`.
  43013. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43014. */
  43015. var LensFlareSystem = /** @class */ (function () {
  43016. /**
  43017. * Instantiates a lens flare system.
  43018. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  43019. * It is usually composed of several `lensFlare`.
  43020. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43021. * @param name Define the name of the lens flare system in the scene
  43022. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  43023. * @param scene Define the scene the lens flare system belongs to
  43024. */
  43025. function LensFlareSystem(
  43026. /**
  43027. * Define the name of the lens flare system
  43028. */
  43029. name, emitter, scene) {
  43030. this.name = name;
  43031. /**
  43032. * List of lens flares used in this system.
  43033. */
  43034. this.lensFlares = new Array();
  43035. /**
  43036. * Define a limit from the border the lens flare can be visible.
  43037. */
  43038. this.borderLimit = 300;
  43039. /**
  43040. * Define a viewport border we do not want to see the lens flare in.
  43041. */
  43042. this.viewportBorder = 0;
  43043. /**
  43044. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  43045. */
  43046. this.layerMask = 0x0FFFFFFF;
  43047. this._vertexBuffers = {};
  43048. this._isEnabled = true;
  43049. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  43050. LensFlareSystem._SceneComponentInitialization(this._scene);
  43051. this._emitter = emitter;
  43052. this.id = name;
  43053. scene.lensFlareSystems.push(this);
  43054. this.meshesSelectionPredicate = function (m) { return (scene.activeCamera && m.material && m.isVisible && m.isEnabled() && m.isBlocker && ((m.layerMask & scene.activeCamera.layerMask) != 0)); };
  43055. var engine = scene.getEngine();
  43056. // VBO
  43057. var vertices = [];
  43058. vertices.push(1, 1);
  43059. vertices.push(-1, 1);
  43060. vertices.push(-1, -1);
  43061. vertices.push(1, -1);
  43062. 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);
  43063. // Indices
  43064. var indices = [];
  43065. indices.push(0);
  43066. indices.push(1);
  43067. indices.push(2);
  43068. indices.push(0);
  43069. indices.push(2);
  43070. indices.push(3);
  43071. this._indexBuffer = engine.createIndexBuffer(indices);
  43072. // Effects
  43073. this._effect = engine.createEffect("lensFlare", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["color", "viewportMatrix"], ["textureSampler"], "");
  43074. }
  43075. Object.defineProperty(LensFlareSystem.prototype, "isEnabled", {
  43076. /**
  43077. * Define if the lens flare system is enabled.
  43078. */
  43079. get: function () {
  43080. return this._isEnabled;
  43081. },
  43082. set: function (value) {
  43083. this._isEnabled = value;
  43084. },
  43085. enumerable: true,
  43086. configurable: true
  43087. });
  43088. /**
  43089. * Get the scene the effects belongs to.
  43090. * @returns the scene holding the lens flare system
  43091. */
  43092. LensFlareSystem.prototype.getScene = function () {
  43093. return this._scene;
  43094. };
  43095. /**
  43096. * Get the emitter of the lens flare system.
  43097. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  43098. * @returns the emitter of the lens flare system
  43099. */
  43100. LensFlareSystem.prototype.getEmitter = function () {
  43101. return this._emitter;
  43102. };
  43103. /**
  43104. * Set the emitter of the lens flare system.
  43105. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  43106. * @param newEmitter Define the new emitter of the system
  43107. */
  43108. LensFlareSystem.prototype.setEmitter = function (newEmitter) {
  43109. this._emitter = newEmitter;
  43110. };
  43111. /**
  43112. * Get the lens flare system emitter position.
  43113. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  43114. * @returns the position
  43115. */
  43116. LensFlareSystem.prototype.getEmitterPosition = function () {
  43117. return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position;
  43118. };
  43119. /**
  43120. * @hidden
  43121. */
  43122. LensFlareSystem.prototype.computeEffectivePosition = function (globalViewport) {
  43123. var position = this.getEmitterPosition();
  43124. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), this._scene.getTransformMatrix(), globalViewport);
  43125. this._positionX = position.x;
  43126. this._positionY = position.y;
  43127. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(this.getEmitterPosition(), this._scene.getViewMatrix());
  43128. if (this.viewportBorder > 0) {
  43129. globalViewport.x -= this.viewportBorder;
  43130. globalViewport.y -= this.viewportBorder;
  43131. globalViewport.width += this.viewportBorder * 2;
  43132. globalViewport.height += this.viewportBorder * 2;
  43133. position.x += this.viewportBorder;
  43134. position.y += this.viewportBorder;
  43135. this._positionX += this.viewportBorder;
  43136. this._positionY += this.viewportBorder;
  43137. }
  43138. if (position.z > 0) {
  43139. if ((this._positionX > globalViewport.x) && (this._positionX < globalViewport.x + globalViewport.width)) {
  43140. if ((this._positionY > globalViewport.y) && (this._positionY < globalViewport.y + globalViewport.height)) {
  43141. return true;
  43142. }
  43143. }
  43144. return true;
  43145. }
  43146. return false;
  43147. };
  43148. /** @hidden */
  43149. LensFlareSystem.prototype._isVisible = function () {
  43150. if (!this._isEnabled || !this._scene.activeCamera) {
  43151. return false;
  43152. }
  43153. var emitterPosition = this.getEmitterPosition();
  43154. var direction = emitterPosition.subtract(this._scene.activeCamera.globalPosition);
  43155. var distance = direction.length();
  43156. direction.normalize();
  43157. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](this._scene.activeCamera.globalPosition, direction);
  43158. var pickInfo = this._scene.pickWithRay(ray, this.meshesSelectionPredicate, true);
  43159. return !pickInfo || !pickInfo.hit || pickInfo.distance > distance;
  43160. };
  43161. /**
  43162. * @hidden
  43163. */
  43164. LensFlareSystem.prototype.render = function () {
  43165. if (!this._effect.isReady() || !this._scene.activeCamera) {
  43166. return false;
  43167. }
  43168. var engine = this._scene.getEngine();
  43169. var viewport = this._scene.activeCamera.viewport;
  43170. var globalViewport = viewport.toGlobal(engine.getRenderWidth(true), engine.getRenderHeight(true));
  43171. // Position
  43172. if (!this.computeEffectivePosition(globalViewport)) {
  43173. return false;
  43174. }
  43175. // Visibility
  43176. if (!this._isVisible()) {
  43177. return false;
  43178. }
  43179. // Intensity
  43180. var awayX;
  43181. var awayY;
  43182. if (this._positionX < this.borderLimit + globalViewport.x) {
  43183. awayX = this.borderLimit + globalViewport.x - this._positionX;
  43184. }
  43185. else if (this._positionX > globalViewport.x + globalViewport.width - this.borderLimit) {
  43186. awayX = this._positionX - globalViewport.x - globalViewport.width + this.borderLimit;
  43187. }
  43188. else {
  43189. awayX = 0;
  43190. }
  43191. if (this._positionY < this.borderLimit + globalViewport.y) {
  43192. awayY = this.borderLimit + globalViewport.y - this._positionY;
  43193. }
  43194. else if (this._positionY > globalViewport.y + globalViewport.height - this.borderLimit) {
  43195. awayY = this._positionY - globalViewport.y - globalViewport.height + this.borderLimit;
  43196. }
  43197. else {
  43198. awayY = 0;
  43199. }
  43200. var away = (awayX > awayY) ? awayX : awayY;
  43201. away -= this.viewportBorder;
  43202. if (away > this.borderLimit) {
  43203. away = this.borderLimit;
  43204. }
  43205. var intensity = 1.0 - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Clamp(away / this.borderLimit, 0, 1);
  43206. if (intensity < 0) {
  43207. return false;
  43208. }
  43209. if (intensity > 1.0) {
  43210. intensity = 1.0;
  43211. }
  43212. if (this.viewportBorder > 0) {
  43213. globalViewport.x += this.viewportBorder;
  43214. globalViewport.y += this.viewportBorder;
  43215. globalViewport.width -= this.viewportBorder * 2;
  43216. globalViewport.height -= this.viewportBorder * 2;
  43217. this._positionX -= this.viewportBorder;
  43218. this._positionY -= this.viewportBorder;
  43219. }
  43220. // Position
  43221. var centerX = globalViewport.x + globalViewport.width / 2;
  43222. var centerY = globalViewport.y + globalViewport.height / 2;
  43223. var distX = centerX - this._positionX;
  43224. var distY = centerY - this._positionY;
  43225. // Effects
  43226. engine.enableEffect(this._effect);
  43227. engine.setState(false);
  43228. engine.setDepthBuffer(false);
  43229. // VBOs
  43230. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  43231. // Flares
  43232. for (var index = 0; index < this.lensFlares.length; index++) {
  43233. var flare = this.lensFlares[index];
  43234. engine.setAlphaMode(flare.alphaMode);
  43235. var x = centerX - (distX * flare.position);
  43236. var y = centerY - (distY * flare.position);
  43237. var cw = flare.size;
  43238. var ch = flare.size * engine.getAspectRatio(this._scene.activeCamera, true);
  43239. var cx = 2 * (x / (globalViewport.width + globalViewport.x * 2)) - 1.0;
  43240. var cy = 1.0 - 2 * (y / (globalViewport.height + globalViewport.y * 2));
  43241. 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);
  43242. this._effect.setMatrix("viewportMatrix", viewportMatrix);
  43243. // Texture
  43244. this._effect.setTexture("textureSampler", flare.texture);
  43245. // Color
  43246. this._effect.setFloat4("color", flare.color.r * intensity, flare.color.g * intensity, flare.color.b * intensity, 1.0);
  43247. // Draw order
  43248. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  43249. }
  43250. engine.setDepthBuffer(true);
  43251. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  43252. return true;
  43253. };
  43254. /**
  43255. * Dispose and release the lens flare with its associated resources.
  43256. */
  43257. LensFlareSystem.prototype.dispose = function () {
  43258. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  43259. if (vertexBuffer) {
  43260. vertexBuffer.dispose();
  43261. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind] = null;
  43262. }
  43263. if (this._indexBuffer) {
  43264. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  43265. this._indexBuffer = null;
  43266. }
  43267. while (this.lensFlares.length) {
  43268. this.lensFlares[0].dispose();
  43269. }
  43270. // Remove from scene
  43271. var index = this._scene.lensFlareSystems.indexOf(this);
  43272. this._scene.lensFlareSystems.splice(index, 1);
  43273. };
  43274. /**
  43275. * Parse a lens flare system from a JSON repressentation
  43276. * @param parsedLensFlareSystem Define the JSON to parse
  43277. * @param scene Define the scene the parsed system should be instantiated in
  43278. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  43279. * @returns the parsed system
  43280. */
  43281. LensFlareSystem.Parse = function (parsedLensFlareSystem, scene, rootUrl) {
  43282. var emitter = scene.getLastEntryByID(parsedLensFlareSystem.emitterId);
  43283. var name = parsedLensFlareSystem.name || "lensFlareSystem#" + parsedLensFlareSystem.emitterId;
  43284. var lensFlareSystem = new LensFlareSystem(name, emitter, scene);
  43285. lensFlareSystem.id = parsedLensFlareSystem.id || name;
  43286. lensFlareSystem.borderLimit = parsedLensFlareSystem.borderLimit;
  43287. for (var index = 0; index < parsedLensFlareSystem.flares.length; index++) {
  43288. var parsedFlare = parsedLensFlareSystem.flares[index];
  43289. _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);
  43290. }
  43291. return lensFlareSystem;
  43292. };
  43293. /**
  43294. * Serialize the current Lens Flare System into a JSON representation.
  43295. * @returns the serialized JSON
  43296. */
  43297. LensFlareSystem.prototype.serialize = function () {
  43298. var serializationObject = {};
  43299. serializationObject.id = this.id;
  43300. serializationObject.name = this.name;
  43301. serializationObject.emitterId = this.getEmitter().id;
  43302. serializationObject.borderLimit = this.borderLimit;
  43303. serializationObject.flares = [];
  43304. for (var index = 0; index < this.lensFlares.length; index++) {
  43305. var flare = this.lensFlares[index];
  43306. serializationObject.flares.push({
  43307. size: flare.size,
  43308. position: flare.position,
  43309. color: flare.color.asArray(),
  43310. textureName: _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(flare.texture ? flare.texture.name : "")
  43311. });
  43312. }
  43313. return serializationObject;
  43314. };
  43315. /** @hidden */
  43316. LensFlareSystem._SceneComponentInitialization = function (_) {
  43317. throw "Import LensFlareSystemSceneComponent before creating LensFlareSystem.";
  43318. };
  43319. return LensFlareSystem;
  43320. }());
  43321. /***/ }),
  43322. /***/ "./LensFlares/lensFlareSystemSceneComponent.ts":
  43323. /*!*****************************************************!*\
  43324. !*** ./LensFlares/lensFlareSystemSceneComponent.ts ***!
  43325. \*****************************************************/
  43326. /*! exports provided: LensFlareSystemSceneComponent */
  43327. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43328. "use strict";
  43329. __webpack_require__.r(__webpack_exports__);
  43330. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return LensFlareSystemSceneComponent; });
  43331. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  43332. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  43333. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  43334. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  43335. // Adds the parser to the scene parsers.
  43336. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM, function (parsedData, scene, container, rootUrl) {
  43337. // Lens flares
  43338. if (parsedData.lensFlareSystems !== undefined && parsedData.lensFlareSystems !== null) {
  43339. if (!container.lensFlareSystems) {
  43340. container.lensFlareSystems = new Array();
  43341. }
  43342. for (var index = 0, cache = parsedData.lensFlareSystems.length; index < cache; index++) {
  43343. var parsedLensFlareSystem = parsedData.lensFlareSystems[index];
  43344. var lf = _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"].Parse(parsedLensFlareSystem, scene, rootUrl);
  43345. container.lensFlareSystems.push(lf);
  43346. }
  43347. }
  43348. });
  43349. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByName = function (name) {
  43350. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  43351. if (this.lensFlareSystems[index].name === name) {
  43352. return this.lensFlareSystems[index];
  43353. }
  43354. }
  43355. return null;
  43356. };
  43357. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByID = function (id) {
  43358. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  43359. if (this.lensFlareSystems[index].id === id) {
  43360. return this.lensFlareSystems[index];
  43361. }
  43362. }
  43363. return null;
  43364. };
  43365. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.removeLensFlareSystem = function (toRemove) {
  43366. var index = this.lensFlareSystems.indexOf(toRemove);
  43367. if (index !== -1) {
  43368. this.lensFlareSystems.splice(index, 1);
  43369. }
  43370. return index;
  43371. };
  43372. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.addLensFlareSystem = function (newLensFlareSystem) {
  43373. this.lensFlareSystems.push(newLensFlareSystem);
  43374. };
  43375. /**
  43376. * Defines the lens flare scene component responsible to manage any lens flares
  43377. * in a given scene.
  43378. */
  43379. var LensFlareSystemSceneComponent = /** @class */ (function () {
  43380. /**
  43381. * Creates a new instance of the component for the given scene
  43382. * @param scene Defines the scene to register the component in
  43383. */
  43384. function LensFlareSystemSceneComponent(scene) {
  43385. /**
  43386. * The component name helpfull to identify the component in the list of scene components.
  43387. */
  43388. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM;
  43389. this.scene = scene;
  43390. scene.lensFlareSystems = new Array();
  43391. }
  43392. /**
  43393. * Registers the component in a given scene
  43394. */
  43395. LensFlareSystemSceneComponent.prototype.register = function () {
  43396. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw);
  43397. };
  43398. /**
  43399. * Rebuilds the elements related to this component in case of
  43400. * context lost for instance.
  43401. */
  43402. LensFlareSystemSceneComponent.prototype.rebuild = function () {
  43403. // Nothing to do for lens flare
  43404. };
  43405. /**
  43406. * Adds all the element from the container to the scene
  43407. * @param container the container holding the elements
  43408. */
  43409. LensFlareSystemSceneComponent.prototype.addFromContainer = function (container) {
  43410. var _this = this;
  43411. if (!container.lensFlareSystems) {
  43412. return;
  43413. }
  43414. container.lensFlareSystems.forEach(function (o) {
  43415. _this.scene.addLensFlareSystem(o);
  43416. });
  43417. };
  43418. /**
  43419. * Removes all the elements in the container from the scene
  43420. * @param container contains the elements to remove
  43421. */
  43422. LensFlareSystemSceneComponent.prototype.removeFromContainer = function (container) {
  43423. var _this = this;
  43424. if (!container.lensFlareSystems) {
  43425. return;
  43426. }
  43427. container.lensFlareSystems.forEach(function (o) {
  43428. _this.scene.removeLensFlareSystem(o);
  43429. });
  43430. };
  43431. /**
  43432. * Serializes the component data to the specified json object
  43433. * @param serializationObject The object to serialize to
  43434. */
  43435. LensFlareSystemSceneComponent.prototype.serialize = function (serializationObject) {
  43436. // Lens flares
  43437. serializationObject.lensFlareSystems = [];
  43438. var lensFlareSystems = this.scene.lensFlareSystems;
  43439. for (var _i = 0, lensFlareSystems_1 = lensFlareSystems; _i < lensFlareSystems_1.length; _i++) {
  43440. var lensFlareSystem = lensFlareSystems_1[_i];
  43441. serializationObject.lensFlareSystems.push(lensFlareSystem.serialize());
  43442. }
  43443. };
  43444. /**
  43445. * Disposes the component and the associated ressources.
  43446. */
  43447. LensFlareSystemSceneComponent.prototype.dispose = function () {
  43448. var lensFlareSystems = this.scene.lensFlareSystems;
  43449. while (lensFlareSystems.length) {
  43450. lensFlareSystems[0].dispose();
  43451. }
  43452. };
  43453. LensFlareSystemSceneComponent.prototype._draw = function (camera) {
  43454. // Lens flares
  43455. if (this.scene.lensFlaresEnabled) {
  43456. var lensFlareSystems = this.scene.lensFlareSystems;
  43457. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  43458. for (var _i = 0, lensFlareSystems_2 = lensFlareSystems; _i < lensFlareSystems_2.length; _i++) {
  43459. var lensFlareSystem = lensFlareSystems_2[_i];
  43460. if ((camera.layerMask & lensFlareSystem.layerMask) !== 0) {
  43461. lensFlareSystem.render();
  43462. }
  43463. }
  43464. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  43465. }
  43466. };
  43467. return LensFlareSystemSceneComponent;
  43468. }());
  43469. _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"]._SceneComponentInitialization = function (scene) {
  43470. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM);
  43471. if (!component) {
  43472. component = new LensFlareSystemSceneComponent(scene);
  43473. scene._addComponent(component);
  43474. }
  43475. };
  43476. /***/ }),
  43477. /***/ "./Lights/Shadows/index.ts":
  43478. /*!*********************************!*\
  43479. !*** ./Lights/Shadows/index.ts ***!
  43480. \*********************************/
  43481. /*! exports provided: ShadowGenerator, ShadowGeneratorSceneComponent */
  43482. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43483. "use strict";
  43484. __webpack_require__.r(__webpack_exports__);
  43485. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  43486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  43487. /* harmony import */ var _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowGeneratorSceneComponent */ "./Lights/Shadows/shadowGeneratorSceneComponent.ts");
  43488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__["ShadowGeneratorSceneComponent"]; });
  43489. /***/ }),
  43490. /***/ "./Lights/Shadows/shadowGenerator.ts":
  43491. /*!*******************************************!*\
  43492. !*** ./Lights/Shadows/shadowGenerator.ts ***!
  43493. \*******************************************/
  43494. /*! exports provided: ShadowGenerator */
  43495. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43496. "use strict";
  43497. __webpack_require__.r(__webpack_exports__);
  43498. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return ShadowGenerator; });
  43499. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  43500. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  43501. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  43502. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  43503. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  43504. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  43505. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43506. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  43507. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  43508. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  43509. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  43510. /* harmony import */ var _Shaders_shadowMap_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Shaders/shadowMap.fragment */ "./Shaders/shadowMap.fragment.ts");
  43511. /* harmony import */ var _Shaders_shadowMap_vertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Shaders/shadowMap.vertex */ "./Shaders/shadowMap.vertex.ts");
  43512. /* harmony import */ var _Shaders_depthBoxBlur_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Shaders/depthBoxBlur.fragment */ "./Shaders/depthBoxBlur.fragment.ts");
  43513. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  43514. /**
  43515. * Default implementation IShadowGenerator.
  43516. * This is the main object responsible of generating shadows in the framework.
  43517. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  43518. */
  43519. var ShadowGenerator = /** @class */ (function () {
  43520. /**
  43521. * Creates a ShadowGenerator object.
  43522. * A ShadowGenerator is the required tool to use the shadows.
  43523. * Each light casting shadows needs to use its own ShadowGenerator.
  43524. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  43525. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  43526. * @param light The light object generating the shadows.
  43527. * @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.
  43528. */
  43529. function ShadowGenerator(mapSize, light, usefulFloatFirst) {
  43530. /**
  43531. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  43532. */
  43533. this.onBeforeShadowMapRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  43534. this._bias = 0.00005;
  43535. this._normalBias = 0;
  43536. this._blurBoxOffset = 1;
  43537. this._blurScale = 2;
  43538. this._blurKernel = 1;
  43539. this._useKernelBlur = false;
  43540. this._filter = ShadowGenerator.FILTER_NONE;
  43541. this._filteringQuality = ShadowGenerator.QUALITY_HIGH;
  43542. this._contactHardeningLightSizeUVRatio = 0.1;
  43543. this._darkness = 0;
  43544. this._transparencyShadow = false;
  43545. /**
  43546. * Controls the extent to which the shadows fade out at the edge of the frustum
  43547. * Used only by directionals and spots
  43548. */
  43549. this.frustumEdgeFalloff = 0;
  43550. /**
  43551. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  43552. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  43553. * It might on the other hand introduce peter panning.
  43554. */
  43555. this.forceBackFacesOnly = false;
  43556. this._lightDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  43557. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  43558. this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  43559. this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  43560. this._cachedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  43561. this._cachedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  43562. this._currentFaceIndex = 0;
  43563. this._currentFaceIndexCache = 0;
  43564. this._defaultTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  43565. this._mapSize = mapSize;
  43566. this._light = light;
  43567. this._scene = light.getScene();
  43568. light._shadowGenerator = this;
  43569. ShadowGenerator._SceneComponentInitialization(this._scene);
  43570. // Texture type fallback from float to int if not supported.
  43571. var caps = this._scene.getEngine().getCaps();
  43572. if (!usefulFloatFirst) {
  43573. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  43574. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  43575. }
  43576. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  43577. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  43578. }
  43579. else {
  43580. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  43581. }
  43582. }
  43583. else {
  43584. if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  43585. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  43586. }
  43587. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  43588. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  43589. }
  43590. else {
  43591. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  43592. }
  43593. }
  43594. this._initializeGenerator();
  43595. this._applyFilterValues();
  43596. }
  43597. Object.defineProperty(ShadowGenerator.prototype, "bias", {
  43598. /**
  43599. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  43600. */
  43601. get: function () {
  43602. return this._bias;
  43603. },
  43604. /**
  43605. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  43606. */
  43607. set: function (bias) {
  43608. this._bias = bias;
  43609. },
  43610. enumerable: true,
  43611. configurable: true
  43612. });
  43613. Object.defineProperty(ShadowGenerator.prototype, "normalBias", {
  43614. /**
  43615. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  43616. */
  43617. get: function () {
  43618. return this._normalBias;
  43619. },
  43620. /**
  43621. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  43622. */
  43623. set: function (normalBias) {
  43624. this._normalBias = normalBias;
  43625. },
  43626. enumerable: true,
  43627. configurable: true
  43628. });
  43629. Object.defineProperty(ShadowGenerator.prototype, "blurBoxOffset", {
  43630. /**
  43631. * Gets the blur box offset: offset applied during the blur pass.
  43632. * Only useful if useKernelBlur = false
  43633. */
  43634. get: function () {
  43635. return this._blurBoxOffset;
  43636. },
  43637. /**
  43638. * Sets the blur box offset: offset applied during the blur pass.
  43639. * Only useful if useKernelBlur = false
  43640. */
  43641. set: function (value) {
  43642. if (this._blurBoxOffset === value) {
  43643. return;
  43644. }
  43645. this._blurBoxOffset = value;
  43646. this._disposeBlurPostProcesses();
  43647. },
  43648. enumerable: true,
  43649. configurable: true
  43650. });
  43651. Object.defineProperty(ShadowGenerator.prototype, "blurScale", {
  43652. /**
  43653. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  43654. * 2 means half of the size.
  43655. */
  43656. get: function () {
  43657. return this._blurScale;
  43658. },
  43659. /**
  43660. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  43661. * 2 means half of the size.
  43662. */
  43663. set: function (value) {
  43664. if (this._blurScale === value) {
  43665. return;
  43666. }
  43667. this._blurScale = value;
  43668. this._disposeBlurPostProcesses();
  43669. },
  43670. enumerable: true,
  43671. configurable: true
  43672. });
  43673. Object.defineProperty(ShadowGenerator.prototype, "blurKernel", {
  43674. /**
  43675. * Gets the blur kernel: kernel size of the blur pass.
  43676. * Only useful if useKernelBlur = true
  43677. */
  43678. get: function () {
  43679. return this._blurKernel;
  43680. },
  43681. /**
  43682. * Sets the blur kernel: kernel size of the blur pass.
  43683. * Only useful if useKernelBlur = true
  43684. */
  43685. set: function (value) {
  43686. if (this._blurKernel === value) {
  43687. return;
  43688. }
  43689. this._blurKernel = value;
  43690. this._disposeBlurPostProcesses();
  43691. },
  43692. enumerable: true,
  43693. configurable: true
  43694. });
  43695. Object.defineProperty(ShadowGenerator.prototype, "useKernelBlur", {
  43696. /**
  43697. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  43698. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  43699. */
  43700. get: function () {
  43701. return this._useKernelBlur;
  43702. },
  43703. /**
  43704. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  43705. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  43706. */
  43707. set: function (value) {
  43708. if (this._useKernelBlur === value) {
  43709. return;
  43710. }
  43711. this._useKernelBlur = value;
  43712. this._disposeBlurPostProcesses();
  43713. },
  43714. enumerable: true,
  43715. configurable: true
  43716. });
  43717. Object.defineProperty(ShadowGenerator.prototype, "depthScale", {
  43718. /**
  43719. * Gets the depth scale used in ESM mode.
  43720. */
  43721. get: function () {
  43722. return this._depthScale !== undefined ? this._depthScale : this._light.getDepthScale();
  43723. },
  43724. /**
  43725. * Sets the depth scale used in ESM mode.
  43726. * This can override the scale stored on the light.
  43727. */
  43728. set: function (value) {
  43729. this._depthScale = value;
  43730. },
  43731. enumerable: true,
  43732. configurable: true
  43733. });
  43734. Object.defineProperty(ShadowGenerator.prototype, "filter", {
  43735. /**
  43736. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  43737. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  43738. */
  43739. get: function () {
  43740. return this._filter;
  43741. },
  43742. /**
  43743. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  43744. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  43745. */
  43746. set: function (value) {
  43747. // Blurring the cubemap is going to be too expensive. Reverting to unblurred version
  43748. if (this._light.needCube()) {
  43749. if (value === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  43750. this.useExponentialShadowMap = true;
  43751. return;
  43752. }
  43753. else if (value === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  43754. this.useCloseExponentialShadowMap = true;
  43755. return;
  43756. }
  43757. // PCF on cubemap would also be expensive
  43758. else if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  43759. this.usePoissonSampling = true;
  43760. return;
  43761. }
  43762. }
  43763. // Weblg1 fallback for PCF.
  43764. if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  43765. if (this._scene.getEngine().webGLVersion === 1) {
  43766. this.usePoissonSampling = true;
  43767. return;
  43768. }
  43769. }
  43770. if (this._filter === value) {
  43771. return;
  43772. }
  43773. this._filter = value;
  43774. this._disposeBlurPostProcesses();
  43775. this._applyFilterValues();
  43776. this._light._markMeshesAsLightDirty();
  43777. },
  43778. enumerable: true,
  43779. configurable: true
  43780. });
  43781. Object.defineProperty(ShadowGenerator.prototype, "usePoissonSampling", {
  43782. /**
  43783. * Gets if the current filter is set to Poisson Sampling.
  43784. */
  43785. get: function () {
  43786. return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
  43787. },
  43788. /**
  43789. * Sets the current filter to Poisson Sampling.
  43790. */
  43791. set: function (value) {
  43792. if (!value && this.filter !== ShadowGenerator.FILTER_POISSONSAMPLING) {
  43793. return;
  43794. }
  43795. this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE);
  43796. },
  43797. enumerable: true,
  43798. configurable: true
  43799. });
  43800. Object.defineProperty(ShadowGenerator.prototype, "useExponentialShadowMap", {
  43801. /**
  43802. * Gets if the current filter is set to ESM.
  43803. */
  43804. get: function () {
  43805. return this.filter === ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP;
  43806. },
  43807. /**
  43808. * Sets the current filter is to ESM.
  43809. */
  43810. set: function (value) {
  43811. if (!value && this.filter !== ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP) {
  43812. return;
  43813. }
  43814. this.filter = (value ? ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  43815. },
  43816. enumerable: true,
  43817. configurable: true
  43818. });
  43819. Object.defineProperty(ShadowGenerator.prototype, "useBlurExponentialShadowMap", {
  43820. /**
  43821. * Gets if the current filter is set to filtered ESM.
  43822. */
  43823. get: function () {
  43824. return this.filter === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP;
  43825. },
  43826. /**
  43827. * Gets if the current filter is set to filtered ESM.
  43828. */
  43829. set: function (value) {
  43830. if (!value && this.filter !== ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  43831. return;
  43832. }
  43833. this.filter = (value ? ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  43834. },
  43835. enumerable: true,
  43836. configurable: true
  43837. });
  43838. Object.defineProperty(ShadowGenerator.prototype, "useCloseExponentialShadowMap", {
  43839. /**
  43840. * Gets if the current filter is set to "close ESM" (using the inverse of the
  43841. * exponential to prevent steep falloff artifacts).
  43842. */
  43843. get: function () {
  43844. return this.filter === ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP;
  43845. },
  43846. /**
  43847. * Sets the current filter to "close ESM" (using the inverse of the
  43848. * exponential to prevent steep falloff artifacts).
  43849. */
  43850. set: function (value) {
  43851. if (!value && this.filter !== ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP) {
  43852. return;
  43853. }
  43854. this.filter = (value ? ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  43855. },
  43856. enumerable: true,
  43857. configurable: true
  43858. });
  43859. Object.defineProperty(ShadowGenerator.prototype, "useBlurCloseExponentialShadowMap", {
  43860. /**
  43861. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  43862. * exponential to prevent steep falloff artifacts).
  43863. */
  43864. get: function () {
  43865. return this.filter === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  43866. },
  43867. /**
  43868. * Sets the current filter to filtered "close ESM" (using the inverse of the
  43869. * exponential to prevent steep falloff artifacts).
  43870. */
  43871. set: function (value) {
  43872. if (!value && this.filter !== ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  43873. return;
  43874. }
  43875. this.filter = (value ? ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  43876. },
  43877. enumerable: true,
  43878. configurable: true
  43879. });
  43880. Object.defineProperty(ShadowGenerator.prototype, "usePercentageCloserFiltering", {
  43881. /**
  43882. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  43883. */
  43884. get: function () {
  43885. return this.filter === ShadowGenerator.FILTER_PCF;
  43886. },
  43887. /**
  43888. * Sets the current filter to "PCF" (percentage closer filtering).
  43889. */
  43890. set: function (value) {
  43891. if (!value && this.filter !== ShadowGenerator.FILTER_PCF) {
  43892. return;
  43893. }
  43894. this.filter = (value ? ShadowGenerator.FILTER_PCF : ShadowGenerator.FILTER_NONE);
  43895. },
  43896. enumerable: true,
  43897. configurable: true
  43898. });
  43899. Object.defineProperty(ShadowGenerator.prototype, "filteringQuality", {
  43900. /**
  43901. * Gets the PCF or PCSS Quality.
  43902. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  43903. */
  43904. get: function () {
  43905. return this._filteringQuality;
  43906. },
  43907. /**
  43908. * Sets the PCF or PCSS Quality.
  43909. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  43910. */
  43911. set: function (filteringQuality) {
  43912. this._filteringQuality = filteringQuality;
  43913. },
  43914. enumerable: true,
  43915. configurable: true
  43916. });
  43917. Object.defineProperty(ShadowGenerator.prototype, "useContactHardeningShadow", {
  43918. /**
  43919. * Gets if the current filter is set to "PCSS" (contact hardening).
  43920. */
  43921. get: function () {
  43922. return this.filter === ShadowGenerator.FILTER_PCSS;
  43923. },
  43924. /**
  43925. * Sets the current filter to "PCSS" (contact hardening).
  43926. */
  43927. set: function (value) {
  43928. if (!value && this.filter !== ShadowGenerator.FILTER_PCSS) {
  43929. return;
  43930. }
  43931. this.filter = (value ? ShadowGenerator.FILTER_PCSS : ShadowGenerator.FILTER_NONE);
  43932. },
  43933. enumerable: true,
  43934. configurable: true
  43935. });
  43936. Object.defineProperty(ShadowGenerator.prototype, "contactHardeningLightSizeUVRatio", {
  43937. /**
  43938. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  43939. * Using a ratio helps keeping shape stability independently of the map size.
  43940. *
  43941. * It does not account for the light projection as it was having too much
  43942. * instability during the light setup or during light position changes.
  43943. *
  43944. * Only valid if useContactHardeningShadow is true.
  43945. */
  43946. get: function () {
  43947. return this._contactHardeningLightSizeUVRatio;
  43948. },
  43949. /**
  43950. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  43951. * Using a ratio helps keeping shape stability independently of the map size.
  43952. *
  43953. * It does not account for the light projection as it was having too much
  43954. * instability during the light setup or during light position changes.
  43955. *
  43956. * Only valid if useContactHardeningShadow is true.
  43957. */
  43958. set: function (contactHardeningLightSizeUVRatio) {
  43959. this._contactHardeningLightSizeUVRatio = contactHardeningLightSizeUVRatio;
  43960. },
  43961. enumerable: true,
  43962. configurable: true
  43963. });
  43964. /**
  43965. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  43966. * 0 means strongest and 1 would means no shadow.
  43967. * @returns the darkness.
  43968. */
  43969. ShadowGenerator.prototype.getDarkness = function () {
  43970. return this._darkness;
  43971. };
  43972. /**
  43973. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  43974. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  43975. * @returns the shadow generator allowing fluent coding.
  43976. */
  43977. ShadowGenerator.prototype.setDarkness = function (darkness) {
  43978. if (darkness >= 1.0) {
  43979. this._darkness = 1.0;
  43980. }
  43981. else if (darkness <= 0.0) {
  43982. this._darkness = 0.0;
  43983. }
  43984. else {
  43985. this._darkness = darkness;
  43986. }
  43987. return this;
  43988. };
  43989. /**
  43990. * Sets the ability to have transparent shadow (boolean).
  43991. * @param transparent True if transparent else False
  43992. * @returns the shadow generator allowing fluent coding
  43993. */
  43994. ShadowGenerator.prototype.setTransparencyShadow = function (transparent) {
  43995. this._transparencyShadow = transparent;
  43996. return this;
  43997. };
  43998. /**
  43999. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44000. * @returns The render target texture if present otherwise, null
  44001. */
  44002. ShadowGenerator.prototype.getShadowMap = function () {
  44003. return this._shadowMap;
  44004. };
  44005. /**
  44006. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44007. * @returns The render target texture if the shadow map is present otherwise, null
  44008. */
  44009. ShadowGenerator.prototype.getShadowMapForRendering = function () {
  44010. if (this._shadowMap2) {
  44011. return this._shadowMap2;
  44012. }
  44013. return this._shadowMap;
  44014. };
  44015. /**
  44016. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44017. * @param mesh Mesh to add
  44018. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44019. * @returns the Shadow Generator itself
  44020. */
  44021. ShadowGenerator.prototype.addShadowCaster = function (mesh, includeDescendants) {
  44022. if (includeDescendants === void 0) { includeDescendants = true; }
  44023. var _a;
  44024. if (!this._shadowMap) {
  44025. return this;
  44026. }
  44027. if (!this._shadowMap.renderList) {
  44028. this._shadowMap.renderList = [];
  44029. }
  44030. this._shadowMap.renderList.push(mesh);
  44031. if (includeDescendants) {
  44032. (_a = this._shadowMap.renderList).push.apply(_a, mesh.getChildMeshes());
  44033. }
  44034. return this;
  44035. };
  44036. /**
  44037. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44038. * @param mesh Mesh to remove
  44039. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44040. * @returns the Shadow Generator itself
  44041. */
  44042. ShadowGenerator.prototype.removeShadowCaster = function (mesh, includeDescendants) {
  44043. if (includeDescendants === void 0) { includeDescendants = true; }
  44044. if (!this._shadowMap || !this._shadowMap.renderList) {
  44045. return this;
  44046. }
  44047. var index = this._shadowMap.renderList.indexOf(mesh);
  44048. if (index !== -1) {
  44049. this._shadowMap.renderList.splice(index, 1);
  44050. }
  44051. if (includeDescendants) {
  44052. for (var _i = 0, _a = mesh.getChildren(); _i < _a.length; _i++) {
  44053. var child = _a[_i];
  44054. this.removeShadowCaster(child);
  44055. }
  44056. }
  44057. return this;
  44058. };
  44059. /**
  44060. * Returns the associated light object.
  44061. * @returns the light generating the shadow
  44062. */
  44063. ShadowGenerator.prototype.getLight = function () {
  44064. return this._light;
  44065. };
  44066. ShadowGenerator.prototype._initializeGenerator = function () {
  44067. this._light._markMeshesAsLightDirty();
  44068. this._initializeShadowMap();
  44069. };
  44070. ShadowGenerator.prototype._initializeShadowMap = function () {
  44071. var _this = this;
  44072. // Render target
  44073. var engine = this._scene.getEngine();
  44074. if (engine.webGLVersion > 1) {
  44075. 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);
  44076. this._shadowMap.createDepthStencilTexture(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].LESS, true);
  44077. }
  44078. else {
  44079. 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());
  44080. }
  44081. this._shadowMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44082. this._shadowMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44083. this._shadowMap.anisotropicFilteringLevel = 1;
  44084. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  44085. this._shadowMap.renderParticles = false;
  44086. this._shadowMap.ignoreCameraViewport = true;
  44087. // Record Face Index before render.
  44088. this._shadowMap.onBeforeRenderObservable.add(function (faceIndex) {
  44089. _this._currentFaceIndex = faceIndex;
  44090. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  44091. engine.setColorWrite(false);
  44092. }
  44093. });
  44094. // Custom render function.
  44095. this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this);
  44096. // Blur if required afer render.
  44097. this._shadowMap.onAfterUnbindObservable.add(function () {
  44098. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  44099. engine.setColorWrite(true);
  44100. }
  44101. if (!_this.useBlurExponentialShadowMap && !_this.useBlurCloseExponentialShadowMap) {
  44102. return;
  44103. }
  44104. var shadowMap = _this.getShadowMapForRendering();
  44105. if (shadowMap) {
  44106. _this._scene.postProcessManager.directRender(_this._blurPostProcesses, shadowMap.getInternalTexture(), true);
  44107. }
  44108. });
  44109. // Clear according to the chosen filter.
  44110. var clearZero = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](0, 0, 0, 0);
  44111. var clearOne = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  44112. this._shadowMap.onClearObservable.add(function (engine) {
  44113. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  44114. engine.clear(clearOne, false, true, false);
  44115. }
  44116. else if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
  44117. engine.clear(clearZero, true, true, false);
  44118. }
  44119. else {
  44120. engine.clear(clearOne, true, true, false);
  44121. }
  44122. });
  44123. };
  44124. ShadowGenerator.prototype._initializeBlurRTTAndPostProcesses = function () {
  44125. var _this = this;
  44126. var engine = this._scene.getEngine();
  44127. var targetSize = this._mapSize / this.blurScale;
  44128. if (!this.useKernelBlur || this.blurScale !== 1.0) {
  44129. this._shadowMap2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap2", targetSize, this._scene, false, true, this._textureType);
  44130. this._shadowMap2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44131. this._shadowMap2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44132. this._shadowMap2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  44133. }
  44134. if (this.useKernelBlur) {
  44135. 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);
  44136. this._kernelBlurXPostprocess.width = targetSize;
  44137. this._kernelBlurXPostprocess.height = targetSize;
  44138. this._kernelBlurXPostprocess.onApplyObservable.add(function (effect) {
  44139. effect.setTexture("textureSampler", _this._shadowMap);
  44140. });
  44141. 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);
  44142. this._kernelBlurXPostprocess.autoClear = false;
  44143. this._kernelBlurYPostprocess.autoClear = false;
  44144. if (this._textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  44145. this._kernelBlurXPostprocess.packedFloat = true;
  44146. this._kernelBlurYPostprocess.packedFloat = true;
  44147. }
  44148. this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess];
  44149. }
  44150. else {
  44151. 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);
  44152. this._boxBlurPostprocess.onApplyObservable.add(function (effect) {
  44153. effect.setFloat2("screenSize", targetSize, targetSize);
  44154. effect.setTexture("textureSampler", _this._shadowMap);
  44155. });
  44156. this._boxBlurPostprocess.autoClear = false;
  44157. this._blurPostProcesses = [this._boxBlurPostprocess];
  44158. }
  44159. };
  44160. ShadowGenerator.prototype._renderForShadowMap = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  44161. var index;
  44162. var engine = this._scene.getEngine();
  44163. if (depthOnlySubMeshes.length) {
  44164. engine.setColorWrite(false);
  44165. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  44166. this._renderSubMeshForShadowMap(depthOnlySubMeshes.data[index]);
  44167. }
  44168. engine.setColorWrite(true);
  44169. }
  44170. for (index = 0; index < opaqueSubMeshes.length; index++) {
  44171. this._renderSubMeshForShadowMap(opaqueSubMeshes.data[index]);
  44172. }
  44173. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  44174. this._renderSubMeshForShadowMap(alphaTestSubMeshes.data[index]);
  44175. }
  44176. if (this._transparencyShadow) {
  44177. for (index = 0; index < transparentSubMeshes.length; index++) {
  44178. this._renderSubMeshForShadowMap(transparentSubMeshes.data[index]);
  44179. }
  44180. }
  44181. };
  44182. ShadowGenerator.prototype._renderSubMeshForShadowMap = function (subMesh) {
  44183. var _this = this;
  44184. var mesh = subMesh.getRenderingMesh();
  44185. var scene = this._scene;
  44186. var engine = scene.getEngine();
  44187. var material = subMesh.getMaterial();
  44188. if (!material || subMesh.verticesCount === 0) {
  44189. return;
  44190. }
  44191. // Culling
  44192. engine.setState(material.backFaceCulling);
  44193. // Managing instances
  44194. var batch = mesh._getInstancesRenderList(subMesh._id);
  44195. if (batch.mustReturn) {
  44196. return;
  44197. }
  44198. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  44199. if (this.isReady(subMesh, hardwareInstancedRendering)) {
  44200. engine.enableEffect(this._effect);
  44201. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  44202. this._effect.setFloat3("biasAndScale", this.bias, this.normalBias, this.depthScale);
  44203. this._effect.setMatrix("viewProjection", this.getTransformMatrix());
  44204. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  44205. this._effect.setVector3("lightData", this._cachedDirection);
  44206. }
  44207. else {
  44208. this._effect.setVector3("lightData", this._cachedPosition);
  44209. }
  44210. if (scene.activeCamera) {
  44211. this._effect.setFloat2("depthValues", this.getLight().getDepthMinZ(scene.activeCamera), this.getLight().getDepthMinZ(scene.activeCamera) + this.getLight().getDepthMaxZ(scene.activeCamera));
  44212. }
  44213. // Alpha test
  44214. if (material && material.needAlphaTesting()) {
  44215. var alphaTexture = material.getAlphaTestTexture();
  44216. if (alphaTexture) {
  44217. this._effect.setTexture("diffuseSampler", alphaTexture);
  44218. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix() || this._defaultTextureMatrix);
  44219. }
  44220. }
  44221. // Bones
  44222. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  44223. var skeleton = mesh.skeleton;
  44224. if (skeleton.isUsingTextureForMatrices) {
  44225. var boneTexture = skeleton.getTransformMatrixTexture();
  44226. if (!boneTexture) {
  44227. return;
  44228. }
  44229. this._effect.setTexture("boneSampler", boneTexture);
  44230. this._effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  44231. }
  44232. else {
  44233. this._effect.setMatrices("mBones", skeleton.getTransformMatrices((mesh)));
  44234. }
  44235. }
  44236. // Morph targets
  44237. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effect);
  44238. if (this.forceBackFacesOnly) {
  44239. engine.setState(true, 0, false, true);
  44240. }
  44241. // Observable
  44242. this.onBeforeShadowMapRenderObservable.notifyObservers(this._effect);
  44243. // Draw
  44244. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  44245. if (this.forceBackFacesOnly) {
  44246. engine.setState(true, 0, false, false);
  44247. }
  44248. }
  44249. else {
  44250. // Need to reset refresh rate of the shadowMap
  44251. if (this._shadowMap) {
  44252. this._shadowMap.resetRefreshCounter();
  44253. }
  44254. }
  44255. };
  44256. ShadowGenerator.prototype._applyFilterValues = function () {
  44257. if (!this._shadowMap) {
  44258. return;
  44259. }
  44260. if (this.filter === ShadowGenerator.FILTER_NONE || this.filter === ShadowGenerator.FILTER_PCSS) {
  44261. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].NEAREST_SAMPLINGMODE);
  44262. }
  44263. else {
  44264. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  44265. }
  44266. };
  44267. /**
  44268. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44269. * @param onCompiled Callback triggered at the and of the effects compilation
  44270. * @param options Sets of optional options forcing the compilation with different modes
  44271. */
  44272. ShadowGenerator.prototype.forceCompilation = function (onCompiled, options) {
  44273. var _this = this;
  44274. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ useInstances: false }, options);
  44275. var shadowMap = this.getShadowMap();
  44276. if (!shadowMap) {
  44277. if (onCompiled) {
  44278. onCompiled(this);
  44279. }
  44280. return;
  44281. }
  44282. var renderList = shadowMap.renderList;
  44283. if (!renderList) {
  44284. if (onCompiled) {
  44285. onCompiled(this);
  44286. }
  44287. return;
  44288. }
  44289. var subMeshes = new Array();
  44290. for (var _i = 0, renderList_1 = renderList; _i < renderList_1.length; _i++) {
  44291. var mesh = renderList_1[_i];
  44292. subMeshes.push.apply(subMeshes, mesh.subMeshes);
  44293. }
  44294. if (subMeshes.length === 0) {
  44295. if (onCompiled) {
  44296. onCompiled(this);
  44297. }
  44298. return;
  44299. }
  44300. var currentIndex = 0;
  44301. var checkReady = function () {
  44302. if (!_this._scene || !_this._scene.getEngine()) {
  44303. return;
  44304. }
  44305. while (_this.isReady(subMeshes[currentIndex], localOptions.useInstances)) {
  44306. currentIndex++;
  44307. if (currentIndex >= subMeshes.length) {
  44308. if (onCompiled) {
  44309. onCompiled(_this);
  44310. }
  44311. return;
  44312. }
  44313. }
  44314. setTimeout(checkReady, 16);
  44315. };
  44316. checkReady();
  44317. };
  44318. /**
  44319. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44320. * @param options Sets of optional options forcing the compilation with different modes
  44321. * @returns A promise that resolves when the compilation completes
  44322. */
  44323. ShadowGenerator.prototype.forceCompilationAsync = function (options) {
  44324. var _this = this;
  44325. return new Promise(function (resolve) {
  44326. _this.forceCompilation(function () {
  44327. resolve();
  44328. }, options);
  44329. });
  44330. };
  44331. /**
  44332. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44333. * @param subMesh The submesh we want to render in the shadow map
  44334. * @param useInstances Defines wether will draw in the map using instances
  44335. * @returns true if ready otherwise, false
  44336. */
  44337. ShadowGenerator.prototype.isReady = function (subMesh, useInstances) {
  44338. var defines = [];
  44339. if (this._textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  44340. defines.push("#define FLOAT");
  44341. }
  44342. if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  44343. defines.push("#define ESM");
  44344. }
  44345. else if (this.usePercentageCloserFiltering || this.useContactHardeningShadow) {
  44346. defines.push("#define DEPTHTEXTURE");
  44347. }
  44348. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind];
  44349. var mesh = subMesh.getMesh();
  44350. var material = subMesh.getMaterial();
  44351. // Normal bias.
  44352. if (this.normalBias && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  44353. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  44354. defines.push("#define NORMAL");
  44355. if (mesh.nonUniformScaling) {
  44356. defines.push("#define NONUNIFORMSCALING");
  44357. }
  44358. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  44359. defines.push("#define DIRECTIONINLIGHTDATA");
  44360. }
  44361. }
  44362. // Alpha test
  44363. if (material && material.needAlphaTesting()) {
  44364. var alphaTexture = material.getAlphaTestTexture();
  44365. if (alphaTexture) {
  44366. defines.push("#define ALPHATEST");
  44367. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  44368. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  44369. defines.push("#define UV1");
  44370. }
  44371. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  44372. if (alphaTexture.coordinatesIndex === 1) {
  44373. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  44374. defines.push("#define UV2");
  44375. }
  44376. }
  44377. }
  44378. }
  44379. // Bones
  44380. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  44381. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  44382. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  44383. if (mesh.numBoneInfluencers > 4) {
  44384. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  44385. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind);
  44386. }
  44387. var skeleton = mesh.skeleton;
  44388. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  44389. if (skeleton.isUsingTextureForMatrices) {
  44390. defines.push("#define BONETEXTURE");
  44391. }
  44392. else {
  44393. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  44394. }
  44395. }
  44396. else {
  44397. defines.push("#define NUM_BONE_INFLUENCERS 0");
  44398. }
  44399. // Morph targets
  44400. var manager = mesh.morphTargetManager;
  44401. var morphInfluencers = 0;
  44402. if (manager) {
  44403. if (manager.numInfluencers > 0) {
  44404. defines.push("#define MORPHTARGETS");
  44405. morphInfluencers = manager.numInfluencers;
  44406. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  44407. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  44408. }
  44409. }
  44410. // Instances
  44411. if (useInstances) {
  44412. defines.push("#define INSTANCES");
  44413. attribs.push("world0");
  44414. attribs.push("world1");
  44415. attribs.push("world2");
  44416. attribs.push("world3");
  44417. }
  44418. if (this.customShaderOptions) {
  44419. if (this.customShaderOptions.defines) {
  44420. for (var _i = 0, _a = this.customShaderOptions.defines; _i < _a.length; _i++) {
  44421. var define = _a[_i];
  44422. if (defines.indexOf(define) === -1) {
  44423. defines.push(define);
  44424. }
  44425. }
  44426. }
  44427. }
  44428. // Get correct effect
  44429. var join = defines.join("\n");
  44430. if (this._cachedDefines !== join) {
  44431. this._cachedDefines = join;
  44432. var shaderName = "shadowMap";
  44433. var uniforms = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightData", "depthValues", "biasAndScale", "morphTargetInfluences", "boneTextureWidth"];
  44434. var samplers = ["diffuseSampler", "boneSampler"];
  44435. // Custom shader?
  44436. if (this.customShaderOptions) {
  44437. shaderName = this.customShaderOptions.shaderName;
  44438. if (this.customShaderOptions.attributes) {
  44439. for (var _b = 0, _c = this.customShaderOptions.attributes; _b < _c.length; _b++) {
  44440. var attrib = _c[_b];
  44441. if (attribs.indexOf(attrib) === -1) {
  44442. attribs.push(attrib);
  44443. }
  44444. }
  44445. }
  44446. if (this.customShaderOptions.uniforms) {
  44447. for (var _d = 0, _e = this.customShaderOptions.uniforms; _d < _e.length; _d++) {
  44448. var uniform = _e[_d];
  44449. if (uniforms.indexOf(uniform) === -1) {
  44450. uniforms.push(uniform);
  44451. }
  44452. }
  44453. }
  44454. if (this.customShaderOptions.samplers) {
  44455. for (var _f = 0, _g = this.customShaderOptions.samplers; _f < _g.length; _f++) {
  44456. var sampler = _g[_f];
  44457. if (samplers.indexOf(sampler) === -1) {
  44458. samplers.push(sampler);
  44459. }
  44460. }
  44461. }
  44462. }
  44463. this._effect = this._scene.getEngine().createEffect(shaderName, attribs, uniforms, samplers, join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  44464. }
  44465. if (!this._effect.isReady()) {
  44466. return false;
  44467. }
  44468. if (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  44469. if (!this._blurPostProcesses || !this._blurPostProcesses.length) {
  44470. this._initializeBlurRTTAndPostProcesses();
  44471. }
  44472. }
  44473. if (this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady()) {
  44474. return false;
  44475. }
  44476. if (this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady()) {
  44477. return false;
  44478. }
  44479. if (this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady()) {
  44480. return false;
  44481. }
  44482. return true;
  44483. };
  44484. /**
  44485. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44486. * @param defines Defines of the material we want to update
  44487. * @param lightIndex Index of the light in the enabled light list of the material
  44488. */
  44489. ShadowGenerator.prototype.prepareDefines = function (defines, lightIndex) {
  44490. var scene = this._scene;
  44491. var light = this._light;
  44492. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  44493. return;
  44494. }
  44495. defines["SHADOW" + lightIndex] = true;
  44496. if (this.useContactHardeningShadow) {
  44497. defines["SHADOWPCSS" + lightIndex] = true;
  44498. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  44499. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  44500. }
  44501. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  44502. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  44503. }
  44504. // else default to high.
  44505. }
  44506. if (this.usePercentageCloserFiltering) {
  44507. defines["SHADOWPCF" + lightIndex] = true;
  44508. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  44509. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  44510. }
  44511. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  44512. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  44513. }
  44514. // else default to high.
  44515. }
  44516. else if (this.usePoissonSampling) {
  44517. defines["SHADOWPOISSON" + lightIndex] = true;
  44518. }
  44519. else if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  44520. defines["SHADOWESM" + lightIndex] = true;
  44521. }
  44522. else if (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  44523. defines["SHADOWCLOSEESM" + lightIndex] = true;
  44524. }
  44525. if (light.needCube()) {
  44526. defines["SHADOWCUBE" + lightIndex] = true;
  44527. }
  44528. };
  44529. /**
  44530. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44531. * defined in the generator but impacting the effect).
  44532. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44533. * @param effect The effect we are binfing the information for
  44534. */
  44535. ShadowGenerator.prototype.bindShadowLight = function (lightIndex, effect) {
  44536. var light = this._light;
  44537. var scene = this._scene;
  44538. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  44539. return;
  44540. }
  44541. var camera = scene.activeCamera;
  44542. if (!camera) {
  44543. return;
  44544. }
  44545. var shadowMap = this.getShadowMap();
  44546. if (!shadowMap) {
  44547. return;
  44548. }
  44549. if (!light.needCube()) {
  44550. effect.setMatrix("lightMatrix" + lightIndex, this.getTransformMatrix());
  44551. }
  44552. // Only PCF uses depth stencil texture.
  44553. if (this._filter === ShadowGenerator.FILTER_PCF) {
  44554. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  44555. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), shadowMap.getSize().width, 1 / shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  44556. }
  44557. else if (this._filter === ShadowGenerator.FILTER_PCSS) {
  44558. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  44559. effect.setTexture("depthSampler" + lightIndex, this.getShadowMapForRendering());
  44560. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / shadowMap.getSize().width, this._contactHardeningLightSizeUVRatio * shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  44561. }
  44562. else {
  44563. effect.setTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  44564. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / shadowMap.getSize().width, this.depthScale, this.frustumEdgeFalloff, lightIndex);
  44565. }
  44566. light._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(camera), this.getLight().getDepthMinZ(camera) + this.getLight().getDepthMaxZ(camera), lightIndex);
  44567. };
  44568. /**
  44569. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44570. * (eq to shadow prjection matrix * light transform matrix)
  44571. * @returns The transform matrix used to create the shadow map
  44572. */
  44573. ShadowGenerator.prototype.getTransformMatrix = function () {
  44574. var scene = this._scene;
  44575. if (this._currentRenderID === scene.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex) {
  44576. return this._transformMatrix;
  44577. }
  44578. this._currentRenderID = scene.getRenderId();
  44579. this._currentFaceIndexCache = this._currentFaceIndex;
  44580. var lightPosition = this._light.position;
  44581. if (this._light.computeTransformedInformation()) {
  44582. lightPosition = this._light.transformedPosition;
  44583. }
  44584. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection);
  44585. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this._lightDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up())) === 1.0) {
  44586. this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
  44587. }
  44588. if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
  44589. this._cachedPosition.copyFrom(lightPosition);
  44590. this._cachedDirection.copyFrom(this._lightDirection);
  44591. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up(), this._viewMatrix);
  44592. var shadowMap = this.getShadowMap();
  44593. if (shadowMap) {
  44594. var renderList = shadowMap.renderList;
  44595. if (renderList) {
  44596. this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, renderList);
  44597. }
  44598. }
  44599. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  44600. }
  44601. return this._transformMatrix;
  44602. };
  44603. /**
  44604. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44605. * Cube and 2D textures for instance.
  44606. */
  44607. ShadowGenerator.prototype.recreateShadowMap = function () {
  44608. var shadowMap = this._shadowMap;
  44609. if (!shadowMap) {
  44610. return;
  44611. }
  44612. // Track render list.
  44613. var renderList = shadowMap.renderList;
  44614. // Clean up existing data.
  44615. this._disposeRTTandPostProcesses();
  44616. // Reinitializes.
  44617. this._initializeGenerator();
  44618. // Reaffect the filter to ensure a correct fallback if necessary.
  44619. this.filter = this.filter;
  44620. // Reaffect the filter.
  44621. this._applyFilterValues();
  44622. // Reaffect Render List.
  44623. this._shadowMap.renderList = renderList;
  44624. };
  44625. ShadowGenerator.prototype._disposeBlurPostProcesses = function () {
  44626. if (this._shadowMap2) {
  44627. this._shadowMap2.dispose();
  44628. this._shadowMap2 = null;
  44629. }
  44630. if (this._boxBlurPostprocess) {
  44631. this._boxBlurPostprocess.dispose();
  44632. this._boxBlurPostprocess = null;
  44633. }
  44634. if (this._kernelBlurXPostprocess) {
  44635. this._kernelBlurXPostprocess.dispose();
  44636. this._kernelBlurXPostprocess = null;
  44637. }
  44638. if (this._kernelBlurYPostprocess) {
  44639. this._kernelBlurYPostprocess.dispose();
  44640. this._kernelBlurYPostprocess = null;
  44641. }
  44642. this._blurPostProcesses = [];
  44643. };
  44644. ShadowGenerator.prototype._disposeRTTandPostProcesses = function () {
  44645. if (this._shadowMap) {
  44646. this._shadowMap.dispose();
  44647. this._shadowMap = null;
  44648. }
  44649. this._disposeBlurPostProcesses();
  44650. };
  44651. /**
  44652. * Disposes the ShadowGenerator.
  44653. * Returns nothing.
  44654. */
  44655. ShadowGenerator.prototype.dispose = function () {
  44656. this._disposeRTTandPostProcesses();
  44657. if (this._light) {
  44658. this._light._shadowGenerator = null;
  44659. this._light._markMeshesAsLightDirty();
  44660. }
  44661. };
  44662. /**
  44663. * Serializes the shadow generator setup to a json object.
  44664. * @returns The serialized JSON object
  44665. */
  44666. ShadowGenerator.prototype.serialize = function () {
  44667. var serializationObject = {};
  44668. var shadowMap = this.getShadowMap();
  44669. if (!shadowMap) {
  44670. return serializationObject;
  44671. }
  44672. serializationObject.lightId = this._light.id;
  44673. serializationObject.mapSize = shadowMap.getRenderSize();
  44674. serializationObject.useExponentialShadowMap = this.useExponentialShadowMap;
  44675. serializationObject.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap;
  44676. serializationObject.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  44677. serializationObject.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  44678. serializationObject.usePoissonSampling = this.usePoissonSampling;
  44679. serializationObject.forceBackFacesOnly = this.forceBackFacesOnly;
  44680. serializationObject.depthScale = this.depthScale;
  44681. serializationObject.darkness = this.getDarkness();
  44682. serializationObject.blurBoxOffset = this.blurBoxOffset;
  44683. serializationObject.blurKernel = this.blurKernel;
  44684. serializationObject.blurScale = this.blurScale;
  44685. serializationObject.useKernelBlur = this.useKernelBlur;
  44686. serializationObject.transparencyShadow = this._transparencyShadow;
  44687. serializationObject.frustumEdgeFalloff = this.frustumEdgeFalloff;
  44688. serializationObject.bias = this.bias;
  44689. serializationObject.normalBias = this.normalBias;
  44690. serializationObject.usePercentageCloserFiltering = this.usePercentageCloserFiltering;
  44691. serializationObject.useContactHardeningShadow = this.useContactHardeningShadow;
  44692. serializationObject.filteringQuality = this.filteringQuality;
  44693. serializationObject.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio;
  44694. serializationObject.renderList = [];
  44695. if (shadowMap.renderList) {
  44696. for (var meshIndex = 0; meshIndex < shadowMap.renderList.length; meshIndex++) {
  44697. var mesh = shadowMap.renderList[meshIndex];
  44698. serializationObject.renderList.push(mesh.id);
  44699. }
  44700. }
  44701. return serializationObject;
  44702. };
  44703. /**
  44704. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  44705. * @param parsedShadowGenerator The JSON object to parse
  44706. * @param scene The scene to create the shadow map for
  44707. * @returns The parsed shadow generator
  44708. */
  44709. ShadowGenerator.Parse = function (parsedShadowGenerator, scene) {
  44710. var light = scene.getLightByID(parsedShadowGenerator.lightId);
  44711. var shadowGenerator = new ShadowGenerator(parsedShadowGenerator.mapSize, light);
  44712. var shadowMap = shadowGenerator.getShadowMap();
  44713. for (var meshIndex = 0; meshIndex < parsedShadowGenerator.renderList.length; meshIndex++) {
  44714. var meshes = scene.getMeshesByID(parsedShadowGenerator.renderList[meshIndex]);
  44715. meshes.forEach(function (mesh) {
  44716. if (!shadowMap) {
  44717. return;
  44718. }
  44719. if (!shadowMap.renderList) {
  44720. shadowMap.renderList = [];
  44721. }
  44722. shadowMap.renderList.push(mesh);
  44723. });
  44724. }
  44725. if (parsedShadowGenerator.usePoissonSampling) {
  44726. shadowGenerator.usePoissonSampling = true;
  44727. }
  44728. else if (parsedShadowGenerator.useExponentialShadowMap) {
  44729. shadowGenerator.useExponentialShadowMap = true;
  44730. }
  44731. else if (parsedShadowGenerator.useBlurExponentialShadowMap) {
  44732. shadowGenerator.useBlurExponentialShadowMap = true;
  44733. }
  44734. else if (parsedShadowGenerator.useCloseExponentialShadowMap) {
  44735. shadowGenerator.useCloseExponentialShadowMap = true;
  44736. }
  44737. else if (parsedShadowGenerator.useBlurCloseExponentialShadowMap) {
  44738. shadowGenerator.useBlurCloseExponentialShadowMap = true;
  44739. }
  44740. else if (parsedShadowGenerator.usePercentageCloserFiltering) {
  44741. shadowGenerator.usePercentageCloserFiltering = true;
  44742. }
  44743. else if (parsedShadowGenerator.useContactHardeningShadow) {
  44744. shadowGenerator.useContactHardeningShadow = true;
  44745. }
  44746. if (parsedShadowGenerator.filteringQuality) {
  44747. shadowGenerator.filteringQuality = parsedShadowGenerator.filteringQuality;
  44748. }
  44749. if (parsedShadowGenerator.contactHardeningLightSizeUVRatio) {
  44750. shadowGenerator.contactHardeningLightSizeUVRatio = parsedShadowGenerator.contactHardeningLightSizeUVRatio;
  44751. }
  44752. // Backward compat
  44753. else if (parsedShadowGenerator.useVarianceShadowMap) {
  44754. shadowGenerator.useExponentialShadowMap = true;
  44755. }
  44756. else if (parsedShadowGenerator.useBlurVarianceShadowMap) {
  44757. shadowGenerator.useBlurExponentialShadowMap = true;
  44758. }
  44759. if (parsedShadowGenerator.depthScale) {
  44760. shadowGenerator.depthScale = parsedShadowGenerator.depthScale;
  44761. }
  44762. if (parsedShadowGenerator.blurScale) {
  44763. shadowGenerator.blurScale = parsedShadowGenerator.blurScale;
  44764. }
  44765. if (parsedShadowGenerator.blurBoxOffset) {
  44766. shadowGenerator.blurBoxOffset = parsedShadowGenerator.blurBoxOffset;
  44767. }
  44768. if (parsedShadowGenerator.useKernelBlur) {
  44769. shadowGenerator.useKernelBlur = parsedShadowGenerator.useKernelBlur;
  44770. }
  44771. if (parsedShadowGenerator.blurKernel) {
  44772. shadowGenerator.blurKernel = parsedShadowGenerator.blurKernel;
  44773. }
  44774. if (parsedShadowGenerator.bias !== undefined) {
  44775. shadowGenerator.bias = parsedShadowGenerator.bias;
  44776. }
  44777. if (parsedShadowGenerator.normalBias !== undefined) {
  44778. shadowGenerator.normalBias = parsedShadowGenerator.normalBias;
  44779. }
  44780. if (parsedShadowGenerator.frustumEdgeFalloff !== undefined) {
  44781. shadowGenerator.frustumEdgeFalloff = parsedShadowGenerator.frustumEdgeFalloff;
  44782. }
  44783. if (parsedShadowGenerator.darkness) {
  44784. shadowGenerator.setDarkness(parsedShadowGenerator.darkness);
  44785. }
  44786. if (parsedShadowGenerator.transparencyShadow) {
  44787. shadowGenerator.setTransparencyShadow(true);
  44788. }
  44789. shadowGenerator.forceBackFacesOnly = parsedShadowGenerator.forceBackFacesOnly;
  44790. return shadowGenerator;
  44791. };
  44792. /**
  44793. * Shadow generator mode None: no filtering applied.
  44794. */
  44795. ShadowGenerator.FILTER_NONE = 0;
  44796. /**
  44797. * Shadow generator mode ESM: Exponential Shadow Mapping.
  44798. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44799. */
  44800. ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP = 1;
  44801. /**
  44802. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  44803. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  44804. */
  44805. ShadowGenerator.FILTER_POISSONSAMPLING = 2;
  44806. /**
  44807. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  44808. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44809. */
  44810. ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP = 3;
  44811. /**
  44812. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  44813. * edge artifacts on steep falloff.
  44814. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44815. */
  44816. ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4;
  44817. /**
  44818. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  44819. * edge artifacts on steep falloff.
  44820. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44821. */
  44822. ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5;
  44823. /**
  44824. * Shadow generator mode PCF: Percentage Closer Filtering
  44825. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44826. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  44827. */
  44828. ShadowGenerator.FILTER_PCF = 6;
  44829. /**
  44830. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  44831. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44832. * Contact Hardening
  44833. */
  44834. ShadowGenerator.FILTER_PCSS = 7;
  44835. /**
  44836. * Reserved for PCF and PCSS
  44837. * Highest Quality.
  44838. *
  44839. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  44840. *
  44841. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  44842. */
  44843. ShadowGenerator.QUALITY_HIGH = 0;
  44844. /**
  44845. * Reserved for PCF and PCSS
  44846. * Good tradeoff for quality/perf cross devices
  44847. *
  44848. * Execute PCF on a 3*3 kernel.
  44849. *
  44850. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  44851. */
  44852. ShadowGenerator.QUALITY_MEDIUM = 1;
  44853. /**
  44854. * Reserved for PCF and PCSS
  44855. * The lowest quality but the fastest.
  44856. *
  44857. * Execute PCF on a 1*1 kernel.
  44858. *
  44859. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  44860. */
  44861. ShadowGenerator.QUALITY_LOW = 2;
  44862. /** @hidden */
  44863. ShadowGenerator._SceneComponentInitialization = function (_) {
  44864. throw "Import ShadowGeneratorSceneComponent before creating ShadowGenerator.";
  44865. };
  44866. return ShadowGenerator;
  44867. }());
  44868. /***/ }),
  44869. /***/ "./Lights/Shadows/shadowGeneratorSceneComponent.ts":
  44870. /*!*********************************************************!*\
  44871. !*** ./Lights/Shadows/shadowGeneratorSceneComponent.ts ***!
  44872. \*********************************************************/
  44873. /*! exports provided: ShadowGeneratorSceneComponent */
  44874. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44875. "use strict";
  44876. __webpack_require__.r(__webpack_exports__);
  44877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return ShadowGeneratorSceneComponent; });
  44878. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  44879. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  44880. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  44881. // Adds the parser to the scene parsers.
  44882. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR, function (parsedData, scene) {
  44883. // Shadows
  44884. if (parsedData.shadowGenerators !== undefined && parsedData.shadowGenerators !== null) {
  44885. for (var index = 0, cache = parsedData.shadowGenerators.length; index < cache; index++) {
  44886. var parsedShadowGenerator = parsedData.shadowGenerators[index];
  44887. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"].Parse(parsedShadowGenerator, scene);
  44888. // SG would be available on their associated lights
  44889. }
  44890. }
  44891. });
  44892. /**
  44893. * Defines the shadow generator component responsible to manage any shadow generators
  44894. * in a given scene.
  44895. */
  44896. var ShadowGeneratorSceneComponent = /** @class */ (function () {
  44897. /**
  44898. * Creates a new instance of the component for the given scene
  44899. * @param scene Defines the scene to register the component in
  44900. */
  44901. function ShadowGeneratorSceneComponent(scene) {
  44902. /**
  44903. * The component name helpfull to identify the component in the list of scene components.
  44904. */
  44905. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR;
  44906. this.scene = scene;
  44907. }
  44908. /**
  44909. * Registers the component in a given scene
  44910. */
  44911. ShadowGeneratorSceneComponent.prototype.register = function () {
  44912. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets);
  44913. };
  44914. /**
  44915. * Rebuilds the elements related to this component in case of
  44916. * context lost for instance.
  44917. */
  44918. ShadowGeneratorSceneComponent.prototype.rebuild = function () {
  44919. // Nothing To Do Here.
  44920. };
  44921. /**
  44922. * Serializes the component data to the specified json object
  44923. * @param serializationObject The object to serialize to
  44924. */
  44925. ShadowGeneratorSceneComponent.prototype.serialize = function (serializationObject) {
  44926. // Shadows
  44927. serializationObject.shadowGenerators = [];
  44928. var lights = this.scene.lights;
  44929. for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
  44930. var light = lights_1[_i];
  44931. var shadowGenerator = light.getShadowGenerator();
  44932. if (shadowGenerator) {
  44933. serializationObject.shadowGenerators.push(shadowGenerator.serialize());
  44934. }
  44935. }
  44936. };
  44937. /**
  44938. * Adds all the element from the container to the scene
  44939. * @param container the container holding the elements
  44940. */
  44941. ShadowGeneratorSceneComponent.prototype.addFromContainer = function (container) {
  44942. // Nothing To Do Here. (directly attached to a light)
  44943. };
  44944. /**
  44945. * Removes all the elements in the container from the scene
  44946. * @param container contains the elements to remove
  44947. */
  44948. ShadowGeneratorSceneComponent.prototype.removeFromContainer = function (container) {
  44949. // Nothing To Do Here. (directly attached to a light)
  44950. };
  44951. /**
  44952. * Rebuilds the elements related to this component in case of
  44953. * context lost for instance.
  44954. */
  44955. ShadowGeneratorSceneComponent.prototype.dispose = function () {
  44956. // Nothing To Do Here.
  44957. };
  44958. ShadowGeneratorSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  44959. // Shadows
  44960. var scene = this.scene;
  44961. if (this.scene.shadowsEnabled) {
  44962. for (var lightIndex = 0; lightIndex < scene.lights.length; lightIndex++) {
  44963. var light = scene.lights[lightIndex];
  44964. var shadowGenerator = light.getShadowGenerator();
  44965. if (light.isEnabled() && light.shadowEnabled && shadowGenerator) {
  44966. var shadowMap = (shadowGenerator.getShadowMap());
  44967. if (scene.textures.indexOf(shadowMap) !== -1) {
  44968. renderTargets.push(shadowMap);
  44969. }
  44970. }
  44971. }
  44972. }
  44973. };
  44974. return ShadowGeneratorSceneComponent;
  44975. }());
  44976. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]._SceneComponentInitialization = function (scene) {
  44977. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR);
  44978. if (!component) {
  44979. component = new ShadowGeneratorSceneComponent(scene);
  44980. scene._addComponent(component);
  44981. }
  44982. };
  44983. /***/ }),
  44984. /***/ "./Lights/directionalLight.ts":
  44985. /*!************************************!*\
  44986. !*** ./Lights/directionalLight.ts ***!
  44987. \************************************/
  44988. /*! exports provided: DirectionalLight */
  44989. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44990. "use strict";
  44991. __webpack_require__.r(__webpack_exports__);
  44992. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return DirectionalLight; });
  44993. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  44994. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  44995. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  44996. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  44997. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  44998. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  44999. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_1", function (name, scene) {
  45000. return function () { return new DirectionalLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  45001. });
  45002. /**
  45003. * A directional light is defined by a direction (what a surprise!).
  45004. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45005. * 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.
  45006. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45007. */
  45008. var DirectionalLight = /** @class */ (function (_super) {
  45009. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DirectionalLight, _super);
  45010. /**
  45011. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45012. * The directional light is emitted from everywhere in the given direction.
  45013. * It can cast shadows.
  45014. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45015. * @param name The friendly name of the light
  45016. * @param direction The direction of the light
  45017. * @param scene The scene the light belongs to
  45018. */
  45019. function DirectionalLight(name, direction, scene) {
  45020. var _this = _super.call(this, name, scene) || this;
  45021. _this._shadowFrustumSize = 0;
  45022. _this._shadowOrthoScale = 0.1;
  45023. /**
  45024. * Automatically compute the projection matrix to best fit (including all the casters)
  45025. * on each frame.
  45026. */
  45027. _this.autoUpdateExtends = true;
  45028. // Cache
  45029. _this._orthoLeft = Number.MAX_VALUE;
  45030. _this._orthoRight = Number.MIN_VALUE;
  45031. _this._orthoTop = Number.MIN_VALUE;
  45032. _this._orthoBottom = Number.MAX_VALUE;
  45033. _this.position = direction.scale(-1.0);
  45034. _this.direction = direction;
  45035. return _this;
  45036. }
  45037. Object.defineProperty(DirectionalLight.prototype, "shadowFrustumSize", {
  45038. /**
  45039. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45040. */
  45041. get: function () {
  45042. return this._shadowFrustumSize;
  45043. },
  45044. /**
  45045. * Specifies a fix frustum size for the shadow generation.
  45046. */
  45047. set: function (value) {
  45048. this._shadowFrustumSize = value;
  45049. this.forceProjectionMatrixCompute();
  45050. },
  45051. enumerable: true,
  45052. configurable: true
  45053. });
  45054. Object.defineProperty(DirectionalLight.prototype, "shadowOrthoScale", {
  45055. /**
  45056. * Gets the shadow projection scale against the optimal computed one.
  45057. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45058. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45059. */
  45060. get: function () {
  45061. return this._shadowOrthoScale;
  45062. },
  45063. /**
  45064. * Sets the shadow projection scale against the optimal computed one.
  45065. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45066. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45067. */
  45068. set: function (value) {
  45069. this._shadowOrthoScale = value;
  45070. this.forceProjectionMatrixCompute();
  45071. },
  45072. enumerable: true,
  45073. configurable: true
  45074. });
  45075. /**
  45076. * Returns the string "DirectionalLight".
  45077. * @return The class name
  45078. */
  45079. DirectionalLight.prototype.getClassName = function () {
  45080. return "DirectionalLight";
  45081. };
  45082. /**
  45083. * Returns the integer 1.
  45084. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45085. */
  45086. DirectionalLight.prototype.getTypeID = function () {
  45087. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT;
  45088. };
  45089. /**
  45090. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45091. * Returns the DirectionalLight Shadow projection matrix.
  45092. */
  45093. DirectionalLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  45094. if (this.shadowFrustumSize > 0) {
  45095. this._setDefaultFixedFrustumShadowProjectionMatrix(matrix);
  45096. }
  45097. else {
  45098. this._setDefaultAutoExtendShadowProjectionMatrix(matrix, viewMatrix, renderList);
  45099. }
  45100. };
  45101. /**
  45102. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45103. * Returns the DirectionalLight Shadow projection matrix.
  45104. */
  45105. DirectionalLight.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function (matrix) {
  45106. var activeCamera = this.getScene().activeCamera;
  45107. if (!activeCamera) {
  45108. return;
  45109. }
  45110. _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);
  45111. };
  45112. /**
  45113. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45114. * Returns the DirectionalLight Shadow projection matrix.
  45115. */
  45116. DirectionalLight.prototype._setDefaultAutoExtendShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  45117. var activeCamera = this.getScene().activeCamera;
  45118. if (!activeCamera) {
  45119. return;
  45120. }
  45121. // Check extends
  45122. if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
  45123. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  45124. this._orthoLeft = Number.MAX_VALUE;
  45125. this._orthoRight = Number.MIN_VALUE;
  45126. this._orthoTop = Number.MIN_VALUE;
  45127. this._orthoBottom = Number.MAX_VALUE;
  45128. for (var meshIndex = 0; meshIndex < renderList.length; meshIndex++) {
  45129. var mesh = renderList[meshIndex];
  45130. if (!mesh) {
  45131. continue;
  45132. }
  45133. var boundingInfo = mesh.getBoundingInfo();
  45134. var boundingBox = boundingInfo.boundingBox;
  45135. for (var index = 0; index < boundingBox.vectorsWorld.length; index++) {
  45136. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(boundingBox.vectorsWorld[index], viewMatrix, tempVector3);
  45137. if (tempVector3.x < this._orthoLeft) {
  45138. this._orthoLeft = tempVector3.x;
  45139. }
  45140. if (tempVector3.y < this._orthoBottom) {
  45141. this._orthoBottom = tempVector3.y;
  45142. }
  45143. if (tempVector3.x > this._orthoRight) {
  45144. this._orthoRight = tempVector3.x;
  45145. }
  45146. if (tempVector3.y > this._orthoTop) {
  45147. this._orthoTop = tempVector3.y;
  45148. }
  45149. }
  45150. }
  45151. }
  45152. var xOffset = this._orthoRight - this._orthoLeft;
  45153. var yOffset = this._orthoTop - this._orthoBottom;
  45154. _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);
  45155. };
  45156. DirectionalLight.prototype._buildUniformLayout = function () {
  45157. this._uniformBuffer.addUniform("vLightData", 4);
  45158. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  45159. this._uniformBuffer.addUniform("vLightSpecular", 3);
  45160. this._uniformBuffer.addUniform("shadowsInfo", 3);
  45161. this._uniformBuffer.addUniform("depthValues", 2);
  45162. this._uniformBuffer.create();
  45163. };
  45164. /**
  45165. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45166. * @param effect The effect to update
  45167. * @param lightIndex The index of the light in the effect to update
  45168. * @returns The directional light
  45169. */
  45170. DirectionalLight.prototype.transferToEffect = function (effect, lightIndex) {
  45171. if (this.computeTransformedInformation()) {
  45172. this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, lightIndex);
  45173. return this;
  45174. }
  45175. this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, lightIndex);
  45176. return this;
  45177. };
  45178. /**
  45179. * Gets the minZ used for shadow according to both the scene and the light.
  45180. *
  45181. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45182. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45183. * @param activeCamera The camera we are returning the min for
  45184. * @returns the depth min z
  45185. */
  45186. DirectionalLight.prototype.getDepthMinZ = function (activeCamera) {
  45187. return 1;
  45188. };
  45189. /**
  45190. * Gets the maxZ used for shadow according to both the scene and the light.
  45191. *
  45192. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45193. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45194. * @param activeCamera The camera we are returning the max for
  45195. * @returns the depth max z
  45196. */
  45197. DirectionalLight.prototype.getDepthMaxZ = function (activeCamera) {
  45198. return 1;
  45199. };
  45200. /**
  45201. * Prepares the list of defines specific to the light type.
  45202. * @param defines the list of defines
  45203. * @param lightIndex defines the index of the light for the effect
  45204. */
  45205. DirectionalLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  45206. defines["DIRLIGHT" + lightIndex] = true;
  45207. };
  45208. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45209. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45210. ], DirectionalLight.prototype, "shadowFrustumSize", null);
  45211. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45212. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45213. ], DirectionalLight.prototype, "shadowOrthoScale", null);
  45214. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45215. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45216. ], DirectionalLight.prototype, "autoUpdateExtends", void 0);
  45217. return DirectionalLight;
  45218. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  45219. /***/ }),
  45220. /***/ "./Lights/hemisphericLight.ts":
  45221. /*!************************************!*\
  45222. !*** ./Lights/hemisphericLight.ts ***!
  45223. \************************************/
  45224. /*! exports provided: HemisphericLight */
  45225. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45226. "use strict";
  45227. __webpack_require__.r(__webpack_exports__);
  45228. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return HemisphericLight; });
  45229. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45230. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  45231. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  45232. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  45233. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  45234. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_3", function (name, scene) {
  45235. return function () { return new HemisphericLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  45236. });
  45237. /**
  45238. * The HemisphericLight simulates the ambient environment light,
  45239. * so the passed direction is the light reflection direction, not the incoming direction.
  45240. */
  45241. var HemisphericLight = /** @class */ (function (_super) {
  45242. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HemisphericLight, _super);
  45243. /**
  45244. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  45245. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  45246. * The HemisphericLight can't cast shadows.
  45247. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45248. * @param name The friendly name of the light
  45249. * @param direction The direction of the light reflection
  45250. * @param scene The scene the light belongs to
  45251. */
  45252. function HemisphericLight(name, direction, scene) {
  45253. var _this = _super.call(this, name, scene) || this;
  45254. /**
  45255. * The groundColor is the light in the opposite direction to the one specified during creation.
  45256. * 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.
  45257. */
  45258. _this.groundColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.0, 0.0, 0.0);
  45259. _this.direction = direction || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  45260. return _this;
  45261. }
  45262. HemisphericLight.prototype._buildUniformLayout = function () {
  45263. this._uniformBuffer.addUniform("vLightData", 4);
  45264. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  45265. this._uniformBuffer.addUniform("vLightSpecular", 3);
  45266. this._uniformBuffer.addUniform("vLightGround", 3);
  45267. this._uniformBuffer.addUniform("shadowsInfo", 3);
  45268. this._uniformBuffer.addUniform("depthValues", 2);
  45269. this._uniformBuffer.create();
  45270. };
  45271. /**
  45272. * Returns the string "HemisphericLight".
  45273. * @return The class name
  45274. */
  45275. HemisphericLight.prototype.getClassName = function () {
  45276. return "HemisphericLight";
  45277. };
  45278. /**
  45279. * Sets the HemisphericLight direction towards the passed target (Vector3).
  45280. * Returns the updated direction.
  45281. * @param target The target the direction should point to
  45282. * @return The computed direction
  45283. */
  45284. HemisphericLight.prototype.setDirectionToTarget = function (target) {
  45285. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero()));
  45286. return this.direction;
  45287. };
  45288. /**
  45289. * Returns the shadow generator associated to the light.
  45290. * @returns Always null for hemispheric lights because it does not support shadows.
  45291. */
  45292. HemisphericLight.prototype.getShadowGenerator = function () {
  45293. return null;
  45294. };
  45295. /**
  45296. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  45297. * @param effect The effect to update
  45298. * @param lightIndex The index of the light in the effect to update
  45299. * @returns The hemispheric light
  45300. */
  45301. HemisphericLight.prototype.transferToEffect = function (effect, lightIndex) {
  45302. var normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  45303. this._uniformBuffer.updateFloat4("vLightData", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0.0, lightIndex);
  45304. this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), lightIndex);
  45305. return this;
  45306. };
  45307. /**
  45308. * Computes the world matrix of the node
  45309. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  45310. * @param useWasUpdatedFlag defines a reserved property
  45311. * @returns the world matrix
  45312. */
  45313. HemisphericLight.prototype.computeWorldMatrix = function () {
  45314. if (!this._worldMatrix) {
  45315. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  45316. }
  45317. return this._worldMatrix;
  45318. };
  45319. /**
  45320. * Returns the integer 3.
  45321. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45322. */
  45323. HemisphericLight.prototype.getTypeID = function () {
  45324. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_HEMISPHERICLIGHT;
  45325. };
  45326. /**
  45327. * Prepares the list of defines specific to the light type.
  45328. * @param defines the list of defines
  45329. * @param lightIndex defines the index of the light for the effect
  45330. */
  45331. HemisphericLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  45332. defines["HEMILIGHT" + lightIndex] = true;
  45333. };
  45334. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45335. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  45336. ], HemisphericLight.prototype, "groundColor", void 0);
  45337. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45338. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  45339. ], HemisphericLight.prototype, "direction", void 0);
  45340. return HemisphericLight;
  45341. }(_light__WEBPACK_IMPORTED_MODULE_4__["Light"]));
  45342. /***/ }),
  45343. /***/ "./Lights/index.ts":
  45344. /*!*************************!*\
  45345. !*** ./Lights/index.ts ***!
  45346. \*************************/
  45347. /*! exports provided: Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, ShadowGenerator, ShadowGeneratorSceneComponent */
  45348. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45349. "use strict";
  45350. __webpack_require__.r(__webpack_exports__);
  45351. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  45352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _light__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  45353. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  45354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _shadowLight__WEBPACK_IMPORTED_MODULE_1__["ShadowLight"]; });
  45355. /* harmony import */ var _Shadows_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Shadows/index */ "./Lights/Shadows/index.ts");
  45356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGenerator"]; });
  45357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGeneratorSceneComponent"]; });
  45358. /* harmony import */ var _directionalLight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./directionalLight */ "./Lights/directionalLight.ts");
  45359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _directionalLight__WEBPACK_IMPORTED_MODULE_3__["DirectionalLight"]; });
  45360. /* harmony import */ var _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphericLight */ "./Lights/hemisphericLight.ts");
  45361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]; });
  45362. /* harmony import */ var _pointLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pointLight */ "./Lights/pointLight.ts");
  45363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _pointLight__WEBPACK_IMPORTED_MODULE_5__["PointLight"]; });
  45364. /* harmony import */ var _spotLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./spotLight */ "./Lights/spotLight.ts");
  45365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _spotLight__WEBPACK_IMPORTED_MODULE_6__["SpotLight"]; });
  45366. /***/ }),
  45367. /***/ "./Lights/light.ts":
  45368. /*!*************************!*\
  45369. !*** ./Lights/light.ts ***!
  45370. \*************************/
  45371. /*! exports provided: Light */
  45372. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45373. "use strict";
  45374. __webpack_require__.r(__webpack_exports__);
  45375. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return Light; });
  45376. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45377. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  45378. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  45379. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  45380. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  45381. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  45382. /**
  45383. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  45384. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  45385. * 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.
  45386. */
  45387. var Light = /** @class */ (function (_super) {
  45388. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Light, _super);
  45389. /**
  45390. * Creates a Light object in the scene.
  45391. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45392. * @param name The firendly name of the light
  45393. * @param scene The scene the light belongs too
  45394. */
  45395. function Light(name, scene) {
  45396. var _this = _super.call(this, name, scene) || this;
  45397. /**
  45398. * Diffuse gives the basic color to an object.
  45399. */
  45400. _this.diffuse = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  45401. /**
  45402. * Specular produces a highlight color on an object.
  45403. * Note: This is note affecting PBR materials.
  45404. */
  45405. _this.specular = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  45406. /**
  45407. * Defines the falloff type for this light. This lets overrriding how punctual light are
  45408. * falling off base on range or angle.
  45409. * This can be set to any values in Light.FALLOFF_x.
  45410. *
  45411. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  45412. * other types of materials.
  45413. */
  45414. _this.falloffType = Light.FALLOFF_DEFAULT;
  45415. /**
  45416. * Strength of the light.
  45417. * Note: By default it is define in the framework own unit.
  45418. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  45419. */
  45420. _this.intensity = 1.0;
  45421. _this._range = Number.MAX_VALUE;
  45422. _this._inverseSquaredRange = 0;
  45423. /**
  45424. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  45425. * of light.
  45426. */
  45427. _this._photometricScale = 1.0;
  45428. _this._intensityMode = Light.INTENSITYMODE_AUTOMATIC;
  45429. _this._radius = 0.00001;
  45430. /**
  45431. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  45432. * exceeding the number allowed of the materials.
  45433. */
  45434. _this.renderPriority = 0;
  45435. _this._shadowEnabled = true;
  45436. _this._excludeWithLayerMask = 0;
  45437. _this._includeOnlyWithLayerMask = 0;
  45438. _this._lightmapMode = 0;
  45439. /**
  45440. * @hidden Internal use only.
  45441. */
  45442. _this._excludedMeshesIds = new Array();
  45443. /**
  45444. * @hidden Internal use only.
  45445. */
  45446. _this._includedOnlyMeshesIds = new Array();
  45447. /** @hidden */
  45448. _this._isLight = true;
  45449. _this.getScene().addLight(_this);
  45450. _this._uniformBuffer = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__["UniformBuffer"](_this.getScene().getEngine());
  45451. _this._buildUniformLayout();
  45452. _this.includedOnlyMeshes = new Array();
  45453. _this.excludedMeshes = new Array();
  45454. _this._resyncMeshes();
  45455. return _this;
  45456. }
  45457. Object.defineProperty(Light.prototype, "range", {
  45458. /**
  45459. * Defines how far from the source the light is impacting in scene units.
  45460. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  45461. */
  45462. get: function () {
  45463. return this._range;
  45464. },
  45465. /**
  45466. * Defines how far from the source the light is impacting in scene units.
  45467. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  45468. */
  45469. set: function (value) {
  45470. this._range = value;
  45471. this._inverseSquaredRange = 1.0 / (this.range * this.range);
  45472. },
  45473. enumerable: true,
  45474. configurable: true
  45475. });
  45476. Object.defineProperty(Light.prototype, "intensityMode", {
  45477. /**
  45478. * Gets the photometric scale used to interpret the intensity.
  45479. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  45480. */
  45481. get: function () {
  45482. return this._intensityMode;
  45483. },
  45484. /**
  45485. * Sets the photometric scale used to interpret the intensity.
  45486. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  45487. */
  45488. set: function (value) {
  45489. this._intensityMode = value;
  45490. this._computePhotometricScale();
  45491. },
  45492. enumerable: true,
  45493. configurable: true
  45494. });
  45495. Object.defineProperty(Light.prototype, "radius", {
  45496. /**
  45497. * Gets the light radius used by PBR Materials to simulate soft area lights.
  45498. */
  45499. get: function () {
  45500. return this._radius;
  45501. },
  45502. /**
  45503. * sets the light radius used by PBR Materials to simulate soft area lights.
  45504. */
  45505. set: function (value) {
  45506. this._radius = value;
  45507. this._computePhotometricScale();
  45508. },
  45509. enumerable: true,
  45510. configurable: true
  45511. });
  45512. Object.defineProperty(Light.prototype, "shadowEnabled", {
  45513. /**
  45514. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  45515. * the current shadow generator.
  45516. */
  45517. get: function () {
  45518. return this._shadowEnabled;
  45519. },
  45520. /**
  45521. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  45522. * the current shadow generator.
  45523. */
  45524. set: function (value) {
  45525. if (this._shadowEnabled === value) {
  45526. return;
  45527. }
  45528. this._shadowEnabled = value;
  45529. this._markMeshesAsLightDirty();
  45530. },
  45531. enumerable: true,
  45532. configurable: true
  45533. });
  45534. Object.defineProperty(Light.prototype, "includedOnlyMeshes", {
  45535. /**
  45536. * Gets the only meshes impacted by this light.
  45537. */
  45538. get: function () {
  45539. return this._includedOnlyMeshes;
  45540. },
  45541. /**
  45542. * Sets the only meshes impacted by this light.
  45543. */
  45544. set: function (value) {
  45545. this._includedOnlyMeshes = value;
  45546. this._hookArrayForIncludedOnly(value);
  45547. },
  45548. enumerable: true,
  45549. configurable: true
  45550. });
  45551. Object.defineProperty(Light.prototype, "excludedMeshes", {
  45552. /**
  45553. * Gets the meshes not impacted by this light.
  45554. */
  45555. get: function () {
  45556. return this._excludedMeshes;
  45557. },
  45558. /**
  45559. * Sets the meshes not impacted by this light.
  45560. */
  45561. set: function (value) {
  45562. this._excludedMeshes = value;
  45563. this._hookArrayForExcluded(value);
  45564. },
  45565. enumerable: true,
  45566. configurable: true
  45567. });
  45568. Object.defineProperty(Light.prototype, "excludeWithLayerMask", {
  45569. /**
  45570. * Gets the layer id use to find what meshes are not impacted by the light.
  45571. * Inactive if 0
  45572. */
  45573. get: function () {
  45574. return this._excludeWithLayerMask;
  45575. },
  45576. /**
  45577. * Sets the layer id use to find what meshes are not impacted by the light.
  45578. * Inactive if 0
  45579. */
  45580. set: function (value) {
  45581. this._excludeWithLayerMask = value;
  45582. this._resyncMeshes();
  45583. },
  45584. enumerable: true,
  45585. configurable: true
  45586. });
  45587. Object.defineProperty(Light.prototype, "includeOnlyWithLayerMask", {
  45588. /**
  45589. * Gets the layer id use to find what meshes are impacted by the light.
  45590. * Inactive if 0
  45591. */
  45592. get: function () {
  45593. return this._includeOnlyWithLayerMask;
  45594. },
  45595. /**
  45596. * Sets the layer id use to find what meshes are impacted by the light.
  45597. * Inactive if 0
  45598. */
  45599. set: function (value) {
  45600. this._includeOnlyWithLayerMask = value;
  45601. this._resyncMeshes();
  45602. },
  45603. enumerable: true,
  45604. configurable: true
  45605. });
  45606. Object.defineProperty(Light.prototype, "lightmapMode", {
  45607. /**
  45608. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  45609. */
  45610. get: function () {
  45611. return this._lightmapMode;
  45612. },
  45613. /**
  45614. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  45615. */
  45616. set: function (value) {
  45617. if (this._lightmapMode === value) {
  45618. return;
  45619. }
  45620. this._lightmapMode = value;
  45621. this._markMeshesAsLightDirty();
  45622. },
  45623. enumerable: true,
  45624. configurable: true
  45625. });
  45626. /**
  45627. * Returns the string "Light".
  45628. * @returns the class name
  45629. */
  45630. Light.prototype.getClassName = function () {
  45631. return "Light";
  45632. };
  45633. /**
  45634. * Converts the light information to a readable string for debug purpose.
  45635. * @param fullDetails Supports for multiple levels of logging within scene loading
  45636. * @returns the human readable light info
  45637. */
  45638. Light.prototype.toString = function (fullDetails) {
  45639. var ret = "Name: " + this.name;
  45640. ret += ", type: " + (["Point", "Directional", "Spot", "Hemispheric"])[this.getTypeID()];
  45641. if (this.animations) {
  45642. for (var i = 0; i < this.animations.length; i++) {
  45643. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  45644. }
  45645. }
  45646. if (fullDetails) {
  45647. }
  45648. return ret;
  45649. };
  45650. /** @hidden */
  45651. Light.prototype._syncParentEnabledState = function () {
  45652. _super.prototype._syncParentEnabledState.call(this);
  45653. this._resyncMeshes();
  45654. };
  45655. /**
  45656. * Set the enabled state of this node.
  45657. * @param value - the new enabled state
  45658. */
  45659. Light.prototype.setEnabled = function (value) {
  45660. _super.prototype.setEnabled.call(this, value);
  45661. this._resyncMeshes();
  45662. };
  45663. /**
  45664. * Returns the Light associated shadow generator if any.
  45665. * @return the associated shadow generator.
  45666. */
  45667. Light.prototype.getShadowGenerator = function () {
  45668. return this._shadowGenerator;
  45669. };
  45670. /**
  45671. * Returns a Vector3, the absolute light position in the World.
  45672. * @returns the world space position of the light
  45673. */
  45674. Light.prototype.getAbsolutePosition = function () {
  45675. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  45676. };
  45677. /**
  45678. * Specifies if the light will affect the passed mesh.
  45679. * @param mesh The mesh to test against the light
  45680. * @return true the mesh is affected otherwise, false.
  45681. */
  45682. Light.prototype.canAffectMesh = function (mesh) {
  45683. if (!mesh) {
  45684. return true;
  45685. }
  45686. if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
  45687. return false;
  45688. }
  45689. if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  45690. return false;
  45691. }
  45692. if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {
  45693. return false;
  45694. }
  45695. if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {
  45696. return false;
  45697. }
  45698. return true;
  45699. };
  45700. /**
  45701. * Sort function to order lights for rendering.
  45702. * @param a First Light object to compare to second.
  45703. * @param b Second Light object to compare first.
  45704. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  45705. */
  45706. Light.CompareLightsPriority = function (a, b) {
  45707. //shadow-casting lights have priority over non-shadow-casting lights
  45708. //the renderPrioirty is a secondary sort criterion
  45709. if (a.shadowEnabled !== b.shadowEnabled) {
  45710. return (b.shadowEnabled ? 1 : 0) - (a.shadowEnabled ? 1 : 0);
  45711. }
  45712. return b.renderPriority - a.renderPriority;
  45713. };
  45714. /**
  45715. * Releases resources associated with this node.
  45716. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45717. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45718. */
  45719. Light.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  45720. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  45721. if (this._shadowGenerator) {
  45722. this._shadowGenerator.dispose();
  45723. this._shadowGenerator = null;
  45724. }
  45725. // Animations
  45726. this.getScene().stopAnimation(this);
  45727. // Remove from meshes
  45728. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  45729. var mesh = _a[_i];
  45730. mesh._removeLightSource(this);
  45731. }
  45732. this._uniformBuffer.dispose();
  45733. // Remove from scene
  45734. this.getScene().removeLight(this);
  45735. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  45736. };
  45737. /**
  45738. * Returns the light type ID (integer).
  45739. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45740. */
  45741. Light.prototype.getTypeID = function () {
  45742. return 0;
  45743. };
  45744. /**
  45745. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  45746. * @returns the scaled intensity in intensity mode unit
  45747. */
  45748. Light.prototype.getScaledIntensity = function () {
  45749. return this._photometricScale * this.intensity;
  45750. };
  45751. /**
  45752. * Returns a new Light object, named "name", from the current one.
  45753. * @param name The name of the cloned light
  45754. * @returns the new created light
  45755. */
  45756. Light.prototype.clone = function (name) {
  45757. var constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());
  45758. if (!constructor) {
  45759. return null;
  45760. }
  45761. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(constructor, this);
  45762. };
  45763. /**
  45764. * Serializes the current light into a Serialization object.
  45765. * @returns the serialized object.
  45766. */
  45767. Light.prototype.serialize = function () {
  45768. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  45769. // Type
  45770. serializationObject.type = this.getTypeID();
  45771. // Parent
  45772. if (this.parent) {
  45773. serializationObject.parentId = this.parent.id;
  45774. }
  45775. // Inclusion / exclusions
  45776. if (this.excludedMeshes.length > 0) {
  45777. serializationObject.excludedMeshesIds = [];
  45778. this.excludedMeshes.forEach(function (mesh) {
  45779. serializationObject.excludedMeshesIds.push(mesh.id);
  45780. });
  45781. }
  45782. if (this.includedOnlyMeshes.length > 0) {
  45783. serializationObject.includedOnlyMeshesIds = [];
  45784. this.includedOnlyMeshes.forEach(function (mesh) {
  45785. serializationObject.includedOnlyMeshesIds.push(mesh.id);
  45786. });
  45787. }
  45788. // Animations
  45789. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  45790. serializationObject.ranges = this.serializeAnimationRanges();
  45791. return serializationObject;
  45792. };
  45793. /**
  45794. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  45795. * This new light is named "name" and added to the passed scene.
  45796. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  45797. * @param name The friendly name of the light
  45798. * @param scene The scene the new light will belong to
  45799. * @returns the constructor function
  45800. */
  45801. Light.GetConstructorFromName = function (type, name, scene) {
  45802. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_3__["Node"].Construct("Light_Type_" + type, name, scene);
  45803. if (constructorFunc) {
  45804. return constructorFunc;
  45805. }
  45806. // Default to no light for none present once.
  45807. return null;
  45808. };
  45809. /**
  45810. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  45811. * @param parsedLight The JSON representation of the light
  45812. * @param scene The scene to create the parsed light in
  45813. * @returns the created light after parsing
  45814. */
  45815. Light.Parse = function (parsedLight, scene) {
  45816. var constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);
  45817. if (!constructor) {
  45818. return null;
  45819. }
  45820. var light = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(constructor, parsedLight, scene);
  45821. // Inclusion / exclusions
  45822. if (parsedLight.excludedMeshesIds) {
  45823. light._excludedMeshesIds = parsedLight.excludedMeshesIds;
  45824. }
  45825. if (parsedLight.includedOnlyMeshesIds) {
  45826. light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
  45827. }
  45828. // Parent
  45829. if (parsedLight.parentId) {
  45830. light._waitingParentId = parsedLight.parentId;
  45831. }
  45832. // Animations
  45833. if (parsedLight.animations) {
  45834. for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
  45835. var parsedAnimation = parsedLight.animations[animationIndex];
  45836. light.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].Parse(parsedAnimation));
  45837. }
  45838. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].ParseAnimationRanges(light, parsedLight, scene);
  45839. }
  45840. if (parsedLight.autoAnimate) {
  45841. scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);
  45842. }
  45843. return light;
  45844. };
  45845. Light.prototype._hookArrayForExcluded = function (array) {
  45846. var _this = this;
  45847. var oldPush = array.push;
  45848. array.push = function () {
  45849. var items = [];
  45850. for (var _i = 0; _i < arguments.length; _i++) {
  45851. items[_i] = arguments[_i];
  45852. }
  45853. var result = oldPush.apply(array, items);
  45854. for (var _a = 0, items_1 = items; _a < items_1.length; _a++) {
  45855. var item = items_1[_a];
  45856. item._resyncLighSource(_this);
  45857. }
  45858. return result;
  45859. };
  45860. var oldSplice = array.splice;
  45861. array.splice = function (index, deleteCount) {
  45862. var deleted = oldSplice.apply(array, [index, deleteCount]);
  45863. for (var _i = 0, deleted_1 = deleted; _i < deleted_1.length; _i++) {
  45864. var item = deleted_1[_i];
  45865. item._resyncLighSource(_this);
  45866. }
  45867. return deleted;
  45868. };
  45869. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  45870. var item = array_1[_i];
  45871. item._resyncLighSource(this);
  45872. }
  45873. };
  45874. Light.prototype._hookArrayForIncludedOnly = function (array) {
  45875. var _this = this;
  45876. var oldPush = array.push;
  45877. array.push = function () {
  45878. var items = [];
  45879. for (var _i = 0; _i < arguments.length; _i++) {
  45880. items[_i] = arguments[_i];
  45881. }
  45882. var result = oldPush.apply(array, items);
  45883. _this._resyncMeshes();
  45884. return result;
  45885. };
  45886. var oldSplice = array.splice;
  45887. array.splice = function (index, deleteCount) {
  45888. var deleted = oldSplice.apply(array, [index, deleteCount]);
  45889. _this._resyncMeshes();
  45890. return deleted;
  45891. };
  45892. this._resyncMeshes();
  45893. };
  45894. Light.prototype._resyncMeshes = function () {
  45895. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  45896. var mesh = _a[_i];
  45897. mesh._resyncLighSource(this);
  45898. }
  45899. };
  45900. /**
  45901. * Forces the meshes to update their light related information in their rendering used effects
  45902. * @hidden Internal Use Only
  45903. */
  45904. Light.prototype._markMeshesAsLightDirty = function () {
  45905. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  45906. var mesh = _a[_i];
  45907. if (mesh._lightSources.indexOf(this) !== -1) {
  45908. mesh._markSubMeshesAsLightDirty();
  45909. }
  45910. }
  45911. };
  45912. /**
  45913. * Recomputes the cached photometric scale if needed.
  45914. */
  45915. Light.prototype._computePhotometricScale = function () {
  45916. this._photometricScale = this._getPhotometricScale();
  45917. this.getScene().resetCachedMaterial();
  45918. };
  45919. /**
  45920. * Returns the Photometric Scale according to the light type and intensity mode.
  45921. */
  45922. Light.prototype._getPhotometricScale = function () {
  45923. var photometricScale = 0.0;
  45924. var lightTypeID = this.getTypeID();
  45925. //get photometric mode
  45926. var photometricMode = this.intensityMode;
  45927. if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {
  45928. if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {
  45929. photometricMode = Light.INTENSITYMODE_ILLUMINANCE;
  45930. }
  45931. else {
  45932. photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;
  45933. }
  45934. }
  45935. //compute photometric scale
  45936. switch (lightTypeID) {
  45937. case Light.LIGHTTYPEID_POINTLIGHT:
  45938. case Light.LIGHTTYPEID_SPOTLIGHT:
  45939. switch (photometricMode) {
  45940. case Light.INTENSITYMODE_LUMINOUSPOWER:
  45941. photometricScale = 1.0 / (4.0 * Math.PI);
  45942. break;
  45943. case Light.INTENSITYMODE_LUMINOUSINTENSITY:
  45944. photometricScale = 1.0;
  45945. break;
  45946. case Light.INTENSITYMODE_LUMINANCE:
  45947. photometricScale = this.radius * this.radius;
  45948. break;
  45949. }
  45950. break;
  45951. case Light.LIGHTTYPEID_DIRECTIONALLIGHT:
  45952. switch (photometricMode) {
  45953. case Light.INTENSITYMODE_ILLUMINANCE:
  45954. photometricScale = 1.0;
  45955. break;
  45956. case Light.INTENSITYMODE_LUMINANCE:
  45957. // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.
  45958. // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).
  45959. var apexAngleRadians = this.radius;
  45960. // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).
  45961. apexAngleRadians = Math.max(apexAngleRadians, 0.001);
  45962. var solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));
  45963. photometricScale = solidAngle;
  45964. break;
  45965. }
  45966. break;
  45967. case Light.LIGHTTYPEID_HEMISPHERICLIGHT:
  45968. // No fall off in hemisperic light.
  45969. photometricScale = 1.0;
  45970. break;
  45971. }
  45972. return photometricScale;
  45973. };
  45974. /**
  45975. * Reorder the light in the scene according to their defined priority.
  45976. * @hidden Internal Use Only
  45977. */
  45978. Light.prototype._reorderLightsInScene = function () {
  45979. var scene = this.getScene();
  45980. if (this._renderPriority != 0) {
  45981. scene.requireLightSorting = true;
  45982. }
  45983. this.getScene().sortLightsByPriority();
  45984. };
  45985. /**
  45986. * Falloff Default: light is falling off following the material specification:
  45987. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  45988. */
  45989. Light.FALLOFF_DEFAULT = 0;
  45990. /**
  45991. * Falloff Physical: light is falling off following the inverse squared distance law.
  45992. */
  45993. Light.FALLOFF_PHYSICAL = 1;
  45994. /**
  45995. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  45996. * to enhance interoperability with other engines.
  45997. */
  45998. Light.FALLOFF_GLTF = 2;
  45999. /**
  46000. * Falloff Standard: light is falling off like in the standard material
  46001. * to enhance interoperability with other materials.
  46002. */
  46003. Light.FALLOFF_STANDARD = 3;
  46004. //lightmapMode Consts
  46005. /**
  46006. * If every light affecting the material is in this lightmapMode,
  46007. * material.lightmapTexture adds or multiplies
  46008. * (depends on material.useLightmapAsShadowmap)
  46009. * after every other light calculations.
  46010. */
  46011. Light.LIGHTMAP_DEFAULT = 0;
  46012. /**
  46013. * material.lightmapTexture as only diffuse lighting from this light
  46014. * adds only specular lighting from this light
  46015. * adds dynamic shadows
  46016. */
  46017. Light.LIGHTMAP_SPECULAR = 1;
  46018. /**
  46019. * material.lightmapTexture as only lighting
  46020. * no light calculation from this light
  46021. * only adds dynamic shadows from this light
  46022. */
  46023. Light.LIGHTMAP_SHADOWSONLY = 2;
  46024. // Intensity Mode Consts
  46025. /**
  46026. * Each light type uses the default quantity according to its type:
  46027. * point/spot lights use luminous intensity
  46028. * directional lights use illuminance
  46029. */
  46030. Light.INTENSITYMODE_AUTOMATIC = 0;
  46031. /**
  46032. * lumen (lm)
  46033. */
  46034. Light.INTENSITYMODE_LUMINOUSPOWER = 1;
  46035. /**
  46036. * candela (lm/sr)
  46037. */
  46038. Light.INTENSITYMODE_LUMINOUSINTENSITY = 2;
  46039. /**
  46040. * lux (lm/m^2)
  46041. */
  46042. Light.INTENSITYMODE_ILLUMINANCE = 3;
  46043. /**
  46044. * nit (cd/m^2)
  46045. */
  46046. Light.INTENSITYMODE_LUMINANCE = 4;
  46047. // Light types ids const.
  46048. /**
  46049. * Light type const id of the point light.
  46050. */
  46051. Light.LIGHTTYPEID_POINTLIGHT = 0;
  46052. /**
  46053. * Light type const id of the directional light.
  46054. */
  46055. Light.LIGHTTYPEID_DIRECTIONALLIGHT = 1;
  46056. /**
  46057. * Light type const id of the spot light.
  46058. */
  46059. Light.LIGHTTYPEID_SPOTLIGHT = 2;
  46060. /**
  46061. * Light type const id of the hemispheric light.
  46062. */
  46063. Light.LIGHTTYPEID_HEMISPHERICLIGHT = 3;
  46064. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46065. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  46066. ], Light.prototype, "diffuse", void 0);
  46067. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46068. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  46069. ], Light.prototype, "specular", void 0);
  46070. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46071. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46072. ], Light.prototype, "falloffType", void 0);
  46073. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46074. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46075. ], Light.prototype, "intensity", void 0);
  46076. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46077. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46078. ], Light.prototype, "range", null);
  46079. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46080. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46081. ], Light.prototype, "intensityMode", null);
  46082. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46083. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46084. ], Light.prototype, "radius", null);
  46085. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46086. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46087. ], Light.prototype, "_renderPriority", void 0);
  46088. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46089. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_reorderLightsInScene")
  46090. ], Light.prototype, "renderPriority", void 0);
  46091. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46092. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("shadowEnabled")
  46093. ], Light.prototype, "_shadowEnabled", void 0);
  46094. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46095. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("excludeWithLayerMask")
  46096. ], Light.prototype, "_excludeWithLayerMask", void 0);
  46097. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46098. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("includeOnlyWithLayerMask")
  46099. ], Light.prototype, "_includeOnlyWithLayerMask", void 0);
  46100. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46101. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("lightmapMode")
  46102. ], Light.prototype, "_lightmapMode", void 0);
  46103. return Light;
  46104. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  46105. /***/ }),
  46106. /***/ "./Lights/pointLight.ts":
  46107. /*!******************************!*\
  46108. !*** ./Lights/pointLight.ts ***!
  46109. \******************************/
  46110. /*! exports provided: PointLight */
  46111. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46112. "use strict";
  46113. __webpack_require__.r(__webpack_exports__);
  46114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return PointLight; });
  46115. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46116. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46117. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46118. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46119. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46120. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46121. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_0", function (name, scene) {
  46122. return function () { return new PointLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  46123. });
  46124. /**
  46125. * A point light is a light defined by an unique point in world space.
  46126. * The light is emitted in every direction from this point.
  46127. * A good example of a point light is a standard light bulb.
  46128. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46129. */
  46130. var PointLight = /** @class */ (function (_super) {
  46131. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointLight, _super);
  46132. /**
  46133. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  46134. * A PointLight emits the light in every direction.
  46135. * It can cast shadows.
  46136. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  46137. * ```javascript
  46138. * var pointLight = new PointLight("pl", camera.position, scene);
  46139. * ```
  46140. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46141. * @param name The light friendly name
  46142. * @param position The position of the point light in the scene
  46143. * @param scene The scene the lights belongs to
  46144. */
  46145. function PointLight(name, position, scene) {
  46146. var _this = _super.call(this, name, scene) || this;
  46147. _this._shadowAngle = Math.PI / 2;
  46148. _this.position = position;
  46149. return _this;
  46150. }
  46151. Object.defineProperty(PointLight.prototype, "shadowAngle", {
  46152. /**
  46153. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46154. * This specifies what angle the shadow will use to be created.
  46155. *
  46156. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46157. */
  46158. get: function () {
  46159. return this._shadowAngle;
  46160. },
  46161. /**
  46162. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46163. * This specifies what angle the shadow will use to be created.
  46164. *
  46165. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46166. */
  46167. set: function (value) {
  46168. this._shadowAngle = value;
  46169. this.forceProjectionMatrixCompute();
  46170. },
  46171. enumerable: true,
  46172. configurable: true
  46173. });
  46174. Object.defineProperty(PointLight.prototype, "direction", {
  46175. /**
  46176. * Gets the direction if it has been set.
  46177. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46178. */
  46179. get: function () {
  46180. return this._direction;
  46181. },
  46182. /**
  46183. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46184. */
  46185. set: function (value) {
  46186. var previousNeedCube = this.needCube();
  46187. this._direction = value;
  46188. if (this.needCube() !== previousNeedCube && this._shadowGenerator) {
  46189. this._shadowGenerator.recreateShadowMap();
  46190. }
  46191. },
  46192. enumerable: true,
  46193. configurable: true
  46194. });
  46195. /**
  46196. * Returns the string "PointLight"
  46197. * @returns the class name
  46198. */
  46199. PointLight.prototype.getClassName = function () {
  46200. return "PointLight";
  46201. };
  46202. /**
  46203. * Returns the integer 0.
  46204. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46205. */
  46206. PointLight.prototype.getTypeID = function () {
  46207. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_POINTLIGHT;
  46208. };
  46209. /**
  46210. * Specifies wether or not the shadowmap should be a cube texture.
  46211. * @returns true if the shadowmap needs to be a cube texture.
  46212. */
  46213. PointLight.prototype.needCube = function () {
  46214. return !this.direction;
  46215. };
  46216. /**
  46217. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  46218. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46219. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46220. */
  46221. PointLight.prototype.getShadowDirection = function (faceIndex) {
  46222. if (this.direction) {
  46223. return _super.prototype.getShadowDirection.call(this, faceIndex);
  46224. }
  46225. else {
  46226. switch (faceIndex) {
  46227. case 0:
  46228. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1.0, 0.0, 0.0);
  46229. case 1:
  46230. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](-1.0, 0.0, 0.0);
  46231. case 2:
  46232. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, -1.0, 0.0);
  46233. case 3:
  46234. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 1.0, 0.0);
  46235. case 4:
  46236. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, 1.0);
  46237. case 5:
  46238. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, -1.0);
  46239. }
  46240. }
  46241. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46242. };
  46243. /**
  46244. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  46245. * - fov = PI / 2
  46246. * - aspect ratio : 1.0
  46247. * - z-near and far equal to the active camera minZ and maxZ.
  46248. * Returns the PointLight.
  46249. */
  46250. PointLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  46251. var activeCamera = this.getScene().activeCamera;
  46252. if (!activeCamera) {
  46253. return;
  46254. }
  46255. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(this.shadowAngle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  46256. };
  46257. PointLight.prototype._buildUniformLayout = function () {
  46258. this._uniformBuffer.addUniform("vLightData", 4);
  46259. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  46260. this._uniformBuffer.addUniform("vLightSpecular", 3);
  46261. this._uniformBuffer.addUniform("vLightFalloff", 4);
  46262. this._uniformBuffer.addUniform("shadowsInfo", 3);
  46263. this._uniformBuffer.addUniform("depthValues", 2);
  46264. this._uniformBuffer.create();
  46265. };
  46266. /**
  46267. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  46268. * @param effect The effect to update
  46269. * @param lightIndex The index of the light in the effect to update
  46270. * @returns The point light
  46271. */
  46272. PointLight.prototype.transferToEffect = function (effect, lightIndex) {
  46273. if (this.computeTransformedInformation()) {
  46274. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0.0, lightIndex);
  46275. }
  46276. else {
  46277. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, lightIndex);
  46278. }
  46279. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, lightIndex);
  46280. return this;
  46281. };
  46282. /**
  46283. * Prepares the list of defines specific to the light type.
  46284. * @param defines the list of defines
  46285. * @param lightIndex defines the index of the light for the effect
  46286. */
  46287. PointLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  46288. defines["POINTLIGHT" + lightIndex] = true;
  46289. };
  46290. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46291. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46292. ], PointLight.prototype, "shadowAngle", null);
  46293. return PointLight;
  46294. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  46295. /***/ }),
  46296. /***/ "./Lights/shadowLight.ts":
  46297. /*!*******************************!*\
  46298. !*** ./Lights/shadowLight.ts ***!
  46299. \*******************************/
  46300. /*! exports provided: ShadowLight */
  46301. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46302. "use strict";
  46303. __webpack_require__.r(__webpack_exports__);
  46304. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return ShadowLight; });
  46305. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46306. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46307. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46308. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46309. /**
  46310. * Base implementation IShadowLight
  46311. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  46312. */
  46313. var ShadowLight = /** @class */ (function (_super) {
  46314. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowLight, _super);
  46315. function ShadowLight() {
  46316. var _this = _super !== null && _super.apply(this, arguments) || this;
  46317. _this._needProjectionMatrixCompute = true;
  46318. return _this;
  46319. }
  46320. ShadowLight.prototype._setPosition = function (value) {
  46321. this._position = value;
  46322. };
  46323. Object.defineProperty(ShadowLight.prototype, "position", {
  46324. /**
  46325. * Sets the position the shadow will be casted from. Also use as the light position for both
  46326. * point and spot lights.
  46327. */
  46328. get: function () {
  46329. return this._position;
  46330. },
  46331. /**
  46332. * Sets the position the shadow will be casted from. Also use as the light position for both
  46333. * point and spot lights.
  46334. */
  46335. set: function (value) {
  46336. this._setPosition(value);
  46337. },
  46338. enumerable: true,
  46339. configurable: true
  46340. });
  46341. ShadowLight.prototype._setDirection = function (value) {
  46342. this._direction = value;
  46343. };
  46344. Object.defineProperty(ShadowLight.prototype, "direction", {
  46345. /**
  46346. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  46347. * Also use as the light direction on spot and directional lights.
  46348. */
  46349. get: function () {
  46350. return this._direction;
  46351. },
  46352. /**
  46353. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  46354. * Also use as the light direction on spot and directional lights.
  46355. */
  46356. set: function (value) {
  46357. this._setDirection(value);
  46358. },
  46359. enumerable: true,
  46360. configurable: true
  46361. });
  46362. Object.defineProperty(ShadowLight.prototype, "shadowMinZ", {
  46363. /**
  46364. * Gets the shadow projection clipping minimum z value.
  46365. */
  46366. get: function () {
  46367. return this._shadowMinZ;
  46368. },
  46369. /**
  46370. * Sets the shadow projection clipping minimum z value.
  46371. */
  46372. set: function (value) {
  46373. this._shadowMinZ = value;
  46374. this.forceProjectionMatrixCompute();
  46375. },
  46376. enumerable: true,
  46377. configurable: true
  46378. });
  46379. Object.defineProperty(ShadowLight.prototype, "shadowMaxZ", {
  46380. /**
  46381. * Sets the shadow projection clipping maximum z value.
  46382. */
  46383. get: function () {
  46384. return this._shadowMaxZ;
  46385. },
  46386. /**
  46387. * Gets the shadow projection clipping maximum z value.
  46388. */
  46389. set: function (value) {
  46390. this._shadowMaxZ = value;
  46391. this.forceProjectionMatrixCompute();
  46392. },
  46393. enumerable: true,
  46394. configurable: true
  46395. });
  46396. /**
  46397. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  46398. * @returns true if the information has been computed, false if it does not need to (no parenting)
  46399. */
  46400. ShadowLight.prototype.computeTransformedInformation = function () {
  46401. if (this.parent && this.parent.getWorldMatrix) {
  46402. if (!this.transformedPosition) {
  46403. this.transformedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46404. }
  46405. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
  46406. // In case the direction is present.
  46407. if (this.direction) {
  46408. if (!this.transformedDirection) {
  46409. this.transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46410. }
  46411. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection);
  46412. }
  46413. return true;
  46414. }
  46415. return false;
  46416. };
  46417. /**
  46418. * Return the depth scale used for the shadow map.
  46419. * @returns the depth scale.
  46420. */
  46421. ShadowLight.prototype.getDepthScale = function () {
  46422. return 50.0;
  46423. };
  46424. /**
  46425. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  46426. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46427. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46428. */
  46429. ShadowLight.prototype.getShadowDirection = function (faceIndex) {
  46430. return this.transformedDirection ? this.transformedDirection : this.direction;
  46431. };
  46432. /**
  46433. * Returns the ShadowLight absolute position in the World.
  46434. * @returns the position vector in world space
  46435. */
  46436. ShadowLight.prototype.getAbsolutePosition = function () {
  46437. return this.transformedPosition ? this.transformedPosition : this.position;
  46438. };
  46439. /**
  46440. * Sets the ShadowLight direction toward the passed target.
  46441. * @param target The point tot target in local space
  46442. * @returns the updated ShadowLight direction
  46443. */
  46444. ShadowLight.prototype.setDirectionToTarget = function (target) {
  46445. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(this.position));
  46446. return this.direction;
  46447. };
  46448. /**
  46449. * Returns the light rotation in euler definition.
  46450. * @returns the x y z rotation in local space.
  46451. */
  46452. ShadowLight.prototype.getRotation = function () {
  46453. this.direction.normalize();
  46454. var xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y);
  46455. var yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(xaxis, this.direction);
  46456. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].RotationFromAxis(xaxis, yaxis, this.direction);
  46457. };
  46458. /**
  46459. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  46460. * @returns true if a cube texture needs to be use
  46461. */
  46462. ShadowLight.prototype.needCube = function () {
  46463. return false;
  46464. };
  46465. /**
  46466. * Detects if the projection matrix requires to be recomputed this frame.
  46467. * @returns true if it requires to be recomputed otherwise, false.
  46468. */
  46469. ShadowLight.prototype.needProjectionMatrixCompute = function () {
  46470. return this._needProjectionMatrixCompute;
  46471. };
  46472. /**
  46473. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  46474. */
  46475. ShadowLight.prototype.forceProjectionMatrixCompute = function () {
  46476. this._needProjectionMatrixCompute = true;
  46477. };
  46478. /** @hidden */
  46479. ShadowLight.prototype._initCache = function () {
  46480. _super.prototype._initCache.call(this);
  46481. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46482. };
  46483. /** @hidden */
  46484. ShadowLight.prototype._isSynchronized = function () {
  46485. if (!this._cache.position.equals(this.position)) {
  46486. return false;
  46487. }
  46488. return true;
  46489. };
  46490. /**
  46491. * Computes the world matrix of the node
  46492. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  46493. * @returns the world matrix
  46494. */
  46495. ShadowLight.prototype.computeWorldMatrix = function (force) {
  46496. if (!force && this.isSynchronized()) {
  46497. this._currentRenderId = this.getScene().getRenderId();
  46498. return this._worldMatrix;
  46499. }
  46500. this._updateCache();
  46501. this._cache.position.copyFrom(this.position);
  46502. if (!this._worldMatrix) {
  46503. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  46504. }
  46505. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
  46506. if (this.parent && this.parent.getWorldMatrix) {
  46507. this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  46508. this._markSyncedWithParent();
  46509. }
  46510. // Cache the determinant
  46511. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  46512. return this._worldMatrix;
  46513. };
  46514. /**
  46515. * Gets the minZ used for shadow according to both the scene and the light.
  46516. * @param activeCamera The camera we are returning the min for
  46517. * @returns the depth min z
  46518. */
  46519. ShadowLight.prototype.getDepthMinZ = function (activeCamera) {
  46520. return this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ;
  46521. };
  46522. /**
  46523. * Gets the maxZ used for shadow according to both the scene and the light.
  46524. * @param activeCamera The camera we are returning the max for
  46525. * @returns the depth max z
  46526. */
  46527. ShadowLight.prototype.getDepthMaxZ = function (activeCamera) {
  46528. return this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;
  46529. };
  46530. /**
  46531. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  46532. * @param matrix The materix to updated with the projection information
  46533. * @param viewMatrix The transform matrix of the light
  46534. * @param renderList The list of mesh to render in the map
  46535. * @returns The current light
  46536. */
  46537. ShadowLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  46538. if (this.customProjectionMatrixBuilder) {
  46539. this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
  46540. }
  46541. else {
  46542. this._setDefaultShadowProjectionMatrix(matrix, viewMatrix, renderList);
  46543. }
  46544. return this;
  46545. };
  46546. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46547. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  46548. ], ShadowLight.prototype, "position", null);
  46549. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46550. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  46551. ], ShadowLight.prototype, "direction", null);
  46552. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46553. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46554. ], ShadowLight.prototype, "shadowMinZ", null);
  46555. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46556. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46557. ], ShadowLight.prototype, "shadowMaxZ", null);
  46558. return ShadowLight;
  46559. }(_light__WEBPACK_IMPORTED_MODULE_3__["Light"]));
  46560. /***/ }),
  46561. /***/ "./Lights/spotLight.ts":
  46562. /*!*****************************!*\
  46563. !*** ./Lights/spotLight.ts ***!
  46564. \*****************************/
  46565. /*! exports provided: SpotLight */
  46566. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46567. "use strict";
  46568. __webpack_require__.r(__webpack_exports__);
  46569. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return SpotLight; });
  46570. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46571. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46572. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46573. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46574. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46575. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46576. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_2", function (name, scene) {
  46577. 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); };
  46578. });
  46579. /**
  46580. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46581. * These values define a cone of light starting from the position, emitting toward the direction.
  46582. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46583. * and the exponent defines the speed of the decay of the light with distance (reach).
  46584. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46585. */
  46586. var SpotLight = /** @class */ (function (_super) {
  46587. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpotLight, _super);
  46588. /**
  46589. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46590. * It can cast shadows.
  46591. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46592. * @param name The light friendly name
  46593. * @param position The position of the spot light in the scene
  46594. * @param direction The direction of the light in the scene
  46595. * @param angle The cone angle of the light in Radians
  46596. * @param exponent The light decay speed with the distance from the emission spot
  46597. * @param scene The scene the lights belongs to
  46598. */
  46599. function SpotLight(name, position, direction, angle, exponent, scene) {
  46600. var _this = _super.call(this, name, scene) || this;
  46601. _this._innerAngle = 0;
  46602. _this._projectionTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  46603. _this._projectionTextureLightNear = 1e-6;
  46604. _this._projectionTextureLightFar = 1000.0;
  46605. _this._projectionTextureUpDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  46606. _this._projectionTextureViewLightDirty = true;
  46607. _this._projectionTextureProjectionLightDirty = true;
  46608. _this._projectionTextureDirty = true;
  46609. _this._projectionTextureViewTargetVector = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46610. _this._projectionTextureViewLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  46611. _this._projectionTextureProjectionLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  46612. _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);
  46613. _this.position = position;
  46614. _this.direction = direction;
  46615. _this.angle = angle;
  46616. _this.exponent = exponent;
  46617. return _this;
  46618. }
  46619. Object.defineProperty(SpotLight.prototype, "angle", {
  46620. /**
  46621. * Gets the cone angle of the spot light in Radians.
  46622. */
  46623. get: function () {
  46624. return this._angle;
  46625. },
  46626. /**
  46627. * Sets the cone angle of the spot light in Radians.
  46628. */
  46629. set: function (value) {
  46630. this._angle = value;
  46631. this._cosHalfAngle = Math.cos(value * 0.5);
  46632. this._projectionTextureProjectionLightDirty = true;
  46633. this.forceProjectionMatrixCompute();
  46634. this._computeAngleValues();
  46635. },
  46636. enumerable: true,
  46637. configurable: true
  46638. });
  46639. Object.defineProperty(SpotLight.prototype, "innerAngle", {
  46640. /**
  46641. * Only used in gltf falloff mode, this defines the angle where
  46642. * the directional falloff will start before cutting at angle which could be seen
  46643. * as outer angle.
  46644. */
  46645. get: function () {
  46646. return this._innerAngle;
  46647. },
  46648. /**
  46649. * Only used in gltf falloff mode, this defines the angle where
  46650. * the directional falloff will start before cutting at angle which could be seen
  46651. * as outer angle.
  46652. */
  46653. set: function (value) {
  46654. this._innerAngle = value;
  46655. this._computeAngleValues();
  46656. },
  46657. enumerable: true,
  46658. configurable: true
  46659. });
  46660. Object.defineProperty(SpotLight.prototype, "shadowAngleScale", {
  46661. /**
  46662. * Allows scaling the angle of the light for shadow generation only.
  46663. */
  46664. get: function () {
  46665. return this._shadowAngleScale;
  46666. },
  46667. /**
  46668. * Allows scaling the angle of the light for shadow generation only.
  46669. */
  46670. set: function (value) {
  46671. this._shadowAngleScale = value;
  46672. this.forceProjectionMatrixCompute();
  46673. },
  46674. enumerable: true,
  46675. configurable: true
  46676. });
  46677. Object.defineProperty(SpotLight.prototype, "projectionTextureMatrix", {
  46678. /**
  46679. * Allows reading the projecton texture
  46680. */
  46681. get: function () {
  46682. return this._projectionTextureMatrix;
  46683. },
  46684. enumerable: true,
  46685. configurable: true
  46686. });
  46687. Object.defineProperty(SpotLight.prototype, "projectionTextureLightNear", {
  46688. /**
  46689. * Gets the near clip of the Spotlight for texture projection.
  46690. */
  46691. get: function () {
  46692. return this._projectionTextureLightNear;
  46693. },
  46694. /**
  46695. * Sets the near clip of the Spotlight for texture projection.
  46696. */
  46697. set: function (value) {
  46698. this._projectionTextureLightNear = value;
  46699. this._projectionTextureProjectionLightDirty = true;
  46700. },
  46701. enumerable: true,
  46702. configurable: true
  46703. });
  46704. Object.defineProperty(SpotLight.prototype, "projectionTextureLightFar", {
  46705. /**
  46706. * Gets the far clip of the Spotlight for texture projection.
  46707. */
  46708. get: function () {
  46709. return this._projectionTextureLightFar;
  46710. },
  46711. /**
  46712. * Sets the far clip of the Spotlight for texture projection.
  46713. */
  46714. set: function (value) {
  46715. this._projectionTextureLightFar = value;
  46716. this._projectionTextureProjectionLightDirty = true;
  46717. },
  46718. enumerable: true,
  46719. configurable: true
  46720. });
  46721. Object.defineProperty(SpotLight.prototype, "projectionTextureUpDirection", {
  46722. /**
  46723. * Gets the Up vector of the Spotlight for texture projection.
  46724. */
  46725. get: function () {
  46726. return this._projectionTextureUpDirection;
  46727. },
  46728. /**
  46729. * Sets the Up vector of the Spotlight for texture projection.
  46730. */
  46731. set: function (value) {
  46732. this._projectionTextureUpDirection = value;
  46733. this._projectionTextureProjectionLightDirty = true;
  46734. },
  46735. enumerable: true,
  46736. configurable: true
  46737. });
  46738. Object.defineProperty(SpotLight.prototype, "projectionTexture", {
  46739. /**
  46740. * Gets the projection texture of the light.
  46741. */
  46742. get: function () {
  46743. return this._projectionTexture;
  46744. },
  46745. /**
  46746. * Sets the projection texture of the light.
  46747. */
  46748. set: function (value) {
  46749. this._projectionTexture = value;
  46750. this._projectionTextureDirty = true;
  46751. },
  46752. enumerable: true,
  46753. configurable: true
  46754. });
  46755. /**
  46756. * Returns the string "SpotLight".
  46757. * @returns the class name
  46758. */
  46759. SpotLight.prototype.getClassName = function () {
  46760. return "SpotLight";
  46761. };
  46762. /**
  46763. * Returns the integer 2.
  46764. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46765. */
  46766. SpotLight.prototype.getTypeID = function () {
  46767. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_SPOTLIGHT;
  46768. };
  46769. /**
  46770. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46771. */
  46772. SpotLight.prototype._setDirection = function (value) {
  46773. _super.prototype._setDirection.call(this, value);
  46774. this._projectionTextureViewLightDirty = true;
  46775. };
  46776. /**
  46777. * Overrides the position setter to recompute the projection texture view light Matrix.
  46778. */
  46779. SpotLight.prototype._setPosition = function (value) {
  46780. _super.prototype._setPosition.call(this, value);
  46781. this._projectionTextureViewLightDirty = true;
  46782. };
  46783. /**
  46784. * 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.
  46785. * Returns the SpotLight.
  46786. */
  46787. SpotLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  46788. var activeCamera = this.getScene().activeCamera;
  46789. if (!activeCamera) {
  46790. return;
  46791. }
  46792. this._shadowAngleScale = this._shadowAngleScale || 1;
  46793. var angle = this._shadowAngleScale * this._angle;
  46794. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(angle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  46795. };
  46796. SpotLight.prototype._computeProjectionTextureViewLightMatrix = function () {
  46797. this._projectionTextureViewLightDirty = false;
  46798. this._projectionTextureDirty = true;
  46799. this.position.addToRef(this.direction, this._projectionTextureViewTargetVector);
  46800. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix);
  46801. };
  46802. SpotLight.prototype._computeProjectionTextureProjectionLightMatrix = function () {
  46803. this._projectionTextureProjectionLightDirty = false;
  46804. this._projectionTextureDirty = true;
  46805. var light_far = this.projectionTextureLightFar;
  46806. var light_near = this.projectionTextureLightNear;
  46807. var P = light_far / (light_far - light_near);
  46808. var Q = -P * light_near;
  46809. var S = 1.0 / Math.tan(this._angle / 2.0);
  46810. var A = 1.0;
  46811. _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);
  46812. };
  46813. /**
  46814. * Main function for light texture projection matrix computing.
  46815. */
  46816. SpotLight.prototype._computeProjectionTextureMatrix = function () {
  46817. this._projectionTextureDirty = false;
  46818. this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix);
  46819. this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);
  46820. };
  46821. SpotLight.prototype._buildUniformLayout = function () {
  46822. this._uniformBuffer.addUniform("vLightData", 4);
  46823. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  46824. this._uniformBuffer.addUniform("vLightSpecular", 3);
  46825. this._uniformBuffer.addUniform("vLightDirection", 3);
  46826. this._uniformBuffer.addUniform("vLightFalloff", 4);
  46827. this._uniformBuffer.addUniform("shadowsInfo", 3);
  46828. this._uniformBuffer.addUniform("depthValues", 2);
  46829. this._uniformBuffer.create();
  46830. };
  46831. SpotLight.prototype._computeAngleValues = function () {
  46832. this._lightAngleScale = 1.0 / Math.max(0.001, (Math.cos(this._innerAngle * 0.5) - this._cosHalfAngle));
  46833. this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale;
  46834. };
  46835. /**
  46836. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46837. * @param effect The effect to update
  46838. * @param lightIndex The index of the light in the effect to update
  46839. * @returns The spot light
  46840. */
  46841. SpotLight.prototype.transferToEffect = function (effect, lightIndex) {
  46842. var normalizeDirection;
  46843. if (this.computeTransformedInformation()) {
  46844. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, lightIndex);
  46845. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.transformedDirection);
  46846. }
  46847. else {
  46848. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, lightIndex);
  46849. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  46850. }
  46851. this._uniformBuffer.updateFloat4("vLightDirection", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, this._cosHalfAngle, lightIndex);
  46852. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, lightIndex);
  46853. if (this.projectionTexture && this.projectionTexture.isReady()) {
  46854. if (this._projectionTextureViewLightDirty) {
  46855. this._computeProjectionTextureViewLightMatrix();
  46856. }
  46857. if (this._projectionTextureProjectionLightDirty) {
  46858. this._computeProjectionTextureProjectionLightMatrix();
  46859. }
  46860. if (this._projectionTextureDirty) {
  46861. this._computeProjectionTextureMatrix();
  46862. }
  46863. effect.setMatrix("textureProjectionMatrix" + lightIndex, this._projectionTextureMatrix);
  46864. effect.setTexture("projectionLightSampler" + lightIndex, this.projectionTexture);
  46865. }
  46866. return this;
  46867. };
  46868. /**
  46869. * Disposes the light and the associated resources.
  46870. */
  46871. SpotLight.prototype.dispose = function () {
  46872. _super.prototype.dispose.call(this);
  46873. if (this._projectionTexture) {
  46874. this._projectionTexture.dispose();
  46875. }
  46876. };
  46877. /**
  46878. * Prepares the list of defines specific to the light type.
  46879. * @param defines the list of defines
  46880. * @param lightIndex defines the index of the light for the effect
  46881. */
  46882. SpotLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  46883. defines["SPOTLIGHT" + lightIndex] = true;
  46884. defines["PROJECTEDLIGHTTEXTURE" + lightIndex] = this.projectionTexture ? true : false;
  46885. };
  46886. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46887. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46888. ], SpotLight.prototype, "angle", null);
  46889. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46890. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46891. ], SpotLight.prototype, "innerAngle", null);
  46892. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46893. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46894. ], SpotLight.prototype, "shadowAngleScale", null);
  46895. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46896. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46897. ], SpotLight.prototype, "exponent", void 0);
  46898. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46899. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46900. ], SpotLight.prototype, "projectionTextureLightNear", null);
  46901. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46902. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46903. ], SpotLight.prototype, "projectionTextureLightFar", null);
  46904. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46905. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46906. ], SpotLight.prototype, "projectionTextureUpDirection", null);
  46907. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46908. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("projectedLightTexture")
  46909. ], SpotLight.prototype, "_projectionTexture", void 0);
  46910. return SpotLight;
  46911. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  46912. /***/ }),
  46913. /***/ "./Loading/Plugins/babylonFileLoader.ts":
  46914. /*!**********************************************!*\
  46915. !*** ./Loading/Plugins/babylonFileLoader.ts ***!
  46916. \**********************************************/
  46917. /*! exports provided: _BabylonLoaderRegistered */
  46918. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46919. "use strict";
  46920. __webpack_require__.r(__webpack_exports__);
  46921. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _BabylonLoaderRegistered; });
  46922. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  46923. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  46924. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  46925. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  46926. /* harmony import */ var _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/geometry */ "./Meshes/geometry.ts");
  46927. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/transformNode */ "./Meshes/transformNode.ts");
  46928. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  46929. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  46930. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  46931. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  46932. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  46933. /* harmony import */ var _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Animations/animationGroup */ "./Animations/animationGroup.ts");
  46934. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  46935. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  46936. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  46937. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  46938. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../assetContainer */ "./assetContainer.ts");
  46939. /* harmony import */ var _Actions_actionManager__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Actions/actionManager */ "./Actions/actionManager.ts");
  46940. /* harmony import */ var _Bones_skeleton__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Bones/skeleton */ "./Bones/skeleton.ts");
  46941. /* harmony import */ var _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Morph/morphTargetManager */ "./Morph/morphTargetManager.ts");
  46942. /* harmony import */ var _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Physics/Plugins/cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  46943. /* harmony import */ var _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Physics/Plugins/oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  46944. /* harmony import */ var _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Probes/reflectionProbe */ "./Probes/reflectionProbe.ts");
  46945. /** @hidden */
  46946. var _BabylonLoaderRegistered = true;
  46947. var parseMaterialById = function (id, parsedData, scene, rootUrl) {
  46948. for (var index = 0, cache = parsedData.materials.length; index < cache; index++) {
  46949. var parsedMaterial = parsedData.materials[index];
  46950. if (parsedMaterial.id === id) {
  46951. return _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  46952. }
  46953. }
  46954. return null;
  46955. };
  46956. var isDescendantOf = function (mesh, names, hierarchyIds) {
  46957. for (var i in names) {
  46958. if (mesh.name === names[i]) {
  46959. hierarchyIds.push(mesh.id);
  46960. return true;
  46961. }
  46962. }
  46963. if (mesh.parentId && hierarchyIds.indexOf(mesh.parentId) !== -1) {
  46964. hierarchyIds.push(mesh.id);
  46965. return true;
  46966. }
  46967. return false;
  46968. };
  46969. var logOperation = function (operation, producer) {
  46970. return operation + " of " + (producer ? producer.file + " from " + producer.name + " version: " + producer.version + ", exporter version: " + producer.exporter_version : "unknown");
  46971. };
  46972. var loadAssetContainer = function (scene, data, rootUrl, onError, addToScene) {
  46973. if (addToScene === void 0) { addToScene = false; }
  46974. var container = new _assetContainer__WEBPACK_IMPORTED_MODULE_16__["AssetContainer"](scene);
  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 = "importScene 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. var index;
  46985. var cache;
  46986. // Lights
  46987. if (parsedData.lights !== undefined && parsedData.lights !== null) {
  46988. for (index = 0, cache = parsedData.lights.length; index < cache; index++) {
  46989. var parsedLight = parsedData.lights[index];
  46990. var light = _Lights_light__WEBPACK_IMPORTED_MODULE_12__["Light"].Parse(parsedLight, scene);
  46991. if (light) {
  46992. container.lights.push(light);
  46993. log += (index === 0 ? "\n\tLights:" : "");
  46994. log += "\n\t\t" + light.toString(fullDetails);
  46995. }
  46996. }
  46997. }
  46998. // Reflection probes
  46999. if (parsedData.reflectionProbes !== undefined && parsedData.reflectionProbes !== null) {
  47000. for (index = 0, cache = parsedData.reflectionProbes.length; index < cache; index++) {
  47001. var parsedReflectionProbe = parsedData.reflectionProbes[index];
  47002. var reflectionProbe = _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_22__["ReflectionProbe"].Parse(parsedReflectionProbe, scene, rootUrl);
  47003. if (reflectionProbe) {
  47004. container.reflectionProbes.push(reflectionProbe);
  47005. log += (index === 0 ? "\n\tReflection Probes:" : "");
  47006. log += "\n\t\t" + reflectionProbe.toString(fullDetails);
  47007. }
  47008. }
  47009. }
  47010. // Animations
  47011. if (parsedData.animations !== undefined && parsedData.animations !== null) {
  47012. for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
  47013. var parsedAnimation = parsedData.animations[index];
  47014. var animation = _Animations_animation__WEBPACK_IMPORTED_MODULE_10__["Animation"].Parse(parsedAnimation);
  47015. scene.animations.push(animation);
  47016. container.animations.push(animation);
  47017. log += (index === 0 ? "\n\tAnimations:" : "");
  47018. log += "\n\t\t" + animation.toString(fullDetails);
  47019. }
  47020. }
  47021. // Materials
  47022. if (parsedData.materials !== undefined && parsedData.materials !== null) {
  47023. for (index = 0, cache = parsedData.materials.length; index < cache; index++) {
  47024. var parsedMaterial = parsedData.materials[index];
  47025. var mat = _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  47026. container.materials.push(mat);
  47027. log += (index === 0 ? "\n\tMaterials:" : "");
  47028. log += "\n\t\t" + mat.toString(fullDetails);
  47029. }
  47030. }
  47031. if (parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  47032. for (index = 0, cache = parsedData.multiMaterials.length; index < cache; index++) {
  47033. var parsedMultiMaterial = parsedData.multiMaterials[index];
  47034. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  47035. container.multiMaterials.push(mmat);
  47036. log += (index === 0 ? "\n\tMultiMaterials:" : "");
  47037. log += "\n\t\t" + mmat.toString(fullDetails);
  47038. }
  47039. }
  47040. // Morph targets
  47041. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  47042. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  47043. var managerData = _a[_i];
  47044. container.morphTargetManagers.push(_Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_19__["MorphTargetManager"].Parse(managerData, scene));
  47045. }
  47046. }
  47047. // Skeletons
  47048. if (parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  47049. for (index = 0, cache = parsedData.skeletons.length; index < cache; index++) {
  47050. var parsedSkeleton = parsedData.skeletons[index];
  47051. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_18__["Skeleton"].Parse(parsedSkeleton, scene);
  47052. container.skeletons.push(skeleton);
  47053. log += (index === 0 ? "\n\tSkeletons:" : "");
  47054. log += "\n\t\t" + skeleton.toString(fullDetails);
  47055. }
  47056. }
  47057. // Geometries
  47058. var geometries = parsedData.geometries;
  47059. if (geometries !== undefined && geometries !== null) {
  47060. var addedGeometry = new Array();
  47061. // Boxes
  47062. var boxes = geometries.boxes;
  47063. if (boxes !== undefined && boxes !== null) {
  47064. for (index = 0, cache = boxes.length; index < cache; index++) {
  47065. var parsedBox = boxes[index];
  47066. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["BoxGeometry"].Parse(parsedBox, scene));
  47067. }
  47068. }
  47069. // Spheres
  47070. var spheres = geometries.spheres;
  47071. if (spheres !== undefined && spheres !== null) {
  47072. for (index = 0, cache = spheres.length; index < cache; index++) {
  47073. var parsedSphere = spheres[index];
  47074. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["SphereGeometry"].Parse(parsedSphere, scene));
  47075. }
  47076. }
  47077. // Cylinders
  47078. var cylinders = geometries.cylinders;
  47079. if (cylinders !== undefined && cylinders !== null) {
  47080. for (index = 0, cache = cylinders.length; index < cache; index++) {
  47081. var parsedCylinder = cylinders[index];
  47082. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["CylinderGeometry"].Parse(parsedCylinder, scene));
  47083. }
  47084. }
  47085. // Toruses
  47086. var toruses = geometries.toruses;
  47087. if (toruses !== undefined && toruses !== null) {
  47088. for (index = 0, cache = toruses.length; index < cache; index++) {
  47089. var parsedTorus = toruses[index];
  47090. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["TorusGeometry"].Parse(parsedTorus, scene));
  47091. }
  47092. }
  47093. // Grounds
  47094. var grounds = geometries.grounds;
  47095. if (grounds !== undefined && grounds !== null) {
  47096. for (index = 0, cache = grounds.length; index < cache; index++) {
  47097. var parsedGround = grounds[index];
  47098. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["GroundGeometry"].Parse(parsedGround, scene));
  47099. }
  47100. }
  47101. // Planes
  47102. var planes = geometries.planes;
  47103. if (planes !== undefined && planes !== null) {
  47104. for (index = 0, cache = planes.length; index < cache; index++) {
  47105. var parsedPlane = planes[index];
  47106. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["PlaneGeometry"].Parse(parsedPlane, scene));
  47107. }
  47108. }
  47109. // TorusKnots
  47110. var torusKnots = geometries.torusKnots;
  47111. if (torusKnots !== undefined && torusKnots !== null) {
  47112. for (index = 0, cache = torusKnots.length; index < cache; index++) {
  47113. var parsedTorusKnot = torusKnots[index];
  47114. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["TorusKnotGeometry"].Parse(parsedTorusKnot, scene));
  47115. }
  47116. }
  47117. // VertexData
  47118. var vertexData = geometries.vertexData;
  47119. if (vertexData !== undefined && vertexData !== null) {
  47120. for (index = 0, cache = vertexData.length; index < cache; index++) {
  47121. var parsedVertexData = vertexData[index];
  47122. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedVertexData, scene, rootUrl));
  47123. }
  47124. }
  47125. addedGeometry.forEach(function (g) {
  47126. if (g) {
  47127. container.geometries.push(g);
  47128. }
  47129. });
  47130. }
  47131. // Transform nodes
  47132. if (parsedData.transformNodes !== undefined && parsedData.transformNodes !== null) {
  47133. for (index = 0, cache = parsedData.transformNodes.length; index < cache; index++) {
  47134. var parsedTransformNode = parsedData.transformNodes[index];
  47135. var node = _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__["TransformNode"].Parse(parsedTransformNode, scene, rootUrl);
  47136. container.transformNodes.push(node);
  47137. }
  47138. }
  47139. // Meshes
  47140. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  47141. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  47142. var parsedMesh = parsedData.meshes[index];
  47143. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  47144. container.meshes.push(mesh);
  47145. log += (index === 0 ? "\n\tMeshes:" : "");
  47146. log += "\n\t\t" + mesh.toString(fullDetails);
  47147. }
  47148. }
  47149. // Cameras
  47150. if (parsedData.cameras !== undefined && parsedData.cameras !== null) {
  47151. for (index = 0, cache = parsedData.cameras.length; index < cache; index++) {
  47152. var parsedCamera = parsedData.cameras[index];
  47153. var camera = _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].Parse(parsedCamera, scene);
  47154. container.cameras.push(camera);
  47155. log += (index === 0 ? "\n\tCameras:" : "");
  47156. log += "\n\t\t" + camera.toString(fullDetails);
  47157. }
  47158. }
  47159. // Animation Groups
  47160. if (parsedData.animationGroups !== undefined && parsedData.animationGroups !== null) {
  47161. for (index = 0, cache = parsedData.animationGroups.length; index < cache; index++) {
  47162. var parsedAnimationGroup = parsedData.animationGroups[index];
  47163. var animationGroup = _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_11__["AnimationGroup"].Parse(parsedAnimationGroup, scene);
  47164. container.animationGroups.push(animationGroup);
  47165. log += (index === 0 ? "\n\tAnimationGroups:" : "");
  47166. log += "\n\t\t" + animationGroup.toString(fullDetails);
  47167. }
  47168. }
  47169. // Browsing all the graph to connect the dots
  47170. for (index = 0, cache = scene.cameras.length; index < cache; index++) {
  47171. var camera = scene.cameras[index];
  47172. if (camera._waitingParentId) {
  47173. camera.parent = scene.getLastEntryByID(camera._waitingParentId);
  47174. camera._waitingParentId = null;
  47175. }
  47176. }
  47177. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  47178. var light_1 = scene.lights[index];
  47179. if (light_1 && light_1._waitingParentId) {
  47180. light_1.parent = scene.getLastEntryByID(light_1._waitingParentId);
  47181. light_1._waitingParentId = null;
  47182. }
  47183. }
  47184. // Connect parents & children and parse actions
  47185. for (index = 0, cache = scene.transformNodes.length; index < cache; index++) {
  47186. var transformNode = scene.transformNodes[index];
  47187. if (transformNode._waitingParentId) {
  47188. transformNode.parent = scene.getLastEntryByID(transformNode._waitingParentId);
  47189. transformNode._waitingParentId = null;
  47190. }
  47191. }
  47192. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47193. var mesh = scene.meshes[index];
  47194. if (mesh._waitingParentId) {
  47195. mesh.parent = scene.getLastEntryByID(mesh._waitingParentId);
  47196. mesh._waitingParentId = null;
  47197. }
  47198. }
  47199. // freeze world matrix application
  47200. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47201. var currentMesh = scene.meshes[index];
  47202. if (currentMesh._waitingFreezeWorldMatrix) {
  47203. currentMesh.freezeWorldMatrix();
  47204. currentMesh._waitingFreezeWorldMatrix = null;
  47205. }
  47206. else {
  47207. currentMesh.computeWorldMatrix(true);
  47208. }
  47209. }
  47210. // Lights exclusions / inclusions
  47211. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  47212. var light_2 = scene.lights[index];
  47213. // Excluded check
  47214. if (light_2._excludedMeshesIds.length > 0) {
  47215. for (var excludedIndex = 0; excludedIndex < light_2._excludedMeshesIds.length; excludedIndex++) {
  47216. var excludedMesh = scene.getMeshByID(light_2._excludedMeshesIds[excludedIndex]);
  47217. if (excludedMesh) {
  47218. light_2.excludedMeshes.push(excludedMesh);
  47219. }
  47220. }
  47221. light_2._excludedMeshesIds = [];
  47222. }
  47223. // Included check
  47224. if (light_2._includedOnlyMeshesIds.length > 0) {
  47225. for (var includedOnlyIndex = 0; includedOnlyIndex < light_2._includedOnlyMeshesIds.length; includedOnlyIndex++) {
  47226. var includedOnlyMesh = scene.getMeshByID(light_2._includedOnlyMeshesIds[includedOnlyIndex]);
  47227. if (includedOnlyMesh) {
  47228. light_2.includedOnlyMeshes.push(includedOnlyMesh);
  47229. }
  47230. }
  47231. light_2._includedOnlyMeshesIds = [];
  47232. }
  47233. }
  47234. _abstractScene__WEBPACK_IMPORTED_MODULE_15__["AbstractScene"].Parse(parsedData, scene, container, rootUrl);
  47235. // Actions (scene) Done last as it can access other objects.
  47236. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47237. var mesh = scene.meshes[index];
  47238. if (mesh._waitingActions) {
  47239. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_17__["ActionManager"].Parse(mesh._waitingActions, mesh, scene);
  47240. mesh._waitingActions = null;
  47241. }
  47242. }
  47243. if (parsedData.actions !== undefined && parsedData.actions !== null) {
  47244. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_17__["ActionManager"].Parse(parsedData.actions, null, scene);
  47245. }
  47246. if (!addToScene) {
  47247. container.removeAllFromScene();
  47248. }
  47249. }
  47250. catch (err) {
  47251. var msg = logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + log;
  47252. if (onError) {
  47253. onError(msg, err);
  47254. }
  47255. else {
  47256. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  47257. throw err;
  47258. }
  47259. }
  47260. finally {
  47261. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].NO_LOGGING) {
  47262. _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 : ""));
  47263. }
  47264. }
  47265. return container;
  47266. };
  47267. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].RegisterPlugin({
  47268. name: "babylon.js",
  47269. extensions: ".babylon",
  47270. canDirectLoad: function (data) {
  47271. if (data.indexOf("babylon") !== -1) { // We consider that the producer string is filled
  47272. return true;
  47273. }
  47274. return false;
  47275. },
  47276. importMesh: function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons, onError) {
  47277. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  47278. // when SceneLoader.debugLogging = true (default), or exception encountered.
  47279. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  47280. // and avoid problems with multiple concurrent .babylon loads.
  47281. var log = "importMesh has failed JSON parse";
  47282. try {
  47283. var parsedData = JSON.parse(data);
  47284. log = "";
  47285. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].DETAILED_LOGGING;
  47286. if (!meshesNames) {
  47287. meshesNames = null;
  47288. }
  47289. else if (!Array.isArray(meshesNames)) {
  47290. meshesNames = [meshesNames];
  47291. }
  47292. var hierarchyIds = new Array();
  47293. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  47294. var loadedSkeletonsIds = [];
  47295. var loadedMaterialsIds = [];
  47296. var index;
  47297. var cache;
  47298. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  47299. var parsedMesh = parsedData.meshes[index];
  47300. if (meshesNames === null || isDescendantOf(parsedMesh, meshesNames, hierarchyIds)) {
  47301. if (meshesNames !== null) {
  47302. // Remove found mesh name from list.
  47303. delete meshesNames[meshesNames.indexOf(parsedMesh.name)];
  47304. }
  47305. //Geometry?
  47306. if (parsedMesh.geometryId !== undefined && parsedMesh.geometryId !== null) {
  47307. //does the file contain geometries?
  47308. if (parsedData.geometries !== undefined && parsedData.geometries !== null) {
  47309. //find the correct geometry and add it to the scene
  47310. var found = false;
  47311. ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function (geometryType) {
  47312. if (found === true || !parsedData.geometries[geometryType] || !(Array.isArray(parsedData.geometries[geometryType]))) {
  47313. return;
  47314. }
  47315. else {
  47316. parsedData.geometries[geometryType].forEach(function (parsedGeometryData) {
  47317. if (parsedGeometryData.id === parsedMesh.geometryId) {
  47318. switch (geometryType) {
  47319. case "boxes":
  47320. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["BoxGeometry"].Parse(parsedGeometryData, scene);
  47321. break;
  47322. case "spheres":
  47323. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["SphereGeometry"].Parse(parsedGeometryData, scene);
  47324. break;
  47325. case "cylinders":
  47326. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["CylinderGeometry"].Parse(parsedGeometryData, scene);
  47327. break;
  47328. case "toruses":
  47329. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["TorusGeometry"].Parse(parsedGeometryData, scene);
  47330. break;
  47331. case "grounds":
  47332. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["GroundGeometry"].Parse(parsedGeometryData, scene);
  47333. break;
  47334. case "planes":
  47335. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["PlaneGeometry"].Parse(parsedGeometryData, scene);
  47336. break;
  47337. case "torusKnots":
  47338. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["TorusKnotGeometry"].Parse(parsedGeometryData, scene);
  47339. break;
  47340. case "vertexData":
  47341. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedGeometryData, scene, rootUrl);
  47342. break;
  47343. }
  47344. found = true;
  47345. }
  47346. });
  47347. }
  47348. });
  47349. if (found === false) {
  47350. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Geometry not found for mesh " + parsedMesh.id);
  47351. }
  47352. }
  47353. }
  47354. // Material ?
  47355. if (parsedMesh.materialId) {
  47356. var materialFound = (loadedMaterialsIds.indexOf(parsedMesh.materialId) !== -1);
  47357. if (materialFound === false && parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  47358. for (var multimatIndex = 0, multimatCache = parsedData.multiMaterials.length; multimatIndex < multimatCache; multimatIndex++) {
  47359. var parsedMultiMaterial = parsedData.multiMaterials[multimatIndex];
  47360. if (parsedMultiMaterial.id === parsedMesh.materialId) {
  47361. for (var matIndex = 0, matCache = parsedMultiMaterial.materials.length; matIndex < matCache; matIndex++) {
  47362. var subMatId = parsedMultiMaterial.materials[matIndex];
  47363. loadedMaterialsIds.push(subMatId);
  47364. var mat = parseMaterialById(subMatId, parsedData, scene, rootUrl);
  47365. if (mat) {
  47366. log += "\n\tMaterial " + mat.toString(fullDetails);
  47367. }
  47368. }
  47369. loadedMaterialsIds.push(parsedMultiMaterial.id);
  47370. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  47371. if (mmat) {
  47372. materialFound = true;
  47373. log += "\n\tMulti-Material " + mmat.toString(fullDetails);
  47374. }
  47375. break;
  47376. }
  47377. }
  47378. }
  47379. if (materialFound === false) {
  47380. loadedMaterialsIds.push(parsedMesh.materialId);
  47381. var mat = parseMaterialById(parsedMesh.materialId, parsedData, scene, rootUrl);
  47382. if (!mat) {
  47383. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Material not found for mesh " + parsedMesh.id);
  47384. }
  47385. else {
  47386. log += "\n\tMaterial " + mat.toString(fullDetails);
  47387. }
  47388. }
  47389. }
  47390. // Skeleton ?
  47391. if (parsedMesh.skeletonId > -1 && parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  47392. var skeletonAlreadyLoaded = (loadedSkeletonsIds.indexOf(parsedMesh.skeletonId) > -1);
  47393. if (skeletonAlreadyLoaded === false) {
  47394. for (var skeletonIndex = 0, skeletonCache = parsedData.skeletons.length; skeletonIndex < skeletonCache; skeletonIndex++) {
  47395. var parsedSkeleton = parsedData.skeletons[skeletonIndex];
  47396. if (parsedSkeleton.id === parsedMesh.skeletonId) {
  47397. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_18__["Skeleton"].Parse(parsedSkeleton, scene);
  47398. skeletons.push(skeleton);
  47399. loadedSkeletonsIds.push(parsedSkeleton.id);
  47400. log += "\n\tSkeleton " + skeleton.toString(fullDetails);
  47401. }
  47402. }
  47403. }
  47404. }
  47405. // Morph targets ?
  47406. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  47407. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  47408. var managerData = _a[_i];
  47409. _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_19__["MorphTargetManager"].Parse(managerData, scene);
  47410. }
  47411. }
  47412. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  47413. meshes.push(mesh);
  47414. log += "\n\tMesh " + mesh.toString(fullDetails);
  47415. }
  47416. }
  47417. // Connecting parents
  47418. var currentMesh;
  47419. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47420. currentMesh = scene.meshes[index];
  47421. if (currentMesh._waitingParentId) {
  47422. currentMesh.parent = scene.getLastEntryByID(currentMesh._waitingParentId);
  47423. currentMesh._waitingParentId = null;
  47424. }
  47425. }
  47426. // freeze and compute world matrix application
  47427. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47428. currentMesh = scene.meshes[index];
  47429. if (currentMesh._waitingFreezeWorldMatrix) {
  47430. currentMesh.freezeWorldMatrix();
  47431. currentMesh._waitingFreezeWorldMatrix = null;
  47432. }
  47433. else {
  47434. currentMesh.computeWorldMatrix(true);
  47435. }
  47436. }
  47437. }
  47438. // Particles
  47439. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  47440. var parser = _abstractScene__WEBPACK_IMPORTED_MODULE_15__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_13__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  47441. if (parser) {
  47442. for (index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  47443. var parsedParticleSystem = parsedData.particleSystems[index];
  47444. if (hierarchyIds.indexOf(parsedParticleSystem.emitterId) !== -1) {
  47445. particleSystems.push(parser(parsedParticleSystem, scene, rootUrl));
  47446. }
  47447. }
  47448. }
  47449. }
  47450. return true;
  47451. }
  47452. catch (err) {
  47453. var msg = logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + log;
  47454. if (onError) {
  47455. onError(msg, err);
  47456. }
  47457. else {
  47458. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  47459. throw err;
  47460. }
  47461. }
  47462. finally {
  47463. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].NO_LOGGING) {
  47464. _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 : ""));
  47465. }
  47466. }
  47467. return false;
  47468. },
  47469. load: function (scene, data, rootUrl, onError) {
  47470. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  47471. // when SceneLoader.debugLogging = true (default), or exception encountered.
  47472. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  47473. // and avoid problems with multiple concurrent .babylon loads.
  47474. var log = "importScene has failed JSON parse";
  47475. try {
  47476. var parsedData = JSON.parse(data);
  47477. log = "";
  47478. // Scene
  47479. if (parsedData.useDelayedTextureLoading !== undefined && parsedData.useDelayedTextureLoading !== null) {
  47480. scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading && !_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].ForceFullSceneLoadingForIncremental;
  47481. }
  47482. if (parsedData.autoClear !== undefined && parsedData.autoClear !== null) {
  47483. scene.autoClear = parsedData.autoClear;
  47484. }
  47485. if (parsedData.clearColor !== undefined && parsedData.clearColor !== null) {
  47486. scene.clearColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(parsedData.clearColor);
  47487. }
  47488. if (parsedData.ambientColor !== undefined && parsedData.ambientColor !== null) {
  47489. scene.ambientColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.ambientColor);
  47490. }
  47491. if (parsedData.gravity !== undefined && parsedData.gravity !== null) {
  47492. scene.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.gravity);
  47493. }
  47494. // Fog
  47495. if (parsedData.fogMode && parsedData.fogMode !== 0) {
  47496. scene.fogMode = parsedData.fogMode;
  47497. scene.fogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.fogColor);
  47498. scene.fogStart = parsedData.fogStart;
  47499. scene.fogEnd = parsedData.fogEnd;
  47500. scene.fogDensity = parsedData.fogDensity;
  47501. log += "\tFog mode for scene: ";
  47502. switch (scene.fogMode) {
  47503. // getters not compiling, so using hardcoded
  47504. case 1:
  47505. log += "exp\n";
  47506. break;
  47507. case 2:
  47508. log += "exp2\n";
  47509. break;
  47510. case 3:
  47511. log += "linear\n";
  47512. break;
  47513. }
  47514. }
  47515. //Physics
  47516. if (parsedData.physicsEnabled) {
  47517. var physicsPlugin;
  47518. if (parsedData.physicsEngine === "cannon") {
  47519. physicsPlugin = new _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_20__["CannonJSPlugin"]();
  47520. }
  47521. else if (parsedData.physicsEngine === "oimo") {
  47522. physicsPlugin = new _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_21__["OimoJSPlugin"]();
  47523. }
  47524. log = "\tPhysics engine " + (parsedData.physicsEngine ? parsedData.physicsEngine : "oimo") + " enabled\n";
  47525. //else - default engine, which is currently oimo
  47526. var physicsGravity = parsedData.physicsGravity ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.physicsGravity) : null;
  47527. scene.enablePhysics(physicsGravity, physicsPlugin);
  47528. }
  47529. // Metadata
  47530. if (parsedData.metadata !== undefined && parsedData.metadata !== null) {
  47531. scene.metadata = parsedData.metadata;
  47532. }
  47533. //collisions, if defined. otherwise, default is true
  47534. if (parsedData.collisionsEnabled !== undefined && parsedData.collisionsEnabled !== null) {
  47535. scene.collisionsEnabled = parsedData.collisionsEnabled;
  47536. }
  47537. var container = loadAssetContainer(scene, data, rootUrl, onError, true);
  47538. if (!container) {
  47539. return false;
  47540. }
  47541. if (parsedData.autoAnimate) {
  47542. scene.beginAnimation(scene, parsedData.autoAnimateFrom, parsedData.autoAnimateTo, parsedData.autoAnimateLoop, parsedData.autoAnimateSpeed || 1.0);
  47543. }
  47544. if (parsedData.activeCameraID !== undefined && parsedData.activeCameraID !== null) {
  47545. scene.setActiveCameraByID(parsedData.activeCameraID);
  47546. }
  47547. // Environment texture
  47548. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  47549. // PBR needed for both HDR texture (gamma space) & a sky box
  47550. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  47551. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  47552. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  47553. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"](rootUrl + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  47554. if (parsedData.environmentTextureRotationY) {
  47555. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  47556. }
  47557. scene.environmentTexture = hdrTexture;
  47558. }
  47559. else {
  47560. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(rootUrl + parsedData.environmentTexture, scene);
  47561. if (parsedData.environmentTextureRotationY) {
  47562. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  47563. }
  47564. scene.environmentTexture = cubeTexture;
  47565. }
  47566. if (parsedData.createDefaultSkybox === true) {
  47567. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  47568. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  47569. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  47570. }
  47571. }
  47572. // Finish
  47573. return true;
  47574. }
  47575. catch (err) {
  47576. var msg = logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + log;
  47577. if (onError) {
  47578. onError(msg, err);
  47579. }
  47580. else {
  47581. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  47582. throw err;
  47583. }
  47584. }
  47585. finally {
  47586. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].NO_LOGGING) {
  47587. _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 : ""));
  47588. }
  47589. }
  47590. return false;
  47591. },
  47592. loadAssetContainer: function (scene, data, rootUrl, onError) {
  47593. var container = loadAssetContainer(scene, data, rootUrl, onError);
  47594. return container;
  47595. }
  47596. });
  47597. /***/ }),
  47598. /***/ "./Loading/Plugins/index.ts":
  47599. /*!**********************************!*\
  47600. !*** ./Loading/Plugins/index.ts ***!
  47601. \**********************************/
  47602. /*! exports provided: _BabylonLoaderRegistered */
  47603. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47604. "use strict";
  47605. __webpack_require__.r(__webpack_exports__);
  47606. /* harmony import */ var _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./babylonFileLoader */ "./Loading/Plugins/babylonFileLoader.ts");
  47607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  47608. /***/ }),
  47609. /***/ "./Loading/index.ts":
  47610. /*!**************************!*\
  47611. !*** ./Loading/index.ts ***!
  47612. \**************************/
  47613. /*! exports provided: DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, _BabylonLoaderRegistered */
  47614. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47615. "use strict";
  47616. __webpack_require__.r(__webpack_exports__);
  47617. /* harmony import */ var _loadingScreen__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./loadingScreen */ "./Loading/loadingScreen.ts");
  47618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _loadingScreen__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  47619. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Plugins/index */ "./Loading/Plugins/index.ts");
  47620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_1__["_BabylonLoaderRegistered"]; });
  47621. /* harmony import */ var _sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneLoader */ "./Loading/sceneLoader.ts");
  47622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoaderProgressEvent"]; });
  47623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"]; });
  47624. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  47625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__["SceneLoaderFlags"]; });
  47626. /***/ }),
  47627. /***/ "./Loading/loadingScreen.ts":
  47628. /*!**********************************!*\
  47629. !*** ./Loading/loadingScreen.ts ***!
  47630. \**********************************/
  47631. /*! exports provided: DefaultLoadingScreen */
  47632. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47633. "use strict";
  47634. __webpack_require__.r(__webpack_exports__);
  47635. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return DefaultLoadingScreen; });
  47636. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  47637. /**
  47638. * Class used for the default loading screen
  47639. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  47640. */
  47641. var DefaultLoadingScreen = /** @class */ (function () {
  47642. /**
  47643. * Creates a new default loading screen
  47644. * @param _renderingCanvas defines the canvas used to render the scene
  47645. * @param _loadingText defines the default text to display
  47646. * @param _loadingDivBackgroundColor defines the default background color
  47647. */
  47648. function DefaultLoadingScreen(_renderingCanvas, _loadingText, _loadingDivBackgroundColor) {
  47649. if (_loadingText === void 0) { _loadingText = ""; }
  47650. if (_loadingDivBackgroundColor === void 0) { _loadingDivBackgroundColor = "black"; }
  47651. var _this = this;
  47652. this._renderingCanvas = _renderingCanvas;
  47653. this._loadingText = _loadingText;
  47654. this._loadingDivBackgroundColor = _loadingDivBackgroundColor;
  47655. // Resize
  47656. this._resizeLoadingUI = function () {
  47657. var canvasRect = _this._renderingCanvas.getBoundingClientRect();
  47658. var canvasPositioning = window.getComputedStyle(_this._renderingCanvas).position;
  47659. if (!_this._loadingDiv) {
  47660. return;
  47661. }
  47662. _this._loadingDiv.style.position = (canvasPositioning === "fixed") ? "fixed" : "absolute";
  47663. _this._loadingDiv.style.left = canvasRect.left + "px";
  47664. _this._loadingDiv.style.top = canvasRect.top + "px";
  47665. _this._loadingDiv.style.width = canvasRect.width + "px";
  47666. _this._loadingDiv.style.height = canvasRect.height + "px";
  47667. };
  47668. }
  47669. /**
  47670. * Function called to display the loading screen
  47671. */
  47672. DefaultLoadingScreen.prototype.displayLoadingUI = function () {
  47673. if (this._loadingDiv) {
  47674. // Do not add a loading screen if there is already one
  47675. return;
  47676. }
  47677. this._loadingDiv = document.createElement("div");
  47678. this._loadingDiv.id = "babylonjsLoadingDiv";
  47679. this._loadingDiv.style.opacity = "0";
  47680. this._loadingDiv.style.transition = "opacity 1.5s ease";
  47681. this._loadingDiv.style.pointerEvents = "none";
  47682. // Loading text
  47683. this._loadingTextDiv = document.createElement("div");
  47684. this._loadingTextDiv.style.position = "absolute";
  47685. this._loadingTextDiv.style.left = "0";
  47686. this._loadingTextDiv.style.top = "50%";
  47687. this._loadingTextDiv.style.marginTop = "80px";
  47688. this._loadingTextDiv.style.width = "100%";
  47689. this._loadingTextDiv.style.height = "20px";
  47690. this._loadingTextDiv.style.fontFamily = "Arial";
  47691. this._loadingTextDiv.style.fontSize = "14px";
  47692. this._loadingTextDiv.style.color = "white";
  47693. this._loadingTextDiv.style.textAlign = "center";
  47694. this._loadingTextDiv.innerHTML = "Loading";
  47695. this._loadingDiv.appendChild(this._loadingTextDiv);
  47696. //set the predefined text
  47697. this._loadingTextDiv.innerHTML = this._loadingText;
  47698. // Generating keyframes
  47699. var style = document.createElement('style');
  47700. style.type = 'text/css';
  47701. 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 }";
  47702. style.innerHTML = keyFrames;
  47703. document.getElementsByTagName('head')[0].appendChild(style);
  47704. // Loading img
  47705. var imgBack = new Image();
  47706. 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";
  47707. imgBack.style.position = "absolute";
  47708. imgBack.style.left = "50%";
  47709. imgBack.style.top = "50%";
  47710. imgBack.style.marginLeft = "-60px";
  47711. imgBack.style.marginTop = "-60px";
  47712. imgBack.style.animation = "spin1 2s infinite ease-in-out";
  47713. imgBack.style.webkitAnimation = "spin1 2s infinite ease-in-out";
  47714. imgBack.style.transformOrigin = "50% 50%";
  47715. imgBack.style.webkitTransformOrigin = "50% 50%";
  47716. this._loadingDiv.appendChild(imgBack);
  47717. this._resizeLoadingUI();
  47718. window.addEventListener("resize", this._resizeLoadingUI);
  47719. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  47720. document.body.appendChild(this._loadingDiv);
  47721. this._loadingDiv.style.opacity = "1";
  47722. };
  47723. /**
  47724. * Function called to hide the loading screen
  47725. */
  47726. DefaultLoadingScreen.prototype.hideLoadingUI = function () {
  47727. var _this = this;
  47728. if (!this._loadingDiv) {
  47729. return;
  47730. }
  47731. var onTransitionEnd = function () {
  47732. if (!_this._loadingDiv) {
  47733. return;
  47734. }
  47735. if (_this._loadingDiv.parentElement) {
  47736. _this._loadingDiv.parentElement.removeChild(_this._loadingDiv);
  47737. }
  47738. window.removeEventListener("resize", _this._resizeLoadingUI);
  47739. _this._loadingDiv = null;
  47740. };
  47741. this._loadingDiv.style.opacity = "0";
  47742. this._loadingDiv.addEventListener("transitionend", onTransitionEnd);
  47743. };
  47744. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIText", {
  47745. get: function () {
  47746. return this._loadingText;
  47747. },
  47748. /**
  47749. * Gets or sets the text to display while loading
  47750. */
  47751. set: function (text) {
  47752. this._loadingText = text;
  47753. if (this._loadingTextDiv) {
  47754. this._loadingTextDiv.innerHTML = this._loadingText;
  47755. }
  47756. },
  47757. enumerable: true,
  47758. configurable: true
  47759. });
  47760. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIBackgroundColor", {
  47761. /**
  47762. * Gets or sets the color to use for the background
  47763. */
  47764. get: function () {
  47765. return this._loadingDivBackgroundColor;
  47766. },
  47767. set: function (color) {
  47768. this._loadingDivBackgroundColor = color;
  47769. if (!this._loadingDiv) {
  47770. return;
  47771. }
  47772. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  47773. },
  47774. enumerable: true,
  47775. configurable: true
  47776. });
  47777. return DefaultLoadingScreen;
  47778. }());
  47779. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].DefaultLoadingScreenFactory = function (canvas) { return new DefaultLoadingScreen(canvas); };
  47780. /***/ }),
  47781. /***/ "./Loading/sceneLoader.ts":
  47782. /*!********************************!*\
  47783. !*** ./Loading/sceneLoader.ts ***!
  47784. \********************************/
  47785. /*! exports provided: SceneLoaderProgressEvent, SceneLoader */
  47786. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47787. "use strict";
  47788. __webpack_require__.r(__webpack_exports__);
  47789. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return SceneLoaderProgressEvent; });
  47790. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return SceneLoader; });
  47791. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  47792. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  47793. /* harmony import */ var _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/filesInputStore */ "./Misc/filesInputStore.ts");
  47794. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  47795. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  47796. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  47797. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  47798. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  47799. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  47800. /**
  47801. * Class used to represent data loading progression
  47802. */
  47803. var SceneLoaderProgressEvent = /** @class */ (function () {
  47804. /**
  47805. * Create a new progress event
  47806. * @param lengthComputable defines if data length to load can be evaluated
  47807. * @param loaded defines the loaded data length
  47808. * @param total defines the data length to load
  47809. */
  47810. function SceneLoaderProgressEvent(
  47811. /** defines if data length to load can be evaluated */
  47812. lengthComputable,
  47813. /** defines the loaded data length */
  47814. loaded,
  47815. /** defines the data length to load */
  47816. total) {
  47817. this.lengthComputable = lengthComputable;
  47818. this.loaded = loaded;
  47819. this.total = total;
  47820. }
  47821. /**
  47822. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  47823. * @param event defines the source event
  47824. * @returns a new SceneLoaderProgressEvent
  47825. */
  47826. SceneLoaderProgressEvent.FromProgressEvent = function (event) {
  47827. return new SceneLoaderProgressEvent(event.lengthComputable, event.loaded, event.total);
  47828. };
  47829. return SceneLoaderProgressEvent;
  47830. }());
  47831. /**
  47832. * Class used to load scene from various file formats using registered plugins
  47833. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  47834. */
  47835. var SceneLoader = /** @class */ (function () {
  47836. function SceneLoader() {
  47837. }
  47838. Object.defineProperty(SceneLoader, "ForceFullSceneLoadingForIncremental", {
  47839. /**
  47840. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47841. */
  47842. get: function () {
  47843. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental;
  47844. },
  47845. set: function (value) {
  47846. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental = value;
  47847. },
  47848. enumerable: true,
  47849. configurable: true
  47850. });
  47851. Object.defineProperty(SceneLoader, "ShowLoadingScreen", {
  47852. /**
  47853. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47854. */
  47855. get: function () {
  47856. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen;
  47857. },
  47858. set: function (value) {
  47859. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen = value;
  47860. },
  47861. enumerable: true,
  47862. configurable: true
  47863. });
  47864. Object.defineProperty(SceneLoader, "loggingLevel", {
  47865. /**
  47866. * Defines the current logging level (while loading the scene)
  47867. * @ignorenaming
  47868. */
  47869. get: function () {
  47870. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel;
  47871. },
  47872. set: function (value) {
  47873. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel = value;
  47874. },
  47875. enumerable: true,
  47876. configurable: true
  47877. });
  47878. Object.defineProperty(SceneLoader, "CleanBoneMatrixWeights", {
  47879. /**
  47880. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47881. */
  47882. get: function () {
  47883. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights;
  47884. },
  47885. set: function (value) {
  47886. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights = value;
  47887. },
  47888. enumerable: true,
  47889. configurable: true
  47890. });
  47891. SceneLoader._getDefaultPlugin = function () {
  47892. return SceneLoader._registeredPlugins[".babylon"];
  47893. };
  47894. SceneLoader._getPluginForExtension = function (extension) {
  47895. var registeredPlugin = SceneLoader._registeredPlugins[extension];
  47896. if (registeredPlugin) {
  47897. return registeredPlugin;
  47898. }
  47899. _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");
  47900. return SceneLoader._getDefaultPlugin();
  47901. };
  47902. SceneLoader._getPluginForDirectLoad = function (data) {
  47903. for (var extension in SceneLoader._registeredPlugins) {
  47904. var plugin = SceneLoader._registeredPlugins[extension].plugin;
  47905. if (plugin.canDirectLoad && plugin.canDirectLoad(data)) {
  47906. return SceneLoader._registeredPlugins[extension];
  47907. }
  47908. }
  47909. return SceneLoader._getDefaultPlugin();
  47910. };
  47911. SceneLoader._getPluginForFilename = function (sceneFilename) {
  47912. var queryStringPosition = sceneFilename.indexOf("?");
  47913. if (queryStringPosition !== -1) {
  47914. sceneFilename = sceneFilename.substring(0, queryStringPosition);
  47915. }
  47916. var dotPosition = sceneFilename.lastIndexOf(".");
  47917. var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
  47918. return SceneLoader._getPluginForExtension(extension);
  47919. };
  47920. // use babylon file loader directly if sceneFilename is prefixed with "data:"
  47921. SceneLoader._getDirectLoad = function (sceneFilename) {
  47922. if (sceneFilename.substr(0, 5) === "data:") {
  47923. return sceneFilename.substr(5);
  47924. }
  47925. return null;
  47926. };
  47927. SceneLoader._loadData = function (fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
  47928. var directLoad = SceneLoader._getDirectLoad(fileInfo.name);
  47929. var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(fileInfo.name) : SceneLoader._getPluginForFilename(fileInfo.name));
  47930. var plugin;
  47931. if (registeredPlugin.plugin.createPlugin) {
  47932. plugin = registeredPlugin.plugin.createPlugin();
  47933. }
  47934. else {
  47935. plugin = registeredPlugin.plugin;
  47936. }
  47937. var useArrayBuffer = registeredPlugin.isBinary;
  47938. var offlineProvider;
  47939. SceneLoader.OnPluginActivatedObservable.notifyObservers(plugin);
  47940. var dataCallback = function (data, responseURL) {
  47941. if (scene.isDisposed) {
  47942. onError("Scene has been disposed");
  47943. return;
  47944. }
  47945. scene.offlineProvider = offlineProvider;
  47946. onSuccess(plugin, data, responseURL);
  47947. };
  47948. var request = null;
  47949. var pluginDisposed = false;
  47950. var onDisposeObservable = plugin.onDisposeObservable;
  47951. if (onDisposeObservable) {
  47952. onDisposeObservable.add(function () {
  47953. pluginDisposed = true;
  47954. if (request) {
  47955. request.abort();
  47956. request = null;
  47957. }
  47958. onDispose();
  47959. });
  47960. }
  47961. var manifestChecked = function () {
  47962. if (pluginDisposed) {
  47963. return;
  47964. }
  47965. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(fileInfo.url, dataCallback, onProgress ? function (event) {
  47966. onProgress(SceneLoaderProgressEvent.FromProgressEvent(event));
  47967. } : undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  47968. onError("Failed to load scene." + (exception ? " " + exception.message : ""), exception);
  47969. });
  47970. };
  47971. if (directLoad) {
  47972. dataCallback(directLoad);
  47973. return plugin;
  47974. }
  47975. var file = fileInfo.file || _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad[fileInfo.name.toLowerCase()];
  47976. if (fileInfo.rootUrl.indexOf("file:") === -1 || (fileInfo.rootUrl.indexOf("file:") !== -1 && !file)) {
  47977. var engine = scene.getEngine();
  47978. var canUseOfflineSupport = engine.enableOfflineSupport;
  47979. if (canUseOfflineSupport) {
  47980. // Also check for exceptions
  47981. var exceptionFound = false;
  47982. for (var _i = 0, _a = scene.disableOfflineSupportExceptionRules; _i < _a.length; _i++) {
  47983. var regex = _a[_i];
  47984. if (regex.test(fileInfo.url)) {
  47985. exceptionFound = true;
  47986. break;
  47987. }
  47988. }
  47989. canUseOfflineSupport = !exceptionFound;
  47990. }
  47991. if (canUseOfflineSupport && _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory) {
  47992. // Checking if a manifest file has been set for this scene and if offline mode has been requested
  47993. offlineProvider = _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory(fileInfo.url, manifestChecked, engine.disableManifestCheck);
  47994. }
  47995. else {
  47996. manifestChecked();
  47997. }
  47998. }
  47999. // Loading file from disk via input file or drag'n'drop
  48000. else {
  48001. if (file) {
  48002. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ReadFile(file, dataCallback, onProgress, useArrayBuffer);
  48003. }
  48004. else {
  48005. onError("Unable to find file named " + fileInfo.name);
  48006. }
  48007. }
  48008. return plugin;
  48009. };
  48010. SceneLoader._getFileInfo = function (rootUrl, sceneFilename) {
  48011. var url;
  48012. var name;
  48013. var file = null;
  48014. if (!sceneFilename) {
  48015. url = rootUrl;
  48016. name = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(rootUrl);
  48017. rootUrl = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFolderPath(rootUrl);
  48018. }
  48019. else if (sceneFilename.lastModified) {
  48020. var sceneFile = sceneFilename;
  48021. url = rootUrl + sceneFile.name;
  48022. name = sceneFile.name;
  48023. file = sceneFile;
  48024. }
  48025. else {
  48026. var filename = sceneFilename;
  48027. if (filename.substr(0, 1) === "/") {
  48028. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Wrong sceneFilename parameter");
  48029. return null;
  48030. }
  48031. url = rootUrl + filename;
  48032. name = filename;
  48033. }
  48034. return {
  48035. url: url,
  48036. rootUrl: rootUrl,
  48037. name: name,
  48038. file: file
  48039. };
  48040. };
  48041. // Public functions
  48042. /**
  48043. * Gets a plugin that can load the given extension
  48044. * @param extension defines the extension to load
  48045. * @returns a plugin or null if none works
  48046. */
  48047. SceneLoader.GetPluginForExtension = function (extension) {
  48048. return SceneLoader._getPluginForExtension(extension).plugin;
  48049. };
  48050. /**
  48051. * Gets a boolean indicating that the given extension can be loaded
  48052. * @param extension defines the extension to load
  48053. * @returns true if the extension is supported
  48054. */
  48055. SceneLoader.IsPluginForExtensionAvailable = function (extension) {
  48056. return !!SceneLoader._registeredPlugins[extension];
  48057. };
  48058. /**
  48059. * Adds a new plugin to the list of registered plugins
  48060. * @param plugin defines the plugin to add
  48061. */
  48062. SceneLoader.RegisterPlugin = function (plugin) {
  48063. if (typeof plugin.extensions === "string") {
  48064. var extension = plugin.extensions;
  48065. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  48066. plugin: plugin,
  48067. isBinary: false
  48068. };
  48069. }
  48070. else {
  48071. var extensions = plugin.extensions;
  48072. Object.keys(extensions).forEach(function (extension) {
  48073. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  48074. plugin: plugin,
  48075. isBinary: extensions[extension].isBinary
  48076. };
  48077. });
  48078. }
  48079. };
  48080. /**
  48081. * Import meshes into a scene
  48082. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48083. * @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)
  48084. * @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)
  48085. * @param scene the instance of BABYLON.Scene to append to
  48086. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48087. * @param onProgress a callback with a progress event for each file being loaded
  48088. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48089. * @param pluginExtension the extension used to determine the plugin
  48090. * @returns The loaded plugin
  48091. */
  48092. SceneLoader.ImportMesh = function (meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  48093. if (sceneFilename === void 0) { sceneFilename = ""; }
  48094. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48095. if (onSuccess === void 0) { onSuccess = null; }
  48096. if (onProgress === void 0) { onProgress = null; }
  48097. if (onError === void 0) { onError = null; }
  48098. if (pluginExtension === void 0) { pluginExtension = null; }
  48099. if (!scene) {
  48100. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to import mesh to");
  48101. return null;
  48102. }
  48103. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  48104. if (!fileInfo) {
  48105. return null;
  48106. }
  48107. var loadingToken = {};
  48108. scene._addPendingData(loadingToken);
  48109. var disposeHandler = function () {
  48110. scene._removePendingData(loadingToken);
  48111. };
  48112. var errorHandler = function (message, exception) {
  48113. var errorMessage = "Unable to import meshes from " + fileInfo.url + ": " + message;
  48114. if (onError) {
  48115. onError(scene, errorMessage, exception);
  48116. }
  48117. else {
  48118. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  48119. // should the exception be thrown?
  48120. }
  48121. disposeHandler();
  48122. };
  48123. var progressHandler = onProgress ? function (event) {
  48124. try {
  48125. onProgress(event);
  48126. }
  48127. catch (e) {
  48128. errorHandler("Error in onProgress callback", e);
  48129. }
  48130. } : undefined;
  48131. var successHandler = function (meshes, particleSystems, skeletons, animationGroups) {
  48132. scene.importedMeshesFiles.push(fileInfo.url);
  48133. if (onSuccess) {
  48134. try {
  48135. onSuccess(meshes, particleSystems, skeletons, animationGroups);
  48136. }
  48137. catch (e) {
  48138. errorHandler("Error in onSuccess callback", e);
  48139. }
  48140. }
  48141. scene._removePendingData(loadingToken);
  48142. };
  48143. return SceneLoader._loadData(fileInfo, scene, function (plugin, data, responseURL) {
  48144. if (plugin.rewriteRootURL) {
  48145. fileInfo.rootUrl = plugin.rewriteRootURL(fileInfo.rootUrl, responseURL);
  48146. }
  48147. if (plugin.importMesh) {
  48148. var syncedPlugin = plugin;
  48149. var meshes = new Array();
  48150. var particleSystems = new Array();
  48151. var skeletons = new Array();
  48152. if (!syncedPlugin.importMesh(meshNames, scene, data, fileInfo.rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
  48153. return;
  48154. }
  48155. scene.loadingPluginName = plugin.name;
  48156. successHandler(meshes, particleSystems, skeletons, []);
  48157. }
  48158. else {
  48159. var asyncedPlugin = plugin;
  48160. asyncedPlugin.importMeshAsync(meshNames, scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (result) {
  48161. scene.loadingPluginName = plugin.name;
  48162. successHandler(result.meshes, result.particleSystems, result.skeletons, result.animationGroups);
  48163. }).catch(function (error) {
  48164. errorHandler(error.message, error);
  48165. });
  48166. }
  48167. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  48168. };
  48169. /**
  48170. * Import meshes into a scene
  48171. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48172. * @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)
  48173. * @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)
  48174. * @param scene the instance of BABYLON.Scene to append to
  48175. * @param onProgress a callback with a progress event for each file being loaded
  48176. * @param pluginExtension the extension used to determine the plugin
  48177. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48178. */
  48179. SceneLoader.ImportMeshAsync = function (meshNames, rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  48180. if (sceneFilename === void 0) { sceneFilename = ""; }
  48181. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48182. if (onProgress === void 0) { onProgress = null; }
  48183. if (pluginExtension === void 0) { pluginExtension = null; }
  48184. return new Promise(function (resolve, reject) {
  48185. SceneLoader.ImportMesh(meshNames, rootUrl, sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  48186. resolve({
  48187. meshes: meshes,
  48188. particleSystems: particleSystems,
  48189. skeletons: skeletons,
  48190. animationGroups: animationGroups
  48191. });
  48192. }, onProgress, function (scene, message, exception) {
  48193. reject(exception || new Error(message));
  48194. }, pluginExtension);
  48195. });
  48196. };
  48197. /**
  48198. * Load a scene
  48199. * @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)
  48200. * @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)
  48201. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48202. * @param onSuccess a callback with the scene when import succeeds
  48203. * @param onProgress a callback with a progress event for each file being loaded
  48204. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48205. * @param pluginExtension the extension used to determine the plugin
  48206. * @returns The loaded plugin
  48207. */
  48208. SceneLoader.Load = function (rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension) {
  48209. if (sceneFilename === void 0) { sceneFilename = ""; }
  48210. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  48211. if (onSuccess === void 0) { onSuccess = null; }
  48212. if (onProgress === void 0) { onProgress = null; }
  48213. if (onError === void 0) { onError = null; }
  48214. if (pluginExtension === void 0) { pluginExtension = null; }
  48215. if (!engine) {
  48216. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("No engine available");
  48217. return null;
  48218. }
  48219. return SceneLoader.Append(rootUrl, sceneFilename, new _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"](engine), onSuccess, onProgress, onError, pluginExtension);
  48220. };
  48221. /**
  48222. * Load a scene
  48223. * @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)
  48224. * @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)
  48225. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48226. * @param onProgress a callback with a progress event for each file being loaded
  48227. * @param pluginExtension the extension used to determine the plugin
  48228. * @returns The loaded scene
  48229. */
  48230. SceneLoader.LoadAsync = function (rootUrl, sceneFilename, engine, onProgress, pluginExtension) {
  48231. if (sceneFilename === void 0) { sceneFilename = ""; }
  48232. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  48233. if (onProgress === void 0) { onProgress = null; }
  48234. if (pluginExtension === void 0) { pluginExtension = null; }
  48235. return new Promise(function (resolve, reject) {
  48236. SceneLoader.Load(rootUrl, sceneFilename, engine, function (scene) {
  48237. resolve(scene);
  48238. }, onProgress, function (scene, message, exception) {
  48239. reject(exception || new Error(message));
  48240. }, pluginExtension);
  48241. });
  48242. };
  48243. /**
  48244. * Append a scene
  48245. * @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)
  48246. * @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)
  48247. * @param scene is the instance of BABYLON.Scene to append to
  48248. * @param onSuccess a callback with the scene when import succeeds
  48249. * @param onProgress a callback with a progress event for each file being loaded
  48250. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48251. * @param pluginExtension the extension used to determine the plugin
  48252. * @returns The loaded plugin
  48253. */
  48254. SceneLoader.Append = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  48255. if (sceneFilename === void 0) { sceneFilename = ""; }
  48256. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48257. if (onSuccess === void 0) { onSuccess = null; }
  48258. if (onProgress === void 0) { onProgress = null; }
  48259. if (onError === void 0) { onError = null; }
  48260. if (pluginExtension === void 0) { pluginExtension = null; }
  48261. if (!scene) {
  48262. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to append to");
  48263. return null;
  48264. }
  48265. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  48266. if (!fileInfo) {
  48267. return null;
  48268. }
  48269. if (SceneLoader.ShowLoadingScreen) {
  48270. scene.getEngine().displayLoadingUI();
  48271. }
  48272. var loadingToken = {};
  48273. scene._addPendingData(loadingToken);
  48274. var disposeHandler = function () {
  48275. scene._removePendingData(loadingToken);
  48276. scene.getEngine().hideLoadingUI();
  48277. };
  48278. var errorHandler = function (message, exception) {
  48279. var errorMessage = "Unable to load from " + fileInfo.url + (message ? ": " + message : "");
  48280. if (onError) {
  48281. onError(scene, errorMessage, exception);
  48282. }
  48283. else {
  48284. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  48285. // should the exception be thrown?
  48286. }
  48287. disposeHandler();
  48288. };
  48289. var progressHandler = onProgress ? function (event) {
  48290. try {
  48291. onProgress(event);
  48292. }
  48293. catch (e) {
  48294. errorHandler("Error in onProgress callback", e);
  48295. }
  48296. } : undefined;
  48297. var successHandler = function () {
  48298. if (onSuccess) {
  48299. try {
  48300. onSuccess(scene);
  48301. }
  48302. catch (e) {
  48303. errorHandler("Error in onSuccess callback", e);
  48304. }
  48305. }
  48306. scene._removePendingData(loadingToken);
  48307. };
  48308. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  48309. if (plugin.load) {
  48310. var syncedPlugin = plugin;
  48311. if (!syncedPlugin.load(scene, data, fileInfo.rootUrl, errorHandler)) {
  48312. return;
  48313. }
  48314. scene.loadingPluginName = plugin.name;
  48315. successHandler();
  48316. }
  48317. else {
  48318. var asyncedPlugin = plugin;
  48319. asyncedPlugin.loadAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function () {
  48320. scene.loadingPluginName = plugin.name;
  48321. successHandler();
  48322. }).catch(function (error) {
  48323. errorHandler(error.message, error);
  48324. });
  48325. }
  48326. if (SceneLoader.ShowLoadingScreen) {
  48327. scene.executeWhenReady(function () {
  48328. scene.getEngine().hideLoadingUI();
  48329. });
  48330. }
  48331. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  48332. };
  48333. /**
  48334. * Append a scene
  48335. * @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)
  48336. * @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)
  48337. * @param scene is the instance of BABYLON.Scene to append to
  48338. * @param onProgress a callback with a progress event for each file being loaded
  48339. * @param pluginExtension the extension used to determine the plugin
  48340. * @returns The given scene
  48341. */
  48342. SceneLoader.AppendAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  48343. if (sceneFilename === void 0) { sceneFilename = ""; }
  48344. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48345. if (onProgress === void 0) { onProgress = null; }
  48346. if (pluginExtension === void 0) { pluginExtension = null; }
  48347. return new Promise(function (resolve, reject) {
  48348. SceneLoader.Append(rootUrl, sceneFilename, scene, function (scene) {
  48349. resolve(scene);
  48350. }, onProgress, function (scene, message, exception) {
  48351. reject(exception || new Error(message));
  48352. }, pluginExtension);
  48353. });
  48354. };
  48355. /**
  48356. * Load a scene into an asset container
  48357. * @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)
  48358. * @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)
  48359. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48360. * @param onSuccess a callback with the scene when import succeeds
  48361. * @param onProgress a callback with a progress event for each file being loaded
  48362. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48363. * @param pluginExtension the extension used to determine the plugin
  48364. * @returns The loaded plugin
  48365. */
  48366. SceneLoader.LoadAssetContainer = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  48367. if (sceneFilename === void 0) { sceneFilename = ""; }
  48368. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48369. if (onSuccess === void 0) { onSuccess = null; }
  48370. if (onProgress === void 0) { onProgress = null; }
  48371. if (onError === void 0) { onError = null; }
  48372. if (pluginExtension === void 0) { pluginExtension = null; }
  48373. if (!scene) {
  48374. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to load asset container to");
  48375. return null;
  48376. }
  48377. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  48378. if (!fileInfo) {
  48379. return null;
  48380. }
  48381. var loadingToken = {};
  48382. scene._addPendingData(loadingToken);
  48383. var disposeHandler = function () {
  48384. scene._removePendingData(loadingToken);
  48385. };
  48386. var errorHandler = function (message, exception) {
  48387. var errorMessage = "Unable to load assets from " + fileInfo.url + (message ? ": " + message : "");
  48388. if (onError) {
  48389. onError(scene, errorMessage, exception);
  48390. }
  48391. else {
  48392. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  48393. // should the exception be thrown?
  48394. }
  48395. disposeHandler();
  48396. };
  48397. var progressHandler = onProgress ? function (event) {
  48398. try {
  48399. onProgress(event);
  48400. }
  48401. catch (e) {
  48402. errorHandler("Error in onProgress callback", e);
  48403. }
  48404. } : undefined;
  48405. var successHandler = function (assets) {
  48406. if (onSuccess) {
  48407. try {
  48408. onSuccess(assets);
  48409. }
  48410. catch (e) {
  48411. errorHandler("Error in onSuccess callback", e);
  48412. }
  48413. }
  48414. scene._removePendingData(loadingToken);
  48415. };
  48416. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  48417. if (plugin.loadAssetContainer) {
  48418. var syncedPlugin = plugin;
  48419. var assetContainer = syncedPlugin.loadAssetContainer(scene, data, fileInfo.rootUrl, errorHandler);
  48420. if (!assetContainer) {
  48421. return;
  48422. }
  48423. scene.loadingPluginName = plugin.name;
  48424. successHandler(assetContainer);
  48425. }
  48426. else if (plugin.loadAssetContainerAsync) {
  48427. var asyncedPlugin = plugin;
  48428. asyncedPlugin.loadAssetContainerAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (assetContainer) {
  48429. scene.loadingPluginName = plugin.name;
  48430. successHandler(assetContainer);
  48431. }).catch(function (error) {
  48432. errorHandler(error.message, error);
  48433. });
  48434. }
  48435. else {
  48436. errorHandler("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");
  48437. }
  48438. if (SceneLoader.ShowLoadingScreen) {
  48439. scene.executeWhenReady(function () {
  48440. scene.getEngine().hideLoadingUI();
  48441. });
  48442. }
  48443. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  48444. };
  48445. /**
  48446. * Load a scene into an asset container
  48447. * @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)
  48448. * @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)
  48449. * @param scene is the instance of Scene to append to
  48450. * @param onProgress a callback with a progress event for each file being loaded
  48451. * @param pluginExtension the extension used to determine the plugin
  48452. * @returns The loaded asset container
  48453. */
  48454. SceneLoader.LoadAssetContainerAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  48455. if (sceneFilename === void 0) { sceneFilename = ""; }
  48456. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48457. if (onProgress === void 0) { onProgress = null; }
  48458. if (pluginExtension === void 0) { pluginExtension = null; }
  48459. return new Promise(function (resolve, reject) {
  48460. SceneLoader.LoadAssetContainer(rootUrl, sceneFilename, scene, function (assetContainer) {
  48461. resolve(assetContainer);
  48462. }, onProgress, function (scene, message, exception) {
  48463. reject(exception || new Error(message));
  48464. }, pluginExtension);
  48465. });
  48466. };
  48467. /**
  48468. * No logging while loading
  48469. */
  48470. SceneLoader.NO_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_NO_LOGGING;
  48471. /**
  48472. * Minimal logging while loading
  48473. */
  48474. SceneLoader.MINIMAL_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_MINIMAL_LOGGING;
  48475. /**
  48476. * Summary logging while loading
  48477. */
  48478. SceneLoader.SUMMARY_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_SUMMARY_LOGGING;
  48479. /**
  48480. * Detailled logging while loading
  48481. */
  48482. SceneLoader.DETAILED_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_DETAILED_LOGGING;
  48483. // Members
  48484. /**
  48485. * Event raised when a plugin is used to load a scene
  48486. */
  48487. SceneLoader.OnPluginActivatedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  48488. SceneLoader._registeredPlugins = {};
  48489. return SceneLoader;
  48490. }());
  48491. /***/ }),
  48492. /***/ "./Loading/sceneLoaderFlags.ts":
  48493. /*!*************************************!*\
  48494. !*** ./Loading/sceneLoaderFlags.ts ***!
  48495. \*************************************/
  48496. /*! exports provided: SceneLoaderFlags */
  48497. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48498. "use strict";
  48499. __webpack_require__.r(__webpack_exports__);
  48500. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return SceneLoaderFlags; });
  48501. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  48502. /**
  48503. * Class used to represent data loading progression
  48504. */
  48505. var SceneLoaderFlags = /** @class */ (function () {
  48506. function SceneLoaderFlags() {
  48507. }
  48508. Object.defineProperty(SceneLoaderFlags, "ForceFullSceneLoadingForIncremental", {
  48509. /**
  48510. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48511. */
  48512. get: function () {
  48513. return SceneLoaderFlags._ForceFullSceneLoadingForIncremental;
  48514. },
  48515. set: function (value) {
  48516. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = value;
  48517. },
  48518. enumerable: true,
  48519. configurable: true
  48520. });
  48521. Object.defineProperty(SceneLoaderFlags, "ShowLoadingScreen", {
  48522. /**
  48523. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48524. */
  48525. get: function () {
  48526. return SceneLoaderFlags._ShowLoadingScreen;
  48527. },
  48528. set: function (value) {
  48529. SceneLoaderFlags._ShowLoadingScreen = value;
  48530. },
  48531. enumerable: true,
  48532. configurable: true
  48533. });
  48534. Object.defineProperty(SceneLoaderFlags, "loggingLevel", {
  48535. /**
  48536. * Defines the current logging level (while loading the scene)
  48537. * @ignorenaming
  48538. */
  48539. get: function () {
  48540. return SceneLoaderFlags._loggingLevel;
  48541. },
  48542. set: function (value) {
  48543. SceneLoaderFlags._loggingLevel = value;
  48544. },
  48545. enumerable: true,
  48546. configurable: true
  48547. });
  48548. Object.defineProperty(SceneLoaderFlags, "CleanBoneMatrixWeights", {
  48549. /**
  48550. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48551. */
  48552. get: function () {
  48553. return SceneLoaderFlags._CleanBoneMatrixWeights;
  48554. },
  48555. set: function (value) {
  48556. SceneLoaderFlags._CleanBoneMatrixWeights = value;
  48557. },
  48558. enumerable: true,
  48559. configurable: true
  48560. });
  48561. // Flags
  48562. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = false;
  48563. SceneLoaderFlags._ShowLoadingScreen = true;
  48564. SceneLoaderFlags._CleanBoneMatrixWeights = false;
  48565. SceneLoaderFlags._loggingLevel = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].SCENELOADER_NO_LOGGING;
  48566. return SceneLoaderFlags;
  48567. }());
  48568. /***/ }),
  48569. /***/ "./Materials/Background/backgroundMaterial.ts":
  48570. /*!****************************************************!*\
  48571. !*** ./Materials/Background/backgroundMaterial.ts ***!
  48572. \****************************************************/
  48573. /*! exports provided: BackgroundMaterial */
  48574. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48575. "use strict";
  48576. __webpack_require__.r(__webpack_exports__);
  48577. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return BackgroundMaterial; });
  48578. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  48579. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  48580. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  48581. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  48582. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  48583. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  48584. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  48585. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  48586. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  48587. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  48588. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  48589. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  48590. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  48591. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  48592. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  48593. /* harmony import */ var _Shaders_background_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Shaders/background.fragment */ "./Shaders/background.fragment.ts");
  48594. /* harmony import */ var _Shaders_background_vertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/background.vertex */ "./Shaders/background.vertex.ts");
  48595. /**
  48596. * Background material defines definition.
  48597. * @hidden Mainly internal Use
  48598. */
  48599. var BackgroundMaterialDefines = /** @class */ (function (_super) {
  48600. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterialDefines, _super);
  48601. /**
  48602. * Constructor of the defines.
  48603. */
  48604. function BackgroundMaterialDefines() {
  48605. var _this = _super.call(this) || this;
  48606. /**
  48607. * True if the diffuse texture is in use.
  48608. */
  48609. _this.DIFFUSE = false;
  48610. /**
  48611. * The direct UV channel to use.
  48612. */
  48613. _this.DIFFUSEDIRECTUV = 0;
  48614. /**
  48615. * True if the diffuse texture is in gamma space.
  48616. */
  48617. _this.GAMMADIFFUSE = false;
  48618. /**
  48619. * True if the diffuse texture has opacity in the alpha channel.
  48620. */
  48621. _this.DIFFUSEHASALPHA = false;
  48622. /**
  48623. * True if you want the material to fade to transparent at grazing angle.
  48624. */
  48625. _this.OPACITYFRESNEL = false;
  48626. /**
  48627. * True if an extra blur needs to be added in the reflection.
  48628. */
  48629. _this.REFLECTIONBLUR = false;
  48630. /**
  48631. * True if you want the material to fade to reflection at grazing angle.
  48632. */
  48633. _this.REFLECTIONFRESNEL = false;
  48634. /**
  48635. * True if you want the material to falloff as far as you move away from the scene center.
  48636. */
  48637. _this.REFLECTIONFALLOFF = false;
  48638. /**
  48639. * False if the current Webgl implementation does not support the texture lod extension.
  48640. */
  48641. _this.TEXTURELODSUPPORT = false;
  48642. /**
  48643. * True to ensure the data are premultiplied.
  48644. */
  48645. _this.PREMULTIPLYALPHA = false;
  48646. /**
  48647. * True if the texture contains cooked RGB values and not gray scaled multipliers.
  48648. */
  48649. _this.USERGBCOLOR = false;
  48650. /**
  48651. * True if highlight and shadow levels have been specified. It can help ensuring the main perceived color
  48652. * stays aligned with the desired configuration.
  48653. */
  48654. _this.USEHIGHLIGHTANDSHADOWCOLORS = false;
  48655. /**
  48656. * True to add noise in order to reduce the banding effect.
  48657. */
  48658. _this.NOISE = false;
  48659. /**
  48660. * is the reflection texture in BGR color scheme?
  48661. * Mainly used to solve a bug in ios10 video tag
  48662. */
  48663. _this.REFLECTIONBGR = false;
  48664. _this.IMAGEPROCESSING = false;
  48665. _this.VIGNETTE = false;
  48666. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  48667. _this.VIGNETTEBLENDMODEOPAQUE = false;
  48668. _this.TONEMAPPING = false;
  48669. _this.TONEMAPPING_ACES = false;
  48670. _this.CONTRAST = false;
  48671. _this.COLORCURVES = false;
  48672. _this.COLORGRADING = false;
  48673. _this.COLORGRADING3D = false;
  48674. _this.SAMPLER3DGREENDEPTH = false;
  48675. _this.SAMPLER3DBGRMAP = false;
  48676. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  48677. _this.EXPOSURE = false;
  48678. // Reflection.
  48679. _this.REFLECTION = false;
  48680. _this.REFLECTIONMAP_3D = false;
  48681. _this.REFLECTIONMAP_SPHERICAL = false;
  48682. _this.REFLECTIONMAP_PLANAR = false;
  48683. _this.REFLECTIONMAP_CUBIC = false;
  48684. _this.REFLECTIONMAP_PROJECTION = false;
  48685. _this.REFLECTIONMAP_SKYBOX = false;
  48686. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  48687. _this.REFLECTIONMAP_EXPLICIT = false;
  48688. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  48689. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  48690. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  48691. _this.INVERTCUBICMAP = false;
  48692. _this.REFLECTIONMAP_OPPOSITEZ = false;
  48693. _this.LODINREFLECTIONALPHA = false;
  48694. _this.GAMMAREFLECTION = false;
  48695. _this.RGBDREFLECTION = false;
  48696. _this.EQUIRECTANGULAR_RELFECTION_FOV = false;
  48697. // Default BJS.
  48698. _this.MAINUV1 = false;
  48699. _this.MAINUV2 = false;
  48700. _this.UV1 = false;
  48701. _this.UV2 = false;
  48702. _this.CLIPPLANE = false;
  48703. _this.CLIPPLANE2 = false;
  48704. _this.CLIPPLANE3 = false;
  48705. _this.CLIPPLANE4 = false;
  48706. _this.POINTSIZE = false;
  48707. _this.FOG = false;
  48708. _this.NORMAL = false;
  48709. _this.NUM_BONE_INFLUENCERS = 0;
  48710. _this.BonesPerMesh = 0;
  48711. _this.INSTANCES = false;
  48712. _this.SHADOWFLOAT = false;
  48713. _this.rebuild();
  48714. return _this;
  48715. }
  48716. return BackgroundMaterialDefines;
  48717. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  48718. /**
  48719. * Background material used to create an efficient environement around your scene.
  48720. */
  48721. var BackgroundMaterial = /** @class */ (function (_super) {
  48722. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterial, _super);
  48723. /**
  48724. * Instantiates a Background Material in the given scene
  48725. * @param name The friendly name of the material
  48726. * @param scene The scene to add the material to
  48727. */
  48728. function BackgroundMaterial(name, scene) {
  48729. var _this = _super.call(this, name, scene) || this;
  48730. /**
  48731. * Key light Color (multiply against the environement texture)
  48732. */
  48733. _this.primaryColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  48734. _this._primaryColorShadowLevel = 0;
  48735. _this._primaryColorHighlightLevel = 0;
  48736. /**
  48737. * Reflection Texture used in the material.
  48738. * Should be author in a specific way for the best result (refer to the documentation).
  48739. */
  48740. _this.reflectionTexture = null;
  48741. /**
  48742. * Reflection Texture level of blur.
  48743. *
  48744. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48745. * texture twice.
  48746. */
  48747. _this.reflectionBlur = 0;
  48748. /**
  48749. * Diffuse Texture used in the material.
  48750. * Should be author in a specific way for the best result (refer to the documentation).
  48751. */
  48752. _this.diffuseTexture = null;
  48753. _this._shadowLights = null;
  48754. /**
  48755. * Specify the list of lights casting shadow on the material.
  48756. * All scene shadow lights will be included if null.
  48757. */
  48758. _this.shadowLights = null;
  48759. /**
  48760. * Helps adjusting the shadow to a softer level if required.
  48761. * 0 means black shadows and 1 means no shadows.
  48762. */
  48763. _this.shadowLevel = 0;
  48764. /**
  48765. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48766. * It is usually zero but might be interesting to modify according to your setup.
  48767. */
  48768. _this.sceneCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  48769. /**
  48770. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48771. * This helps ensuring a nice transition when the camera goes under the ground.
  48772. */
  48773. _this.opacityFresnel = true;
  48774. /**
  48775. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48776. * This helps adding a mirror texture on the ground.
  48777. */
  48778. _this.reflectionFresnel = false;
  48779. /**
  48780. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48781. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48782. */
  48783. _this.reflectionFalloffDistance = 0.0;
  48784. /**
  48785. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48786. */
  48787. _this.reflectionAmount = 1.0;
  48788. /**
  48789. * This specifies the weight of the reflection at grazing angle.
  48790. */
  48791. _this.reflectionReflectance0 = 0.05;
  48792. /**
  48793. * This specifies the weight of the reflection at a perpendicular point of view.
  48794. */
  48795. _this.reflectionReflectance90 = 0.5;
  48796. /**
  48797. * Helps to directly use the maps channels instead of their level.
  48798. */
  48799. _this.useRGBColor = true;
  48800. /**
  48801. * This helps reducing the banding effect that could occur on the background.
  48802. */
  48803. _this.enableNoise = false;
  48804. _this._fovMultiplier = 1.0;
  48805. /**
  48806. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48807. */
  48808. _this.useEquirectangularFOV = false;
  48809. _this._maxSimultaneousLights = 4;
  48810. /**
  48811. * Number of Simultaneous lights allowed on the material.
  48812. */
  48813. _this.maxSimultaneousLights = 4;
  48814. /**
  48815. * Keep track of the image processing observer to allow dispose and replace.
  48816. */
  48817. _this._imageProcessingObserver = null;
  48818. /**
  48819. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48820. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48821. */
  48822. _this.switchToBGR = false;
  48823. // Temp values kept as cache in the material.
  48824. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  48825. _this._reflectionControls = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector4"].Zero();
  48826. _this._white = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  48827. _this._primaryShadowColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  48828. _this._primaryHighlightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  48829. // Setup the default processing configuration to the scene.
  48830. _this._attachImageProcessingConfiguration(null);
  48831. _this.getRenderTargetTextures = function () {
  48832. _this._renderTargets.reset();
  48833. if (_this._diffuseTexture && _this._diffuseTexture.isRenderTarget) {
  48834. _this._renderTargets.push(_this._diffuseTexture);
  48835. }
  48836. if (_this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  48837. _this._renderTargets.push(_this._reflectionTexture);
  48838. }
  48839. return _this._renderTargets;
  48840. };
  48841. return _this;
  48842. }
  48843. Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
  48844. /**
  48845. * Experimental Internal Use Only.
  48846. *
  48847. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48848. * This acts as a helper to set the primary color to a more "human friendly" value.
  48849. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48850. * output color as close as possible from the chosen value.
  48851. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48852. * part of lighting setup.)
  48853. */
  48854. get: function () {
  48855. return this.__perceptualColor;
  48856. },
  48857. set: function (value) {
  48858. this.__perceptualColor = value;
  48859. this._computePrimaryColorFromPerceptualColor();
  48860. this._markAllSubMeshesAsLightsDirty();
  48861. },
  48862. enumerable: true,
  48863. configurable: true
  48864. });
  48865. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorShadowLevel", {
  48866. /**
  48867. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48868. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48869. */
  48870. get: function () {
  48871. return this._primaryColorShadowLevel;
  48872. },
  48873. set: function (value) {
  48874. this._primaryColorShadowLevel = value;
  48875. this._computePrimaryColors();
  48876. this._markAllSubMeshesAsLightsDirty();
  48877. },
  48878. enumerable: true,
  48879. configurable: true
  48880. });
  48881. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorHighlightLevel", {
  48882. /**
  48883. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48884. * The primary color is used at the level chosen to define what the white area would look.
  48885. */
  48886. get: function () {
  48887. return this._primaryColorHighlightLevel;
  48888. },
  48889. set: function (value) {
  48890. this._primaryColorHighlightLevel = value;
  48891. this._computePrimaryColors();
  48892. this._markAllSubMeshesAsLightsDirty();
  48893. },
  48894. enumerable: true,
  48895. configurable: true
  48896. });
  48897. Object.defineProperty(BackgroundMaterial.prototype, "reflectionStandardFresnelWeight", {
  48898. /**
  48899. * Sets the reflection reflectance fresnel values according to the default standard
  48900. * empirically know to work well :-)
  48901. */
  48902. set: function (value) {
  48903. var reflectionWeight = value;
  48904. if (reflectionWeight < 0.5) {
  48905. reflectionWeight = reflectionWeight * 2.0;
  48906. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 * reflectionWeight;
  48907. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 * reflectionWeight;
  48908. }
  48909. else {
  48910. reflectionWeight = reflectionWeight * 2.0 - 1.0;
  48911. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 + (1.0 - BackgroundMaterial.StandardReflectance0) * reflectionWeight;
  48912. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 + (1.0 - BackgroundMaterial.StandardReflectance90) * reflectionWeight;
  48913. }
  48914. },
  48915. enumerable: true,
  48916. configurable: true
  48917. });
  48918. Object.defineProperty(BackgroundMaterial.prototype, "fovMultiplier", {
  48919. /**
  48920. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48921. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48922. * Recommended to be keep at 1.0 except for special cases.
  48923. */
  48924. get: function () {
  48925. return this._fovMultiplier;
  48926. },
  48927. set: function (value) {
  48928. if (isNaN(value)) {
  48929. value = 1.0;
  48930. }
  48931. this._fovMultiplier = Math.max(0.0, Math.min(2.0, value));
  48932. },
  48933. enumerable: true,
  48934. configurable: true
  48935. });
  48936. /**
  48937. * Attaches a new image processing configuration to the PBR Material.
  48938. * @param configuration (if null the scene configuration will be use)
  48939. */
  48940. BackgroundMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  48941. var _this = this;
  48942. if (configuration === this._imageProcessingConfiguration) {
  48943. return;
  48944. }
  48945. // Detaches observer.
  48946. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  48947. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  48948. }
  48949. // Pick the scene configuration if needed.
  48950. if (!configuration) {
  48951. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  48952. }
  48953. else {
  48954. this._imageProcessingConfiguration = configuration;
  48955. }
  48956. // Attaches observer.
  48957. if (this._imageProcessingConfiguration) {
  48958. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  48959. _this._computePrimaryColorFromPerceptualColor();
  48960. _this._markAllSubMeshesAsImageProcessingDirty();
  48961. });
  48962. }
  48963. };
  48964. Object.defineProperty(BackgroundMaterial.prototype, "imageProcessingConfiguration", {
  48965. /**
  48966. * Gets the image processing configuration used either in this material.
  48967. */
  48968. get: function () {
  48969. return this._imageProcessingConfiguration;
  48970. },
  48971. /**
  48972. * Sets the Default image processing configuration used either in the this material.
  48973. *
  48974. * If sets to null, the scene one is in use.
  48975. */
  48976. set: function (value) {
  48977. this._attachImageProcessingConfiguration(value);
  48978. // Ensure the effect will be rebuilt.
  48979. this._markAllSubMeshesAsTexturesDirty();
  48980. },
  48981. enumerable: true,
  48982. configurable: true
  48983. });
  48984. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurvesEnabled", {
  48985. /**
  48986. * Gets wether the color curves effect is enabled.
  48987. */
  48988. get: function () {
  48989. return this.imageProcessingConfiguration.colorCurvesEnabled;
  48990. },
  48991. /**
  48992. * Sets wether the color curves effect is enabled.
  48993. */
  48994. set: function (value) {
  48995. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  48996. },
  48997. enumerable: true,
  48998. configurable: true
  48999. });
  49000. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingEnabled", {
  49001. /**
  49002. * Gets wether the color grading effect is enabled.
  49003. */
  49004. get: function () {
  49005. return this.imageProcessingConfiguration.colorGradingEnabled;
  49006. },
  49007. /**
  49008. * Gets wether the color grading effect is enabled.
  49009. */
  49010. set: function (value) {
  49011. this.imageProcessingConfiguration.colorGradingEnabled = value;
  49012. },
  49013. enumerable: true,
  49014. configurable: true
  49015. });
  49016. Object.defineProperty(BackgroundMaterial.prototype, "cameraToneMappingEnabled", {
  49017. /**
  49018. * Gets wether tonemapping is enabled or not.
  49019. */
  49020. get: function () {
  49021. return this._imageProcessingConfiguration.toneMappingEnabled;
  49022. },
  49023. /**
  49024. * Sets wether tonemapping is enabled or not
  49025. */
  49026. set: function (value) {
  49027. this._imageProcessingConfiguration.toneMappingEnabled = value;
  49028. },
  49029. enumerable: true,
  49030. configurable: true
  49031. });
  49032. Object.defineProperty(BackgroundMaterial.prototype, "cameraExposure", {
  49033. /**
  49034. * The camera exposure used on this material.
  49035. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49036. * This corresponds to a photographic exposure.
  49037. */
  49038. get: function () {
  49039. return this._imageProcessingConfiguration.exposure;
  49040. },
  49041. /**
  49042. * The camera exposure used on this material.
  49043. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49044. * This corresponds to a photographic exposure.
  49045. */
  49046. set: function (value) {
  49047. this._imageProcessingConfiguration.exposure = value;
  49048. },
  49049. enumerable: true,
  49050. configurable: true
  49051. });
  49052. Object.defineProperty(BackgroundMaterial.prototype, "cameraContrast", {
  49053. /**
  49054. * Gets The camera contrast used on this material.
  49055. */
  49056. get: function () {
  49057. return this._imageProcessingConfiguration.contrast;
  49058. },
  49059. /**
  49060. * Sets The camera contrast used on this material.
  49061. */
  49062. set: function (value) {
  49063. this._imageProcessingConfiguration.contrast = value;
  49064. },
  49065. enumerable: true,
  49066. configurable: true
  49067. });
  49068. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingTexture", {
  49069. /**
  49070. * Gets the Color Grading 2D Lookup Texture.
  49071. */
  49072. get: function () {
  49073. return this._imageProcessingConfiguration.colorGradingTexture;
  49074. },
  49075. /**
  49076. * Sets the Color Grading 2D Lookup Texture.
  49077. */
  49078. set: function (value) {
  49079. this.imageProcessingConfiguration.colorGradingTexture = value;
  49080. },
  49081. enumerable: true,
  49082. configurable: true
  49083. });
  49084. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurves", {
  49085. /**
  49086. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49087. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49088. * 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;
  49089. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49090. */
  49091. get: function () {
  49092. return this.imageProcessingConfiguration.colorCurves;
  49093. },
  49094. /**
  49095. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49096. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49097. * 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;
  49098. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49099. */
  49100. set: function (value) {
  49101. this.imageProcessingConfiguration.colorCurves = value;
  49102. },
  49103. enumerable: true,
  49104. configurable: true
  49105. });
  49106. Object.defineProperty(BackgroundMaterial.prototype, "hasRenderTargetTextures", {
  49107. /**
  49108. * Gets a boolean indicating that current material needs to register RTT
  49109. */
  49110. get: function () {
  49111. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  49112. return true;
  49113. }
  49114. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  49115. return true;
  49116. }
  49117. return false;
  49118. },
  49119. enumerable: true,
  49120. configurable: true
  49121. });
  49122. /**
  49123. * The entire material has been created in order to prevent overdraw.
  49124. * @returns false
  49125. */
  49126. BackgroundMaterial.prototype.needAlphaTesting = function () {
  49127. return true;
  49128. };
  49129. /**
  49130. * The entire material has been created in order to prevent overdraw.
  49131. * @returns true if blending is enable
  49132. */
  49133. BackgroundMaterial.prototype.needAlphaBlending = function () {
  49134. return ((this.alpha < 0) || (this._diffuseTexture != null && this._diffuseTexture.hasAlpha));
  49135. };
  49136. /**
  49137. * Checks wether the material is ready to be rendered for a given mesh.
  49138. * @param mesh The mesh to render
  49139. * @param subMesh The submesh to check against
  49140. * @param useInstances Specify wether or not the material is used with instances
  49141. * @returns true if all the dependencies are ready (Textures, Effects...)
  49142. */
  49143. BackgroundMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  49144. var _this = this;
  49145. if (useInstances === void 0) { useInstances = false; }
  49146. if (subMesh.effect && this.isFrozen) {
  49147. if (this._wasPreviouslyReady) {
  49148. return true;
  49149. }
  49150. }
  49151. if (!subMesh._materialDefines) {
  49152. subMesh._materialDefines = new BackgroundMaterialDefines();
  49153. }
  49154. var scene = this.getScene();
  49155. var defines = subMesh._materialDefines;
  49156. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  49157. if (defines._renderId === scene.getRenderId()) {
  49158. return true;
  49159. }
  49160. }
  49161. var engine = scene.getEngine();
  49162. // Lights
  49163. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
  49164. defines._needNormals = true;
  49165. // Textures
  49166. if (defines._areTexturesDirty) {
  49167. defines._needUVs = false;
  49168. if (scene.texturesEnabled) {
  49169. if (scene.getEngine().getCaps().textureLOD) {
  49170. defines.TEXTURELODSUPPORT = true;
  49171. }
  49172. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  49173. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  49174. return false;
  49175. }
  49176. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  49177. defines.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha;
  49178. defines.GAMMADIFFUSE = this._diffuseTexture.gammaSpace;
  49179. defines.OPACITYFRESNEL = this._opacityFresnel;
  49180. }
  49181. else {
  49182. defines.DIFFUSE = false;
  49183. defines.DIFFUSEHASALPHA = false;
  49184. defines.GAMMADIFFUSE = false;
  49185. defines.OPACITYFRESNEL = false;
  49186. }
  49187. var reflectionTexture = this._reflectionTexture;
  49188. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  49189. if (!reflectionTexture.isReadyOrNotBlocking()) {
  49190. return false;
  49191. }
  49192. defines.REFLECTION = true;
  49193. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  49194. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  49195. defines.REFLECTIONBLUR = this._reflectionBlur > 0;
  49196. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  49197. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  49198. defines.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV;
  49199. defines.REFLECTIONBGR = this.switchToBGR;
  49200. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE) {
  49201. defines.INVERTCUBICMAP = true;
  49202. }
  49203. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  49204. switch (reflectionTexture.coordinatesMode) {
  49205. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  49206. defines.REFLECTIONMAP_EXPLICIT = true;
  49207. break;
  49208. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  49209. defines.REFLECTIONMAP_PLANAR = true;
  49210. break;
  49211. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  49212. defines.REFLECTIONMAP_PROJECTION = true;
  49213. break;
  49214. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  49215. defines.REFLECTIONMAP_SKYBOX = true;
  49216. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  49217. break;
  49218. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  49219. defines.REFLECTIONMAP_SPHERICAL = true;
  49220. break;
  49221. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  49222. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  49223. break;
  49224. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  49225. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  49226. break;
  49227. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  49228. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  49229. break;
  49230. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  49231. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  49232. default:
  49233. defines.REFLECTIONMAP_CUBIC = true;
  49234. break;
  49235. }
  49236. if (this.reflectionFresnel) {
  49237. defines.REFLECTIONFRESNEL = true;
  49238. defines.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0;
  49239. this._reflectionControls.x = this.reflectionAmount;
  49240. this._reflectionControls.y = this.reflectionReflectance0;
  49241. this._reflectionControls.z = this.reflectionReflectance90;
  49242. this._reflectionControls.w = 1 / this.reflectionFalloffDistance;
  49243. }
  49244. else {
  49245. defines.REFLECTIONFRESNEL = false;
  49246. defines.REFLECTIONFALLOFF = false;
  49247. }
  49248. }
  49249. else {
  49250. defines.REFLECTION = false;
  49251. defines.REFLECTIONFRESNEL = false;
  49252. defines.REFLECTIONFALLOFF = false;
  49253. defines.REFLECTIONBLUR = false;
  49254. defines.REFLECTIONMAP_3D = false;
  49255. defines.REFLECTIONMAP_SPHERICAL = false;
  49256. defines.REFLECTIONMAP_PLANAR = false;
  49257. defines.REFLECTIONMAP_CUBIC = false;
  49258. defines.REFLECTIONMAP_PROJECTION = false;
  49259. defines.REFLECTIONMAP_SKYBOX = false;
  49260. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  49261. defines.REFLECTIONMAP_EXPLICIT = false;
  49262. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  49263. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  49264. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  49265. defines.INVERTCUBICMAP = false;
  49266. defines.REFLECTIONMAP_OPPOSITEZ = false;
  49267. defines.LODINREFLECTIONALPHA = false;
  49268. defines.GAMMAREFLECTION = false;
  49269. defines.RGBDREFLECTION = false;
  49270. }
  49271. }
  49272. 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);
  49273. defines.USERGBCOLOR = this._useRGBColor;
  49274. defines.NOISE = this._enableNoise;
  49275. }
  49276. if (defines._areLightsDirty) {
  49277. defines.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (this._primaryColorShadowLevel !== 0 || this._primaryColorHighlightLevel !== 0);
  49278. }
  49279. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  49280. if (!this._imageProcessingConfiguration.isReady()) {
  49281. return false;
  49282. }
  49283. this._imageProcessingConfiguration.prepareDefines(defines);
  49284. }
  49285. // Misc.
  49286. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  49287. // Values that need to be evaluated on every frame
  49288. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  49289. // Attribs
  49290. if (_Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
  49291. if (mesh) {
  49292. if (!scene.getEngine().getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  49293. mesh.createNormals(true);
  49294. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("BackgroundMaterial: Normals have been created for the mesh: " + mesh.name);
  49295. }
  49296. }
  49297. }
  49298. // Get correct effect
  49299. if (defines.isDirty) {
  49300. defines.markAsProcessed();
  49301. scene.resetCachedMaterial();
  49302. // Fallbacks
  49303. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  49304. if (defines.FOG) {
  49305. fallbacks.addFallback(0, "FOG");
  49306. }
  49307. if (defines.POINTSIZE) {
  49308. fallbacks.addFallback(1, "POINTSIZE");
  49309. }
  49310. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  49311. if (defines.NUM_BONE_INFLUENCERS > 0) {
  49312. fallbacks.addCPUSkinningFallback(0, mesh);
  49313. }
  49314. //Attributes
  49315. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  49316. if (defines.NORMAL) {
  49317. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  49318. }
  49319. if (defines.UV1) {
  49320. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  49321. }
  49322. if (defines.UV2) {
  49323. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  49324. }
  49325. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  49326. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  49327. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
  49328. "vFogInfos", "vFogColor", "pointSize",
  49329. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "mBones",
  49330. "vPrimaryColor", "vPrimaryColorShadow",
  49331. "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier",
  49332. "shadowLevel", "alpha",
  49333. "vBackgroundCenter", "vReflectionControl",
  49334. "vDiffuseInfos", "diffuseMatrix",
  49335. ];
  49336. var samplers = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"];
  49337. var uniformBuffers = ["Material", "Scene"];
  49338. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"]) {
  49339. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  49340. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  49341. }
  49342. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareUniformsAndSamplersList({
  49343. uniformsNames: uniforms,
  49344. uniformBuffersNames: uniformBuffers,
  49345. samplers: samplers,
  49346. defines: defines,
  49347. maxSimultaneousLights: this._maxSimultaneousLights
  49348. });
  49349. var onCompiled = function (effect) {
  49350. if (_this.onCompiled) {
  49351. _this.onCompiled(effect);
  49352. }
  49353. _this.bindSceneUniformBuffer(effect, scene.getSceneUniformBuffer());
  49354. };
  49355. var join = defines.toString();
  49356. subMesh.setEffect(scene.getEngine().createEffect("background", {
  49357. attributes: attribs,
  49358. uniformsNames: uniforms,
  49359. uniformBuffersNames: uniformBuffers,
  49360. samplers: samplers,
  49361. defines: join,
  49362. fallbacks: fallbacks,
  49363. onCompiled: onCompiled,
  49364. onError: this.onError,
  49365. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights }
  49366. }, engine), defines);
  49367. this.buildUniformLayout();
  49368. }
  49369. if (!subMesh.effect || !subMesh.effect.isReady()) {
  49370. return false;
  49371. }
  49372. defines._renderId = scene.getRenderId();
  49373. this._wasPreviouslyReady = true;
  49374. return true;
  49375. };
  49376. /**
  49377. * Compute the primary color according to the chosen perceptual color.
  49378. */
  49379. BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
  49380. if (!this.__perceptualColor) {
  49381. return;
  49382. }
  49383. this._primaryColor.copyFrom(this.__perceptualColor);
  49384. // Revert gamma space.
  49385. this._primaryColor.toLinearSpaceToRef(this._primaryColor);
  49386. // Revert image processing configuration.
  49387. if (this._imageProcessingConfiguration) {
  49388. // Revert Exposure.
  49389. this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
  49390. }
  49391. this._computePrimaryColors();
  49392. };
  49393. /**
  49394. * Compute the highlights and shadow colors according to their chosen levels.
  49395. */
  49396. BackgroundMaterial.prototype._computePrimaryColors = function () {
  49397. if (this._primaryColorShadowLevel === 0 && this._primaryColorHighlightLevel === 0) {
  49398. return;
  49399. }
  49400. // Find the highlight color based on the configuration.
  49401. this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
  49402. this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
  49403. // Find the shadow color based on the configuration.
  49404. this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
  49405. this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
  49406. this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
  49407. };
  49408. /**
  49409. * Build the uniform buffer used in the material.
  49410. */
  49411. BackgroundMaterial.prototype.buildUniformLayout = function () {
  49412. // Order is important !
  49413. this._uniformBuffer.addUniform("vPrimaryColor", 4);
  49414. this._uniformBuffer.addUniform("vPrimaryColorShadow", 4);
  49415. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  49416. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  49417. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  49418. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  49419. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  49420. this._uniformBuffer.addUniform("fFovMultiplier", 1);
  49421. this._uniformBuffer.addUniform("pointSize", 1);
  49422. this._uniformBuffer.addUniform("shadowLevel", 1);
  49423. this._uniformBuffer.addUniform("alpha", 1);
  49424. this._uniformBuffer.addUniform("vBackgroundCenter", 3);
  49425. this._uniformBuffer.addUniform("vReflectionControl", 4);
  49426. this._uniformBuffer.create();
  49427. };
  49428. /**
  49429. * Unbind the material.
  49430. */
  49431. BackgroundMaterial.prototype.unbind = function () {
  49432. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  49433. this._uniformBuffer.setTexture("diffuseSampler", null);
  49434. }
  49435. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  49436. this._uniformBuffer.setTexture("reflectionSampler", null);
  49437. }
  49438. _super.prototype.unbind.call(this);
  49439. };
  49440. /**
  49441. * Bind only the world matrix to the material.
  49442. * @param world The world matrix to bind.
  49443. */
  49444. BackgroundMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  49445. this._activeEffect.setMatrix("world", world);
  49446. };
  49447. /**
  49448. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49449. * @param world The world matrix to bind.
  49450. * @param subMesh The submesh to bind for.
  49451. */
  49452. BackgroundMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  49453. var scene = this.getScene();
  49454. var defines = subMesh._materialDefines;
  49455. if (!defines) {
  49456. return;
  49457. }
  49458. var effect = subMesh.effect;
  49459. if (!effect) {
  49460. return;
  49461. }
  49462. this._activeEffect = effect;
  49463. // Matrices
  49464. this.bindOnlyWorldMatrix(world);
  49465. // Bones
  49466. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  49467. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  49468. if (mustRebind) {
  49469. this._uniformBuffer.bindToEffect(effect, "Material");
  49470. this.bindViewProjection(effect);
  49471. var reflectionTexture = this._reflectionTexture;
  49472. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  49473. // Texture uniforms
  49474. if (scene.texturesEnabled) {
  49475. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  49476. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  49477. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  49478. }
  49479. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  49480. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  49481. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, this._reflectionBlur);
  49482. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  49483. }
  49484. }
  49485. if (this.shadowLevel > 0) {
  49486. this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel);
  49487. }
  49488. this._uniformBuffer.updateFloat("alpha", this.alpha);
  49489. // Point size
  49490. if (this.pointsCloud) {
  49491. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  49492. }
  49493. if (defines.USEHIGHLIGHTANDSHADOWCOLORS) {
  49494. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1.0);
  49495. this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1.0);
  49496. }
  49497. else {
  49498. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1.0);
  49499. }
  49500. }
  49501. this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier);
  49502. // Textures
  49503. if (scene.texturesEnabled) {
  49504. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  49505. this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture);
  49506. }
  49507. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  49508. if (defines.REFLECTIONBLUR && defines.TEXTURELODSUPPORT) {
  49509. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  49510. }
  49511. else if (!defines.REFLECTIONBLUR) {
  49512. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  49513. }
  49514. else {
  49515. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  49516. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  49517. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  49518. }
  49519. if (defines.REFLECTIONFRESNEL) {
  49520. this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z);
  49521. this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w);
  49522. }
  49523. }
  49524. }
  49525. // Clip plane
  49526. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  49527. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindEyePosition(effect, scene);
  49528. }
  49529. if (mustRebind || !this.isFrozen) {
  49530. if (scene.lightsEnabled) {
  49531. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, false);
  49532. }
  49533. // View
  49534. this.bindView(effect);
  49535. // Fog
  49536. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  49537. // image processing
  49538. if (this._imageProcessingConfiguration) {
  49539. this._imageProcessingConfiguration.bind(this._activeEffect);
  49540. }
  49541. }
  49542. this._uniformBuffer.update();
  49543. this._afterBind(mesh, this._activeEffect);
  49544. };
  49545. /**
  49546. * Dispose the material.
  49547. * @param forceDisposeEffect Force disposal of the associated effect.
  49548. * @param forceDisposeTextures Force disposal of the associated textures.
  49549. */
  49550. BackgroundMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  49551. if (forceDisposeEffect === void 0) { forceDisposeEffect = false; }
  49552. if (forceDisposeTextures === void 0) { forceDisposeTextures = false; }
  49553. if (forceDisposeTextures) {
  49554. if (this.diffuseTexture) {
  49555. this.diffuseTexture.dispose();
  49556. }
  49557. if (this.reflectionTexture) {
  49558. this.reflectionTexture.dispose();
  49559. }
  49560. }
  49561. this._renderTargets.dispose();
  49562. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  49563. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  49564. }
  49565. _super.prototype.dispose.call(this, forceDisposeEffect);
  49566. };
  49567. /**
  49568. * Clones the material.
  49569. * @param name The cloned name.
  49570. * @returns The cloned material.
  49571. */
  49572. BackgroundMaterial.prototype.clone = function (name) {
  49573. var _this = this;
  49574. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new BackgroundMaterial(name, _this.getScene()); }, this);
  49575. };
  49576. /**
  49577. * Serializes the current material to its JSON representation.
  49578. * @returns The JSON representation.
  49579. */
  49580. BackgroundMaterial.prototype.serialize = function () {
  49581. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  49582. serializationObject.customType = "BABYLON.BackgroundMaterial";
  49583. return serializationObject;
  49584. };
  49585. /**
  49586. * Gets the class name of the material
  49587. * @returns "BackgroundMaterial"
  49588. */
  49589. BackgroundMaterial.prototype.getClassName = function () {
  49590. return "BackgroundMaterial";
  49591. };
  49592. /**
  49593. * Parse a JSON input to create back a background material.
  49594. * @param source The JSON data to parse
  49595. * @param scene The scene to create the parsed material in
  49596. * @param rootUrl The root url of the assets the material depends upon
  49597. * @returns the instantiated BackgroundMaterial.
  49598. */
  49599. BackgroundMaterial.Parse = function (source, scene, rootUrl) {
  49600. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new BackgroundMaterial(source.name, scene); }, source, scene, rootUrl);
  49601. };
  49602. /**
  49603. * Standard reflectance value at parallel view angle.
  49604. */
  49605. BackgroundMaterial.StandardReflectance0 = 0.05;
  49606. /**
  49607. * Standard reflectance value at grazing angle.
  49608. */
  49609. BackgroundMaterial.StandardReflectance90 = 0.5;
  49610. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49611. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  49612. ], BackgroundMaterial.prototype, "_primaryColor", void 0);
  49613. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49614. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  49615. ], BackgroundMaterial.prototype, "primaryColor", void 0);
  49616. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49617. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  49618. ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
  49619. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49620. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49621. ], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
  49622. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49623. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49624. ], BackgroundMaterial.prototype, "_primaryColorHighlightLevel", void 0);
  49625. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49626. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  49627. ], BackgroundMaterial.prototype, "primaryColorHighlightLevel", null);
  49628. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49629. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  49630. ], BackgroundMaterial.prototype, "_reflectionTexture", void 0);
  49631. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49632. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49633. ], BackgroundMaterial.prototype, "reflectionTexture", void 0);
  49634. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49635. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49636. ], BackgroundMaterial.prototype, "_reflectionBlur", void 0);
  49637. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49638. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49639. ], BackgroundMaterial.prototype, "reflectionBlur", void 0);
  49640. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49641. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  49642. ], BackgroundMaterial.prototype, "_diffuseTexture", void 0);
  49643. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49644. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49645. ], BackgroundMaterial.prototype, "diffuseTexture", void 0);
  49646. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49647. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49648. ], BackgroundMaterial.prototype, "shadowLights", void 0);
  49649. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49650. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49651. ], BackgroundMaterial.prototype, "_shadowLevel", void 0);
  49652. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49653. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49654. ], BackgroundMaterial.prototype, "shadowLevel", void 0);
  49655. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49656. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  49657. ], BackgroundMaterial.prototype, "_sceneCenter", void 0);
  49658. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49659. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49660. ], BackgroundMaterial.prototype, "sceneCenter", void 0);
  49661. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49662. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49663. ], BackgroundMaterial.prototype, "_opacityFresnel", void 0);
  49664. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49665. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49666. ], BackgroundMaterial.prototype, "opacityFresnel", void 0);
  49667. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49668. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49669. ], BackgroundMaterial.prototype, "_reflectionFresnel", void 0);
  49670. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49671. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49672. ], BackgroundMaterial.prototype, "reflectionFresnel", void 0);
  49673. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49674. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49675. ], BackgroundMaterial.prototype, "_reflectionFalloffDistance", void 0);
  49676. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49677. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49678. ], BackgroundMaterial.prototype, "reflectionFalloffDistance", void 0);
  49679. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49680. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49681. ], BackgroundMaterial.prototype, "_reflectionAmount", void 0);
  49682. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49683. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49684. ], BackgroundMaterial.prototype, "reflectionAmount", void 0);
  49685. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49686. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49687. ], BackgroundMaterial.prototype, "_reflectionReflectance0", void 0);
  49688. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49689. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49690. ], BackgroundMaterial.prototype, "reflectionReflectance0", void 0);
  49691. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49692. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49693. ], BackgroundMaterial.prototype, "_reflectionReflectance90", void 0);
  49694. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49695. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49696. ], BackgroundMaterial.prototype, "reflectionReflectance90", void 0);
  49697. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49698. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49699. ], BackgroundMaterial.prototype, "_useRGBColor", void 0);
  49700. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49701. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49702. ], BackgroundMaterial.prototype, "useRGBColor", void 0);
  49703. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49704. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49705. ], BackgroundMaterial.prototype, "_enableNoise", void 0);
  49706. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49707. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49708. ], BackgroundMaterial.prototype, "enableNoise", void 0);
  49709. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49710. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49711. ], BackgroundMaterial.prototype, "_maxSimultaneousLights", void 0);
  49712. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49713. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49714. ], BackgroundMaterial.prototype, "maxSimultaneousLights", void 0);
  49715. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49716. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  49717. ], BackgroundMaterial.prototype, "_imageProcessingConfiguration", void 0);
  49718. return BackgroundMaterial;
  49719. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  49720. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__["_TypeStore"].RegisteredTypes["BABYLON.BackgroundMaterial"] = BackgroundMaterial;
  49721. /***/ }),
  49722. /***/ "./Materials/Background/index.ts":
  49723. /*!***************************************!*\
  49724. !*** ./Materials/Background/index.ts ***!
  49725. \***************************************/
  49726. /*! exports provided: BackgroundMaterial */
  49727. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49728. "use strict";
  49729. __webpack_require__.r(__webpack_exports__);
  49730. /* harmony import */ var _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  49731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  49732. /***/ }),
  49733. /***/ "./Materials/PBR/index.ts":
  49734. /*!********************************!*\
  49735. !*** ./Materials/PBR/index.ts ***!
  49736. \********************************/
  49737. /*! exports provided: PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial */
  49738. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49739. "use strict";
  49740. __webpack_require__.r(__webpack_exports__);
  49741. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  49742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  49743. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  49744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__["PBRBaseSimpleMaterial"]; });
  49745. /* harmony import */ var _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  49746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRMaterial"]; });
  49747. /* harmony import */ var _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrMetallicRoughnessMaterial */ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts");
  49748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRMetallicRoughnessMaterial"]; });
  49749. /* harmony import */ var _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrSpecularGlossinessMaterial */ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts");
  49750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRSpecularGlossinessMaterial"]; });
  49751. /***/ }),
  49752. /***/ "./Materials/PBR/pbrBaseMaterial.ts":
  49753. /*!******************************************!*\
  49754. !*** ./Materials/PBR/pbrBaseMaterial.ts ***!
  49755. \******************************************/
  49756. /*! exports provided: PBRBaseMaterial */
  49757. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49758. "use strict";
  49759. __webpack_require__.r(__webpack_exports__);
  49760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return PBRBaseMaterial; });
  49761. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  49762. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  49763. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  49764. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  49765. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  49766. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  49767. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  49768. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  49769. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  49770. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  49771. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  49772. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  49773. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  49774. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  49775. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  49776. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  49777. /* harmony import */ var _Shaders_pbr_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/pbr.fragment */ "./Shaders/pbr.fragment.ts");
  49778. /* harmony import */ var _Shaders_pbr_vertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Shaders/pbr.vertex */ "./Shaders/pbr.vertex.ts");
  49779. /**
  49780. * Manages the defines for the PBR Material.
  49781. * @hiddenChildren
  49782. */
  49783. var PBRMaterialDefines = /** @class */ (function (_super) {
  49784. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterialDefines, _super);
  49785. /**
  49786. * Initializes the PBR Material defines.
  49787. */
  49788. function PBRMaterialDefines() {
  49789. var _this = _super.call(this) || this;
  49790. _this.PBR = true;
  49791. _this.MAINUV1 = false;
  49792. _this.MAINUV2 = false;
  49793. _this.UV1 = false;
  49794. _this.UV2 = false;
  49795. _this.ALBEDO = false;
  49796. _this.ALBEDODIRECTUV = 0;
  49797. _this.VERTEXCOLOR = false;
  49798. _this.AMBIENT = false;
  49799. _this.AMBIENTDIRECTUV = 0;
  49800. _this.AMBIENTINGRAYSCALE = false;
  49801. _this.OPACITY = false;
  49802. _this.VERTEXALPHA = false;
  49803. _this.OPACITYDIRECTUV = 0;
  49804. _this.OPACITYRGB = false;
  49805. _this.ALPHATEST = false;
  49806. _this.DEPTHPREPASS = false;
  49807. _this.ALPHABLEND = false;
  49808. _this.ALPHAFROMALBEDO = false;
  49809. _this.ALPHATESTVALUE = "0.5";
  49810. _this.SPECULAROVERALPHA = false;
  49811. _this.RADIANCEOVERALPHA = false;
  49812. _this.ALPHAFRESNEL = false;
  49813. _this.LINEARALPHAFRESNEL = false;
  49814. _this.PREMULTIPLYALPHA = false;
  49815. _this.EMISSIVE = false;
  49816. _this.EMISSIVEDIRECTUV = 0;
  49817. _this.REFLECTIVITY = false;
  49818. _this.REFLECTIVITYDIRECTUV = 0;
  49819. _this.SPECULARTERM = false;
  49820. _this.MICROSURFACEFROMREFLECTIVITYMAP = false;
  49821. _this.MICROSURFACEAUTOMATIC = false;
  49822. _this.LODBASEDMICROSFURACE = false;
  49823. _this.MICROSURFACEMAP = false;
  49824. _this.MICROSURFACEMAPDIRECTUV = 0;
  49825. _this.METALLICWORKFLOW = false;
  49826. _this.ROUGHNESSSTOREINMETALMAPALPHA = false;
  49827. _this.ROUGHNESSSTOREINMETALMAPGREEN = false;
  49828. _this.METALLNESSSTOREINMETALMAPBLUE = false;
  49829. _this.AOSTOREINMETALMAPRED = false;
  49830. _this.ENVIRONMENTBRDF = false;
  49831. _this.NORMAL = false;
  49832. _this.TANGENT = false;
  49833. _this.BUMP = false;
  49834. _this.BUMPDIRECTUV = 0;
  49835. _this.OBJECTSPACE_NORMALMAP = false;
  49836. _this.PARALLAX = false;
  49837. _this.PARALLAXOCCLUSION = false;
  49838. _this.NORMALXYSCALE = true;
  49839. _this.LIGHTMAP = false;
  49840. _this.LIGHTMAPDIRECTUV = 0;
  49841. _this.USELIGHTMAPASSHADOWMAP = false;
  49842. _this.GAMMALIGHTMAP = false;
  49843. _this.REFLECTION = false;
  49844. _this.REFLECTIONMAP_3D = false;
  49845. _this.REFLECTIONMAP_SPHERICAL = false;
  49846. _this.REFLECTIONMAP_PLANAR = false;
  49847. _this.REFLECTIONMAP_CUBIC = false;
  49848. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  49849. _this.REFLECTIONMAP_PROJECTION = false;
  49850. _this.REFLECTIONMAP_SKYBOX = false;
  49851. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  49852. _this.REFLECTIONMAP_EXPLICIT = false;
  49853. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  49854. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  49855. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  49856. _this.INVERTCUBICMAP = false;
  49857. _this.USESPHERICALFROMREFLECTIONMAP = false;
  49858. _this.USESPHERICALINVERTEX = false;
  49859. _this.REFLECTIONMAP_OPPOSITEZ = false;
  49860. _this.LODINREFLECTIONALPHA = false;
  49861. _this.GAMMAREFLECTION = false;
  49862. _this.RGBDREFLECTION = false;
  49863. _this.RADIANCEOCCLUSION = false;
  49864. _this.HORIZONOCCLUSION = false;
  49865. _this.REFRACTION = false;
  49866. _this.REFRACTIONMAP_3D = false;
  49867. _this.REFRACTIONMAP_OPPOSITEZ = false;
  49868. _this.LODINREFRACTIONALPHA = false;
  49869. _this.GAMMAREFRACTION = false;
  49870. _this.RGBDREFRACTION = false;
  49871. _this.LINKREFRACTIONTOTRANSPARENCY = false;
  49872. _this.INSTANCES = false;
  49873. _this.NUM_BONE_INFLUENCERS = 0;
  49874. _this.BonesPerMesh = 0;
  49875. _this.BONETEXTURE = false;
  49876. _this.NONUNIFORMSCALING = false;
  49877. _this.MORPHTARGETS = false;
  49878. _this.MORPHTARGETS_NORMAL = false;
  49879. _this.MORPHTARGETS_TANGENT = false;
  49880. _this.NUM_MORPH_INFLUENCERS = 0;
  49881. _this.IMAGEPROCESSING = false;
  49882. _this.VIGNETTE = false;
  49883. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  49884. _this.VIGNETTEBLENDMODEOPAQUE = false;
  49885. _this.TONEMAPPING = false;
  49886. _this.TONEMAPPING_ACES = false;
  49887. _this.CONTRAST = false;
  49888. _this.COLORCURVES = false;
  49889. _this.COLORGRADING = false;
  49890. _this.COLORGRADING3D = false;
  49891. _this.SAMPLER3DGREENDEPTH = false;
  49892. _this.SAMPLER3DBGRMAP = false;
  49893. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  49894. _this.EXPOSURE = false;
  49895. _this.USEPHYSICALLIGHTFALLOFF = false;
  49896. _this.USEGLTFLIGHTFALLOFF = false;
  49897. _this.TWOSIDEDLIGHTING = false;
  49898. _this.SHADOWFLOAT = false;
  49899. _this.CLIPPLANE = false;
  49900. _this.CLIPPLANE2 = false;
  49901. _this.CLIPPLANE3 = false;
  49902. _this.CLIPPLANE4 = false;
  49903. _this.POINTSIZE = false;
  49904. _this.FOG = false;
  49905. _this.LOGARITHMICDEPTH = false;
  49906. _this.FORCENORMALFORWARD = false;
  49907. _this.SPECULARAA = false;
  49908. _this.UNLIT = false;
  49909. _this.rebuild();
  49910. return _this;
  49911. }
  49912. /**
  49913. * Resets the PBR Material defines.
  49914. */
  49915. PBRMaterialDefines.prototype.reset = function () {
  49916. _super.prototype.reset.call(this);
  49917. this.ALPHATESTVALUE = "0.5";
  49918. this.PBR = true;
  49919. };
  49920. return PBRMaterialDefines;
  49921. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_10__["MaterialDefines"]));
  49922. /**
  49923. * The Physically based material base class of BJS.
  49924. *
  49925. * This offers the main features of a standard PBR material.
  49926. * For more information, please refer to the documentation :
  49927. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  49928. */
  49929. var PBRBaseMaterial = /** @class */ (function (_super) {
  49930. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseMaterial, _super);
  49931. /**
  49932. * Instantiates a new PBRMaterial instance.
  49933. *
  49934. * @param name The material name
  49935. * @param scene The scene the material will be use in.
  49936. */
  49937. function PBRBaseMaterial(name, scene) {
  49938. var _this = _super.call(this, name, scene) || this;
  49939. /**
  49940. * Intensity of the direct lights e.g. the four lights available in your scene.
  49941. * This impacts both the direct diffuse and specular highlights.
  49942. */
  49943. _this._directIntensity = 1.0;
  49944. /**
  49945. * Intensity of the emissive part of the material.
  49946. * This helps controlling the emissive effect without modifying the emissive color.
  49947. */
  49948. _this._emissiveIntensity = 1.0;
  49949. /**
  49950. * Intensity of the environment e.g. how much the environment will light the object
  49951. * either through harmonics for rough material or through the refelction for shiny ones.
  49952. */
  49953. _this._environmentIntensity = 1.0;
  49954. /**
  49955. * This is a special control allowing the reduction of the specular highlights coming from the
  49956. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49957. */
  49958. _this._specularIntensity = 1.0;
  49959. /**
  49960. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49961. */
  49962. _this._lightingInfos = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](_this._directIntensity, _this._emissiveIntensity, _this._environmentIntensity, _this._specularIntensity);
  49963. /**
  49964. * Debug Control allowing disabling the bump map on this material.
  49965. */
  49966. _this._disableBumpMap = false;
  49967. /**
  49968. * AKA Occlusion Texture Intensity in other nomenclature.
  49969. */
  49970. _this._ambientTextureStrength = 1.0;
  49971. /**
  49972. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49973. * 1 means it completely occludes it
  49974. * 0 mean it has no impact
  49975. */
  49976. _this._ambientTextureImpactOnAnalyticalLights = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  49977. /**
  49978. * The color of a material in ambient lighting.
  49979. */
  49980. _this._ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  49981. /**
  49982. * AKA Diffuse Color in other nomenclature.
  49983. */
  49984. _this._albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  49985. /**
  49986. * AKA Specular Color in other nomenclature.
  49987. */
  49988. _this._reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  49989. /**
  49990. * The color applied when light is reflected from a material.
  49991. */
  49992. _this._reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  49993. /**
  49994. * The color applied when light is emitted from a material.
  49995. */
  49996. _this._emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  49997. /**
  49998. * AKA Glossiness in other nomenclature.
  49999. */
  50000. _this._microSurface = 0.9;
  50001. /**
  50002. * source material index of refraction (IOR)' / 'destination material IOR.
  50003. */
  50004. _this._indexOfRefraction = 0.66;
  50005. /**
  50006. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50007. */
  50008. _this._invertRefractionY = false;
  50009. /**
  50010. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50011. * Materials half opaque for instance using refraction could benefit from this control.
  50012. */
  50013. _this._linkRefractionWithTransparency = false;
  50014. /**
  50015. * Specifies that the material will use the light map as a show map.
  50016. */
  50017. _this._useLightmapAsShadowmap = false;
  50018. /**
  50019. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50020. * makes the reflect vector face the model (under horizon).
  50021. */
  50022. _this._useHorizonOcclusion = true;
  50023. /**
  50024. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50025. * too much the area relying on ambient texture to define their ambient occlusion.
  50026. */
  50027. _this._useRadianceOcclusion = true;
  50028. /**
  50029. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50030. */
  50031. _this._useAlphaFromAlbedoTexture = false;
  50032. /**
  50033. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50034. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50035. */
  50036. _this._useSpecularOverAlpha = true;
  50037. /**
  50038. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50039. */
  50040. _this._useMicroSurfaceFromReflectivityMapAlpha = false;
  50041. /**
  50042. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50043. */
  50044. _this._useRoughnessFromMetallicTextureAlpha = true;
  50045. /**
  50046. * Specifies if the metallic texture contains the roughness information in its green channel.
  50047. */
  50048. _this._useRoughnessFromMetallicTextureGreen = false;
  50049. /**
  50050. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50051. */
  50052. _this._useMetallnessFromMetallicTextureBlue = false;
  50053. /**
  50054. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50055. */
  50056. _this._useAmbientOcclusionFromMetallicTextureRed = false;
  50057. /**
  50058. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50059. */
  50060. _this._useAmbientInGrayScale = false;
  50061. /**
  50062. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50063. * The material will try to infer what glossiness each pixel should be.
  50064. */
  50065. _this._useAutoMicroSurfaceFromReflectivityMap = false;
  50066. /**
  50067. * Defines the falloff type used in this material.
  50068. * It by default is Physical.
  50069. */
  50070. _this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL;
  50071. /**
  50072. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50073. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50074. */
  50075. _this._useRadianceOverAlpha = true;
  50076. /**
  50077. * Allows using an object space normal map (instead of tangent space).
  50078. */
  50079. _this._useObjectSpaceNormalMap = false;
  50080. /**
  50081. * Allows using the bump map in parallax mode.
  50082. */
  50083. _this._useParallax = false;
  50084. /**
  50085. * Allows using the bump map in parallax occlusion mode.
  50086. */
  50087. _this._useParallaxOcclusion = false;
  50088. /**
  50089. * Controls the scale bias of the parallax mode.
  50090. */
  50091. _this._parallaxScaleBias = 0.05;
  50092. /**
  50093. * If sets to true, disables all the lights affecting the material.
  50094. */
  50095. _this._disableLighting = false;
  50096. /**
  50097. * Number of Simultaneous lights allowed on the material.
  50098. */
  50099. _this._maxSimultaneousLights = 4;
  50100. /**
  50101. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50102. */
  50103. _this._invertNormalMapX = false;
  50104. /**
  50105. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50106. */
  50107. _this._invertNormalMapY = false;
  50108. /**
  50109. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50110. */
  50111. _this._twoSidedLighting = false;
  50112. /**
  50113. * Defines the alpha limits in alpha test mode.
  50114. */
  50115. _this._alphaCutOff = 0.4;
  50116. /**
  50117. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50118. */
  50119. _this._forceAlphaTest = false;
  50120. /**
  50121. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50122. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50123. */
  50124. _this._useAlphaFresnel = false;
  50125. /**
  50126. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50127. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50128. */
  50129. _this._useLinearAlphaFresnel = false;
  50130. /**
  50131. * The transparency mode of the material.
  50132. */
  50133. _this._transparencyMode = null;
  50134. /**
  50135. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50136. * from cos thetav and roughness:
  50137. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50138. */
  50139. _this._environmentBRDFTexture = null;
  50140. /**
  50141. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50142. */
  50143. _this._forceIrradianceInFragment = false;
  50144. /**
  50145. * Force normal to face away from face.
  50146. */
  50147. _this._forceNormalForward = false;
  50148. /**
  50149. * Enables specular anti aliasing in the PBR shader.
  50150. * It will both interacts on the Geometry for analytical and IBL lighting.
  50151. * It also prefilter the roughness map based on the bump values.
  50152. */
  50153. _this._enableSpecularAntiAliasing = false;
  50154. /**
  50155. * Stores the available render targets.
  50156. */
  50157. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__["SmartArray"](16);
  50158. /**
  50159. * Sets the global ambient color for the material used in lighting calculations.
  50160. */
  50161. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  50162. /**
  50163. * If set to true, no lighting calculations will be applied.
  50164. */
  50165. _this._unlit = false;
  50166. // Setup the default processing configuration to the scene.
  50167. _this._attachImageProcessingConfiguration(null);
  50168. _this.getRenderTargetTextures = function () {
  50169. _this._renderTargets.reset();
  50170. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  50171. _this._renderTargets.push(_this._reflectionTexture);
  50172. }
  50173. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  50174. _this._renderTargets.push(_this._refractionTexture);
  50175. }
  50176. return _this._renderTargets;
  50177. };
  50178. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  50179. return _this;
  50180. }
  50181. /**
  50182. * Attaches a new image processing configuration to the PBR Material.
  50183. * @param configuration
  50184. */
  50185. PBRBaseMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  50186. var _this = this;
  50187. if (configuration === this._imageProcessingConfiguration) {
  50188. return;
  50189. }
  50190. // Detaches observer.
  50191. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50192. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50193. }
  50194. // Pick the scene configuration if needed.
  50195. if (!configuration) {
  50196. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  50197. }
  50198. else {
  50199. this._imageProcessingConfiguration = configuration;
  50200. }
  50201. // Attaches observer.
  50202. if (this._imageProcessingConfiguration) {
  50203. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  50204. _this._markAllSubMeshesAsImageProcessingDirty();
  50205. });
  50206. }
  50207. };
  50208. Object.defineProperty(PBRBaseMaterial.prototype, "hasRenderTargetTextures", {
  50209. /**
  50210. * Gets a boolean indicating that current material needs to register RTT
  50211. */
  50212. get: function () {
  50213. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  50214. return true;
  50215. }
  50216. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  50217. return true;
  50218. }
  50219. return false;
  50220. },
  50221. enumerable: true,
  50222. configurable: true
  50223. });
  50224. /**
  50225. * Gets the name of the material class.
  50226. */
  50227. PBRBaseMaterial.prototype.getClassName = function () {
  50228. return "PBRBaseMaterial";
  50229. };
  50230. Object.defineProperty(PBRBaseMaterial.prototype, "useLogarithmicDepth", {
  50231. /**
  50232. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50233. */
  50234. get: function () {
  50235. return this._useLogarithmicDepth;
  50236. },
  50237. /**
  50238. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50239. */
  50240. set: function (value) {
  50241. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  50242. },
  50243. enumerable: true,
  50244. configurable: true
  50245. });
  50246. Object.defineProperty(PBRBaseMaterial.prototype, "transparencyMode", {
  50247. /**
  50248. * Gets the current transparency mode.
  50249. */
  50250. get: function () {
  50251. return this._transparencyMode;
  50252. },
  50253. /**
  50254. * Sets the transparency mode of the material.
  50255. *
  50256. * | Value | Type | Description |
  50257. * | ----- | ----------------------------------- | ----------- |
  50258. * | 0 | OPAQUE | |
  50259. * | 1 | ALPHATEST | |
  50260. * | 2 | ALPHABLEND | |
  50261. * | 3 | ALPHATESTANDBLEND | |
  50262. *
  50263. */
  50264. set: function (value) {
  50265. if (this._transparencyMode === value) {
  50266. return;
  50267. }
  50268. this._transparencyMode = value;
  50269. this._forceAlphaTest = (value === PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
  50270. this._markAllSubMeshesAsTexturesAndMiscDirty();
  50271. },
  50272. enumerable: true,
  50273. configurable: true
  50274. });
  50275. Object.defineProperty(PBRBaseMaterial.prototype, "_disableAlphaBlending", {
  50276. /**
  50277. * Returns true if alpha blending should be disabled.
  50278. */
  50279. get: function () {
  50280. return (this._linkRefractionWithTransparency ||
  50281. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_OPAQUE ||
  50282. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  50283. },
  50284. enumerable: true,
  50285. configurable: true
  50286. });
  50287. /**
  50288. * Specifies whether or not this material should be rendered in alpha blend mode.
  50289. */
  50290. PBRBaseMaterial.prototype.needAlphaBlending = function () {
  50291. if (this._disableAlphaBlending) {
  50292. return false;
  50293. }
  50294. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromAlbedoTexture();
  50295. };
  50296. /**
  50297. * Specifies if the mesh will require alpha blending.
  50298. * @param mesh - BJS mesh.
  50299. */
  50300. PBRBaseMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
  50301. if (this._disableAlphaBlending) {
  50302. return false;
  50303. }
  50304. return _super.prototype.needAlphaBlendingForMesh.call(this, mesh);
  50305. };
  50306. /**
  50307. * Specifies whether or not this material should be rendered in alpha test mode.
  50308. */
  50309. PBRBaseMaterial.prototype.needAlphaTesting = function () {
  50310. if (this._forceAlphaTest) {
  50311. return true;
  50312. }
  50313. if (this._linkRefractionWithTransparency) {
  50314. return false;
  50315. }
  50316. return this._albedoTexture != null && this._albedoTexture.hasAlpha && (this._transparencyMode == null || this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  50317. };
  50318. /**
  50319. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50320. */
  50321. PBRBaseMaterial.prototype._shouldUseAlphaFromAlbedoTexture = function () {
  50322. return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE;
  50323. };
  50324. /**
  50325. * Gets the texture used for the alpha test.
  50326. */
  50327. PBRBaseMaterial.prototype.getAlphaTestTexture = function () {
  50328. return this._albedoTexture;
  50329. };
  50330. /**
  50331. * Specifies that the submesh is ready to be used.
  50332. * @param mesh - BJS mesh.
  50333. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50334. * @param useInstances - Specifies that instances should be used.
  50335. * @returns - boolean indicating that the submesh is ready or not.
  50336. */
  50337. PBRBaseMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  50338. if (subMesh.effect && this.isFrozen) {
  50339. if (this._wasPreviouslyReady) {
  50340. return true;
  50341. }
  50342. }
  50343. if (!subMesh._materialDefines) {
  50344. subMesh._materialDefines = new PBRMaterialDefines();
  50345. }
  50346. var defines = subMesh._materialDefines;
  50347. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  50348. if (defines._renderId === this.getScene().getRenderId()) {
  50349. return true;
  50350. }
  50351. }
  50352. var scene = this.getScene();
  50353. var engine = scene.getEngine();
  50354. if (defines._areTexturesDirty) {
  50355. if (scene.texturesEnabled) {
  50356. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50357. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  50358. return false;
  50359. }
  50360. }
  50361. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  50362. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  50363. return false;
  50364. }
  50365. }
  50366. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  50367. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  50368. return false;
  50369. }
  50370. }
  50371. var reflectionTexture = this._getReflectionTexture();
  50372. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50373. if (!reflectionTexture.isReadyOrNotBlocking()) {
  50374. return false;
  50375. }
  50376. }
  50377. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  50378. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  50379. return false;
  50380. }
  50381. }
  50382. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  50383. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  50384. return false;
  50385. }
  50386. }
  50387. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  50388. if (this._metallicTexture) {
  50389. if (!this._metallicTexture.isReadyOrNotBlocking()) {
  50390. return false;
  50391. }
  50392. }
  50393. else if (this._reflectivityTexture) {
  50394. if (!this._reflectivityTexture.isReadyOrNotBlocking()) {
  50395. return false;
  50396. }
  50397. }
  50398. if (this._microSurfaceTexture) {
  50399. if (!this._microSurfaceTexture.isReadyOrNotBlocking()) {
  50400. return false;
  50401. }
  50402. }
  50403. }
  50404. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  50405. // Bump texture cannot be not blocking.
  50406. if (!this._bumpTexture.isReady()) {
  50407. return false;
  50408. }
  50409. }
  50410. var refractionTexture = this._getRefractionTexture();
  50411. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  50412. if (!refractionTexture.isReadyOrNotBlocking()) {
  50413. return false;
  50414. }
  50415. }
  50416. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50417. // This is blocking.
  50418. if (!this._environmentBRDFTexture.isReady()) {
  50419. return false;
  50420. }
  50421. }
  50422. }
  50423. }
  50424. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  50425. if (!this._imageProcessingConfiguration.isReady()) {
  50426. return false;
  50427. }
  50428. }
  50429. if (!engine.getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  50430. mesh.createNormals(true);
  50431. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
  50432. }
  50433. var previousEffect = subMesh.effect;
  50434. var effect = this._prepareEffect(mesh, defines, this.onCompiled, this.onError, useInstances);
  50435. if (effect) {
  50436. // Use previous effect while new one is compiling
  50437. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  50438. effect = previousEffect;
  50439. defines.markAsUnprocessed();
  50440. }
  50441. else {
  50442. scene.resetCachedMaterial();
  50443. subMesh.setEffect(effect, defines);
  50444. this.buildUniformLayout();
  50445. }
  50446. }
  50447. if (!subMesh.effect || !subMesh.effect.isReady()) {
  50448. return false;
  50449. }
  50450. defines._renderId = scene.getRenderId();
  50451. this._wasPreviouslyReady = true;
  50452. return true;
  50453. };
  50454. /**
  50455. * Specifies if the material uses metallic roughness workflow.
  50456. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50457. */
  50458. PBRBaseMaterial.prototype.isMetallicWorkflow = function () {
  50459. if (this._metallic != null || this._roughness != null || this._metallicTexture) {
  50460. return true;
  50461. }
  50462. return false;
  50463. };
  50464. PBRBaseMaterial.prototype._prepareEffect = function (mesh, defines, onCompiled, onError, useInstances, useClipPlane) {
  50465. if (onCompiled === void 0) { onCompiled = null; }
  50466. if (onError === void 0) { onError = null; }
  50467. if (useInstances === void 0) { useInstances = null; }
  50468. if (useClipPlane === void 0) { useClipPlane = null; }
  50469. this._prepareDefines(mesh, defines, useInstances, useClipPlane);
  50470. if (!defines.isDirty) {
  50471. return null;
  50472. }
  50473. defines.markAsProcessed();
  50474. var scene = this.getScene();
  50475. var engine = scene.getEngine();
  50476. // Fallbacks
  50477. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["EffectFallbacks"]();
  50478. var fallbackRank = 0;
  50479. if (defines.USESPHERICALINVERTEX) {
  50480. fallbacks.addFallback(fallbackRank++, "USESPHERICALINVERTEX");
  50481. }
  50482. if (defines.FOG) {
  50483. fallbacks.addFallback(fallbackRank, "FOG");
  50484. }
  50485. if (defines.SPECULARAA) {
  50486. fallbacks.addFallback(fallbackRank, "SPECULARAA");
  50487. }
  50488. if (defines.POINTSIZE) {
  50489. fallbacks.addFallback(fallbackRank, "POINTSIZE");
  50490. }
  50491. if (defines.LOGARITHMICDEPTH) {
  50492. fallbacks.addFallback(fallbackRank, "LOGARITHMICDEPTH");
  50493. }
  50494. if (defines.PARALLAX) {
  50495. fallbacks.addFallback(fallbackRank, "PARALLAX");
  50496. }
  50497. if (defines.PARALLAXOCCLUSION) {
  50498. fallbacks.addFallback(fallbackRank++, "PARALLAXOCCLUSION");
  50499. }
  50500. if (defines.ENVIRONMENTBRDF) {
  50501. fallbacks.addFallback(fallbackRank++, "ENVIRONMENTBRDF");
  50502. }
  50503. if (defines.TANGENT) {
  50504. fallbacks.addFallback(fallbackRank++, "TANGENT");
  50505. }
  50506. if (defines.BUMP) {
  50507. fallbacks.addFallback(fallbackRank++, "BUMP");
  50508. }
  50509. fallbackRank = _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights, fallbackRank++);
  50510. if (defines.SPECULARTERM) {
  50511. fallbacks.addFallback(fallbackRank++, "SPECULARTERM");
  50512. }
  50513. if (defines.USESPHERICALFROMREFLECTIONMAP) {
  50514. fallbacks.addFallback(fallbackRank++, "USESPHERICALFROMREFLECTIONMAP");
  50515. }
  50516. if (defines.LIGHTMAP) {
  50517. fallbacks.addFallback(fallbackRank++, "LIGHTMAP");
  50518. }
  50519. if (defines.NORMAL) {
  50520. fallbacks.addFallback(fallbackRank++, "NORMAL");
  50521. }
  50522. if (defines.AMBIENT) {
  50523. fallbacks.addFallback(fallbackRank++, "AMBIENT");
  50524. }
  50525. if (defines.EMISSIVE) {
  50526. fallbacks.addFallback(fallbackRank++, "EMISSIVE");
  50527. }
  50528. if (defines.VERTEXCOLOR) {
  50529. fallbacks.addFallback(fallbackRank++, "VERTEXCOLOR");
  50530. }
  50531. if (defines.NUM_BONE_INFLUENCERS > 0) {
  50532. fallbacks.addCPUSkinningFallback(fallbackRank++, mesh);
  50533. }
  50534. if (defines.MORPHTARGETS) {
  50535. fallbacks.addFallback(fallbackRank++, "MORPHTARGETS");
  50536. }
  50537. //Attributes
  50538. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  50539. if (defines.NORMAL) {
  50540. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  50541. }
  50542. if (defines.TANGENT) {
  50543. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind);
  50544. }
  50545. if (defines.UV1) {
  50546. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  50547. }
  50548. if (defines.UV2) {
  50549. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  50550. }
  50551. if (defines.VERTEXCOLOR) {
  50552. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  50553. }
  50554. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  50555. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  50556. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  50557. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vEmissiveColor", "vReflectionColor",
  50558. "vFogInfos", "vFogColor", "pointSize",
  50559. "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos",
  50560. "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  50561. "mBones",
  50562. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix", "refractionMatrix",
  50563. "vLightingIntensity",
  50564. "logarithmicDepthConstant",
  50565. "vSphericalX", "vSphericalY", "vSphericalZ",
  50566. "vSphericalXX", "vSphericalYY", "vSphericalZZ",
  50567. "vSphericalXY", "vSphericalYZ", "vSphericalZX",
  50568. "vReflectionMicrosurfaceInfos", "vRefractionMicrosurfaceInfos",
  50569. "vTangentSpaceParams", "boneTextureWidth"
  50570. ];
  50571. var samplers = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler",
  50572. "bumpSampler", "lightmapSampler", "opacitySampler",
  50573. "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh",
  50574. "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh",
  50575. "microSurfaceSampler", "environmentBrdfSampler", "boneSampler"];
  50576. var uniformBuffers = ["Material", "Scene"];
  50577. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"]) {
  50578. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  50579. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  50580. }
  50581. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareUniformsAndSamplersList({
  50582. uniformsNames: uniforms,
  50583. uniformBuffersNames: uniformBuffers,
  50584. samplers: samplers,
  50585. defines: defines,
  50586. maxSimultaneousLights: this._maxSimultaneousLights
  50587. });
  50588. var join = defines.toString();
  50589. return engine.createEffect("pbr", {
  50590. attributes: attribs,
  50591. uniformsNames: uniforms,
  50592. uniformBuffersNames: uniformBuffers,
  50593. samplers: samplers,
  50594. defines: join,
  50595. fallbacks: fallbacks,
  50596. onCompiled: onCompiled,
  50597. onError: onError,
  50598. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  50599. }, engine);
  50600. };
  50601. PBRBaseMaterial.prototype._prepareDefines = function (mesh, defines, useInstances, useClipPlane) {
  50602. if (useInstances === void 0) { useInstances = null; }
  50603. if (useClipPlane === void 0) { useClipPlane = null; }
  50604. var scene = this.getScene();
  50605. var engine = scene.getEngine();
  50606. // Lights
  50607. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  50608. defines._needNormals = true;
  50609. // Textures
  50610. defines.METALLICWORKFLOW = this.isMetallicWorkflow();
  50611. if (defines._areTexturesDirty) {
  50612. defines._needUVs = false;
  50613. if (scene.texturesEnabled) {
  50614. if (scene.getEngine().getCaps().textureLOD) {
  50615. defines.LODBASEDMICROSFURACE = true;
  50616. }
  50617. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50618. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._albedoTexture, defines, "ALBEDO");
  50619. }
  50620. else {
  50621. defines.ALBEDO = false;
  50622. }
  50623. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  50624. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  50625. defines.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale;
  50626. }
  50627. else {
  50628. defines.AMBIENT = false;
  50629. }
  50630. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  50631. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  50632. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  50633. }
  50634. else {
  50635. defines.OPACITY = false;
  50636. }
  50637. var reflectionTexture = this._getReflectionTexture();
  50638. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50639. defines.REFLECTION = true;
  50640. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  50641. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  50642. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  50643. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  50644. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].INVCUBIC_MODE) {
  50645. defines.INVERTCUBICMAP = true;
  50646. }
  50647. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  50648. defines.REFLECTIONMAP_CUBIC = false;
  50649. defines.REFLECTIONMAP_EXPLICIT = false;
  50650. defines.REFLECTIONMAP_PLANAR = false;
  50651. defines.REFLECTIONMAP_PROJECTION = false;
  50652. defines.REFLECTIONMAP_SKYBOX = false;
  50653. defines.REFLECTIONMAP_SPHERICAL = false;
  50654. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  50655. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  50656. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  50657. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  50658. switch (reflectionTexture.coordinatesMode) {
  50659. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].EXPLICIT_MODE:
  50660. defines.REFLECTIONMAP_EXPLICIT = true;
  50661. break;
  50662. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].PLANAR_MODE:
  50663. defines.REFLECTIONMAP_PLANAR = true;
  50664. break;
  50665. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].PROJECTION_MODE:
  50666. defines.REFLECTIONMAP_PROJECTION = true;
  50667. break;
  50668. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SKYBOX_MODE:
  50669. defines.REFLECTIONMAP_SKYBOX = true;
  50670. break;
  50671. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SPHERICAL_MODE:
  50672. defines.REFLECTIONMAP_SPHERICAL = true;
  50673. break;
  50674. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].EQUIRECTANGULAR_MODE:
  50675. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  50676. break;
  50677. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  50678. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  50679. break;
  50680. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  50681. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  50682. break;
  50683. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].CUBIC_MODE:
  50684. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].INVCUBIC_MODE:
  50685. default:
  50686. defines.REFLECTIONMAP_CUBIC = true;
  50687. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = reflectionTexture.boundingBoxSize ? true : false;
  50688. break;
  50689. }
  50690. if (reflectionTexture.coordinatesMode !== _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SKYBOX_MODE) {
  50691. if (reflectionTexture.sphericalPolynomial) {
  50692. defines.USESPHERICALFROMREFLECTIONMAP = true;
  50693. if (this._forceIrradianceInFragment || scene.getEngine().getCaps().maxVaryingVectors <= 8) {
  50694. defines.USESPHERICALINVERTEX = false;
  50695. }
  50696. else {
  50697. defines.USESPHERICALINVERTEX = true;
  50698. }
  50699. }
  50700. }
  50701. else {
  50702. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  50703. }
  50704. }
  50705. else {
  50706. defines.REFLECTION = false;
  50707. defines.REFLECTIONMAP_3D = false;
  50708. defines.REFLECTIONMAP_SPHERICAL = false;
  50709. defines.REFLECTIONMAP_PLANAR = false;
  50710. defines.REFLECTIONMAP_CUBIC = false;
  50711. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  50712. defines.REFLECTIONMAP_PROJECTION = false;
  50713. defines.REFLECTIONMAP_SKYBOX = false;
  50714. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  50715. defines.REFLECTIONMAP_EXPLICIT = false;
  50716. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  50717. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  50718. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  50719. defines.INVERTCUBICMAP = false;
  50720. defines.USESPHERICALFROMREFLECTIONMAP = false;
  50721. defines.USESPHERICALINVERTEX = false;
  50722. defines.REFLECTIONMAP_OPPOSITEZ = false;
  50723. defines.LODINREFLECTIONALPHA = false;
  50724. defines.GAMMAREFLECTION = false;
  50725. defines.RGBDREFLECTION = false;
  50726. }
  50727. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  50728. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  50729. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  50730. defines.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace;
  50731. }
  50732. else {
  50733. defines.LIGHTMAP = false;
  50734. }
  50735. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  50736. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  50737. }
  50738. else {
  50739. defines.EMISSIVE = false;
  50740. }
  50741. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  50742. if (this._metallicTexture) {
  50743. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._metallicTexture, defines, "REFLECTIVITY");
  50744. defines.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha;
  50745. defines.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen;
  50746. defines.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue;
  50747. defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;
  50748. }
  50749. else if (this._reflectivityTexture) {
  50750. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._reflectivityTexture, defines, "REFLECTIVITY");
  50751. defines.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha;
  50752. defines.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap;
  50753. }
  50754. else {
  50755. defines.REFLECTIVITY = false;
  50756. }
  50757. if (this._microSurfaceTexture) {
  50758. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._microSurfaceTexture, defines, "MICROSURFACEMAP");
  50759. }
  50760. else {
  50761. defines.MICROSURFACEMAP = false;
  50762. }
  50763. }
  50764. else {
  50765. defines.REFLECTIVITY = false;
  50766. defines.MICROSURFACEMAP = false;
  50767. }
  50768. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  50769. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  50770. if (this._useParallax && this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50771. defines.PARALLAX = true;
  50772. defines.PARALLAXOCCLUSION = !!this._useParallaxOcclusion;
  50773. }
  50774. else {
  50775. defines.PARALLAX = false;
  50776. }
  50777. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  50778. }
  50779. else {
  50780. defines.BUMP = false;
  50781. }
  50782. var refractionTexture = this._getRefractionTexture();
  50783. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  50784. defines.REFRACTION = true;
  50785. defines.REFRACTIONMAP_3D = refractionTexture.isCube;
  50786. defines.GAMMAREFRACTION = refractionTexture.gammaSpace;
  50787. defines.RGBDREFRACTION = refractionTexture.isRGBD;
  50788. defines.REFRACTIONMAP_OPPOSITEZ = refractionTexture.invertZ;
  50789. defines.LODINREFRACTIONALPHA = refractionTexture.lodLevelInAlpha;
  50790. if (this._linkRefractionWithTransparency) {
  50791. defines.LINKREFRACTIONTOTRANSPARENCY = true;
  50792. }
  50793. }
  50794. else {
  50795. defines.REFRACTION = false;
  50796. }
  50797. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50798. defines.ENVIRONMENTBRDF = true;
  50799. }
  50800. else {
  50801. defines.ENVIRONMENTBRDF = false;
  50802. }
  50803. if (this._shouldUseAlphaFromAlbedoTexture()) {
  50804. defines.ALPHAFROMALBEDO = true;
  50805. }
  50806. else {
  50807. defines.ALPHAFROMALBEDO = false;
  50808. }
  50809. }
  50810. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  50811. if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD) {
  50812. defines.USEPHYSICALLIGHTFALLOFF = false;
  50813. defines.USEGLTFLIGHTFALLOFF = false;
  50814. }
  50815. else if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF) {
  50816. defines.USEPHYSICALLIGHTFALLOFF = false;
  50817. defines.USEGLTFLIGHTFALLOFF = true;
  50818. }
  50819. else {
  50820. defines.USEPHYSICALLIGHTFALLOFF = true;
  50821. defines.USEGLTFLIGHTFALLOFF = false;
  50822. }
  50823. defines.RADIANCEOVERALPHA = this._useRadianceOverAlpha;
  50824. if (!this.backFaceCulling && this._twoSidedLighting) {
  50825. defines.TWOSIDEDLIGHTING = true;
  50826. }
  50827. else {
  50828. defines.TWOSIDEDLIGHTING = false;
  50829. }
  50830. defines.ALPHATESTVALUE = "" + this._alphaCutOff + (this._alphaCutOff % 1 === 0 ? "." : "");
  50831. 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);
  50832. defines.ALPHABLEND = this.needAlphaBlendingForMesh(mesh);
  50833. defines.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel;
  50834. defines.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel;
  50835. defines.SPECULARAA = scene.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
  50836. }
  50837. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  50838. this._imageProcessingConfiguration.prepareDefines(defines);
  50839. }
  50840. defines.FORCENORMALFORWARD = this._forceNormalForward;
  50841. defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
  50842. defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
  50843. // Misc.
  50844. if (defines._areMiscDirty) {
  50845. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
  50846. defines.UNLIT = this._unlit || ((this.pointsCloud || this.wireframe) && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind));
  50847. }
  50848. // Values that need to be evaluated on every frame
  50849. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, useClipPlane);
  50850. // Attribs
  50851. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE);
  50852. };
  50853. /**
  50854. * Force shader compilation
  50855. */
  50856. PBRBaseMaterial.prototype.forceCompilation = function (mesh, onCompiled, options) {
  50857. var _this = this;
  50858. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  50859. var defines = new PBRMaterialDefines();
  50860. var effect = this._prepareEffect(mesh, defines, undefined, undefined, undefined, localOptions.clipPlane);
  50861. if (effect.isReady()) {
  50862. if (onCompiled) {
  50863. onCompiled(this);
  50864. }
  50865. }
  50866. else {
  50867. effect.onCompileObservable.add(function () {
  50868. if (onCompiled) {
  50869. onCompiled(_this);
  50870. }
  50871. });
  50872. }
  50873. };
  50874. /**
  50875. * Initializes the uniform buffer layout for the shader.
  50876. */
  50877. PBRBaseMaterial.prototype.buildUniformLayout = function () {
  50878. // Order is important !
  50879. this._uniformBuffer.addUniform("vAlbedoInfos", 2);
  50880. this._uniformBuffer.addUniform("vAmbientInfos", 4);
  50881. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  50882. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  50883. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  50884. this._uniformBuffer.addUniform("vReflectivityInfos", 3);
  50885. this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos", 2);
  50886. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  50887. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  50888. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  50889. this._uniformBuffer.addUniform("vReflectionSize", 3);
  50890. this._uniformBuffer.addUniform("vBumpInfos", 3);
  50891. this._uniformBuffer.addUniform("albedoMatrix", 16);
  50892. this._uniformBuffer.addUniform("ambientMatrix", 16);
  50893. this._uniformBuffer.addUniform("opacityMatrix", 16);
  50894. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  50895. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  50896. this._uniformBuffer.addUniform("reflectivityMatrix", 16);
  50897. this._uniformBuffer.addUniform("microSurfaceSamplerMatrix", 16);
  50898. this._uniformBuffer.addUniform("bumpMatrix", 16);
  50899. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  50900. this._uniformBuffer.addUniform("refractionMatrix", 16);
  50901. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  50902. this._uniformBuffer.addUniform("vReflectionColor", 3);
  50903. this._uniformBuffer.addUniform("vAlbedoColor", 4);
  50904. this._uniformBuffer.addUniform("vLightingIntensity", 4);
  50905. this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos", 3);
  50906. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  50907. this._uniformBuffer.addUniform("vReflectivityColor", 4);
  50908. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  50909. this._uniformBuffer.addUniform("pointSize", 1);
  50910. this._uniformBuffer.create();
  50911. };
  50912. /**
  50913. * Unbinds the textures.
  50914. */
  50915. PBRBaseMaterial.prototype.unbind = function () {
  50916. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  50917. this._uniformBuffer.setTexture("reflectionSampler", null);
  50918. }
  50919. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  50920. this._uniformBuffer.setTexture("refractionSampler", null);
  50921. }
  50922. _super.prototype.unbind.call(this);
  50923. };
  50924. /**
  50925. * Binds the submesh data.
  50926. * @param world - The world matrix.
  50927. * @param mesh - The BJS mesh.
  50928. * @param subMesh - A submesh of the BJS mesh.
  50929. */
  50930. PBRBaseMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  50931. var scene = this.getScene();
  50932. var defines = subMesh._materialDefines;
  50933. if (!defines) {
  50934. return;
  50935. }
  50936. var effect = subMesh.effect;
  50937. if (!effect) {
  50938. return;
  50939. }
  50940. this._activeEffect = effect;
  50941. // Matrices
  50942. this.bindOnlyWorldMatrix(world);
  50943. // Normal Matrix
  50944. if (defines.OBJECTSPACE_NORMALMAP) {
  50945. world.toNormalMatrix(this._normalMatrix);
  50946. this.bindOnlyNormalMatrix(this._normalMatrix);
  50947. }
  50948. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  50949. // Bones
  50950. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  50951. var reflectionTexture = null;
  50952. if (mustRebind) {
  50953. this._uniformBuffer.bindToEffect(effect, "Material");
  50954. this.bindViewProjection(effect);
  50955. reflectionTexture = this._getReflectionTexture();
  50956. var refractionTexture = this._getRefractionTexture();
  50957. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  50958. // Texture uniforms
  50959. if (scene.texturesEnabled) {
  50960. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50961. this._uniformBuffer.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level);
  50962. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._albedoTexture, this._uniformBuffer, "albedo");
  50963. }
  50964. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  50965. this._uniformBuffer.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights);
  50966. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  50967. }
  50968. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  50969. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  50970. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  50971. }
  50972. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50973. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  50974. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, 0);
  50975. if (reflectionTexture.boundingBoxSize) {
  50976. var cubeTexture = reflectionTexture;
  50977. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  50978. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  50979. }
  50980. var polynomials = reflectionTexture.sphericalPolynomial;
  50981. if (defines.USESPHERICALFROMREFLECTIONMAP && polynomials) {
  50982. this._activeEffect.setFloat3("vSphericalX", polynomials.x.x, polynomials.x.y, polynomials.x.z);
  50983. this._activeEffect.setFloat3("vSphericalY", polynomials.y.x, polynomials.y.y, polynomials.y.z);
  50984. this._activeEffect.setFloat3("vSphericalZ", polynomials.z.x, polynomials.z.y, polynomials.z.z);
  50985. this._activeEffect.setFloat3("vSphericalXX_ZZ", polynomials.xx.x - polynomials.zz.x, polynomials.xx.y - polynomials.zz.y, polynomials.xx.z - polynomials.zz.z);
  50986. this._activeEffect.setFloat3("vSphericalYY_ZZ", polynomials.yy.x - polynomials.zz.x, polynomials.yy.y - polynomials.zz.y, polynomials.yy.z - polynomials.zz.z);
  50987. this._activeEffect.setFloat3("vSphericalZZ", polynomials.zz.x, polynomials.zz.y, polynomials.zz.z);
  50988. this._activeEffect.setFloat3("vSphericalXY", polynomials.xy.x, polynomials.xy.y, polynomials.xy.z);
  50989. this._activeEffect.setFloat3("vSphericalYZ", polynomials.yz.x, polynomials.yz.y, polynomials.yz.z);
  50990. this._activeEffect.setFloat3("vSphericalZX", polynomials.zx.x, polynomials.zx.y, polynomials.zx.z);
  50991. }
  50992. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  50993. }
  50994. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  50995. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  50996. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  50997. }
  50998. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  50999. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  51000. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  51001. }
  51002. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  51003. if (this._metallicTexture) {
  51004. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength);
  51005. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._metallicTexture, this._uniformBuffer, "reflectivity");
  51006. }
  51007. else if (this._reflectivityTexture) {
  51008. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1.0);
  51009. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._reflectivityTexture, this._uniformBuffer, "reflectivity");
  51010. }
  51011. if (this._microSurfaceTexture) {
  51012. this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level);
  51013. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._microSurfaceTexture, this._uniformBuffer, "microSurfaceSampler");
  51014. }
  51015. }
  51016. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51017. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias);
  51018. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  51019. if (scene._mirroredCameraPosition) {
  51020. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  51021. }
  51022. else {
  51023. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  51024. }
  51025. }
  51026. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  51027. this._uniformBuffer.updateMatrix("refractionMatrix", refractionTexture.getReflectionTextureMatrix());
  51028. var depth = 1.0;
  51029. if (!refractionTexture.isCube) {
  51030. if (refractionTexture.depth) {
  51031. depth = refractionTexture.depth;
  51032. }
  51033. }
  51034. this._uniformBuffer.updateFloat4("vRefractionInfos", refractionTexture.level, this._indexOfRefraction, depth, this._invertRefractionY ? -1 : 1);
  51035. this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos", refractionTexture.getSize().width, refractionTexture.lodGenerationScale, refractionTexture.lodGenerationOffset);
  51036. }
  51037. }
  51038. // Point size
  51039. if (this.pointsCloud) {
  51040. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  51041. }
  51042. // Colors
  51043. if (defines.METALLICWORKFLOW) {
  51044. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].r = (this._metallic === undefined || this._metallic === null) ? 1 : this._metallic;
  51045. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].g = (this._roughness === undefined || this._roughness === null) ? 1 : this._roughness;
  51046. this._uniformBuffer.updateColor4("vReflectivityColor", _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0], 0);
  51047. }
  51048. else {
  51049. this._uniformBuffer.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
  51050. }
  51051. this._uniformBuffer.updateColor3("vEmissiveColor", _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled ? this._emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"].BlackReadOnly);
  51052. this._uniformBuffer.updateColor3("vReflectionColor", this._reflectionColor);
  51053. this._uniformBuffer.updateColor4("vAlbedoColor", this._albedoColor, this.alpha * mesh.visibility);
  51054. // Misc
  51055. this._lightingInfos.x = this._directIntensity;
  51056. this._lightingInfos.y = this._emissiveIntensity;
  51057. this._lightingInfos.z = this._environmentIntensity;
  51058. this._lightingInfos.w = this._specularIntensity;
  51059. this._uniformBuffer.updateVector4("vLightingIntensity", this._lightingInfos);
  51060. }
  51061. // Textures
  51062. if (scene.texturesEnabled) {
  51063. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51064. this._uniformBuffer.setTexture("albedoSampler", this._albedoTexture);
  51065. }
  51066. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  51067. this._uniformBuffer.setTexture("ambientSampler", this._ambientTexture);
  51068. }
  51069. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  51070. this._uniformBuffer.setTexture("opacitySampler", this._opacityTexture);
  51071. }
  51072. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51073. if (defines.LODBASEDMICROSFURACE) {
  51074. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  51075. }
  51076. else {
  51077. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  51078. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  51079. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  51080. }
  51081. }
  51082. if (defines.ENVIRONMENTBRDF) {
  51083. this._uniformBuffer.setTexture("environmentBrdfSampler", this._environmentBRDFTexture);
  51084. }
  51085. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  51086. if (defines.LODBASEDMICROSFURACE) {
  51087. this._uniformBuffer.setTexture("refractionSampler", refractionTexture);
  51088. }
  51089. else {
  51090. this._uniformBuffer.setTexture("refractionSampler", refractionTexture._lodTextureMid || refractionTexture);
  51091. this._uniformBuffer.setTexture("refractionSamplerLow", refractionTexture._lodTextureLow || refractionTexture);
  51092. this._uniformBuffer.setTexture("refractionSamplerHigh", refractionTexture._lodTextureHigh || refractionTexture);
  51093. }
  51094. }
  51095. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  51096. this._uniformBuffer.setTexture("emissiveSampler", this._emissiveTexture);
  51097. }
  51098. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  51099. this._uniformBuffer.setTexture("lightmapSampler", this._lightmapTexture);
  51100. }
  51101. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  51102. if (this._metallicTexture) {
  51103. this._uniformBuffer.setTexture("reflectivitySampler", this._metallicTexture);
  51104. }
  51105. else if (this._reflectivityTexture) {
  51106. this._uniformBuffer.setTexture("reflectivitySampler", this._reflectivityTexture);
  51107. }
  51108. if (this._microSurfaceTexture) {
  51109. this._uniformBuffer.setTexture("microSurfaceSampler", this._microSurfaceTexture);
  51110. }
  51111. }
  51112. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51113. this._uniformBuffer.setTexture("bumpSampler", this._bumpTexture);
  51114. }
  51115. }
  51116. // Clip plane
  51117. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  51118. // Colors
  51119. scene.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor);
  51120. var eyePosition = scene._forcedViewPosition ? scene._forcedViewPosition : (scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  51121. var invertNormal = (scene.useRightHandedSystem === (scene._mirroredCameraPosition != null));
  51122. effect.setFloat4("vEyePosition", eyePosition.x, eyePosition.y, eyePosition.z, invertNormal ? -1 : 1);
  51123. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  51124. }
  51125. if (mustRebind || !this.isFrozen) {
  51126. // Lights
  51127. if (scene.lightsEnabled && !this._disableLighting) {
  51128. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, this._lightFalloff !== PBRBaseMaterial.LIGHTFALLOFF_STANDARD);
  51129. }
  51130. // View
  51131. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].FOGMODE_NONE || reflectionTexture) {
  51132. this.bindView(effect);
  51133. }
  51134. // Fog
  51135. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  51136. // Morph targets
  51137. if (defines.NUM_MORPH_INFLUENCERS) {
  51138. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindMorphTargetParameters(mesh, this._activeEffect);
  51139. }
  51140. // image processing
  51141. this._imageProcessingConfiguration.bind(this._activeEffect);
  51142. // Log. depth
  51143. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindLogDepth(defines, this._activeEffect, scene);
  51144. }
  51145. this._uniformBuffer.update();
  51146. this._afterBind(mesh, this._activeEffect);
  51147. };
  51148. /**
  51149. * Returns the animatable textures.
  51150. * @returns - Array of animatable textures.
  51151. */
  51152. PBRBaseMaterial.prototype.getAnimatables = function () {
  51153. var results = [];
  51154. if (this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0) {
  51155. results.push(this._albedoTexture);
  51156. }
  51157. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  51158. results.push(this._ambientTexture);
  51159. }
  51160. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  51161. results.push(this._opacityTexture);
  51162. }
  51163. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  51164. results.push(this._reflectionTexture);
  51165. }
  51166. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  51167. results.push(this._emissiveTexture);
  51168. }
  51169. if (this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0) {
  51170. results.push(this._metallicTexture);
  51171. }
  51172. else if (this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0) {
  51173. results.push(this._reflectivityTexture);
  51174. }
  51175. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  51176. results.push(this._bumpTexture);
  51177. }
  51178. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  51179. results.push(this._lightmapTexture);
  51180. }
  51181. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  51182. results.push(this._refractionTexture);
  51183. }
  51184. return results;
  51185. };
  51186. /**
  51187. * Returns the texture used for reflections.
  51188. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51189. */
  51190. PBRBaseMaterial.prototype._getReflectionTexture = function () {
  51191. if (this._reflectionTexture) {
  51192. return this._reflectionTexture;
  51193. }
  51194. return this.getScene().environmentTexture;
  51195. };
  51196. /**
  51197. * Returns the texture used for refraction or null if none is used.
  51198. * @returns - Refection texture if present. If no refraction texture and refraction
  51199. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51200. */
  51201. PBRBaseMaterial.prototype._getRefractionTexture = function () {
  51202. if (this._refractionTexture) {
  51203. return this._refractionTexture;
  51204. }
  51205. if (this._linkRefractionWithTransparency) {
  51206. return this.getScene().environmentTexture;
  51207. }
  51208. return null;
  51209. };
  51210. /**
  51211. * Disposes the resources of the material.
  51212. * @param forceDisposeEffect - Forces the disposal of effects.
  51213. * @param forceDisposeTextures - Forces the disposal of all textures.
  51214. */
  51215. PBRBaseMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  51216. if (forceDisposeTextures) {
  51217. if (this._albedoTexture) {
  51218. this._albedoTexture.dispose();
  51219. }
  51220. if (this._ambientTexture) {
  51221. this._ambientTexture.dispose();
  51222. }
  51223. if (this._opacityTexture) {
  51224. this._opacityTexture.dispose();
  51225. }
  51226. if (this._reflectionTexture) {
  51227. this._reflectionTexture.dispose();
  51228. }
  51229. if (this._environmentBRDFTexture && this.getScene()._environmentBRDFTexture !== this._environmentBRDFTexture) {
  51230. this._environmentBRDFTexture.dispose();
  51231. }
  51232. if (this._emissiveTexture) {
  51233. this._emissiveTexture.dispose();
  51234. }
  51235. if (this._metallicTexture) {
  51236. this._metallicTexture.dispose();
  51237. }
  51238. if (this._reflectivityTexture) {
  51239. this._reflectivityTexture.dispose();
  51240. }
  51241. if (this._bumpTexture) {
  51242. this._bumpTexture.dispose();
  51243. }
  51244. if (this._lightmapTexture) {
  51245. this._lightmapTexture.dispose();
  51246. }
  51247. if (this._refractionTexture) {
  51248. this._refractionTexture.dispose();
  51249. }
  51250. }
  51251. this._renderTargets.dispose();
  51252. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  51253. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  51254. }
  51255. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  51256. };
  51257. /**
  51258. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51259. */
  51260. PBRBaseMaterial.PBRMATERIAL_OPAQUE = 0;
  51261. /**
  51262. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51263. */
  51264. PBRBaseMaterial.PBRMATERIAL_ALPHATEST = 1;
  51265. /**
  51266. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51267. */
  51268. PBRBaseMaterial.PBRMATERIAL_ALPHABLEND = 2;
  51269. /**
  51270. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51271. * They are also discarded below the alpha cutoff threshold to improve performances.
  51272. */
  51273. PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND = 3;
  51274. /**
  51275. * Defines the default value of how much AO map is occluding the analytical lights
  51276. * (point spot...).
  51277. */
  51278. PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 1;
  51279. /**
  51280. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51281. */
  51282. PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL = 0;
  51283. /**
  51284. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51285. * to enhance interoperability with other engines.
  51286. */
  51287. PBRBaseMaterial.LIGHTFALLOFF_GLTF = 1;
  51288. /**
  51289. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51290. * to enhance interoperability with other materials.
  51291. */
  51292. PBRBaseMaterial.LIGHTFALLOFF_STANDARD = 2;
  51293. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51294. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  51295. ], PBRBaseMaterial.prototype, "_imageProcessingConfiguration", void 0);
  51296. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51297. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51298. ], PBRBaseMaterial.prototype, "useLogarithmicDepth", null);
  51299. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51300. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51301. ], PBRBaseMaterial.prototype, "transparencyMode", null);
  51302. return PBRBaseMaterial;
  51303. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_11__["PushMaterial"]));
  51304. /***/ }),
  51305. /***/ "./Materials/PBR/pbrBaseSimpleMaterial.ts":
  51306. /*!************************************************!*\
  51307. !*** ./Materials/PBR/pbrBaseSimpleMaterial.ts ***!
  51308. \************************************************/
  51309. /*! exports provided: PBRBaseSimpleMaterial */
  51310. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51311. "use strict";
  51312. __webpack_require__.r(__webpack_exports__);
  51313. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return PBRBaseSimpleMaterial; });
  51314. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51315. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51316. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  51317. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  51318. /**
  51319. * The Physically based simple base material of BJS.
  51320. *
  51321. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51322. * It is used as the base class for both the specGloss and metalRough conventions.
  51323. */
  51324. var PBRBaseSimpleMaterial = /** @class */ (function (_super) {
  51325. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseSimpleMaterial, _super);
  51326. /**
  51327. * Instantiates a new PBRMaterial instance.
  51328. *
  51329. * @param name The material name
  51330. * @param scene The scene the material will be use in.
  51331. */
  51332. function PBRBaseSimpleMaterial(name, scene) {
  51333. var _this = _super.call(this, name, scene) || this;
  51334. /**
  51335. * Number of Simultaneous lights allowed on the material.
  51336. */
  51337. _this.maxSimultaneousLights = 4;
  51338. /**
  51339. * If sets to true, disables all the lights affecting the material.
  51340. */
  51341. _this.disableLighting = false;
  51342. /**
  51343. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51344. */
  51345. _this.invertNormalMapX = false;
  51346. /**
  51347. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51348. */
  51349. _this.invertNormalMapY = false;
  51350. /**
  51351. * Emissivie color used to self-illuminate the model.
  51352. */
  51353. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0, 0, 0);
  51354. /**
  51355. * Occlusion Channel Strenght.
  51356. */
  51357. _this.occlusionStrength = 1.0;
  51358. /**
  51359. * If true, the light map contains occlusion information instead of lighting info.
  51360. */
  51361. _this.useLightmapAsShadowmap = false;
  51362. _this._useAlphaFromAlbedoTexture = true;
  51363. _this._useAmbientInGrayScale = true;
  51364. return _this;
  51365. }
  51366. Object.defineProperty(PBRBaseSimpleMaterial.prototype, "doubleSided", {
  51367. /**
  51368. * Gets the current double sided mode.
  51369. */
  51370. get: function () {
  51371. return this._twoSidedLighting;
  51372. },
  51373. /**
  51374. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51375. */
  51376. set: function (value) {
  51377. if (this._twoSidedLighting === value) {
  51378. return;
  51379. }
  51380. this._twoSidedLighting = value;
  51381. this.backFaceCulling = !value;
  51382. this._markAllSubMeshesAsTexturesDirty();
  51383. },
  51384. enumerable: true,
  51385. configurable: true
  51386. });
  51387. /**
  51388. * Return the active textures of the material.
  51389. */
  51390. PBRBaseSimpleMaterial.prototype.getActiveTextures = function () {
  51391. var activeTextures = _super.prototype.getActiveTextures.call(this);
  51392. if (this.environmentTexture) {
  51393. activeTextures.push(this.environmentTexture);
  51394. }
  51395. if (this.normalTexture) {
  51396. activeTextures.push(this.normalTexture);
  51397. }
  51398. if (this.emissiveTexture) {
  51399. activeTextures.push(this.emissiveTexture);
  51400. }
  51401. if (this.occlusionTexture) {
  51402. activeTextures.push(this.occlusionTexture);
  51403. }
  51404. if (this.lightmapTexture) {
  51405. activeTextures.push(this.lightmapTexture);
  51406. }
  51407. return activeTextures;
  51408. };
  51409. PBRBaseSimpleMaterial.prototype.hasTexture = function (texture) {
  51410. if (_super.prototype.hasTexture.call(this, texture)) {
  51411. return true;
  51412. }
  51413. if (this.lightmapTexture === texture) {
  51414. return true;
  51415. }
  51416. return false;
  51417. };
  51418. PBRBaseSimpleMaterial.prototype.getClassName = function () {
  51419. return "PBRBaseSimpleMaterial";
  51420. };
  51421. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51422. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51423. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  51424. ], PBRBaseSimpleMaterial.prototype, "maxSimultaneousLights", void 0);
  51425. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51426. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51427. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  51428. ], PBRBaseSimpleMaterial.prototype, "disableLighting", void 0);
  51429. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51430. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51431. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")
  51432. ], PBRBaseSimpleMaterial.prototype, "environmentTexture", void 0);
  51433. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51434. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51435. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51436. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapX", void 0);
  51437. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51438. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51439. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51440. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapY", void 0);
  51441. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51442. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51443. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")
  51444. ], PBRBaseSimpleMaterial.prototype, "normalTexture", void 0);
  51445. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51446. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  51447. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51448. ], PBRBaseSimpleMaterial.prototype, "emissiveColor", void 0);
  51449. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51450. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51451. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51452. ], PBRBaseSimpleMaterial.prototype, "emissiveTexture", void 0);
  51453. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51454. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51455. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")
  51456. ], PBRBaseSimpleMaterial.prototype, "occlusionStrength", void 0);
  51457. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51458. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51459. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")
  51460. ], PBRBaseSimpleMaterial.prototype, "occlusionTexture", void 0);
  51461. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51462. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51463. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")
  51464. ], PBRBaseSimpleMaterial.prototype, "alphaCutOff", void 0);
  51465. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51466. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51467. ], PBRBaseSimpleMaterial.prototype, "doubleSided", null);
  51468. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51469. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51470. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  51471. ], PBRBaseSimpleMaterial.prototype, "lightmapTexture", void 0);
  51472. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51473. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51474. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51475. ], PBRBaseSimpleMaterial.prototype, "useLightmapAsShadowmap", void 0);
  51476. return PBRBaseSimpleMaterial;
  51477. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRBaseMaterial"]));
  51478. /***/ }),
  51479. /***/ "./Materials/PBR/pbrMaterial.ts":
  51480. /*!**************************************!*\
  51481. !*** ./Materials/PBR/pbrMaterial.ts ***!
  51482. \**************************************/
  51483. /*! exports provided: PBRMaterial */
  51484. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51485. "use strict";
  51486. __webpack_require__.r(__webpack_exports__);
  51487. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return PBRMaterial; });
  51488. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51489. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51490. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  51491. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  51492. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  51493. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  51494. /**
  51495. * The Physically based material of BJS.
  51496. *
  51497. * This offers the main features of a standard PBR material.
  51498. * For more information, please refer to the documentation :
  51499. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  51500. */
  51501. var PBRMaterial = /** @class */ (function (_super) {
  51502. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterial, _super);
  51503. /**
  51504. * Instantiates a new PBRMaterial instance.
  51505. *
  51506. * @param name The material name
  51507. * @param scene The scene the material will be use in.
  51508. */
  51509. function PBRMaterial(name, scene) {
  51510. var _this = _super.call(this, name, scene) || this;
  51511. /**
  51512. * Intensity of the direct lights e.g. the four lights available in your scene.
  51513. * This impacts both the direct diffuse and specular highlights.
  51514. */
  51515. _this.directIntensity = 1.0;
  51516. /**
  51517. * Intensity of the emissive part of the material.
  51518. * This helps controlling the emissive effect without modifying the emissive color.
  51519. */
  51520. _this.emissiveIntensity = 1.0;
  51521. /**
  51522. * Intensity of the environment e.g. how much the environment will light the object
  51523. * either through harmonics for rough material or through the refelction for shiny ones.
  51524. */
  51525. _this.environmentIntensity = 1.0;
  51526. /**
  51527. * This is a special control allowing the reduction of the specular highlights coming from the
  51528. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51529. */
  51530. _this.specularIntensity = 1.0;
  51531. /**
  51532. * Debug Control allowing disabling the bump map on this material.
  51533. */
  51534. _this.disableBumpMap = false;
  51535. /**
  51536. * AKA Occlusion Texture Intensity in other nomenclature.
  51537. */
  51538. _this.ambientTextureStrength = 1.0;
  51539. /**
  51540. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51541. * 1 means it completely occludes it
  51542. * 0 mean it has no impact
  51543. */
  51544. _this.ambientTextureImpactOnAnalyticalLights = PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  51545. /**
  51546. * The color of a material in ambient lighting.
  51547. */
  51548. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  51549. /**
  51550. * AKA Diffuse Color in other nomenclature.
  51551. */
  51552. _this.albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  51553. /**
  51554. * AKA Specular Color in other nomenclature.
  51555. */
  51556. _this.reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  51557. /**
  51558. * The color reflected from the material.
  51559. */
  51560. _this.reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1.0, 1.0, 1.0);
  51561. /**
  51562. * The color emitted from the material.
  51563. */
  51564. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  51565. /**
  51566. * AKA Glossiness in other nomenclature.
  51567. */
  51568. _this.microSurface = 1.0;
  51569. /**
  51570. * source material index of refraction (IOR)' / 'destination material IOR.
  51571. */
  51572. _this.indexOfRefraction = 0.66;
  51573. /**
  51574. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51575. */
  51576. _this.invertRefractionY = false;
  51577. /**
  51578. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51579. * Materials half opaque for instance using refraction could benefit from this control.
  51580. */
  51581. _this.linkRefractionWithTransparency = false;
  51582. /**
  51583. * If true, the light map contains occlusion information instead of lighting info.
  51584. */
  51585. _this.useLightmapAsShadowmap = false;
  51586. /**
  51587. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51588. */
  51589. _this.useAlphaFromAlbedoTexture = false;
  51590. /**
  51591. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51592. */
  51593. _this.forceAlphaTest = false;
  51594. /**
  51595. * Defines the alpha limits in alpha test mode.
  51596. */
  51597. _this.alphaCutOff = 0.4;
  51598. /**
  51599. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51600. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51601. */
  51602. _this.useSpecularOverAlpha = true;
  51603. /**
  51604. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51605. */
  51606. _this.useMicroSurfaceFromReflectivityMapAlpha = false;
  51607. /**
  51608. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51609. */
  51610. _this.useRoughnessFromMetallicTextureAlpha = true;
  51611. /**
  51612. * Specifies if the metallic texture contains the roughness information in its green channel.
  51613. */
  51614. _this.useRoughnessFromMetallicTextureGreen = false;
  51615. /**
  51616. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51617. */
  51618. _this.useMetallnessFromMetallicTextureBlue = false;
  51619. /**
  51620. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51621. */
  51622. _this.useAmbientOcclusionFromMetallicTextureRed = false;
  51623. /**
  51624. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51625. */
  51626. _this.useAmbientInGrayScale = false;
  51627. /**
  51628. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51629. * The material will try to infer what glossiness each pixel should be.
  51630. */
  51631. _this.useAutoMicroSurfaceFromReflectivityMap = false;
  51632. /**
  51633. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51634. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51635. */
  51636. _this.useRadianceOverAlpha = true;
  51637. /**
  51638. * Allows using an object space normal map (instead of tangent space).
  51639. */
  51640. _this.useObjectSpaceNormalMap = false;
  51641. /**
  51642. * Allows using the bump map in parallax mode.
  51643. */
  51644. _this.useParallax = false;
  51645. /**
  51646. * Allows using the bump map in parallax occlusion mode.
  51647. */
  51648. _this.useParallaxOcclusion = false;
  51649. /**
  51650. * Controls the scale bias of the parallax mode.
  51651. */
  51652. _this.parallaxScaleBias = 0.05;
  51653. /**
  51654. * If sets to true, disables all the lights affecting the material.
  51655. */
  51656. _this.disableLighting = false;
  51657. /**
  51658. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51659. */
  51660. _this.forceIrradianceInFragment = false;
  51661. /**
  51662. * Number of Simultaneous lights allowed on the material.
  51663. */
  51664. _this.maxSimultaneousLights = 4;
  51665. /**
  51666. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51667. */
  51668. _this.invertNormalMapX = false;
  51669. /**
  51670. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51671. */
  51672. _this.invertNormalMapY = false;
  51673. /**
  51674. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51675. */
  51676. _this.twoSidedLighting = false;
  51677. /**
  51678. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51679. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51680. */
  51681. _this.useAlphaFresnel = false;
  51682. /**
  51683. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51684. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51685. */
  51686. _this.useLinearAlphaFresnel = false;
  51687. /**
  51688. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51689. * And/Or occlude the blended part.
  51690. */
  51691. _this.environmentBRDFTexture = null;
  51692. /**
  51693. * Force normal to face away from face.
  51694. */
  51695. _this.forceNormalForward = false;
  51696. /**
  51697. * Enables specular anti aliasing in the PBR shader.
  51698. * It will both interacts on the Geometry for analytical and IBL lighting.
  51699. * It also prefilter the roughness map based on the bump values.
  51700. */
  51701. _this.enableSpecularAntiAliasing = false;
  51702. /**
  51703. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51704. * makes the reflect vector face the model (under horizon).
  51705. */
  51706. _this.useHorizonOcclusion = true;
  51707. /**
  51708. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51709. * too much the area relying on ambient texture to define their ambient occlusion.
  51710. */
  51711. _this.useRadianceOcclusion = true;
  51712. /**
  51713. * If set to true, no lighting calculations will be applied.
  51714. */
  51715. _this.unlit = false;
  51716. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  51717. return _this;
  51718. }
  51719. Object.defineProperty(PBRMaterial.prototype, "usePhysicalLightFalloff", {
  51720. /**
  51721. * BJS is using an harcoded light falloff based on a manually sets up range.
  51722. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51723. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51724. */
  51725. get: function () {
  51726. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  51727. },
  51728. /**
  51729. * BJS is using an harcoded light falloff based on a manually sets up range.
  51730. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51731. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51732. */
  51733. set: function (value) {
  51734. if (value !== this.usePhysicalLightFalloff) {
  51735. // Ensure the effect will be rebuilt.
  51736. this._markAllSubMeshesAsTexturesDirty();
  51737. if (value) {
  51738. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  51739. }
  51740. else {
  51741. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  51742. }
  51743. }
  51744. },
  51745. enumerable: true,
  51746. configurable: true
  51747. });
  51748. Object.defineProperty(PBRMaterial.prototype, "useGLTFLightFalloff", {
  51749. /**
  51750. * In order to support the falloff compatibility with gltf, a special mode has been added
  51751. * to reproduce the gltf light falloff.
  51752. */
  51753. get: function () {
  51754. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  51755. },
  51756. /**
  51757. * In order to support the falloff compatibility with gltf, a special mode has been added
  51758. * to reproduce the gltf light falloff.
  51759. */
  51760. set: function (value) {
  51761. if (value !== this.useGLTFLightFalloff) {
  51762. // Ensure the effect will be rebuilt.
  51763. this._markAllSubMeshesAsTexturesDirty();
  51764. if (value) {
  51765. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  51766. }
  51767. else {
  51768. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  51769. }
  51770. }
  51771. },
  51772. enumerable: true,
  51773. configurable: true
  51774. });
  51775. Object.defineProperty(PBRMaterial.prototype, "imageProcessingConfiguration", {
  51776. /**
  51777. * Gets the image processing configuration used either in this material.
  51778. */
  51779. get: function () {
  51780. return this._imageProcessingConfiguration;
  51781. },
  51782. /**
  51783. * Sets the Default image processing configuration used either in the this material.
  51784. *
  51785. * If sets to null, the scene one is in use.
  51786. */
  51787. set: function (value) {
  51788. this._attachImageProcessingConfiguration(value);
  51789. // Ensure the effect will be rebuilt.
  51790. this._markAllSubMeshesAsTexturesDirty();
  51791. },
  51792. enumerable: true,
  51793. configurable: true
  51794. });
  51795. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurvesEnabled", {
  51796. /**
  51797. * Gets wether the color curves effect is enabled.
  51798. */
  51799. get: function () {
  51800. return this.imageProcessingConfiguration.colorCurvesEnabled;
  51801. },
  51802. /**
  51803. * Sets wether the color curves effect is enabled.
  51804. */
  51805. set: function (value) {
  51806. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  51807. },
  51808. enumerable: true,
  51809. configurable: true
  51810. });
  51811. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingEnabled", {
  51812. /**
  51813. * Gets wether the color grading effect is enabled.
  51814. */
  51815. get: function () {
  51816. return this.imageProcessingConfiguration.colorGradingEnabled;
  51817. },
  51818. /**
  51819. * Gets wether the color grading effect is enabled.
  51820. */
  51821. set: function (value) {
  51822. this.imageProcessingConfiguration.colorGradingEnabled = value;
  51823. },
  51824. enumerable: true,
  51825. configurable: true
  51826. });
  51827. Object.defineProperty(PBRMaterial.prototype, "cameraToneMappingEnabled", {
  51828. /**
  51829. * Gets wether tonemapping is enabled or not.
  51830. */
  51831. get: function () {
  51832. return this._imageProcessingConfiguration.toneMappingEnabled;
  51833. },
  51834. /**
  51835. * Sets wether tonemapping is enabled or not
  51836. */
  51837. set: function (value) {
  51838. this._imageProcessingConfiguration.toneMappingEnabled = value;
  51839. },
  51840. enumerable: true,
  51841. configurable: true
  51842. });
  51843. Object.defineProperty(PBRMaterial.prototype, "cameraExposure", {
  51844. /**
  51845. * The camera exposure used on this material.
  51846. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51847. * This corresponds to a photographic exposure.
  51848. */
  51849. get: function () {
  51850. return this._imageProcessingConfiguration.exposure;
  51851. },
  51852. /**
  51853. * The camera exposure used on this material.
  51854. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51855. * This corresponds to a photographic exposure.
  51856. */
  51857. set: function (value) {
  51858. this._imageProcessingConfiguration.exposure = value;
  51859. },
  51860. enumerable: true,
  51861. configurable: true
  51862. });
  51863. Object.defineProperty(PBRMaterial.prototype, "cameraContrast", {
  51864. /**
  51865. * Gets The camera contrast used on this material.
  51866. */
  51867. get: function () {
  51868. return this._imageProcessingConfiguration.contrast;
  51869. },
  51870. /**
  51871. * Sets The camera contrast used on this material.
  51872. */
  51873. set: function (value) {
  51874. this._imageProcessingConfiguration.contrast = value;
  51875. },
  51876. enumerable: true,
  51877. configurable: true
  51878. });
  51879. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingTexture", {
  51880. /**
  51881. * Gets the Color Grading 2D Lookup Texture.
  51882. */
  51883. get: function () {
  51884. return this._imageProcessingConfiguration.colorGradingTexture;
  51885. },
  51886. /**
  51887. * Sets the Color Grading 2D Lookup Texture.
  51888. */
  51889. set: function (value) {
  51890. this._imageProcessingConfiguration.colorGradingTexture = value;
  51891. },
  51892. enumerable: true,
  51893. configurable: true
  51894. });
  51895. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurves", {
  51896. /**
  51897. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51898. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51899. * 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;
  51900. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51901. */
  51902. get: function () {
  51903. return this._imageProcessingConfiguration.colorCurves;
  51904. },
  51905. /**
  51906. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51907. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51908. * 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;
  51909. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51910. */
  51911. set: function (value) {
  51912. this._imageProcessingConfiguration.colorCurves = value;
  51913. },
  51914. enumerable: true,
  51915. configurable: true
  51916. });
  51917. /**
  51918. * Returns the name of this material class.
  51919. */
  51920. PBRMaterial.prototype.getClassName = function () {
  51921. return "PBRMaterial";
  51922. };
  51923. /**
  51924. * Returns an array of the actively used textures.
  51925. * @returns - Array of BaseTextures
  51926. */
  51927. PBRMaterial.prototype.getActiveTextures = function () {
  51928. var activeTextures = _super.prototype.getActiveTextures.call(this);
  51929. if (this._albedoTexture) {
  51930. activeTextures.push(this._albedoTexture);
  51931. }
  51932. if (this._ambientTexture) {
  51933. activeTextures.push(this._ambientTexture);
  51934. }
  51935. if (this._opacityTexture) {
  51936. activeTextures.push(this._opacityTexture);
  51937. }
  51938. if (this._reflectionTexture) {
  51939. activeTextures.push(this._reflectionTexture);
  51940. }
  51941. if (this._emissiveTexture) {
  51942. activeTextures.push(this._emissiveTexture);
  51943. }
  51944. if (this._reflectivityTexture) {
  51945. activeTextures.push(this._reflectivityTexture);
  51946. }
  51947. if (this._metallicTexture) {
  51948. activeTextures.push(this._metallicTexture);
  51949. }
  51950. if (this._microSurfaceTexture) {
  51951. activeTextures.push(this._microSurfaceTexture);
  51952. }
  51953. if (this._bumpTexture) {
  51954. activeTextures.push(this._bumpTexture);
  51955. }
  51956. if (this._lightmapTexture) {
  51957. activeTextures.push(this._lightmapTexture);
  51958. }
  51959. if (this._refractionTexture) {
  51960. activeTextures.push(this._refractionTexture);
  51961. }
  51962. return activeTextures;
  51963. };
  51964. /**
  51965. * Checks to see if a texture is used in the material.
  51966. * @param texture - Base texture to use.
  51967. * @returns - Boolean specifying if a texture is used in the material.
  51968. */
  51969. PBRMaterial.prototype.hasTexture = function (texture) {
  51970. if (_super.prototype.hasTexture.call(this, texture)) {
  51971. return true;
  51972. }
  51973. if (this._albedoTexture === texture) {
  51974. return true;
  51975. }
  51976. if (this._ambientTexture === texture) {
  51977. return true;
  51978. }
  51979. if (this._opacityTexture === texture) {
  51980. return true;
  51981. }
  51982. if (this._reflectionTexture === texture) {
  51983. return true;
  51984. }
  51985. if (this._reflectivityTexture === texture) {
  51986. return true;
  51987. }
  51988. if (this._metallicTexture === texture) {
  51989. return true;
  51990. }
  51991. if (this._microSurfaceTexture === texture) {
  51992. return true;
  51993. }
  51994. if (this._bumpTexture === texture) {
  51995. return true;
  51996. }
  51997. if (this._lightmapTexture === texture) {
  51998. return true;
  51999. }
  52000. if (this._refractionTexture === texture) {
  52001. return true;
  52002. }
  52003. return false;
  52004. };
  52005. /**
  52006. * Makes a duplicate of the current material.
  52007. * @param name - name to use for the new material.
  52008. */
  52009. PBRMaterial.prototype.clone = function (name) {
  52010. var _this = this;
  52011. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMaterial(name, _this.getScene()); }, this);
  52012. clone.id = name;
  52013. clone.name = name;
  52014. return clone;
  52015. };
  52016. /**
  52017. * Serializes this PBR Material.
  52018. * @returns - An object with the serialized material.
  52019. */
  52020. PBRMaterial.prototype.serialize = function () {
  52021. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  52022. serializationObject.customType = "BABYLON.PBRMaterial";
  52023. return serializationObject;
  52024. };
  52025. // Statics
  52026. /**
  52027. * Parses a PBR Material from a serialized object.
  52028. * @param source - Serialized object.
  52029. * @param scene - BJS scene instance.
  52030. * @param rootUrl - url for the scene object
  52031. * @returns - PBRMaterial
  52032. */
  52033. PBRMaterial.Parse = function (source, scene, rootUrl) {
  52034. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMaterial(source.name, scene); }, source, scene, rootUrl);
  52035. };
  52036. /**
  52037. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52038. */
  52039. PBRMaterial.PBRMATERIAL_OPAQUE = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_OPAQUE;
  52040. /**
  52041. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52042. */
  52043. PBRMaterial.PBRMATERIAL_ALPHATEST = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATEST;
  52044. /**
  52045. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52046. */
  52047. PBRMaterial.PBRMATERIAL_ALPHABLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHABLEND;
  52048. /**
  52049. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52050. * They are also discarded below the alpha cutoff threshold to improve performances.
  52051. */
  52052. PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATESTANDBLEND;
  52053. /**
  52054. * Defines the default value of how much AO map is occluding the analytical lights
  52055. * (point spot...).
  52056. */
  52057. PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  52058. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52059. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52060. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52061. ], PBRMaterial.prototype, "directIntensity", void 0);
  52062. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52063. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52064. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52065. ], PBRMaterial.prototype, "emissiveIntensity", void 0);
  52066. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52067. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52068. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52069. ], PBRMaterial.prototype, "environmentIntensity", void 0);
  52070. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52071. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52072. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52073. ], PBRMaterial.prototype, "specularIntensity", void 0);
  52074. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52075. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52076. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52077. ], PBRMaterial.prototype, "disableBumpMap", void 0);
  52078. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52079. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52080. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52081. ], PBRMaterial.prototype, "albedoTexture", void 0);
  52082. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52083. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52084. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52085. ], PBRMaterial.prototype, "ambientTexture", void 0);
  52086. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52087. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52088. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52089. ], PBRMaterial.prototype, "ambientTextureStrength", void 0);
  52090. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52091. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52092. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52093. ], PBRMaterial.prototype, "ambientTextureImpactOnAnalyticalLights", void 0);
  52094. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52095. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52096. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52097. ], PBRMaterial.prototype, "opacityTexture", void 0);
  52098. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52099. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52100. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52101. ], PBRMaterial.prototype, "reflectionTexture", void 0);
  52102. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52103. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52104. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52105. ], PBRMaterial.prototype, "emissiveTexture", void 0);
  52106. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52107. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52108. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52109. ], PBRMaterial.prototype, "reflectivityTexture", void 0);
  52110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52112. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52113. ], PBRMaterial.prototype, "metallicTexture", void 0);
  52114. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52115. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52116. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52117. ], PBRMaterial.prototype, "metallic", void 0);
  52118. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52119. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52120. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52121. ], PBRMaterial.prototype, "roughness", void 0);
  52122. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52123. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52124. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52125. ], PBRMaterial.prototype, "microSurfaceTexture", void 0);
  52126. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52127. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52128. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52129. ], PBRMaterial.prototype, "bumpTexture", void 0);
  52130. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52131. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52132. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  52133. ], PBRMaterial.prototype, "lightmapTexture", void 0);
  52134. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52135. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52136. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52137. ], PBRMaterial.prototype, "refractionTexture", void 0);
  52138. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52139. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient"),
  52140. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52141. ], PBRMaterial.prototype, "ambientColor", void 0);
  52142. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52143. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("albedo"),
  52144. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52145. ], PBRMaterial.prototype, "albedoColor", void 0);
  52146. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52147. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflectivity"),
  52148. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52149. ], PBRMaterial.prototype, "reflectivityColor", void 0);
  52150. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52151. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflection"),
  52152. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52153. ], PBRMaterial.prototype, "reflectionColor", void 0);
  52154. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52155. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  52156. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52157. ], PBRMaterial.prototype, "emissiveColor", void 0);
  52158. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52159. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52160. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52161. ], PBRMaterial.prototype, "microSurface", void 0);
  52162. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52163. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52164. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52165. ], PBRMaterial.prototype, "indexOfRefraction", void 0);
  52166. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52167. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52168. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52169. ], PBRMaterial.prototype, "invertRefractionY", void 0);
  52170. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52171. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52172. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52173. ], PBRMaterial.prototype, "linkRefractionWithTransparency", void 0);
  52174. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52175. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52176. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52177. ], PBRMaterial.prototype, "useLightmapAsShadowmap", void 0);
  52178. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52179. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52180. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52181. ], PBRMaterial.prototype, "useAlphaFromAlbedoTexture", void 0);
  52182. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52183. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52184. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52185. ], PBRMaterial.prototype, "forceAlphaTest", void 0);
  52186. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52187. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52188. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52189. ], PBRMaterial.prototype, "alphaCutOff", void 0);
  52190. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52191. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52192. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52193. ], PBRMaterial.prototype, "useSpecularOverAlpha", void 0);
  52194. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52195. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52196. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52197. ], PBRMaterial.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0);
  52198. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52199. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52200. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52201. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureAlpha", void 0);
  52202. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52203. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52204. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52205. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureGreen", void 0);
  52206. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52207. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52208. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52209. ], PBRMaterial.prototype, "useMetallnessFromMetallicTextureBlue", void 0);
  52210. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52211. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52212. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52213. ], PBRMaterial.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0);
  52214. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52215. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52216. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52217. ], PBRMaterial.prototype, "useAmbientInGrayScale", void 0);
  52218. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52219. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52220. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52221. ], PBRMaterial.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0);
  52222. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52223. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52224. ], PBRMaterial.prototype, "usePhysicalLightFalloff", null);
  52225. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52226. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52227. ], PBRMaterial.prototype, "useGLTFLightFalloff", null);
  52228. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52229. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52230. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52231. ], PBRMaterial.prototype, "useRadianceOverAlpha", 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")
  52235. ], PBRMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  52236. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52237. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52238. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52239. ], PBRMaterial.prototype, "useParallax", void 0);
  52240. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52241. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52242. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52243. ], PBRMaterial.prototype, "useParallaxOcclusion", void 0);
  52244. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52245. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52246. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52247. ], PBRMaterial.prototype, "parallaxScaleBias", void 0);
  52248. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52249. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52250. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  52251. ], PBRMaterial.prototype, "disableLighting", void 0);
  52252. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52253. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52254. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52255. ], PBRMaterial.prototype, "forceIrradianceInFragment", void 0);
  52256. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52257. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52258. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  52259. ], PBRMaterial.prototype, "maxSimultaneousLights", void 0);
  52260. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52261. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52262. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52263. ], PBRMaterial.prototype, "invertNormalMapX", void 0);
  52264. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52265. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52266. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52267. ], PBRMaterial.prototype, "invertNormalMapY", void 0);
  52268. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52269. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52270. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52271. ], PBRMaterial.prototype, "twoSidedLighting", void 0);
  52272. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52273. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52274. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52275. ], PBRMaterial.prototype, "useAlphaFresnel", void 0);
  52276. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52277. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52278. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52279. ], PBRMaterial.prototype, "useLinearAlphaFresnel", void 0);
  52280. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52281. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52282. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52283. ], PBRMaterial.prototype, "environmentBRDFTexture", void 0);
  52284. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52285. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52286. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52287. ], PBRMaterial.prototype, "forceNormalForward", void 0);
  52288. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52289. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52290. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52291. ], PBRMaterial.prototype, "enableSpecularAntiAliasing", void 0);
  52292. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52293. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52294. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52295. ], PBRMaterial.prototype, "useHorizonOcclusion", void 0);
  52296. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52297. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52298. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52299. ], PBRMaterial.prototype, "useRadianceOcclusion", void 0);
  52300. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52301. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52302. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  52303. ], PBRMaterial.prototype, "unlit", void 0);
  52304. return PBRMaterial;
  52305. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"]));
  52306. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PBRMaterial"] = PBRMaterial;
  52307. /***/ }),
  52308. /***/ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts":
  52309. /*!*******************************************************!*\
  52310. !*** ./Materials/PBR/pbrMetallicRoughnessMaterial.ts ***!
  52311. \*******************************************************/
  52312. /*! exports provided: PBRMetallicRoughnessMaterial */
  52313. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52314. "use strict";
  52315. __webpack_require__.r(__webpack_exports__);
  52316. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return PBRMetallicRoughnessMaterial; });
  52317. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52318. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52319. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  52320. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  52321. /**
  52322. * The PBR material of BJS following the metal roughness convention.
  52323. *
  52324. * This fits to the PBR convention in the GLTF definition:
  52325. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52326. */
  52327. var PBRMetallicRoughnessMaterial = /** @class */ (function (_super) {
  52328. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMetallicRoughnessMaterial, _super);
  52329. /**
  52330. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52331. *
  52332. * @param name The material name
  52333. * @param scene The scene the material will be use in.
  52334. */
  52335. function PBRMetallicRoughnessMaterial(name, scene) {
  52336. var _this = _super.call(this, name, scene) || this;
  52337. _this._useRoughnessFromMetallicTextureAlpha = false;
  52338. _this._useRoughnessFromMetallicTextureGreen = true;
  52339. _this._useMetallnessFromMetallicTextureBlue = true;
  52340. _this.metallic = 1.0;
  52341. _this.roughness = 1.0;
  52342. return _this;
  52343. }
  52344. /**
  52345. * Return the currrent class name of the material.
  52346. */
  52347. PBRMetallicRoughnessMaterial.prototype.getClassName = function () {
  52348. return "PBRMetallicRoughnessMaterial";
  52349. };
  52350. /**
  52351. * Return the active textures of the material.
  52352. */
  52353. PBRMetallicRoughnessMaterial.prototype.getActiveTextures = function () {
  52354. var activeTextures = _super.prototype.getActiveTextures.call(this);
  52355. if (this.baseTexture) {
  52356. activeTextures.push(this.baseTexture);
  52357. }
  52358. if (this.metallicRoughnessTexture) {
  52359. activeTextures.push(this.metallicRoughnessTexture);
  52360. }
  52361. return activeTextures;
  52362. };
  52363. /**
  52364. * Checks to see if a texture is used in the material.
  52365. * @param texture - Base texture to use.
  52366. * @returns - Boolean specifying if a texture is used in the material.
  52367. */
  52368. PBRMetallicRoughnessMaterial.prototype.hasTexture = function (texture) {
  52369. if (_super.prototype.hasTexture.call(this, texture)) {
  52370. return true;
  52371. }
  52372. if (this.baseTexture === texture) {
  52373. return true;
  52374. }
  52375. if (this.metallicRoughnessTexture === texture) {
  52376. return true;
  52377. }
  52378. return false;
  52379. };
  52380. /**
  52381. * Makes a duplicate of the current material.
  52382. * @param name - name to use for the new material.
  52383. */
  52384. PBRMetallicRoughnessMaterial.prototype.clone = function (name) {
  52385. var _this = this;
  52386. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMetallicRoughnessMaterial(name, _this.getScene()); }, this);
  52387. clone.id = name;
  52388. clone.name = name;
  52389. return clone;
  52390. };
  52391. /**
  52392. * Serialize the material to a parsable JSON object.
  52393. */
  52394. PBRMetallicRoughnessMaterial.prototype.serialize = function () {
  52395. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  52396. serializationObject.customType = "BABYLON.PBRMetallicRoughnessMaterial";
  52397. return serializationObject;
  52398. };
  52399. /**
  52400. * Parses a JSON object correponding to the serialize function.
  52401. */
  52402. PBRMetallicRoughnessMaterial.Parse = function (source, scene, rootUrl) {
  52403. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMetallicRoughnessMaterial(source.name, scene); }, source, scene, rootUrl);
  52404. };
  52405. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52406. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])(),
  52407. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  52408. ], PBRMetallicRoughnessMaterial.prototype, "baseColor", void 0);
  52409. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52410. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52411. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  52412. ], PBRMetallicRoughnessMaterial.prototype, "baseTexture", void 0);
  52413. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52414. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52415. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52416. ], PBRMetallicRoughnessMaterial.prototype, "metallic", void 0);
  52417. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52418. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52419. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52420. ], PBRMetallicRoughnessMaterial.prototype, "roughness", void 0);
  52421. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52422. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52423. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")
  52424. ], PBRMetallicRoughnessMaterial.prototype, "metallicRoughnessTexture", void 0);
  52425. return PBRMetallicRoughnessMaterial;
  52426. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  52427. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"] = PBRMetallicRoughnessMaterial;
  52428. /***/ }),
  52429. /***/ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts":
  52430. /*!********************************************************!*\
  52431. !*** ./Materials/PBR/pbrSpecularGlossinessMaterial.ts ***!
  52432. \********************************************************/
  52433. /*! exports provided: PBRSpecularGlossinessMaterial */
  52434. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52435. "use strict";
  52436. __webpack_require__.r(__webpack_exports__);
  52437. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return PBRSpecularGlossinessMaterial; });
  52438. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52439. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52440. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  52441. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  52442. /**
  52443. * The PBR material of BJS following the specular glossiness convention.
  52444. *
  52445. * This fits to the PBR convention in the GLTF definition:
  52446. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52447. */
  52448. var PBRSpecularGlossinessMaterial = /** @class */ (function (_super) {
  52449. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRSpecularGlossinessMaterial, _super);
  52450. /**
  52451. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52452. *
  52453. * @param name The material name
  52454. * @param scene The scene the material will be use in.
  52455. */
  52456. function PBRSpecularGlossinessMaterial(name, scene) {
  52457. var _this = _super.call(this, name, scene) || this;
  52458. _this._useMicroSurfaceFromReflectivityMapAlpha = true;
  52459. return _this;
  52460. }
  52461. /**
  52462. * Return the currrent class name of the material.
  52463. */
  52464. PBRSpecularGlossinessMaterial.prototype.getClassName = function () {
  52465. return "PBRSpecularGlossinessMaterial";
  52466. };
  52467. /**
  52468. * Return the active textures of the material.
  52469. */
  52470. PBRSpecularGlossinessMaterial.prototype.getActiveTextures = function () {
  52471. var activeTextures = _super.prototype.getActiveTextures.call(this);
  52472. if (this.diffuseTexture) {
  52473. activeTextures.push(this.diffuseTexture);
  52474. }
  52475. if (this.specularGlossinessTexture) {
  52476. activeTextures.push(this.specularGlossinessTexture);
  52477. }
  52478. return activeTextures;
  52479. };
  52480. /**
  52481. * Checks to see if a texture is used in the material.
  52482. * @param texture - Base texture to use.
  52483. * @returns - Boolean specifying if a texture is used in the material.
  52484. */
  52485. PBRSpecularGlossinessMaterial.prototype.hasTexture = function (texture) {
  52486. if (_super.prototype.hasTexture.call(this, texture)) {
  52487. return true;
  52488. }
  52489. if (this.diffuseTexture === texture) {
  52490. return true;
  52491. }
  52492. if (this.specularGlossinessTexture === texture) {
  52493. return true;
  52494. }
  52495. return false;
  52496. };
  52497. /**
  52498. * Makes a duplicate of the current material.
  52499. * @param name - name to use for the new material.
  52500. */
  52501. PBRSpecularGlossinessMaterial.prototype.clone = function (name) {
  52502. var _this = this;
  52503. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRSpecularGlossinessMaterial(name, _this.getScene()); }, this);
  52504. clone.id = name;
  52505. clone.name = name;
  52506. return clone;
  52507. };
  52508. /**
  52509. * Serialize the material to a parsable JSON object.
  52510. */
  52511. PBRSpecularGlossinessMaterial.prototype.serialize = function () {
  52512. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  52513. serializationObject.customType = "BABYLON.PBRSpecularGlossinessMaterial";
  52514. return serializationObject;
  52515. };
  52516. /**
  52517. * Parses a JSON object correponding to the serialize function.
  52518. */
  52519. PBRSpecularGlossinessMaterial.Parse = function (source, scene, rootUrl) {
  52520. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRSpecularGlossinessMaterial(source.name, scene); }, source, scene, rootUrl);
  52521. };
  52522. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52523. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse"),
  52524. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  52525. ], PBRSpecularGlossinessMaterial.prototype, "diffuseColor", void 0);
  52526. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52527. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52528. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  52529. ], PBRSpecularGlossinessMaterial.prototype, "diffuseTexture", void 0);
  52530. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52531. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular"),
  52532. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")
  52533. ], PBRSpecularGlossinessMaterial.prototype, "specularColor", void 0);
  52534. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52535. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52536. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_microSurface")
  52537. ], PBRSpecularGlossinessMaterial.prototype, "glossiness", void 0);
  52538. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52539. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52540. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")
  52541. ], PBRSpecularGlossinessMaterial.prototype, "specularGlossinessTexture", void 0);
  52542. return PBRSpecularGlossinessMaterial;
  52543. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  52544. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRSpecularGlossinessMaterial"] = PBRSpecularGlossinessMaterial;
  52545. /***/ }),
  52546. /***/ "./Materials/Textures/Loaders/ddsTextureLoader.ts":
  52547. /*!********************************************************!*\
  52548. !*** ./Materials/Textures/Loaders/ddsTextureLoader.ts ***!
  52549. \********************************************************/
  52550. /*! exports provided: _DDSTextureLoader */
  52551. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52552. "use strict";
  52553. __webpack_require__.r(__webpack_exports__);
  52554. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _DDSTextureLoader; });
  52555. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  52556. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  52557. /* harmony import */ var _Misc_dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/dds */ "./Misc/dds.ts");
  52558. /**
  52559. * Implementation of the DDS Texture Loader.
  52560. * @hidden
  52561. */
  52562. var _DDSTextureLoader = /** @class */ (function () {
  52563. function _DDSTextureLoader() {
  52564. /**
  52565. * Defines wether the loader supports cascade loading the different faces.
  52566. */
  52567. this.supportCascades = true;
  52568. }
  52569. /**
  52570. * This returns if the loader support the current file information.
  52571. * @param extension defines the file extension of the file being loaded
  52572. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52573. * @param fallback defines the fallback internal texture if any
  52574. * @param isBase64 defines whether the texture is encoded as a base64
  52575. * @param isBuffer defines whether the texture data are stored as a buffer
  52576. * @returns true if the loader can load the specified file
  52577. */
  52578. _DDSTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  52579. return extension.indexOf(".dds") === 0;
  52580. };
  52581. /**
  52582. * Transform the url before loading if required.
  52583. * @param rootUrl the url of the texture
  52584. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52585. * @returns the transformed texture
  52586. */
  52587. _DDSTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  52588. return rootUrl;
  52589. };
  52590. /**
  52591. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52592. * @param rootUrl the url of the texture
  52593. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52594. * @returns the fallback texture
  52595. */
  52596. _DDSTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  52597. return null;
  52598. };
  52599. /**
  52600. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52601. * @param data contains the texture data
  52602. * @param texture defines the BabylonJS internal texture
  52603. * @param createPolynomials will be true if polynomials have been requested
  52604. * @param onLoad defines the callback to trigger once the texture is ready
  52605. * @param onError defines the callback to trigger in case of error
  52606. */
  52607. _DDSTextureLoader.prototype.loadCubeData = function (imgs, texture, createPolynomials, onLoad, onError) {
  52608. var engine = texture.getEngine();
  52609. var info;
  52610. var loadMipmap = false;
  52611. if (Array.isArray(imgs)) {
  52612. for (var index = 0; index < imgs.length; index++) {
  52613. var data_1 = imgs[index];
  52614. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data_1);
  52615. texture.width = info.width;
  52616. texture.height = info.height;
  52617. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  52618. engine._unpackFlipY(info.isCompressed);
  52619. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data_1, info, loadMipmap, 6, -1, index);
  52620. if (!info.isFourCC && info.mipmapCount === 1) {
  52621. engine.generateMipMapsForCubemap(texture);
  52622. }
  52623. }
  52624. }
  52625. else {
  52626. var data = imgs;
  52627. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  52628. texture.width = info.width;
  52629. texture.height = info.height;
  52630. if (createPolynomials) {
  52631. info.sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]();
  52632. }
  52633. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  52634. engine._unpackFlipY(info.isCompressed);
  52635. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data, info, loadMipmap, 6);
  52636. if (!info.isFourCC && info.mipmapCount === 1) {
  52637. engine.generateMipMapsForCubemap(texture);
  52638. }
  52639. }
  52640. engine._setCubeMapTextureParams(loadMipmap);
  52641. texture.isReady = true;
  52642. if (onLoad) {
  52643. onLoad({ isDDS: true, width: texture.width, info: info, data: imgs, texture: texture });
  52644. }
  52645. };
  52646. /**
  52647. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52648. * @param data contains the texture data
  52649. * @param texture defines the BabylonJS internal texture
  52650. * @param callback defines the method to call once ready to upload
  52651. */
  52652. _DDSTextureLoader.prototype.loadData = function (data, texture, callback) {
  52653. var info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  52654. var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps && ((info.width >> (info.mipmapCount - 1)) === 1);
  52655. callback(info.width, info.height, loadMipmap, info.isFourCC, function () {
  52656. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(texture.getEngine(), texture, data, info, loadMipmap, 1);
  52657. });
  52658. };
  52659. return _DDSTextureLoader;
  52660. }());
  52661. // Register the loader.
  52662. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _DDSTextureLoader());
  52663. /***/ }),
  52664. /***/ "./Materials/Textures/Loaders/envTextureLoader.ts":
  52665. /*!********************************************************!*\
  52666. !*** ./Materials/Textures/Loaders/envTextureLoader.ts ***!
  52667. \********************************************************/
  52668. /*! exports provided: _ENVTextureLoader */
  52669. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52670. "use strict";
  52671. __webpack_require__.r(__webpack_exports__);
  52672. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _ENVTextureLoader; });
  52673. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  52674. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  52675. /**
  52676. * Implementation of the ENV Texture Loader.
  52677. * @hidden
  52678. */
  52679. var _ENVTextureLoader = /** @class */ (function () {
  52680. function _ENVTextureLoader() {
  52681. /**
  52682. * Defines wether the loader supports cascade loading the different faces.
  52683. */
  52684. this.supportCascades = false;
  52685. }
  52686. /**
  52687. * This returns if the loader support the current file information.
  52688. * @param extension defines the file extension of the file being loaded
  52689. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52690. * @param fallback defines the fallback internal texture if any
  52691. * @param isBase64 defines whether the texture is encoded as a base64
  52692. * @param isBuffer defines whether the texture data are stored as a buffer
  52693. * @returns true if the loader can load the specified file
  52694. */
  52695. _ENVTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  52696. return extension.indexOf(".env") === 0;
  52697. };
  52698. /**
  52699. * Transform the url before loading if required.
  52700. * @param rootUrl the url of the texture
  52701. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52702. * @returns the transformed texture
  52703. */
  52704. _ENVTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  52705. return rootUrl;
  52706. };
  52707. /**
  52708. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52709. * @param rootUrl the url of the texture
  52710. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52711. * @returns the fallback texture
  52712. */
  52713. _ENVTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  52714. return null;
  52715. };
  52716. /**
  52717. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52718. * @param data contains the texture data
  52719. * @param texture defines the BabylonJS internal texture
  52720. * @param createPolynomials will be true if polynomials have been requested
  52721. * @param onLoad defines the callback to trigger once the texture is ready
  52722. * @param onError defines the callback to trigger in case of error
  52723. */
  52724. _ENVTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  52725. if (Array.isArray(data)) {
  52726. return;
  52727. }
  52728. data = data;
  52729. var info = _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].GetEnvInfo(data);
  52730. if (info) {
  52731. texture.width = info.width;
  52732. texture.height = info.width;
  52733. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvSpherical(texture, info);
  52734. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvLevelsAsync(texture, data, info).then(function () {
  52735. texture.isReady = true;
  52736. if (onLoad) {
  52737. onLoad();
  52738. }
  52739. });
  52740. }
  52741. else if (onError) {
  52742. onError("Can not parse the environment file", null);
  52743. }
  52744. };
  52745. /**
  52746. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52747. * @param data contains the texture data
  52748. * @param texture defines the BabylonJS internal texture
  52749. * @param callback defines the method to call once ready to upload
  52750. */
  52751. _ENVTextureLoader.prototype.loadData = function (data, texture, callback) {
  52752. throw ".env not supported in 2d.";
  52753. };
  52754. return _ENVTextureLoader;
  52755. }());
  52756. // Register the loader.
  52757. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _ENVTextureLoader());
  52758. /***/ }),
  52759. /***/ "./Materials/Textures/Loaders/index.ts":
  52760. /*!*********************************************!*\
  52761. !*** ./Materials/Textures/Loaders/index.ts ***!
  52762. \*********************************************/
  52763. /*! exports provided: _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader */
  52764. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52765. "use strict";
  52766. __webpack_require__.r(__webpack_exports__);
  52767. /* harmony import */ var _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  52768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  52769. /* harmony import */ var _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  52770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__["_ENVTextureLoader"]; });
  52771. /* harmony import */ var _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  52772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__["_KTXTextureLoader"]; });
  52773. /* harmony import */ var _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tgaTextureLoader */ "./Materials/Textures/Loaders/tgaTextureLoader.ts");
  52774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__["_TGATextureLoader"]; });
  52775. /***/ }),
  52776. /***/ "./Materials/Textures/Loaders/ktxTextureLoader.ts":
  52777. /*!********************************************************!*\
  52778. !*** ./Materials/Textures/Loaders/ktxTextureLoader.ts ***!
  52779. \********************************************************/
  52780. /*! exports provided: _KTXTextureLoader */
  52781. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52782. "use strict";
  52783. __webpack_require__.r(__webpack_exports__);
  52784. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _KTXTextureLoader; });
  52785. /* harmony import */ var _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  52786. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  52787. /**
  52788. * Implementation of the KTX Texture Loader.
  52789. * @hidden
  52790. */
  52791. var _KTXTextureLoader = /** @class */ (function () {
  52792. function _KTXTextureLoader() {
  52793. /**
  52794. * Defines wether the loader supports cascade loading the different faces.
  52795. */
  52796. this.supportCascades = false;
  52797. }
  52798. /**
  52799. * This returns if the loader support the current file information.
  52800. * @param extension defines the file extension of the file being loaded
  52801. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52802. * @param fallback defines the fallback internal texture if any
  52803. * @param isBase64 defines whether the texture is encoded as a base64
  52804. * @param isBuffer defines whether the texture data are stored as a buffer
  52805. * @returns true if the loader can load the specified file
  52806. */
  52807. _KTXTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  52808. if (textureFormatInUse && !isBase64 && !fallback && !isBuffer) {
  52809. return true;
  52810. }
  52811. return false;
  52812. };
  52813. /**
  52814. * Transform the url before loading if required.
  52815. * @param rootUrl the url of the texture
  52816. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52817. * @returns the transformed texture
  52818. */
  52819. _KTXTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  52820. var lastDot = rootUrl.lastIndexOf('.');
  52821. if (lastDot != -1 && rootUrl.substring(lastDot + 1) == "ktx") {
  52822. // Already transformed
  52823. return rootUrl;
  52824. }
  52825. return (lastDot > -1 ? rootUrl.substring(0, lastDot) : rootUrl) + textureFormatInUse;
  52826. };
  52827. /**
  52828. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52829. * @param rootUrl the url of the texture
  52830. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52831. * @returns the fallback texture
  52832. */
  52833. _KTXTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  52834. // remove the format appended to the rootUrl in the original createCubeTexture call.
  52835. var exp = new RegExp("" + textureFormatInUse + "$");
  52836. return rootUrl.replace(exp, "");
  52837. };
  52838. /**
  52839. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52840. * @param data contains the texture data
  52841. * @param texture defines the BabylonJS internal texture
  52842. * @param createPolynomials will be true if polynomials have been requested
  52843. * @param onLoad defines the callback to trigger once the texture is ready
  52844. * @param onError defines the callback to trigger in case of error
  52845. */
  52846. _KTXTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  52847. if (Array.isArray(data)) {
  52848. return;
  52849. }
  52850. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  52851. texture._invertVScale = !texture.invertY;
  52852. var engine = texture.getEngine();
  52853. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 6);
  52854. var loadMipmap = ktx.numberOfMipmapLevels > 1 && texture.generateMipMaps;
  52855. engine._unpackFlipY(true);
  52856. ktx.uploadLevels(texture, texture.generateMipMaps);
  52857. texture.width = ktx.pixelWidth;
  52858. texture.height = ktx.pixelHeight;
  52859. engine._setCubeMapTextureParams(loadMipmap);
  52860. texture.isReady = true;
  52861. };
  52862. /**
  52863. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52864. * @param data contains the texture data
  52865. * @param texture defines the BabylonJS internal texture
  52866. * @param callback defines the method to call once ready to upload
  52867. */
  52868. _KTXTextureLoader.prototype.loadData = function (data, texture, callback) {
  52869. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  52870. texture._invertVScale = !texture.invertY;
  52871. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 1);
  52872. callback(ktx.pixelWidth, ktx.pixelHeight, false, true, function () {
  52873. ktx.uploadLevels(texture, texture.generateMipMaps);
  52874. }, ktx.isInvalid);
  52875. };
  52876. return _KTXTextureLoader;
  52877. }());
  52878. // Register the loader.
  52879. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.unshift(new _KTXTextureLoader());
  52880. /***/ }),
  52881. /***/ "./Materials/Textures/Loaders/tgaTextureLoader.ts":
  52882. /*!********************************************************!*\
  52883. !*** ./Materials/Textures/Loaders/tgaTextureLoader.ts ***!
  52884. \********************************************************/
  52885. /*! exports provided: _TGATextureLoader */
  52886. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52887. "use strict";
  52888. __webpack_require__.r(__webpack_exports__);
  52889. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _TGATextureLoader; });
  52890. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tga */ "./Misc/tga.ts");
  52891. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  52892. /**
  52893. * Implementation of the TGA Texture Loader.
  52894. * @hidden
  52895. */
  52896. var _TGATextureLoader = /** @class */ (function () {
  52897. function _TGATextureLoader() {
  52898. /**
  52899. * Defines wether the loader supports cascade loading the different faces.
  52900. */
  52901. this.supportCascades = false;
  52902. }
  52903. /**
  52904. * This returns if the loader support the current file information.
  52905. * @param extension defines the file extension of the file being loaded
  52906. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52907. * @param fallback defines the fallback internal texture if any
  52908. * @param isBase64 defines whether the texture is encoded as a base64
  52909. * @param isBuffer defines whether the texture data are stored as a buffer
  52910. * @returns true if the loader can load the specified file
  52911. */
  52912. _TGATextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  52913. return extension.indexOf(".tga") === 0;
  52914. };
  52915. /**
  52916. * Transform the url before loading if required.
  52917. * @param rootUrl the url of the texture
  52918. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52919. * @returns the transformed texture
  52920. */
  52921. _TGATextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  52922. return rootUrl;
  52923. };
  52924. /**
  52925. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52926. * @param rootUrl the url of the texture
  52927. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52928. * @returns the fallback texture
  52929. */
  52930. _TGATextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  52931. return null;
  52932. };
  52933. /**
  52934. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52935. * @param data contains the texture data
  52936. * @param texture defines the BabylonJS internal texture
  52937. * @param createPolynomials will be true if polynomials have been requested
  52938. * @param onLoad defines the callback to trigger once the texture is ready
  52939. * @param onError defines the callback to trigger in case of error
  52940. */
  52941. _TGATextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  52942. throw ".env not supported in Cube.";
  52943. };
  52944. /**
  52945. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52946. * @param data contains the texture data
  52947. * @param texture defines the BabylonJS internal texture
  52948. * @param callback defines the method to call once ready to upload
  52949. */
  52950. _TGATextureLoader.prototype.loadData = function (data, texture, callback) {
  52951. var uintData = new Uint8Array(data);
  52952. var header = _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].GetTGAHeader(uintData);
  52953. callback(header.width, header.height, texture.generateMipMaps, false, function () {
  52954. _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].UploadContent(texture, uintData);
  52955. });
  52956. };
  52957. return _TGATextureLoader;
  52958. }());
  52959. // Register the loader.
  52960. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _TGATextureLoader());
  52961. /***/ }),
  52962. /***/ "./Materials/Textures/Procedurals/customProceduralTexture.ts":
  52963. /*!*******************************************************************!*\
  52964. !*** ./Materials/Textures/Procedurals/customProceduralTexture.ts ***!
  52965. \*******************************************************************/
  52966. /*! exports provided: CustomProceduralTexture */
  52967. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52968. "use strict";
  52969. __webpack_require__.r(__webpack_exports__);
  52970. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return CustomProceduralTexture; });
  52971. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52972. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  52973. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  52974. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  52975. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  52976. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  52977. /**
  52978. * 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.
  52979. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52980. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52981. */
  52982. var CustomProceduralTexture = /** @class */ (function (_super) {
  52983. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomProceduralTexture, _super);
  52984. /**
  52985. * Instantiates a new Custom Procedural Texture.
  52986. * 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.
  52987. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52988. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52989. * @param name Define the name of the texture
  52990. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52991. * @param size Define the size of the texture to create
  52992. * @param scene Define the scene the texture belongs to
  52993. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52994. * @param generateMipMaps Define if the texture should creates mip maps or not
  52995. */
  52996. function CustomProceduralTexture(name, texturePath, size, scene, fallbackTexture, generateMipMaps) {
  52997. var _this = _super.call(this, name, size, null, scene, fallbackTexture, generateMipMaps) || this;
  52998. _this._animate = true;
  52999. _this._time = 0;
  53000. _this._texturePath = texturePath;
  53001. //Try to load json
  53002. _this._loadJson(texturePath);
  53003. _this.refreshRate = 1;
  53004. return _this;
  53005. }
  53006. CustomProceduralTexture.prototype._loadJson = function (jsonUrl) {
  53007. var _this = this;
  53008. var noConfigFile = function () {
  53009. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
  53010. try {
  53011. _this.setFragment(_this._texturePath);
  53012. }
  53013. catch (ex) {
  53014. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
  53015. }
  53016. };
  53017. var configFileUrl = jsonUrl + "/config.json";
  53018. var xhr = new XMLHttpRequest();
  53019. xhr.open("GET", configFileUrl, true);
  53020. xhr.addEventListener("load", function () {
  53021. if (xhr.status === 200 || (xhr.responseText && xhr.responseText.length > 0)) {
  53022. try {
  53023. _this._config = JSON.parse(xhr.response);
  53024. _this.updateShaderUniforms();
  53025. _this.updateTextures();
  53026. _this.setFragment(_this._texturePath + "/custom");
  53027. _this._animate = _this._config.animate;
  53028. _this.refreshRate = _this._config.refreshrate;
  53029. }
  53030. catch (ex) {
  53031. noConfigFile();
  53032. }
  53033. }
  53034. else {
  53035. noConfigFile();
  53036. }
  53037. }, false);
  53038. xhr.addEventListener("error", function () {
  53039. noConfigFile();
  53040. }, false);
  53041. try {
  53042. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].UseCustomRequestHeaders) {
  53043. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].InjectCustomRequestHeaders(xhr);
  53044. }
  53045. xhr.send();
  53046. }
  53047. catch (ex) {
  53048. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("CustomProceduralTexture: Error on XHR send request.");
  53049. }
  53050. };
  53051. /**
  53052. * Is the texture ready to be used ? (rendered at least once)
  53053. * @returns true if ready, otherwise, false.
  53054. */
  53055. CustomProceduralTexture.prototype.isReady = function () {
  53056. if (!_super.prototype.isReady.call(this)) {
  53057. return false;
  53058. }
  53059. for (var name in this._textures) {
  53060. var texture = this._textures[name];
  53061. if (!texture.isReady()) {
  53062. return false;
  53063. }
  53064. }
  53065. return true;
  53066. };
  53067. /**
  53068. * Render the texture to its associated render target.
  53069. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53070. */
  53071. CustomProceduralTexture.prototype.render = function (useCameraPostProcess) {
  53072. var scene = this.getScene();
  53073. if (this._animate && scene) {
  53074. this._time += scene.getAnimationRatio() * 0.03;
  53075. this.updateShaderUniforms();
  53076. }
  53077. _super.prototype.render.call(this, useCameraPostProcess);
  53078. };
  53079. /**
  53080. * Update the list of dependant textures samplers in the shader.
  53081. */
  53082. CustomProceduralTexture.prototype.updateTextures = function () {
  53083. for (var i = 0; i < this._config.sampler2Ds.length; i++) {
  53084. 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()));
  53085. }
  53086. };
  53087. /**
  53088. * Update the uniform values of the procedural texture in the shader.
  53089. */
  53090. CustomProceduralTexture.prototype.updateShaderUniforms = function () {
  53091. if (this._config) {
  53092. for (var j = 0; j < this._config.uniforms.length; j++) {
  53093. var uniform = this._config.uniforms[j];
  53094. switch (uniform.type) {
  53095. case "float":
  53096. this.setFloat(uniform.name, uniform.value);
  53097. break;
  53098. case "color3":
  53099. this.setColor3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](uniform.r, uniform.g, uniform.b));
  53100. break;
  53101. case "color4":
  53102. this.setColor4(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](uniform.r, uniform.g, uniform.b, uniform.a));
  53103. break;
  53104. case "vector2":
  53105. this.setVector2(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](uniform.x, uniform.y));
  53106. break;
  53107. case "vector3":
  53108. this.setVector3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](uniform.x, uniform.y, uniform.z));
  53109. break;
  53110. }
  53111. }
  53112. }
  53113. this.setFloat("time", this._time);
  53114. };
  53115. Object.defineProperty(CustomProceduralTexture.prototype, "animate", {
  53116. /**
  53117. * Define if the texture animates or not.
  53118. */
  53119. get: function () {
  53120. return this._animate;
  53121. },
  53122. set: function (value) {
  53123. this._animate = value;
  53124. },
  53125. enumerable: true,
  53126. configurable: true
  53127. });
  53128. return CustomProceduralTexture;
  53129. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_5__["ProceduralTexture"]));
  53130. /***/ }),
  53131. /***/ "./Materials/Textures/Procedurals/index.ts":
  53132. /*!*************************************************!*\
  53133. !*** ./Materials/Textures/Procedurals/index.ts ***!
  53134. \*************************************************/
  53135. /*! exports provided: ProceduralTexture, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  53136. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53137. "use strict";
  53138. __webpack_require__.r(__webpack_exports__);
  53139. /* harmony import */ var _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./customProceduralTexture */ "./Materials/Textures/Procedurals/customProceduralTexture.ts");
  53140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  53141. /* harmony import */ var _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./noiseProceduralTexture */ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts");
  53142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__["NoiseProceduralTexture"]; });
  53143. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  53144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]; });
  53145. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  53146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__["ProceduralTextureSceneComponent"]; });
  53147. /***/ }),
  53148. /***/ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts":
  53149. /*!******************************************************************!*\
  53150. !*** ./Materials/Textures/Procedurals/noiseProceduralTexture.ts ***!
  53151. \******************************************************************/
  53152. /*! exports provided: NoiseProceduralTexture */
  53153. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53154. "use strict";
  53155. __webpack_require__.r(__webpack_exports__);
  53156. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return NoiseProceduralTexture; });
  53157. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53158. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  53159. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  53160. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  53161. /* harmony import */ var _Shaders_noise_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Shaders/noise.fragment */ "./Shaders/noise.fragment.ts");
  53162. /**
  53163. * Class used to generate noise procedural textures
  53164. */
  53165. var NoiseProceduralTexture = /** @class */ (function (_super) {
  53166. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NoiseProceduralTexture, _super);
  53167. /**
  53168. * Creates a new NoiseProceduralTexture
  53169. * @param name defines the name fo the texture
  53170. * @param size defines the size of the texture (default is 256)
  53171. * @param scene defines the hosting scene
  53172. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53173. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53174. */
  53175. function NoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  53176. if (size === void 0) { size = 256; }
  53177. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene; }
  53178. var _this = _super.call(this, name, size, "noise", scene, fallbackTexture, generateMipMaps) || this;
  53179. _this._time = 0;
  53180. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53181. _this.brightness = 0.2;
  53182. /** Defines the number of octaves to process */
  53183. _this.octaves = 3;
  53184. /** Defines the level of persistence (0.8 by default) */
  53185. _this.persistence = 0.8;
  53186. /** Gets or sets animation speed factor (default is 1) */
  53187. _this.animationSpeedFactor = 1;
  53188. _this.autoClear = false;
  53189. _this._updateShaderUniforms();
  53190. return _this;
  53191. }
  53192. NoiseProceduralTexture.prototype._updateShaderUniforms = function () {
  53193. var scene = this.getScene();
  53194. if (!scene) {
  53195. return;
  53196. }
  53197. this._time += scene.getAnimationRatio() * this.animationSpeedFactor * 0.01;
  53198. this.setFloat("brightness", this.brightness);
  53199. this.setFloat("persistence", this.persistence);
  53200. this.setFloat("timeScale", this._time);
  53201. };
  53202. NoiseProceduralTexture.prototype._getDefines = function () {
  53203. return "#define OCTAVES " + (this.octaves | 0);
  53204. };
  53205. /** Generate the current state of the procedural texture */
  53206. NoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
  53207. this._updateShaderUniforms();
  53208. _super.prototype.render.call(this, useCameraPostProcess);
  53209. };
  53210. /**
  53211. * Serializes this noise procedural texture
  53212. * @returns a serialized noise procedural texture object
  53213. */
  53214. NoiseProceduralTexture.prototype.serialize = function () {
  53215. var serializationObject = {};
  53216. serializationObject.customType = "BABYLON.NoiseProceduralTexture";
  53217. serializationObject.brightness = this.brightness;
  53218. serializationObject.octaves = this.octaves;
  53219. serializationObject.persistence = this.persistence;
  53220. serializationObject.animationSpeedFactor = this.animationSpeedFactor;
  53221. serializationObject.size = this.getSize().width;
  53222. serializationObject.generateMipMaps = this._generateMipMaps;
  53223. return serializationObject;
  53224. };
  53225. /**
  53226. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53227. * @param parsedTexture defines parsed texture data
  53228. * @param scene defines the current scene
  53229. * @param rootUrl defines the root URL containing noise procedural texture information
  53230. * @returns a parsed NoiseProceduralTexture
  53231. */
  53232. NoiseProceduralTexture.Parse = function (parsedTexture, scene) {
  53233. var texture = new NoiseProceduralTexture(parsedTexture.name, parsedTexture.size, scene, undefined, parsedTexture.generateMipMaps);
  53234. texture.brightness = parsedTexture.brightness;
  53235. texture.octaves = parsedTexture.octaves;
  53236. texture.persistence = parsedTexture.persistence;
  53237. texture.animationSpeedFactor = parsedTexture.animationSpeedFactor;
  53238. return texture;
  53239. };
  53240. return NoiseProceduralTexture;
  53241. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]));
  53242. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.NoiseProceduralTexture"] = NoiseProceduralTexture;
  53243. /***/ }),
  53244. /***/ "./Materials/Textures/Procedurals/proceduralTexture.ts":
  53245. /*!*************************************************************!*\
  53246. !*** ./Materials/Textures/Procedurals/proceduralTexture.ts ***!
  53247. \*************************************************************/
  53248. /*! exports provided: ProceduralTexture */
  53249. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53250. "use strict";
  53251. __webpack_require__.r(__webpack_exports__);
  53252. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return ProceduralTexture; });
  53253. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53254. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  53255. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/observable */ "./Misc/observable.ts");
  53256. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Meshes/buffer */ "./Meshes/buffer.ts");
  53257. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  53258. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/material */ "./Materials/material.ts");
  53259. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  53260. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  53261. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  53262. /* harmony import */ var _Shaders_procedural_vertex__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Shaders/procedural.vertex */ "./Shaders/procedural.vertex.ts");
  53263. /**
  53264. * 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.
  53265. * This is the base class of any Procedural texture and contains most of the shareable code.
  53266. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  53267. */
  53268. var ProceduralTexture = /** @class */ (function (_super) {
  53269. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ProceduralTexture, _super);
  53270. /**
  53271. * Instantiates a new procedural texture.
  53272. * 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.
  53273. * This is the base class of any Procedural texture and contains most of the shareable code.
  53274. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  53275. * @param name Define the name of the texture
  53276. * @param size Define the size of the texture to create
  53277. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  53278. * @param scene Define the scene the texture belongs to
  53279. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53280. * @param generateMipMaps Define if the texture should creates mip maps or not
  53281. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  53282. */
  53283. function ProceduralTexture(name, size, fragment, scene, fallbackTexture, generateMipMaps, isCube) {
  53284. if (fallbackTexture === void 0) { fallbackTexture = null; }
  53285. if (generateMipMaps === void 0) { generateMipMaps = true; }
  53286. if (isCube === void 0) { isCube = false; }
  53287. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  53288. _this.isCube = isCube;
  53289. /**
  53290. * Define if the texture is enabled or not (disabled texture will not render)
  53291. */
  53292. _this.isEnabled = true;
  53293. /**
  53294. * Define if the texture must be cleared before rendering (default is true)
  53295. */
  53296. _this.autoClear = true;
  53297. /**
  53298. * Event raised when the texture is generated
  53299. */
  53300. _this.onGeneratedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  53301. /** @hidden */
  53302. _this._textures = {};
  53303. _this._currentRefreshId = -1;
  53304. _this._refreshRate = 1;
  53305. _this._vertexBuffers = {};
  53306. _this._uniforms = new Array();
  53307. _this._samplers = new Array();
  53308. _this._floats = {};
  53309. _this._ints = {};
  53310. _this._floatsArrays = {};
  53311. _this._colors3 = {};
  53312. _this._colors4 = {};
  53313. _this._vectors2 = {};
  53314. _this._vectors3 = {};
  53315. _this._matrices = {};
  53316. _this._fallbackTextureUsed = false;
  53317. _this._cachedDefines = "";
  53318. _this._contentUpdateId = -1;
  53319. scene = _this.getScene();
  53320. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE);
  53321. if (!component) {
  53322. component = new _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__["ProceduralTextureSceneComponent"](scene);
  53323. scene._addComponent(component);
  53324. }
  53325. scene.proceduralTextures.push(_this);
  53326. _this._engine = scene.getEngine();
  53327. _this.name = name;
  53328. _this.isRenderTarget = true;
  53329. _this._size = size;
  53330. _this._generateMipMaps = generateMipMaps;
  53331. _this.setFragment(fragment);
  53332. _this._fallbackTexture = fallbackTexture;
  53333. if (isCube) {
  53334. _this._texture = _this._engine.createRenderTargetCubeTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  53335. _this.setFloat("face", 0);
  53336. }
  53337. else {
  53338. _this._texture = _this._engine.createRenderTargetTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  53339. }
  53340. // VBO
  53341. var vertices = [];
  53342. vertices.push(1, 1);
  53343. vertices.push(-1, 1);
  53344. vertices.push(-1, -1);
  53345. vertices.push(1, -1);
  53346. _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);
  53347. _this._createIndexBuffer();
  53348. return _this;
  53349. }
  53350. /**
  53351. * The effect that is created when initializing the post process.
  53352. * @returns The created effect corrisponding the the postprocess.
  53353. */
  53354. ProceduralTexture.prototype.getEffect = function () {
  53355. return this._effect;
  53356. };
  53357. /**
  53358. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  53359. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  53360. */
  53361. ProceduralTexture.prototype.getContent = function () {
  53362. if (this._contentData && this._currentRefreshId == this._contentUpdateId) {
  53363. return this._contentData;
  53364. }
  53365. this._contentData = this.readPixels(0, 0, this._contentData);
  53366. this._contentUpdateId = this._currentRefreshId;
  53367. return this._contentData;
  53368. };
  53369. ProceduralTexture.prototype._createIndexBuffer = function () {
  53370. var engine = this._engine;
  53371. // Indices
  53372. var indices = [];
  53373. indices.push(0);
  53374. indices.push(1);
  53375. indices.push(2);
  53376. indices.push(0);
  53377. indices.push(2);
  53378. indices.push(3);
  53379. this._indexBuffer = engine.createIndexBuffer(indices);
  53380. };
  53381. /** @hidden */
  53382. ProceduralTexture.prototype._rebuild = function () {
  53383. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  53384. if (vb) {
  53385. vb._rebuild();
  53386. }
  53387. this._createIndexBuffer();
  53388. if (this.refreshRate === _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE) {
  53389. this.refreshRate = _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE;
  53390. }
  53391. };
  53392. /**
  53393. * Resets the texture in order to recreate its associated resources.
  53394. * This can be called in case of context loss
  53395. */
  53396. ProceduralTexture.prototype.reset = function () {
  53397. if (this._effect === undefined) {
  53398. return;
  53399. }
  53400. var engine = this._engine;
  53401. engine._releaseEffect(this._effect);
  53402. };
  53403. ProceduralTexture.prototype._getDefines = function () {
  53404. return "";
  53405. };
  53406. /**
  53407. * Is the texture ready to be used ? (rendered at least once)
  53408. * @returns true if ready, otherwise, false.
  53409. */
  53410. ProceduralTexture.prototype.isReady = function () {
  53411. var _this = this;
  53412. var engine = this._engine;
  53413. var shaders;
  53414. if (!this._fragment) {
  53415. return false;
  53416. }
  53417. if (this._fallbackTextureUsed) {
  53418. return true;
  53419. }
  53420. var defines = this._getDefines();
  53421. if (this._effect && defines === this._cachedDefines && this._effect.isReady()) {
  53422. return true;
  53423. }
  53424. if (this._fragment.fragmentElement !== undefined) {
  53425. shaders = { vertex: "procedural", fragmentElement: this._fragment.fragmentElement };
  53426. }
  53427. else {
  53428. shaders = { vertex: "procedural", fragment: this._fragment };
  53429. }
  53430. this._cachedDefines = defines;
  53431. this._effect = engine.createEffect(shaders, [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], this._uniforms, this._samplers, defines, undefined, undefined, function () {
  53432. _this.releaseInternalTexture();
  53433. if (_this._fallbackTexture) {
  53434. _this._texture = _this._fallbackTexture._texture;
  53435. if (_this._texture) {
  53436. _this._texture.incrementReferences();
  53437. }
  53438. }
  53439. _this._fallbackTextureUsed = true;
  53440. });
  53441. return this._effect.isReady();
  53442. };
  53443. /**
  53444. * Resets the refresh counter of the texture and start bak from scratch.
  53445. * Could be useful to regenerate the texture if it is setup to render only once.
  53446. */
  53447. ProceduralTexture.prototype.resetRefreshCounter = function () {
  53448. this._currentRefreshId = -1;
  53449. };
  53450. /**
  53451. * Set the fragment shader to use in order to render the texture.
  53452. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  53453. */
  53454. ProceduralTexture.prototype.setFragment = function (fragment) {
  53455. this._fragment = fragment;
  53456. };
  53457. Object.defineProperty(ProceduralTexture.prototype, "refreshRate", {
  53458. /**
  53459. * Define the refresh rate of the texture or the rendering frequency.
  53460. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  53461. */
  53462. get: function () {
  53463. return this._refreshRate;
  53464. },
  53465. set: function (value) {
  53466. this._refreshRate = value;
  53467. this.resetRefreshCounter();
  53468. },
  53469. enumerable: true,
  53470. configurable: true
  53471. });
  53472. /** @hidden */
  53473. ProceduralTexture.prototype._shouldRender = function () {
  53474. if (!this.isEnabled || !this.isReady() || !this._texture) {
  53475. if (this._texture) {
  53476. this._texture.isReady = false;
  53477. }
  53478. return false;
  53479. }
  53480. if (this._fallbackTextureUsed) {
  53481. return false;
  53482. }
  53483. if (this._currentRefreshId === -1) { // At least render once
  53484. this._currentRefreshId = 1;
  53485. return true;
  53486. }
  53487. if (this.refreshRate === this._currentRefreshId) {
  53488. this._currentRefreshId = 1;
  53489. return true;
  53490. }
  53491. this._currentRefreshId++;
  53492. return false;
  53493. };
  53494. /**
  53495. * Get the size the texture is rendering at.
  53496. * @returns the size (texture is always squared)
  53497. */
  53498. ProceduralTexture.prototype.getRenderSize = function () {
  53499. return this._size;
  53500. };
  53501. /**
  53502. * Resize the texture to new value.
  53503. * @param size Define the new size the texture should have
  53504. * @param generateMipMaps Define whether the new texture should create mip maps
  53505. */
  53506. ProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  53507. if (this._fallbackTextureUsed) {
  53508. return;
  53509. }
  53510. this.releaseInternalTexture();
  53511. this._texture = this._engine.createRenderTargetTexture(size, generateMipMaps);
  53512. // Update properties
  53513. this._size = size;
  53514. this._generateMipMaps = generateMipMaps;
  53515. };
  53516. ProceduralTexture.prototype._checkUniform = function (uniformName) {
  53517. if (this._uniforms.indexOf(uniformName) === -1) {
  53518. this._uniforms.push(uniformName);
  53519. }
  53520. };
  53521. /**
  53522. * Set a texture in the shader program used to render.
  53523. * @param name Define the name of the uniform samplers as defined in the shader
  53524. * @param texture Define the texture to bind to this sampler
  53525. * @return the texture itself allowing "fluent" like uniform updates
  53526. */
  53527. ProceduralTexture.prototype.setTexture = function (name, texture) {
  53528. if (this._samplers.indexOf(name) === -1) {
  53529. this._samplers.push(name);
  53530. }
  53531. this._textures[name] = texture;
  53532. return this;
  53533. };
  53534. /**
  53535. * Set a float in the shader.
  53536. * @param name Define the name of the uniform as defined in the shader
  53537. * @param value Define the value to give to the uniform
  53538. * @return the texture itself allowing "fluent" like uniform updates
  53539. */
  53540. ProceduralTexture.prototype.setFloat = function (name, value) {
  53541. this._checkUniform(name);
  53542. this._floats[name] = value;
  53543. return this;
  53544. };
  53545. /**
  53546. * Set a int in the shader.
  53547. * @param name Define the name of the uniform as defined in the shader
  53548. * @param value Define the value to give to the uniform
  53549. * @return the texture itself allowing "fluent" like uniform updates
  53550. */
  53551. ProceduralTexture.prototype.setInt = function (name, value) {
  53552. this._checkUniform(name);
  53553. this._ints[name] = value;
  53554. return this;
  53555. };
  53556. /**
  53557. * Set an array of floats in the shader.
  53558. * @param name Define the name of the uniform as defined in the shader
  53559. * @param value Define the value to give to the uniform
  53560. * @return the texture itself allowing "fluent" like uniform updates
  53561. */
  53562. ProceduralTexture.prototype.setFloats = function (name, value) {
  53563. this._checkUniform(name);
  53564. this._floatsArrays[name] = value;
  53565. return this;
  53566. };
  53567. /**
  53568. * Set a vec3 in the shader from a Color3.
  53569. * @param name Define the name of the uniform as defined in the shader
  53570. * @param value Define the value to give to the uniform
  53571. * @return the texture itself allowing "fluent" like uniform updates
  53572. */
  53573. ProceduralTexture.prototype.setColor3 = function (name, value) {
  53574. this._checkUniform(name);
  53575. this._colors3[name] = value;
  53576. return this;
  53577. };
  53578. /**
  53579. * Set a vec4 in the shader from a Color4.
  53580. * @param name Define the name of the uniform as defined in the shader
  53581. * @param value Define the value to give to the uniform
  53582. * @return the texture itself allowing "fluent" like uniform updates
  53583. */
  53584. ProceduralTexture.prototype.setColor4 = function (name, value) {
  53585. this._checkUniform(name);
  53586. this._colors4[name] = value;
  53587. return this;
  53588. };
  53589. /**
  53590. * Set a vec2 in the shader from a Vector2.
  53591. * @param name Define the name of the uniform as defined in the shader
  53592. * @param value Define the value to give to the uniform
  53593. * @return the texture itself allowing "fluent" like uniform updates
  53594. */
  53595. ProceduralTexture.prototype.setVector2 = function (name, value) {
  53596. this._checkUniform(name);
  53597. this._vectors2[name] = value;
  53598. return this;
  53599. };
  53600. /**
  53601. * Set a vec3 in the shader from a Vector3.
  53602. * @param name Define the name of the uniform as defined in the shader
  53603. * @param value Define the value to give to the uniform
  53604. * @return the texture itself allowing "fluent" like uniform updates
  53605. */
  53606. ProceduralTexture.prototype.setVector3 = function (name, value) {
  53607. this._checkUniform(name);
  53608. this._vectors3[name] = value;
  53609. return this;
  53610. };
  53611. /**
  53612. * Set a mat4 in the shader from a MAtrix.
  53613. * @param name Define the name of the uniform as defined in the shader
  53614. * @param value Define the value to give to the uniform
  53615. * @return the texture itself allowing "fluent" like uniform updates
  53616. */
  53617. ProceduralTexture.prototype.setMatrix = function (name, value) {
  53618. this._checkUniform(name);
  53619. this._matrices[name] = value;
  53620. return this;
  53621. };
  53622. /**
  53623. * Render the texture to its associated render target.
  53624. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53625. */
  53626. ProceduralTexture.prototype.render = function (useCameraPostProcess) {
  53627. var scene = this.getScene();
  53628. if (!scene) {
  53629. return;
  53630. }
  53631. var engine = this._engine;
  53632. // Render
  53633. engine.enableEffect(this._effect);
  53634. engine.setState(false);
  53635. // Texture
  53636. for (var name in this._textures) {
  53637. this._effect.setTexture(name, this._textures[name]);
  53638. }
  53639. // Float
  53640. for (name in this._ints) {
  53641. this._effect.setInt(name, this._ints[name]);
  53642. }
  53643. // Float
  53644. for (name in this._floats) {
  53645. this._effect.setFloat(name, this._floats[name]);
  53646. }
  53647. // Floats
  53648. for (name in this._floatsArrays) {
  53649. this._effect.setArray(name, this._floatsArrays[name]);
  53650. }
  53651. // Color3
  53652. for (name in this._colors3) {
  53653. this._effect.setColor3(name, this._colors3[name]);
  53654. }
  53655. // Color4
  53656. for (name in this._colors4) {
  53657. var color = this._colors4[name];
  53658. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  53659. }
  53660. // Vector2
  53661. for (name in this._vectors2) {
  53662. this._effect.setVector2(name, this._vectors2[name]);
  53663. }
  53664. // Vector3
  53665. for (name in this._vectors3) {
  53666. this._effect.setVector3(name, this._vectors3[name]);
  53667. }
  53668. // Matrix
  53669. for (name in this._matrices) {
  53670. this._effect.setMatrix(name, this._matrices[name]);
  53671. }
  53672. if (!this._texture) {
  53673. return;
  53674. }
  53675. if (this.isCube) {
  53676. for (var face = 0; face < 6; face++) {
  53677. engine.bindFramebuffer(this._texture, face, undefined, undefined, true);
  53678. // VBOs
  53679. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  53680. this._effect.setFloat("face", face);
  53681. // Clear
  53682. if (this.autoClear) {
  53683. engine.clear(scene.clearColor, true, false, false);
  53684. }
  53685. // Draw order
  53686. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  53687. // Mipmaps
  53688. if (face === 5) {
  53689. engine.generateMipMapsForCubemap(this._texture);
  53690. }
  53691. }
  53692. }
  53693. else {
  53694. engine.bindFramebuffer(this._texture, 0, undefined, undefined, true);
  53695. // VBOs
  53696. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  53697. // Clear
  53698. if (this.autoClear) {
  53699. engine.clear(scene.clearColor, true, false, false);
  53700. }
  53701. // Draw order
  53702. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  53703. }
  53704. // Unbind
  53705. engine.unBindFramebuffer(this._texture, this.isCube);
  53706. if (this.onGenerated) {
  53707. this.onGenerated();
  53708. }
  53709. this.onGeneratedObservable.notifyObservers(this);
  53710. };
  53711. /**
  53712. * Clone the texture.
  53713. * @returns the cloned texture
  53714. */
  53715. ProceduralTexture.prototype.clone = function () {
  53716. var textureSize = this.getSize();
  53717. var newTexture = new ProceduralTexture(this.name, textureSize.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
  53718. // Base texture
  53719. newTexture.hasAlpha = this.hasAlpha;
  53720. newTexture.level = this.level;
  53721. // RenderTarget Texture
  53722. newTexture.coordinatesMode = this.coordinatesMode;
  53723. return newTexture;
  53724. };
  53725. /**
  53726. * Dispose the texture and release its asoociated resources.
  53727. */
  53728. ProceduralTexture.prototype.dispose = function () {
  53729. var scene = this.getScene();
  53730. if (!scene) {
  53731. return;
  53732. }
  53733. var index = scene.proceduralTextures.indexOf(this);
  53734. if (index >= 0) {
  53735. scene.proceduralTextures.splice(index, 1);
  53736. }
  53737. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  53738. if (vertexBuffer) {
  53739. vertexBuffer.dispose();
  53740. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  53741. }
  53742. if (this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer)) {
  53743. this._indexBuffer = null;
  53744. }
  53745. _super.prototype.dispose.call(this);
  53746. };
  53747. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53748. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53749. ], ProceduralTexture.prototype, "isEnabled", void 0);
  53750. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53751. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53752. ], ProceduralTexture.prototype, "autoClear", void 0);
  53753. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53754. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53755. ], ProceduralTexture.prototype, "_generateMipMaps", void 0);
  53756. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53757. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53758. ], ProceduralTexture.prototype, "_size", void 0);
  53759. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53760. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53761. ], ProceduralTexture.prototype, "refreshRate", null);
  53762. return ProceduralTexture;
  53763. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"]));
  53764. /***/ }),
  53765. /***/ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts":
  53766. /*!***************************************************************************!*\
  53767. !*** ./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts ***!
  53768. \***************************************************************************/
  53769. /*! exports provided: ProceduralTextureSceneComponent */
  53770. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53771. "use strict";
  53772. __webpack_require__.r(__webpack_exports__);
  53773. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return ProceduralTextureSceneComponent; });
  53774. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  53775. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  53776. /**
  53777. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  53778. * in a given scene.
  53779. */
  53780. var ProceduralTextureSceneComponent = /** @class */ (function () {
  53781. /**
  53782. * Creates a new instance of the component for the given scene
  53783. * @param scene Defines the scene to register the component in
  53784. */
  53785. function ProceduralTextureSceneComponent(scene) {
  53786. /**
  53787. * The component name helpfull to identify the component in the list of scene components.
  53788. */
  53789. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE;
  53790. this.scene = scene;
  53791. this.scene.proceduralTextures = new Array();
  53792. scene.layers = new Array();
  53793. }
  53794. /**
  53795. * Registers the component in a given scene
  53796. */
  53797. ProceduralTextureSceneComponent.prototype.register = function () {
  53798. this.scene._beforeClearStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear);
  53799. };
  53800. /**
  53801. * Rebuilds the elements related to this component in case of
  53802. * context lost for instance.
  53803. */
  53804. ProceduralTextureSceneComponent.prototype.rebuild = function () {
  53805. // Nothing to do here.
  53806. };
  53807. /**
  53808. * Disposes the component and the associated ressources.
  53809. */
  53810. ProceduralTextureSceneComponent.prototype.dispose = function () {
  53811. // Nothing to do here.
  53812. };
  53813. ProceduralTextureSceneComponent.prototype._beforeClear = function () {
  53814. if (this.scene.proceduralTexturesEnabled) {
  53815. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  53816. for (var proceduralIndex = 0; proceduralIndex < this.scene.proceduralTextures.length; proceduralIndex++) {
  53817. var proceduralTexture = this.scene.proceduralTextures[proceduralIndex];
  53818. if (proceduralTexture._shouldRender()) {
  53819. proceduralTexture.render();
  53820. }
  53821. }
  53822. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  53823. }
  53824. };
  53825. return ProceduralTextureSceneComponent;
  53826. }());
  53827. /***/ }),
  53828. /***/ "./Materials/Textures/baseTexture.ts":
  53829. /*!*******************************************!*\
  53830. !*** ./Materials/Textures/baseTexture.ts ***!
  53831. \*******************************************/
  53832. /*! exports provided: BaseTexture */
  53833. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53834. "use strict";
  53835. __webpack_require__.r(__webpack_exports__);
  53836. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return BaseTexture; });
  53837. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53838. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53839. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  53840. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  53841. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  53842. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  53843. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  53844. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  53845. /**
  53846. * Base class of all the textures in babylon.
  53847. * It groups all the common properties the materials, post process, lights... might need
  53848. * in order to make a correct use of the texture.
  53849. */
  53850. var BaseTexture = /** @class */ (function () {
  53851. /**
  53852. * Instantiates a new BaseTexture.
  53853. * Base class of all the textures in babylon.
  53854. * It groups all the common properties the materials, post process, lights... might need
  53855. * in order to make a correct use of the texture.
  53856. * @param scene Define the scene the texture blongs to
  53857. */
  53858. function BaseTexture(scene) {
  53859. /**
  53860. * Gets or sets an object used to store user defined information.
  53861. */
  53862. this.metadata = null;
  53863. /**
  53864. * For internal use only. Please do not use.
  53865. */
  53866. this.reservedDataStore = null;
  53867. this._hasAlpha = false;
  53868. /**
  53869. * Defines if the alpha value should be determined via the rgb values.
  53870. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  53871. */
  53872. this.getAlphaFromRGB = false;
  53873. /**
  53874. * Intensity or strength of the texture.
  53875. * It is commonly used by materials to fine tune the intensity of the texture
  53876. */
  53877. this.level = 1;
  53878. /**
  53879. * Define the UV chanel to use starting from 0 and defaulting to 0.
  53880. * This is part of the texture as textures usually maps to one uv set.
  53881. */
  53882. this.coordinatesIndex = 0;
  53883. this._coordinatesMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_EXPLICIT_MODE;
  53884. /**
  53885. * | Value | Type | Description |
  53886. * | ----- | ------------------ | ----------- |
  53887. * | 0 | CLAMP_ADDRESSMODE | |
  53888. * | 1 | WRAP_ADDRESSMODE | |
  53889. * | 2 | MIRROR_ADDRESSMODE | |
  53890. */
  53891. this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  53892. /**
  53893. * | Value | Type | Description |
  53894. * | ----- | ------------------ | ----------- |
  53895. * | 0 | CLAMP_ADDRESSMODE | |
  53896. * | 1 | WRAP_ADDRESSMODE | |
  53897. * | 2 | MIRROR_ADDRESSMODE | |
  53898. */
  53899. this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  53900. /**
  53901. * | Value | Type | Description |
  53902. * | ----- | ------------------ | ----------- |
  53903. * | 0 | CLAMP_ADDRESSMODE | |
  53904. * | 1 | WRAP_ADDRESSMODE | |
  53905. * | 2 | MIRROR_ADDRESSMODE | |
  53906. */
  53907. this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  53908. /**
  53909. * With compliant hardware and browser (supporting anisotropic filtering)
  53910. * this defines the level of anisotropic filtering in the texture.
  53911. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  53912. */
  53913. this.anisotropicFilteringLevel = BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL;
  53914. /**
  53915. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  53916. * HDR texture are usually stored in linear space.
  53917. * This only impacts the PBR and Background materials
  53918. */
  53919. this.gammaSpace = true;
  53920. /**
  53921. * Is Z inverted in the texture (useful in a cube texture).
  53922. */
  53923. this.invertZ = false;
  53924. /**
  53925. * @hidden
  53926. */
  53927. this.lodLevelInAlpha = false;
  53928. /**
  53929. * Define if the texture is a render target.
  53930. */
  53931. this.isRenderTarget = false;
  53932. /**
  53933. * Define the list of animation attached to the texture.
  53934. */
  53935. this.animations = new Array();
  53936. /**
  53937. * An event triggered when the texture is disposed.
  53938. */
  53939. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  53940. /**
  53941. * Define the current state of the loading sequence when in delayed load mode.
  53942. */
  53943. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  53944. this._cachedSize = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  53945. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  53946. if (this._scene) {
  53947. this.uniqueId = this._scene.getUniqueId();
  53948. this._scene.addTexture(this);
  53949. }
  53950. this._uid = null;
  53951. }
  53952. Object.defineProperty(BaseTexture.prototype, "hasAlpha", {
  53953. get: function () {
  53954. return this._hasAlpha;
  53955. },
  53956. /**
  53957. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  53958. */
  53959. set: function (value) {
  53960. if (this._hasAlpha === value) {
  53961. return;
  53962. }
  53963. this._hasAlpha = value;
  53964. if (this._scene) {
  53965. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag | _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_MiscDirtyFlag);
  53966. }
  53967. },
  53968. enumerable: true,
  53969. configurable: true
  53970. });
  53971. Object.defineProperty(BaseTexture.prototype, "coordinatesMode", {
  53972. get: function () {
  53973. return this._coordinatesMode;
  53974. },
  53975. /**
  53976. * How a texture is mapped.
  53977. *
  53978. * | Value | Type | Description |
  53979. * | ----- | ----------------------------------- | ----------- |
  53980. * | 0 | EXPLICIT_MODE | |
  53981. * | 1 | SPHERICAL_MODE | |
  53982. * | 2 | PLANAR_MODE | |
  53983. * | 3 | CUBIC_MODE | |
  53984. * | 4 | PROJECTION_MODE | |
  53985. * | 5 | SKYBOX_MODE | |
  53986. * | 6 | INVCUBIC_MODE | |
  53987. * | 7 | EQUIRECTANGULAR_MODE | |
  53988. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  53989. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  53990. */
  53991. set: function (value) {
  53992. if (this._coordinatesMode === value) {
  53993. return;
  53994. }
  53995. this._coordinatesMode = value;
  53996. if (this._scene) {
  53997. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  53998. }
  53999. },
  54000. enumerable: true,
  54001. configurable: true
  54002. });
  54003. Object.defineProperty(BaseTexture.prototype, "isCube", {
  54004. /**
  54005. * Define if the texture is a cube texture or if false a 2d texture.
  54006. */
  54007. get: function () {
  54008. if (!this._texture) {
  54009. return false;
  54010. }
  54011. return this._texture.isCube;
  54012. },
  54013. set: function (value) {
  54014. if (!this._texture) {
  54015. return;
  54016. }
  54017. this._texture.isCube = value;
  54018. },
  54019. enumerable: true,
  54020. configurable: true
  54021. });
  54022. Object.defineProperty(BaseTexture.prototype, "is3D", {
  54023. /**
  54024. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  54025. */
  54026. get: function () {
  54027. if (!this._texture) {
  54028. return false;
  54029. }
  54030. return this._texture.is3D;
  54031. },
  54032. set: function (value) {
  54033. if (!this._texture) {
  54034. return;
  54035. }
  54036. this._texture.is3D = value;
  54037. },
  54038. enumerable: true,
  54039. configurable: true
  54040. });
  54041. Object.defineProperty(BaseTexture.prototype, "isRGBD", {
  54042. /**
  54043. * Gets whether or not the texture contains RGBD data.
  54044. */
  54045. get: function () {
  54046. return this._texture != null && this._texture._isRGBD;
  54047. },
  54048. enumerable: true,
  54049. configurable: true
  54050. });
  54051. Object.defineProperty(BaseTexture.prototype, "noMipmap", {
  54052. /**
  54053. * Are mip maps generated for this texture or not.
  54054. */
  54055. get: function () {
  54056. return false;
  54057. },
  54058. enumerable: true,
  54059. configurable: true
  54060. });
  54061. Object.defineProperty(BaseTexture.prototype, "lodGenerationOffset", {
  54062. /**
  54063. * With prefiltered texture, defined the offset used during the prefiltering steps.
  54064. */
  54065. get: function () {
  54066. if (this._texture) {
  54067. return this._texture._lodGenerationOffset;
  54068. }
  54069. return 0.0;
  54070. },
  54071. set: function (value) {
  54072. if (this._texture) {
  54073. this._texture._lodGenerationOffset = value;
  54074. }
  54075. },
  54076. enumerable: true,
  54077. configurable: true
  54078. });
  54079. Object.defineProperty(BaseTexture.prototype, "lodGenerationScale", {
  54080. /**
  54081. * With prefiltered texture, defined the scale used during the prefiltering steps.
  54082. */
  54083. get: function () {
  54084. if (this._texture) {
  54085. return this._texture._lodGenerationScale;
  54086. }
  54087. return 0.0;
  54088. },
  54089. set: function (value) {
  54090. if (this._texture) {
  54091. this._texture._lodGenerationScale = value;
  54092. }
  54093. },
  54094. enumerable: true,
  54095. configurable: true
  54096. });
  54097. Object.defineProperty(BaseTexture.prototype, "uid", {
  54098. /**
  54099. * Define the unique id of the texture in the scene.
  54100. */
  54101. get: function () {
  54102. if (!this._uid) {
  54103. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].RandomId();
  54104. }
  54105. return this._uid;
  54106. },
  54107. enumerable: true,
  54108. configurable: true
  54109. });
  54110. /**
  54111. * Return a string representation of the texture.
  54112. * @returns the texture as a string
  54113. */
  54114. BaseTexture.prototype.toString = function () {
  54115. return this.name;
  54116. };
  54117. /**
  54118. * Get the class name of the texture.
  54119. * @returns "BaseTexture"
  54120. */
  54121. BaseTexture.prototype.getClassName = function () {
  54122. return "BaseTexture";
  54123. };
  54124. Object.defineProperty(BaseTexture.prototype, "onDispose", {
  54125. /**
  54126. * Callback triggered when the texture has been disposed.
  54127. * Kept for back compatibility, you can use the onDisposeObservable instead.
  54128. */
  54129. set: function (callback) {
  54130. if (this._onDisposeObserver) {
  54131. this.onDisposeObservable.remove(this._onDisposeObserver);
  54132. }
  54133. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  54134. },
  54135. enumerable: true,
  54136. configurable: true
  54137. });
  54138. Object.defineProperty(BaseTexture.prototype, "isBlocking", {
  54139. /**
  54140. * Define if the texture is preventinga material to render or not.
  54141. * If not and the texture is not ready, the engine will use a default black texture instead.
  54142. */
  54143. get: function () {
  54144. return true;
  54145. },
  54146. enumerable: true,
  54147. configurable: true
  54148. });
  54149. /**
  54150. * Get the scene the texture belongs to.
  54151. * @returns the scene or null if undefined
  54152. */
  54153. BaseTexture.prototype.getScene = function () {
  54154. return this._scene;
  54155. };
  54156. /**
  54157. * Get the texture transform matrix used to offset tile the texture for istance.
  54158. * @returns the transformation matrix
  54159. */
  54160. BaseTexture.prototype.getTextureMatrix = function () {
  54161. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  54162. };
  54163. /**
  54164. * Get the texture reflection matrix used to rotate/transform the reflection.
  54165. * @returns the reflection matrix
  54166. */
  54167. BaseTexture.prototype.getReflectionTextureMatrix = function () {
  54168. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  54169. };
  54170. /**
  54171. * Get the underlying lower level texture from Babylon.
  54172. * @returns the insternal texture
  54173. */
  54174. BaseTexture.prototype.getInternalTexture = function () {
  54175. return this._texture;
  54176. };
  54177. /**
  54178. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  54179. * @returns true if ready or not blocking
  54180. */
  54181. BaseTexture.prototype.isReadyOrNotBlocking = function () {
  54182. return !this.isBlocking || this.isReady();
  54183. };
  54184. /**
  54185. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  54186. * @returns true if fully ready
  54187. */
  54188. BaseTexture.prototype.isReady = function () {
  54189. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  54190. this.delayLoad();
  54191. return false;
  54192. }
  54193. if (this._texture) {
  54194. return this._texture.isReady;
  54195. }
  54196. return false;
  54197. };
  54198. /**
  54199. * Get the size of the texture.
  54200. * @returns the texture size.
  54201. */
  54202. BaseTexture.prototype.getSize = function () {
  54203. if (this._texture) {
  54204. if (this._texture.width) {
  54205. this._cachedSize.width = this._texture.width;
  54206. this._cachedSize.height = this._texture.height;
  54207. return this._cachedSize;
  54208. }
  54209. if (this._texture._size) {
  54210. this._cachedSize.width = this._texture._size;
  54211. this._cachedSize.height = this._texture._size;
  54212. return this._cachedSize;
  54213. }
  54214. }
  54215. return this._cachedSize;
  54216. };
  54217. /**
  54218. * Get the base size of the texture.
  54219. * It can be different from the size if the texture has been resized for POT for instance
  54220. * @returns the base size
  54221. */
  54222. BaseTexture.prototype.getBaseSize = function () {
  54223. if (!this.isReady() || !this._texture) {
  54224. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  54225. }
  54226. if (this._texture._size) {
  54227. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture._size, this._texture._size);
  54228. }
  54229. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture.baseWidth, this._texture.baseHeight);
  54230. };
  54231. /**
  54232. * Update the sampling mode of the texture.
  54233. * Default is Trilinear mode.
  54234. *
  54235. * | Value | Type | Description |
  54236. * | ----- | ------------------ | ----------- |
  54237. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  54238. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  54239. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  54240. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  54241. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  54242. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  54243. * | 7 | NEAREST_LINEAR | |
  54244. * | 8 | NEAREST_NEAREST | |
  54245. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  54246. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  54247. * | 11 | LINEAR_LINEAR | |
  54248. * | 12 | LINEAR_NEAREST | |
  54249. *
  54250. * > _mag_: magnification filter (close to the viewer)
  54251. * > _min_: minification filter (far from the viewer)
  54252. * > _mip_: filter used between mip map levels
  54253. *@param samplingMode Define the new sampling mode of the texture
  54254. */
  54255. BaseTexture.prototype.updateSamplingMode = function (samplingMode) {
  54256. if (!this._texture) {
  54257. return;
  54258. }
  54259. var scene = this.getScene();
  54260. if (!scene) {
  54261. return;
  54262. }
  54263. scene.getEngine().updateTextureSamplingMode(samplingMode, this._texture);
  54264. };
  54265. /**
  54266. * Scales the texture if is `canRescale()`
  54267. * @param ratio the resize factor we want to use to rescale
  54268. */
  54269. BaseTexture.prototype.scale = function (ratio) {
  54270. };
  54271. Object.defineProperty(BaseTexture.prototype, "canRescale", {
  54272. /**
  54273. * Get if the texture can rescale.
  54274. */
  54275. get: function () {
  54276. return false;
  54277. },
  54278. enumerable: true,
  54279. configurable: true
  54280. });
  54281. /** @hidden */
  54282. BaseTexture.prototype._getFromCache = function (url, noMipmap, sampling) {
  54283. if (!this._scene) {
  54284. return null;
  54285. }
  54286. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  54287. for (var index = 0; index < texturesCache.length; index++) {
  54288. var texturesCacheEntry = texturesCache[index];
  54289. if (texturesCacheEntry.url === url && texturesCacheEntry.generateMipMaps === !noMipmap) {
  54290. if (!sampling || sampling === texturesCacheEntry.samplingMode) {
  54291. texturesCacheEntry.incrementReferences();
  54292. return texturesCacheEntry;
  54293. }
  54294. }
  54295. }
  54296. return null;
  54297. };
  54298. /** @hidden */
  54299. BaseTexture.prototype._rebuild = function () {
  54300. };
  54301. /**
  54302. * Triggers the load sequence in delayed load mode.
  54303. */
  54304. BaseTexture.prototype.delayLoad = function () {
  54305. };
  54306. /**
  54307. * Clones the texture.
  54308. * @returns the cloned texture
  54309. */
  54310. BaseTexture.prototype.clone = function () {
  54311. return null;
  54312. };
  54313. Object.defineProperty(BaseTexture.prototype, "textureType", {
  54314. /**
  54315. * Get the texture underlying type (INT, FLOAT...)
  54316. */
  54317. get: function () {
  54318. if (!this._texture) {
  54319. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  54320. }
  54321. return (this._texture.type !== undefined) ? this._texture.type : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  54322. },
  54323. enumerable: true,
  54324. configurable: true
  54325. });
  54326. Object.defineProperty(BaseTexture.prototype, "textureFormat", {
  54327. /**
  54328. * Get the texture underlying format (RGB, RGBA...)
  54329. */
  54330. get: function () {
  54331. if (!this._texture) {
  54332. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  54333. }
  54334. return (this._texture.format !== undefined) ? this._texture.format : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  54335. },
  54336. enumerable: true,
  54337. configurable: true
  54338. });
  54339. /**
  54340. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  54341. * This will returns an RGBA array buffer containing either in values (0-255) or
  54342. * float values (0-1) depending of the underlying buffer type.
  54343. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  54344. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  54345. * @param buffer defines a user defined buffer to fill with data (can be null)
  54346. * @returns The Array buffer containing the pixels data.
  54347. */
  54348. BaseTexture.prototype.readPixels = function (faceIndex, level, buffer) {
  54349. if (faceIndex === void 0) { faceIndex = 0; }
  54350. if (level === void 0) { level = 0; }
  54351. if (buffer === void 0) { buffer = null; }
  54352. if (!this._texture) {
  54353. return null;
  54354. }
  54355. var size = this.getSize();
  54356. var width = size.width;
  54357. var height = size.height;
  54358. var scene = this.getScene();
  54359. if (!scene) {
  54360. return null;
  54361. }
  54362. var engine = scene.getEngine();
  54363. if (level != 0) {
  54364. width = width / Math.pow(2, level);
  54365. height = height / Math.pow(2, level);
  54366. width = Math.round(width);
  54367. height = Math.round(height);
  54368. }
  54369. if (this._texture.isCube) {
  54370. return engine._readTexturePixels(this._texture, width, height, faceIndex, level, buffer);
  54371. }
  54372. return engine._readTexturePixels(this._texture, width, height, -1, level, buffer);
  54373. };
  54374. /**
  54375. * Release and destroy the underlying lower level texture aka internalTexture.
  54376. */
  54377. BaseTexture.prototype.releaseInternalTexture = function () {
  54378. if (this._texture) {
  54379. this._texture.dispose();
  54380. this._texture = null;
  54381. }
  54382. };
  54383. Object.defineProperty(BaseTexture.prototype, "sphericalPolynomial", {
  54384. /**
  54385. * Get the polynomial representation of the texture data.
  54386. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54387. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54388. */
  54389. get: function () {
  54390. if (!this._texture || !_Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"] || !this.isReady()) {
  54391. return null;
  54392. }
  54393. if (!this._texture._sphericalPolynomial) {
  54394. this._texture._sphericalPolynomial =
  54395. _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapTextureToSphericalPolynomial(this);
  54396. }
  54397. return this._texture._sphericalPolynomial;
  54398. },
  54399. set: function (value) {
  54400. if (this._texture) {
  54401. this._texture._sphericalPolynomial = value;
  54402. }
  54403. },
  54404. enumerable: true,
  54405. configurable: true
  54406. });
  54407. Object.defineProperty(BaseTexture.prototype, "_lodTextureHigh", {
  54408. /** @hidden */
  54409. get: function () {
  54410. if (this._texture) {
  54411. return this._texture._lodTextureHigh;
  54412. }
  54413. return null;
  54414. },
  54415. enumerable: true,
  54416. configurable: true
  54417. });
  54418. Object.defineProperty(BaseTexture.prototype, "_lodTextureMid", {
  54419. /** @hidden */
  54420. get: function () {
  54421. if (this._texture) {
  54422. return this._texture._lodTextureMid;
  54423. }
  54424. return null;
  54425. },
  54426. enumerable: true,
  54427. configurable: true
  54428. });
  54429. Object.defineProperty(BaseTexture.prototype, "_lodTextureLow", {
  54430. /** @hidden */
  54431. get: function () {
  54432. if (this._texture) {
  54433. return this._texture._lodTextureLow;
  54434. }
  54435. return null;
  54436. },
  54437. enumerable: true,
  54438. configurable: true
  54439. });
  54440. /**
  54441. * Dispose the texture and release its associated resources.
  54442. */
  54443. BaseTexture.prototype.dispose = function () {
  54444. if (!this._scene) {
  54445. return;
  54446. }
  54447. // Animations
  54448. this._scene.stopAnimation(this);
  54449. // Remove from scene
  54450. this._scene._removePendingData(this);
  54451. var index = this._scene.textures.indexOf(this);
  54452. if (index >= 0) {
  54453. this._scene.textures.splice(index, 1);
  54454. }
  54455. this._scene.onTextureRemovedObservable.notifyObservers(this);
  54456. if (this._texture === undefined) {
  54457. return;
  54458. }
  54459. // Release
  54460. this.releaseInternalTexture();
  54461. // Callback
  54462. this.onDisposeObservable.notifyObservers(this);
  54463. this.onDisposeObservable.clear();
  54464. };
  54465. /**
  54466. * Serialize the texture into a JSON representation that can be parsed later on.
  54467. * @returns the JSON representation of the texture
  54468. */
  54469. BaseTexture.prototype.serialize = function () {
  54470. if (!this.name) {
  54471. return null;
  54472. }
  54473. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54474. // Animations
  54475. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  54476. return serializationObject;
  54477. };
  54478. /**
  54479. * Helper function to be called back once a list of texture contains only ready textures.
  54480. * @param textures Define the list of textures to wait for
  54481. * @param callback Define the callback triggered once the entire list will be ready
  54482. */
  54483. BaseTexture.WhenAllReady = function (textures, callback) {
  54484. var numRemaining = textures.length;
  54485. if (numRemaining === 0) {
  54486. callback();
  54487. return;
  54488. }
  54489. var _loop_1 = function () {
  54490. texture = textures[i];
  54491. if (texture.isReady()) {
  54492. if (--numRemaining === 0) {
  54493. callback();
  54494. }
  54495. }
  54496. else {
  54497. onLoadObservable = texture.onLoadObservable;
  54498. var onLoadCallback_1 = function () {
  54499. onLoadObservable.removeCallback(onLoadCallback_1);
  54500. if (--numRemaining === 0) {
  54501. callback();
  54502. }
  54503. };
  54504. onLoadObservable.add(onLoadCallback_1);
  54505. }
  54506. };
  54507. var texture, onLoadObservable;
  54508. for (var i = 0; i < textures.length; i++) {
  54509. _loop_1();
  54510. }
  54511. };
  54512. /**
  54513. * Default anisotropic filtering level for the application.
  54514. * It is set to 4 as a good tradeoff between perf and quality.
  54515. */
  54516. BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4;
  54517. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54518. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54519. ], BaseTexture.prototype, "uniqueId", void 0);
  54520. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54521. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54522. ], BaseTexture.prototype, "name", void 0);
  54523. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54524. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54525. ], BaseTexture.prototype, "metadata", void 0);
  54526. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54527. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("hasAlpha")
  54528. ], BaseTexture.prototype, "_hasAlpha", void 0);
  54529. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54530. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54531. ], BaseTexture.prototype, "getAlphaFromRGB", void 0);
  54532. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54533. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54534. ], BaseTexture.prototype, "level", void 0);
  54535. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54536. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54537. ], BaseTexture.prototype, "coordinatesIndex", void 0);
  54538. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54539. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("coordinatesMode")
  54540. ], BaseTexture.prototype, "_coordinatesMode", void 0);
  54541. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54542. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54543. ], BaseTexture.prototype, "wrapU", void 0);
  54544. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54545. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54546. ], BaseTexture.prototype, "wrapV", void 0);
  54547. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54548. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54549. ], BaseTexture.prototype, "wrapR", void 0);
  54550. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54551. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54552. ], BaseTexture.prototype, "anisotropicFilteringLevel", void 0);
  54553. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54554. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54555. ], BaseTexture.prototype, "isCube", null);
  54556. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54557. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54558. ], BaseTexture.prototype, "is3D", null);
  54559. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54560. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54561. ], BaseTexture.prototype, "gammaSpace", void 0);
  54562. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54563. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54564. ], BaseTexture.prototype, "invertZ", void 0);
  54565. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54566. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54567. ], BaseTexture.prototype, "lodLevelInAlpha", void 0);
  54568. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54569. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54570. ], BaseTexture.prototype, "lodGenerationOffset", null);
  54571. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54572. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54573. ], BaseTexture.prototype, "lodGenerationScale", null);
  54574. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54575. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54576. ], BaseTexture.prototype, "isRenderTarget", void 0);
  54577. return BaseTexture;
  54578. }());
  54579. /***/ }),
  54580. /***/ "./Materials/Textures/colorGradingTexture.ts":
  54581. /*!***************************************************!*\
  54582. !*** ./Materials/Textures/colorGradingTexture.ts ***!
  54583. \***************************************************/
  54584. /*! exports provided: ColorGradingTexture */
  54585. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54586. "use strict";
  54587. __webpack_require__.r(__webpack_exports__);
  54588. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return ColorGradingTexture; });
  54589. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54590. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  54591. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  54592. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  54593. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  54594. /**
  54595. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54596. * It can help converting any input color in a desired output one. This can then be used to create effects
  54597. * from sepia, black and white to sixties or futuristic rendering...
  54598. *
  54599. * The only supported format is currently 3dl.
  54600. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54601. */
  54602. var ColorGradingTexture = /** @class */ (function (_super) {
  54603. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorGradingTexture, _super);
  54604. /**
  54605. * Instantiates a ColorGradingTexture from the following parameters.
  54606. *
  54607. * @param url The location of the color gradind data (currently only supporting 3dl)
  54608. * @param scene The scene the texture will be used in
  54609. */
  54610. function ColorGradingTexture(url, scene) {
  54611. var _this = _super.call(this, scene) || this;
  54612. if (!url) {
  54613. return _this;
  54614. }
  54615. _this._engine = scene.getEngine();
  54616. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  54617. _this.name = url;
  54618. _this.url = url;
  54619. _this.hasAlpha = false;
  54620. _this.isCube = false;
  54621. _this.is3D = _this._engine.webGLVersion > 1;
  54622. _this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  54623. _this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  54624. _this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  54625. _this.anisotropicFilteringLevel = 1;
  54626. _this._texture = _this._getFromCache(url, true);
  54627. if (!_this._texture) {
  54628. if (!scene.useDelayedTextureLoading) {
  54629. _this.loadTexture();
  54630. }
  54631. else {
  54632. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED;
  54633. }
  54634. }
  54635. return _this;
  54636. }
  54637. /**
  54638. * Returns the texture matrix used in most of the material.
  54639. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54640. */
  54641. ColorGradingTexture.prototype.getTextureMatrix = function () {
  54642. return this._textureMatrix;
  54643. };
  54644. /**
  54645. * Occurs when the file being loaded is a .3dl LUT file.
  54646. */
  54647. ColorGradingTexture.prototype.load3dlTexture = function () {
  54648. var engine = this._engine;
  54649. var texture;
  54650. if (engine.webGLVersion === 1) {
  54651. 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);
  54652. }
  54653. else {
  54654. 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);
  54655. }
  54656. this._texture = texture;
  54657. var callback = function (text) {
  54658. if (typeof text !== "string") {
  54659. return;
  54660. }
  54661. var data = null;
  54662. var tempData = null;
  54663. var line;
  54664. var lines = text.split('\n');
  54665. var size = 0, pixelIndexW = 0, pixelIndexH = 0, pixelIndexSlice = 0;
  54666. var maxColor = 0;
  54667. for (var i = 0; i < lines.length; i++) {
  54668. line = lines[i];
  54669. if (!ColorGradingTexture._noneEmptyLineRegex.test(line)) {
  54670. continue;
  54671. }
  54672. if (line.indexOf('#') === 0) {
  54673. continue;
  54674. }
  54675. var words = line.split(" ");
  54676. if (size === 0) {
  54677. // Number of space + one
  54678. size = words.length;
  54679. data = new Uint8Array(size * size * size * 4); // volume texture of side size and rgb 8
  54680. tempData = new Float32Array(size * size * size * 4);
  54681. continue;
  54682. }
  54683. if (size != 0) {
  54684. var r = Math.max(parseInt(words[0]), 0);
  54685. var g = Math.max(parseInt(words[1]), 0);
  54686. var b = Math.max(parseInt(words[2]), 0);
  54687. maxColor = Math.max(r, maxColor);
  54688. maxColor = Math.max(g, maxColor);
  54689. maxColor = Math.max(b, maxColor);
  54690. var pixelStorageIndex = (pixelIndexW + pixelIndexSlice * size + pixelIndexH * size * size) * 4;
  54691. if (tempData) {
  54692. tempData[pixelStorageIndex + 0] = r;
  54693. tempData[pixelStorageIndex + 1] = g;
  54694. tempData[pixelStorageIndex + 2] = b;
  54695. }
  54696. // Keep for reference in case of back compat problems.
  54697. // pixelIndexSlice++;
  54698. // if (pixelIndexSlice % size == 0) {
  54699. // pixelIndexH++;
  54700. // pixelIndexSlice = 0;
  54701. // if (pixelIndexH % size == 0) {
  54702. // pixelIndexW++;
  54703. // pixelIndexH = 0;
  54704. // }
  54705. // }
  54706. pixelIndexH++;
  54707. if (pixelIndexH % size == 0) {
  54708. pixelIndexSlice++;
  54709. pixelIndexH = 0;
  54710. if (pixelIndexSlice % size == 0) {
  54711. pixelIndexW++;
  54712. pixelIndexSlice = 0;
  54713. }
  54714. }
  54715. }
  54716. }
  54717. if (tempData && data) {
  54718. for (var i = 0; i < tempData.length; i++) {
  54719. if (i > 0 && (i + 1) % 4 === 0) {
  54720. data[i] = 255;
  54721. }
  54722. else {
  54723. var value = tempData[i];
  54724. data[i] = (value / maxColor * 255);
  54725. }
  54726. }
  54727. }
  54728. if (texture.is3D) {
  54729. texture.updateSize(size, size, size);
  54730. engine.updateRawTexture3D(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  54731. }
  54732. else {
  54733. texture.updateSize(size * size, size);
  54734. engine.updateRawTexture(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  54735. }
  54736. };
  54737. var scene = this.getScene();
  54738. if (scene) {
  54739. scene._loadFile(this.url, callback);
  54740. }
  54741. else {
  54742. this._engine._loadFile(this.url, callback);
  54743. }
  54744. return this._texture;
  54745. };
  54746. /**
  54747. * Starts the loading process of the texture.
  54748. */
  54749. ColorGradingTexture.prototype.loadTexture = function () {
  54750. if (this.url && this.url.toLocaleLowerCase().indexOf(".3dl") == (this.url.length - 4)) {
  54751. this.load3dlTexture();
  54752. }
  54753. };
  54754. /**
  54755. * Clones the color gradind texture.
  54756. */
  54757. ColorGradingTexture.prototype.clone = function () {
  54758. var newTexture = new ColorGradingTexture(this.url, this.getScene());
  54759. // Base texture
  54760. newTexture.level = this.level;
  54761. return newTexture;
  54762. };
  54763. /**
  54764. * Called during delayed load for textures.
  54765. */
  54766. ColorGradingTexture.prototype.delayLoad = function () {
  54767. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  54768. return;
  54769. }
  54770. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED;
  54771. this._texture = this._getFromCache(this.url, true);
  54772. if (!this._texture) {
  54773. this.loadTexture();
  54774. }
  54775. };
  54776. /**
  54777. * Parses a color grading texture serialized by Babylon.
  54778. * @param parsedTexture The texture information being parsedTexture
  54779. * @param scene The scene to load the texture in
  54780. * @param rootUrl The root url of the data assets to load
  54781. * @return A color gradind texture
  54782. */
  54783. ColorGradingTexture.Parse = function (parsedTexture, scene) {
  54784. var texture = null;
  54785. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  54786. texture = new ColorGradingTexture(parsedTexture.name, scene);
  54787. texture.name = parsedTexture.name;
  54788. texture.level = parsedTexture.level;
  54789. }
  54790. return texture;
  54791. };
  54792. /**
  54793. * Serializes the LUT texture to json format.
  54794. */
  54795. ColorGradingTexture.prototype.serialize = function () {
  54796. if (!this.name) {
  54797. return null;
  54798. }
  54799. var serializationObject = {};
  54800. serializationObject.name = this.name;
  54801. serializationObject.level = this.level;
  54802. serializationObject.customType = "BABYLON.ColorGradingTexture";
  54803. return serializationObject;
  54804. };
  54805. /**
  54806. * Empty line regex stored for GC.
  54807. */
  54808. ColorGradingTexture._noneEmptyLineRegex = /\S+/;
  54809. return ColorGradingTexture;
  54810. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__["BaseTexture"]));
  54811. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.ColorGradingTexture"] = ColorGradingTexture;
  54812. /***/ }),
  54813. /***/ "./Materials/Textures/cubeTexture.ts":
  54814. /*!*******************************************!*\
  54815. !*** ./Materials/Textures/cubeTexture.ts ***!
  54816. \*******************************************/
  54817. /*! exports provided: CubeTexture */
  54818. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54819. "use strict";
  54820. __webpack_require__.r(__webpack_exports__);
  54821. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return CubeTexture; });
  54822. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54823. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54824. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  54825. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  54826. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  54827. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  54828. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  54829. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  54830. /**
  54831. * Class for creating a cube texture
  54832. */
  54833. var CubeTexture = /** @class */ (function (_super) {
  54834. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTexture, _super);
  54835. /**
  54836. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  54837. * as prefiltered data.
  54838. * @param rootUrl defines the url of the texture or the root name of the six images
  54839. * @param scene defines the scene the texture is attached to
  54840. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  54841. * @param noMipmap defines if mipmaps should be created or not
  54842. * @param files defines the six files to load for the different faces
  54843. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  54844. * @param onError defines a callback triggered in case of error during load
  54845. * @param format defines the internal format to use for the texture once loaded
  54846. * @param prefiltered defines whether or not the texture is created from prefiltered data
  54847. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  54848. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  54849. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54850. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54851. * @return the cube texture
  54852. */
  54853. function CubeTexture(rootUrl, scene, extensions, noMipmap, files, onLoad, onError, format, prefiltered, forcedExtension, createPolynomials, lodScale, lodOffset) {
  54854. if (extensions === void 0) { extensions = null; }
  54855. if (noMipmap === void 0) { noMipmap = false; }
  54856. if (files === void 0) { files = null; }
  54857. if (onLoad === void 0) { onLoad = null; }
  54858. if (onError === void 0) { onError = null; }
  54859. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA; }
  54860. if (prefiltered === void 0) { prefiltered = false; }
  54861. if (forcedExtension === void 0) { forcedExtension = null; }
  54862. if (createPolynomials === void 0) { createPolynomials = false; }
  54863. if (lodScale === void 0) { lodScale = 0.8; }
  54864. if (lodOffset === void 0) { lodOffset = 0; }
  54865. var _this = _super.call(this, scene) || this;
  54866. /**
  54867. * Gets or sets the center of the bounding box associated with the cube texture.
  54868. * It must define where the camera used to render the texture was set
  54869. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  54870. */
  54871. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  54872. _this._rotationY = 0;
  54873. /** @hidden */
  54874. _this._prefiltered = false;
  54875. _this.name = rootUrl;
  54876. _this.url = rootUrl;
  54877. _this._noMipmap = noMipmap;
  54878. _this.hasAlpha = false;
  54879. _this._format = format;
  54880. _this.isCube = true;
  54881. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  54882. _this._createPolynomials = createPolynomials;
  54883. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CUBIC_MODE;
  54884. if (!rootUrl && !files) {
  54885. return _this;
  54886. }
  54887. var lastDot = rootUrl.lastIndexOf(".");
  54888. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  54889. var isDDS = (extension === ".dds");
  54890. var isEnv = (extension === ".env");
  54891. if (isEnv) {
  54892. _this.gammaSpace = false;
  54893. _this._prefiltered = false;
  54894. }
  54895. else {
  54896. _this._prefiltered = prefiltered;
  54897. if (prefiltered) {
  54898. _this.gammaSpace = false;
  54899. }
  54900. }
  54901. _this._texture = _this._getFromCache(rootUrl, noMipmap);
  54902. if (!files) {
  54903. if (!isEnv && !isDDS && !extensions) {
  54904. extensions = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"];
  54905. }
  54906. files = [];
  54907. if (extensions) {
  54908. for (var index = 0; index < extensions.length; index++) {
  54909. files.push(rootUrl + extensions[index]);
  54910. }
  54911. }
  54912. }
  54913. _this._files = files;
  54914. if (!_this._texture) {
  54915. if (!scene.useDelayedTextureLoading) {
  54916. if (prefiltered) {
  54917. _this._texture = scene.getEngine().createPrefilteredCubeTexture(rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, _this._createPolynomials);
  54918. }
  54919. else {
  54920. _this._texture = scene.getEngine().createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, _this._format, forcedExtension, false, lodScale, lodOffset);
  54921. }
  54922. }
  54923. else {
  54924. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED;
  54925. }
  54926. }
  54927. else if (onLoad) {
  54928. if (_this._texture.isReady) {
  54929. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetImmediate(function () { return onLoad(); });
  54930. }
  54931. else {
  54932. _this._texture.onLoadedObservable.add(onLoad);
  54933. }
  54934. }
  54935. return _this;
  54936. }
  54937. Object.defineProperty(CubeTexture.prototype, "boundingBoxSize", {
  54938. /**
  54939. * Returns the bounding box size
  54940. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  54941. */
  54942. get: function () {
  54943. return this._boundingBoxSize;
  54944. },
  54945. /**
  54946. * Gets or sets the size of the bounding box associated with the cube texture
  54947. * When defined, the cubemap will switch to local mode
  54948. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54949. * @example https://www.babylonjs-playground.com/#RNASML
  54950. */
  54951. set: function (value) {
  54952. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  54953. return;
  54954. }
  54955. this._boundingBoxSize = value;
  54956. var scene = this.getScene();
  54957. if (scene) {
  54958. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  54959. }
  54960. },
  54961. enumerable: true,
  54962. configurable: true
  54963. });
  54964. Object.defineProperty(CubeTexture.prototype, "rotationY", {
  54965. /**
  54966. * Gets texture matrix rotation angle around Y axis radians.
  54967. */
  54968. get: function () {
  54969. return this._rotationY;
  54970. },
  54971. /**
  54972. * Sets texture matrix rotation angle around Y axis in radians.
  54973. */
  54974. set: function (value) {
  54975. this._rotationY = value;
  54976. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(this._rotationY));
  54977. },
  54978. enumerable: true,
  54979. configurable: true
  54980. });
  54981. Object.defineProperty(CubeTexture.prototype, "noMipmap", {
  54982. /**
  54983. * Are mip maps generated for this texture or not.
  54984. */
  54985. get: function () {
  54986. return this._noMipmap;
  54987. },
  54988. enumerable: true,
  54989. configurable: true
  54990. });
  54991. /**
  54992. * Creates a cube texture from an array of image urls
  54993. * @param files defines an array of image urls
  54994. * @param scene defines the hosting scene
  54995. * @param noMipmap specifies if mip maps are not used
  54996. * @returns a cube texture
  54997. */
  54998. CubeTexture.CreateFromImages = function (files, scene, noMipmap) {
  54999. var rootUrlKey = "";
  55000. files.forEach(function (url) { return rootUrlKey += url; });
  55001. return new CubeTexture(rootUrlKey, scene, null, noMipmap, files);
  55002. };
  55003. /**
  55004. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  55005. * @param url defines the url of the prefiltered texture
  55006. * @param scene defines the scene the texture is attached to
  55007. * @param forcedExtension defines the extension of the file if different from the url
  55008. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  55009. * @return the prefiltered texture
  55010. */
  55011. CubeTexture.CreateFromPrefilteredData = function (url, scene, forcedExtension, createPolynomials) {
  55012. if (forcedExtension === void 0) { forcedExtension = null; }
  55013. if (createPolynomials === void 0) { createPolynomials = true; }
  55014. return new CubeTexture(url, scene, null, false, null, null, null, undefined, true, forcedExtension, createPolynomials);
  55015. };
  55016. /**
  55017. * Get the current class name of the texture useful for serialization or dynamic coding.
  55018. * @returns "CubeTexture"
  55019. */
  55020. CubeTexture.prototype.getClassName = function () {
  55021. return "CubeTexture";
  55022. };
  55023. /**
  55024. * Update the url (and optional buffer) of this texture if url was null during construction.
  55025. * @param url the url of the texture
  55026. * @param forcedExtension defines the extension to use
  55027. * @param onLoad callback called when the texture is loaded (defaults to null)
  55028. */
  55029. CubeTexture.prototype.updateURL = function (url, forcedExtension, onLoad) {
  55030. if (this.url) {
  55031. this.releaseInternalTexture();
  55032. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  55033. }
  55034. this.url = url;
  55035. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED;
  55036. this._prefiltered = false;
  55037. if (onLoad) {
  55038. this._delayedOnLoad = onLoad;
  55039. }
  55040. this.delayLoad(forcedExtension);
  55041. };
  55042. /**
  55043. * Delays loading of the cube texture
  55044. * @param forcedExtension defines the extension to use
  55045. */
  55046. CubeTexture.prototype.delayLoad = function (forcedExtension) {
  55047. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  55048. return;
  55049. }
  55050. var scene = this.getScene();
  55051. if (!scene) {
  55052. return;
  55053. }
  55054. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_LOADED;
  55055. this._texture = this._getFromCache(this.url, this._noMipmap);
  55056. if (!this._texture) {
  55057. if (this._prefiltered) {
  55058. this._texture = scene.getEngine().createPrefilteredCubeTexture(this.url, scene, this.lodGenerationScale, this.lodGenerationOffset, this._delayedOnLoad, undefined, this._format, undefined, this._createPolynomials);
  55059. }
  55060. else {
  55061. this._texture = scene.getEngine().createCubeTexture(this.url, scene, this._files, this._noMipmap, this._delayedOnLoad, undefined, this._format, forcedExtension);
  55062. }
  55063. }
  55064. };
  55065. /**
  55066. * Returns the reflection texture matrix
  55067. * @returns the reflection texture matrix
  55068. */
  55069. CubeTexture.prototype.getReflectionTextureMatrix = function () {
  55070. return this._textureMatrix;
  55071. };
  55072. /**
  55073. * Sets the reflection texture matrix
  55074. * @param value Reflection texture matrix
  55075. */
  55076. CubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  55077. var _this = this;
  55078. if (value.updateFlag === this._textureMatrix.updateFlag) {
  55079. return;
  55080. }
  55081. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  55082. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  55083. }
  55084. this._textureMatrix = value;
  55085. };
  55086. /**
  55087. * Parses text to create a cube texture
  55088. * @param parsedTexture define the serialized text to read from
  55089. * @param scene defines the hosting scene
  55090. * @param rootUrl defines the root url of the cube texture
  55091. * @returns a cube texture
  55092. */
  55093. CubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  55094. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  55095. var prefiltered = false;
  55096. if (parsedTexture.prefiltered) {
  55097. prefiltered = parsedTexture.prefiltered;
  55098. }
  55099. return new CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions, false, null, null, null, undefined, prefiltered);
  55100. }, parsedTexture, scene);
  55101. // Local Cubemaps
  55102. if (parsedTexture.boundingBoxPosition) {
  55103. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  55104. }
  55105. if (parsedTexture.boundingBoxSize) {
  55106. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  55107. }
  55108. // Animations
  55109. if (parsedTexture.animations) {
  55110. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  55111. var parsedAnimation = parsedTexture.animations[animationIndex];
  55112. texture.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_6__["Animation"].Parse(parsedAnimation));
  55113. }
  55114. }
  55115. return texture;
  55116. };
  55117. /**
  55118. * Makes a clone, or deep copy, of the cube texture
  55119. * @returns a new cube texture
  55120. */
  55121. CubeTexture.prototype.clone = function () {
  55122. var _this = this;
  55123. var scene = this.getScene();
  55124. var uniqueId = 0;
  55125. var newCubeTexture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  55126. if (!scene) {
  55127. return _this;
  55128. }
  55129. var cubeTexture = new CubeTexture(_this.url, scene, _this._extensions, _this._noMipmap, _this._files);
  55130. uniqueId = cubeTexture.uniqueId;
  55131. return cubeTexture;
  55132. }, this);
  55133. newCubeTexture.uniqueId = uniqueId;
  55134. return newCubeTexture;
  55135. };
  55136. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55137. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("rotationY")
  55138. ], CubeTexture.prototype, "rotationY", null);
  55139. return CubeTexture;
  55140. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__["BaseTexture"]));
  55141. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"]._CubeTextureParser = CubeTexture.Parse;
  55142. /***/ }),
  55143. /***/ "./Materials/Textures/dynamicTexture.ts":
  55144. /*!**********************************************!*\
  55145. !*** ./Materials/Textures/dynamicTexture.ts ***!
  55146. \**********************************************/
  55147. /*! exports provided: DynamicTexture */
  55148. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55149. "use strict";
  55150. __webpack_require__.r(__webpack_exports__);
  55151. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return DynamicTexture; });
  55152. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55153. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  55154. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55155. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55156. /**
  55157. * A class extending Texture allowing drawing on a texture
  55158. * @see http://doc.babylonjs.com/how_to/dynamictexture
  55159. */
  55160. var DynamicTexture = /** @class */ (function (_super) {
  55161. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DynamicTexture, _super);
  55162. /**
  55163. * Creates a DynamicTexture
  55164. * @param name defines the name of the texture
  55165. * @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
  55166. * @param scene defines the scene where you want the texture
  55167. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  55168. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55169. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  55170. */
  55171. function DynamicTexture(name, options, scene, generateMipMaps, samplingMode, format) {
  55172. if (scene === void 0) { scene = null; }
  55173. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  55174. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA; }
  55175. var _this = _super.call(this, null, scene, !generateMipMaps, undefined, samplingMode, undefined, undefined, undefined, undefined, format) || this;
  55176. _this.name = name;
  55177. _this._engine = _this.getScene().getEngine();
  55178. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  55179. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  55180. _this._generateMipMaps = generateMipMaps;
  55181. if (options.getContext) {
  55182. _this._canvas = options;
  55183. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  55184. }
  55185. else {
  55186. _this._canvas = document.createElement("canvas");
  55187. if (options.width || options.width === 0) {
  55188. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  55189. }
  55190. else {
  55191. _this._texture = _this._engine.createDynamicTexture(options, options, generateMipMaps, samplingMode);
  55192. }
  55193. }
  55194. var textureSize = _this.getSize();
  55195. _this._canvas.width = textureSize.width;
  55196. _this._canvas.height = textureSize.height;
  55197. _this._context = _this._canvas.getContext("2d");
  55198. return _this;
  55199. }
  55200. /**
  55201. * Get the current class name of the texture useful for serialization or dynamic coding.
  55202. * @returns "DynamicTexture"
  55203. */
  55204. DynamicTexture.prototype.getClassName = function () {
  55205. return "DynamicTexture";
  55206. };
  55207. Object.defineProperty(DynamicTexture.prototype, "canRescale", {
  55208. /**
  55209. * Gets the current state of canRescale
  55210. */
  55211. get: function () {
  55212. return true;
  55213. },
  55214. enumerable: true,
  55215. configurable: true
  55216. });
  55217. DynamicTexture.prototype._recreate = function (textureSize) {
  55218. this._canvas.width = textureSize.width;
  55219. this._canvas.height = textureSize.height;
  55220. this.releaseInternalTexture();
  55221. this._texture = this._engine.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);
  55222. };
  55223. /**
  55224. * Scales the texture
  55225. * @param ratio the scale factor to apply to both width and height
  55226. */
  55227. DynamicTexture.prototype.scale = function (ratio) {
  55228. var textureSize = this.getSize();
  55229. textureSize.width *= ratio;
  55230. textureSize.height *= ratio;
  55231. this._recreate(textureSize);
  55232. };
  55233. /**
  55234. * Resizes the texture
  55235. * @param width the new width
  55236. * @param height the new height
  55237. */
  55238. DynamicTexture.prototype.scaleTo = function (width, height) {
  55239. var textureSize = this.getSize();
  55240. textureSize.width = width;
  55241. textureSize.height = height;
  55242. this._recreate(textureSize);
  55243. };
  55244. /**
  55245. * Gets the context of the canvas used by the texture
  55246. * @returns the canvas context of the dynamic texture
  55247. */
  55248. DynamicTexture.prototype.getContext = function () {
  55249. return this._context;
  55250. };
  55251. /**
  55252. * Clears the texture
  55253. */
  55254. DynamicTexture.prototype.clear = function () {
  55255. var size = this.getSize();
  55256. this._context.fillRect(0, 0, size.width, size.height);
  55257. };
  55258. /**
  55259. * Updates the texture
  55260. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  55261. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  55262. */
  55263. DynamicTexture.prototype.update = function (invertY, premulAlpha) {
  55264. if (premulAlpha === void 0) { premulAlpha = false; }
  55265. this._engine.updateDynamicTexture(this._texture, this._canvas, invertY === undefined ? true : invertY, premulAlpha, this._format || undefined);
  55266. };
  55267. /**
  55268. * Draws text onto the texture
  55269. * @param text defines the text to be drawn
  55270. * @param x defines the placement of the text from the left
  55271. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  55272. * @param font defines the font to be used with font-style, font-size, font-name
  55273. * @param color defines the color used for the text
  55274. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  55275. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  55276. * @param update defines whether texture is immediately update (default is true)
  55277. */
  55278. DynamicTexture.prototype.drawText = function (text, x, y, font, color, clearColor, invertY, update) {
  55279. if (update === void 0) { update = true; }
  55280. var size = this.getSize();
  55281. if (clearColor) {
  55282. this._context.fillStyle = clearColor;
  55283. this._context.fillRect(0, 0, size.width, size.height);
  55284. }
  55285. this._context.font = font;
  55286. if (x === null || x === undefined) {
  55287. var textSize = this._context.measureText(text);
  55288. x = (size.width - textSize.width) / 2;
  55289. }
  55290. if (y === null || y === undefined) {
  55291. var fontSize = parseInt((font.replace(/\D/g, '')));
  55292. y = (size.height / 2) + (fontSize / 3.65);
  55293. }
  55294. this._context.fillStyle = color;
  55295. this._context.fillText(text, x, y);
  55296. if (update) {
  55297. this.update(invertY);
  55298. }
  55299. };
  55300. /**
  55301. * Clones the texture
  55302. * @returns the clone of the texture.
  55303. */
  55304. DynamicTexture.prototype.clone = function () {
  55305. var scene = this.getScene();
  55306. if (!scene) {
  55307. return this;
  55308. }
  55309. var textureSize = this.getSize();
  55310. var newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);
  55311. // Base texture
  55312. newTexture.hasAlpha = this.hasAlpha;
  55313. newTexture.level = this.level;
  55314. // Dynamic Texture
  55315. newTexture.wrapU = this.wrapU;
  55316. newTexture.wrapV = this.wrapV;
  55317. return newTexture;
  55318. };
  55319. /**
  55320. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  55321. * @returns a serialized dynamic texture object
  55322. */
  55323. DynamicTexture.prototype.serialize = function () {
  55324. var scene = this.getScene();
  55325. if (scene && !scene.isReady()) {
  55326. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The scene must be ready before serializing the dynamic texture");
  55327. }
  55328. var serializationObject = _super.prototype.serialize.call(this);
  55329. serializationObject.base64String = this._canvas.toDataURL();
  55330. serializationObject.invertY = this._invertY;
  55331. serializationObject.samplingMode = this.samplingMode;
  55332. return serializationObject;
  55333. };
  55334. /** @hidden */
  55335. DynamicTexture.prototype._rebuild = function () {
  55336. this.update();
  55337. };
  55338. return DynamicTexture;
  55339. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]));
  55340. /***/ }),
  55341. /***/ "./Materials/Textures/hdrCubeTexture.ts":
  55342. /*!**********************************************!*\
  55343. !*** ./Materials/Textures/hdrCubeTexture.ts ***!
  55344. \**********************************************/
  55345. /*! exports provided: HDRCubeTexture */
  55346. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55347. "use strict";
  55348. __webpack_require__.r(__webpack_exports__);
  55349. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return HDRCubeTexture; });
  55350. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55351. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55352. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  55353. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  55354. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55355. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55356. /* harmony import */ var _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/hdr */ "./Misc/HighDynamicRange/hdr.ts");
  55357. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  55358. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55359. /**
  55360. * This represents a texture coming from an HDR input.
  55361. *
  55362. * The only supported format is currently panorama picture stored in RGBE format.
  55363. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55364. */
  55365. var HDRCubeTexture = /** @class */ (function (_super) {
  55366. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTexture, _super);
  55367. /**
  55368. * Instantiates an HDRTexture from the following parameters.
  55369. *
  55370. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55371. * @param scene The scene the texture will be used in
  55372. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55373. * @param noMipmap Forces to not generate the mipmap if true
  55374. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55375. * @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)
  55376. * @param reserved Reserved flag for internal use.
  55377. */
  55378. function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, gammaSpace, reserved, onLoad, onError) {
  55379. if (noMipmap === void 0) { noMipmap = false; }
  55380. if (generateHarmonics === void 0) { generateHarmonics = true; }
  55381. if (gammaSpace === void 0) { gammaSpace = false; }
  55382. if (reserved === void 0) { reserved = false; }
  55383. if (onLoad === void 0) { onLoad = null; }
  55384. if (onError === void 0) { onError = null; }
  55385. var _this = _super.call(this, scene) || this;
  55386. _this._generateHarmonics = true;
  55387. _this._onLoad = null;
  55388. _this._onError = null;
  55389. /**
  55390. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55391. */
  55392. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  55393. _this._isBlocking = true;
  55394. _this._rotationY = 0;
  55395. /**
  55396. * Gets or sets the center of the bounding box associated with the cube texture
  55397. * It must define where the camera used to render the texture was set
  55398. */
  55399. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  55400. if (!url) {
  55401. return _this;
  55402. }
  55403. _this.name = url;
  55404. _this.url = url;
  55405. _this.hasAlpha = false;
  55406. _this.isCube = true;
  55407. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  55408. _this._onLoad = onLoad;
  55409. _this._onError = onError;
  55410. _this.gammaSpace = gammaSpace;
  55411. _this._noMipmap = noMipmap;
  55412. _this._size = size;
  55413. _this._texture = _this._getFromCache(url, _this._noMipmap);
  55414. if (!_this._texture) {
  55415. if (!scene.useDelayedTextureLoading) {
  55416. _this.loadTexture();
  55417. }
  55418. else {
  55419. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  55420. }
  55421. }
  55422. return _this;
  55423. }
  55424. Object.defineProperty(HDRCubeTexture.prototype, "isBlocking", {
  55425. /**
  55426. * Gets wether or not the texture is blocking during loading.
  55427. */
  55428. get: function () {
  55429. return this._isBlocking;
  55430. },
  55431. /**
  55432. * Sets wether or not the texture is blocking during loading.
  55433. */
  55434. set: function (value) {
  55435. this._isBlocking = value;
  55436. },
  55437. enumerable: true,
  55438. configurable: true
  55439. });
  55440. Object.defineProperty(HDRCubeTexture.prototype, "rotationY", {
  55441. /**
  55442. * Gets texture matrix rotation angle around Y axis radians.
  55443. */
  55444. get: function () {
  55445. return this._rotationY;
  55446. },
  55447. /**
  55448. * Sets texture matrix rotation angle around Y axis in radians.
  55449. */
  55450. set: function (value) {
  55451. this._rotationY = value;
  55452. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationY(this._rotationY));
  55453. },
  55454. enumerable: true,
  55455. configurable: true
  55456. });
  55457. Object.defineProperty(HDRCubeTexture.prototype, "boundingBoxSize", {
  55458. get: function () {
  55459. return this._boundingBoxSize;
  55460. },
  55461. /**
  55462. * Gets or sets the size of the bounding box associated with the cube texture
  55463. * When defined, the cubemap will switch to local mode
  55464. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55465. * @example https://www.babylonjs-playground.com/#RNASML
  55466. */
  55467. set: function (value) {
  55468. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  55469. return;
  55470. }
  55471. this._boundingBoxSize = value;
  55472. var scene = this.getScene();
  55473. if (scene) {
  55474. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag);
  55475. }
  55476. },
  55477. enumerable: true,
  55478. configurable: true
  55479. });
  55480. /**
  55481. * Get the current class name of the texture useful for serialization or dynamic coding.
  55482. * @returns "HDRCubeTexture"
  55483. */
  55484. HDRCubeTexture.prototype.getClassName = function () {
  55485. return "HDRCubeTexture";
  55486. };
  55487. /**
  55488. * Occurs when the file is raw .hdr file.
  55489. */
  55490. HDRCubeTexture.prototype.loadTexture = function () {
  55491. var _this = this;
  55492. var callback = function (buffer) {
  55493. _this.lodGenerationOffset = 0.0;
  55494. _this.lodGenerationScale = 0.8;
  55495. var scene = _this.getScene();
  55496. if (!scene) {
  55497. return null;
  55498. }
  55499. // Extract the raw linear data.
  55500. var data = _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__["HDRTools"].GetCubeMapTextureData(buffer, _this._size);
  55501. // Generate harmonics if needed.
  55502. if (_this._generateHarmonics) {
  55503. var sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial(data);
  55504. _this.sphericalPolynomial = sphericalPolynomial;
  55505. }
  55506. var results = [];
  55507. var byteArray = null;
  55508. // Push each faces.
  55509. for (var j = 0; j < 6; j++) {
  55510. // Create uintarray fallback.
  55511. if (!scene.getEngine().getCaps().textureFloat) {
  55512. // 3 channels of 1 bytes per pixel in bytes.
  55513. var byteBuffer = new ArrayBuffer(_this._size * _this._size * 3);
  55514. byteArray = new Uint8Array(byteBuffer);
  55515. }
  55516. var dataFace = (data[HDRCubeTexture._facesMapping[j]]);
  55517. // If special cases.
  55518. if (_this.gammaSpace || byteArray) {
  55519. for (var i = 0; i < _this._size * _this._size; i++) {
  55520. // Put in gamma space if requested.
  55521. if (_this.gammaSpace) {
  55522. dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  55523. dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  55524. dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  55525. }
  55526. // Convert to int texture for fallback.
  55527. if (byteArray) {
  55528. var r = Math.max(dataFace[(i * 3) + 0] * 255, 0);
  55529. var g = Math.max(dataFace[(i * 3) + 1] * 255, 0);
  55530. var b = Math.max(dataFace[(i * 3) + 2] * 255, 0);
  55531. // May use luminance instead if the result is not accurate.
  55532. var max = Math.max(Math.max(r, g), b);
  55533. if (max > 255) {
  55534. var scale = 255 / max;
  55535. r *= scale;
  55536. g *= scale;
  55537. b *= scale;
  55538. }
  55539. byteArray[(i * 3) + 0] = r;
  55540. byteArray[(i * 3) + 1] = g;
  55541. byteArray[(i * 3) + 2] = b;
  55542. }
  55543. }
  55544. }
  55545. if (byteArray) {
  55546. results.push(byteArray);
  55547. }
  55548. else {
  55549. results.push(dataFace);
  55550. }
  55551. }
  55552. return results;
  55553. };
  55554. var scene = this.getScene();
  55555. if (scene) {
  55556. 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);
  55557. }
  55558. };
  55559. HDRCubeTexture.prototype.clone = function () {
  55560. var scene = this.getScene();
  55561. if (!scene) {
  55562. return this;
  55563. }
  55564. var newTexture = new HDRCubeTexture(this.url, scene, this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
  55565. // Base texture
  55566. newTexture.level = this.level;
  55567. newTexture.wrapU = this.wrapU;
  55568. newTexture.wrapV = this.wrapV;
  55569. newTexture.coordinatesIndex = this.coordinatesIndex;
  55570. newTexture.coordinatesMode = this.coordinatesMode;
  55571. return newTexture;
  55572. };
  55573. // Methods
  55574. HDRCubeTexture.prototype.delayLoad = function () {
  55575. if (this.delayLoadState !== _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED) {
  55576. return;
  55577. }
  55578. this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_LOADED;
  55579. this._texture = this._getFromCache(this.url, this._noMipmap);
  55580. if (!this._texture) {
  55581. this.loadTexture();
  55582. }
  55583. };
  55584. /**
  55585. * Get the texture reflection matrix used to rotate/transform the reflection.
  55586. * @returns the reflection matrix
  55587. */
  55588. HDRCubeTexture.prototype.getReflectionTextureMatrix = function () {
  55589. return this._textureMatrix;
  55590. };
  55591. /**
  55592. * Set the texture reflection matrix used to rotate/transform the reflection.
  55593. * @param value Define the reflection matrix to set
  55594. */
  55595. HDRCubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  55596. var _this = this;
  55597. this._textureMatrix = value;
  55598. if (value.updateFlag === this._textureMatrix.updateFlag) {
  55599. return;
  55600. }
  55601. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  55602. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  55603. }
  55604. };
  55605. /**
  55606. * Parses a JSON representation of an HDR Texture in order to create the texture
  55607. * @param parsedTexture Define the JSON representation
  55608. * @param scene Define the scene the texture should be created in
  55609. * @param rootUrl Define the root url in case we need to load relative dependencies
  55610. * @returns the newly created texture after parsing
  55611. */
  55612. HDRCubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  55613. var texture = null;
  55614. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  55615. texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace);
  55616. texture.name = parsedTexture.name;
  55617. texture.hasAlpha = parsedTexture.hasAlpha;
  55618. texture.level = parsedTexture.level;
  55619. texture.coordinatesMode = parsedTexture.coordinatesMode;
  55620. texture.isBlocking = parsedTexture.isBlocking;
  55621. }
  55622. if (texture) {
  55623. if (parsedTexture.boundingBoxPosition) {
  55624. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  55625. }
  55626. if (parsedTexture.boundingBoxSize) {
  55627. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  55628. }
  55629. if (parsedTexture.rotationY) {
  55630. texture.rotationY = parsedTexture.rotationY;
  55631. }
  55632. }
  55633. return texture;
  55634. };
  55635. HDRCubeTexture.prototype.serialize = function () {
  55636. if (!this.name) {
  55637. return null;
  55638. }
  55639. var serializationObject = {};
  55640. serializationObject.name = this.name;
  55641. serializationObject.hasAlpha = this.hasAlpha;
  55642. serializationObject.isCube = true;
  55643. serializationObject.level = this.level;
  55644. serializationObject.size = this._size;
  55645. serializationObject.coordinatesMode = this.coordinatesMode;
  55646. serializationObject.useInGammaSpace = this.gammaSpace;
  55647. serializationObject.generateHarmonics = this._generateHarmonics;
  55648. serializationObject.customType = "BABYLON.HDRCubeTexture";
  55649. serializationObject.noMipmap = this._noMipmap;
  55650. serializationObject.isBlocking = this._isBlocking;
  55651. serializationObject.rotationY = this._rotationY;
  55652. return serializationObject;
  55653. };
  55654. HDRCubeTexture._facesMapping = [
  55655. "right",
  55656. "left",
  55657. "up",
  55658. "down",
  55659. "front",
  55660. "back"
  55661. ];
  55662. return HDRCubeTexture;
  55663. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  55664. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.HDRCubeTexture"] = HDRCubeTexture;
  55665. /***/ }),
  55666. /***/ "./Materials/Textures/index.ts":
  55667. /*!*************************************!*\
  55668. !*** ./Materials/Textures/index.ts ***!
  55669. \*************************************/
  55670. /*! 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 */
  55671. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55672. "use strict";
  55673. __webpack_require__.r(__webpack_exports__);
  55674. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  55675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _baseTexture__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  55676. /* harmony import */ var _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorGradingTexture */ "./Materials/Textures/colorGradingTexture.ts");
  55677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__["ColorGradingTexture"]; });
  55678. /* harmony import */ var _cubeTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  55679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _cubeTexture__WEBPACK_IMPORTED_MODULE_2__["CubeTexture"]; });
  55680. /* harmony import */ var _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  55681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__["DynamicTexture"]; });
  55682. /* harmony import */ var _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  55683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_4__["HDRCubeTexture"]; });
  55684. /* harmony import */ var _internalTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./internalTexture */ "./Materials/Textures/internalTexture.ts");
  55685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _internalTexture__WEBPACK_IMPORTED_MODULE_5__["InternalTexture"]; });
  55686. /* harmony import */ var _internalTextureTracker__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  55687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _internalTextureTracker__WEBPACK_IMPORTED_MODULE_6__["DummyInternalTextureTracker"]; });
  55688. /* harmony import */ var _Loaders_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Loaders/index */ "./Materials/Textures/Loaders/index.ts");
  55689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_DDSTextureLoader"]; });
  55690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_ENVTextureLoader"]; });
  55691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_KTXTextureLoader"]; });
  55692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_TGATextureLoader"]; });
  55693. /* harmony import */ var _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  55694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__["MirrorTexture"]; });
  55695. /* harmony import */ var _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  55696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__["MultiRenderTarget"]; });
  55697. /* harmony import */ var _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Procedurals/index */ "./Materials/Textures/Procedurals/index.ts");
  55698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTexture"]; });
  55699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["CustomProceduralTexture"]; });
  55700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["NoiseProceduralTexture"]; });
  55701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTextureSceneComponent"]; });
  55702. /* harmony import */ var _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./rawCubeTexture */ "./Materials/Textures/rawCubeTexture.ts");
  55703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__["RawCubeTexture"]; });
  55704. /* harmony import */ var _rawTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./rawTexture */ "./Materials/Textures/rawTexture.ts");
  55705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _rawTexture__WEBPACK_IMPORTED_MODULE_12__["RawTexture"]; });
  55706. /* harmony import */ var _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./rawTexture3D */ "./Materials/Textures/rawTexture3D.ts");
  55707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  55708. /* harmony import */ var _refractionTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./refractionTexture */ "./Materials/Textures/refractionTexture.ts");
  55709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _refractionTexture__WEBPACK_IMPORTED_MODULE_14__["RefractionTexture"]; });
  55710. /* harmony import */ var _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  55711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__["RenderTargetTexture"]; });
  55712. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  55713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _texture__WEBPACK_IMPORTED_MODULE_16__["Texture"]; });
  55714. /* harmony import */ var _videoTexture__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./videoTexture */ "./Materials/Textures/videoTexture.ts");
  55715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _videoTexture__WEBPACK_IMPORTED_MODULE_17__["VideoTexture"]; });
  55716. /***/ }),
  55717. /***/ "./Materials/Textures/internalTexture.ts":
  55718. /*!***********************************************!*\
  55719. !*** ./Materials/Textures/internalTexture.ts ***!
  55720. \***********************************************/
  55721. /*! exports provided: InternalTexture */
  55722. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55723. "use strict";
  55724. __webpack_require__.r(__webpack_exports__);
  55725. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return InternalTexture; });
  55726. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  55727. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  55728. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55729. /**
  55730. * Class used to store data associated with WebGL texture data for the engine
  55731. * This class should not be used directly
  55732. */
  55733. var InternalTexture = /** @class */ (function () {
  55734. /**
  55735. * Creates a new InternalTexture
  55736. * @param engine defines the engine to use
  55737. * @param dataSource defines the type of data that will be used
  55738. * @param delayAllocation if the texture allocation should be delayed (default: false)
  55739. */
  55740. function InternalTexture(engine, dataSource, delayAllocation) {
  55741. if (delayAllocation === void 0) { delayAllocation = false; }
  55742. /**
  55743. * Observable called when the texture is loaded
  55744. */
  55745. this.onLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  55746. /**
  55747. * Gets or set the previous tracker in the list
  55748. */
  55749. this.previous = null;
  55750. /**
  55751. * Gets or set the next tracker in the list
  55752. */
  55753. this.next = null;
  55754. // Private
  55755. /** @hidden */
  55756. this._invertVScale = false;
  55757. /** @hidden */
  55758. this._initialSlot = -1;
  55759. /** @hidden */
  55760. this._designatedSlot = -1;
  55761. /** @hidden */
  55762. this._dataSource = InternalTexture.DATASOURCE_UNKNOWN;
  55763. /** @hidden */
  55764. this._comparisonFunction = 0;
  55765. /** @hidden */
  55766. this._sphericalPolynomial = null;
  55767. /** @hidden */
  55768. this._lodGenerationScale = 0;
  55769. /** @hidden */
  55770. this._lodGenerationOffset = 0;
  55771. /** @hidden */
  55772. this._isRGBD = false;
  55773. /** @hidden */
  55774. this._references = 1;
  55775. this._engine = engine;
  55776. this._dataSource = dataSource;
  55777. if (!delayAllocation) {
  55778. this._webGLTexture = engine._createTexture();
  55779. }
  55780. }
  55781. /**
  55782. * Gets the Engine the texture belongs to.
  55783. * @returns The babylon engine
  55784. */
  55785. InternalTexture.prototype.getEngine = function () {
  55786. return this._engine;
  55787. };
  55788. Object.defineProperty(InternalTexture.prototype, "dataSource", {
  55789. /**
  55790. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  55791. */
  55792. get: function () {
  55793. return this._dataSource;
  55794. },
  55795. enumerable: true,
  55796. configurable: true
  55797. });
  55798. /**
  55799. * Increments the number of references (ie. the number of Texture that point to it)
  55800. */
  55801. InternalTexture.prototype.incrementReferences = function () {
  55802. this._references++;
  55803. };
  55804. /**
  55805. * Change the size of the texture (not the size of the content)
  55806. * @param width defines the new width
  55807. * @param height defines the new height
  55808. * @param depth defines the new depth (1 by default)
  55809. */
  55810. InternalTexture.prototype.updateSize = function (width, height, depth) {
  55811. if (depth === void 0) { depth = 1; }
  55812. this.width = width;
  55813. this.height = height;
  55814. this.depth = depth;
  55815. this.baseWidth = width;
  55816. this.baseHeight = height;
  55817. this.baseDepth = depth;
  55818. this._size = width * height * depth;
  55819. };
  55820. /** @hidden */
  55821. InternalTexture.prototype._rebuild = function () {
  55822. var _this = this;
  55823. var proxy;
  55824. this.isReady = false;
  55825. this._cachedCoordinatesMode = null;
  55826. this._cachedWrapU = null;
  55827. this._cachedWrapV = null;
  55828. this._cachedAnisotropicFilteringLevel = null;
  55829. switch (this._dataSource) {
  55830. case InternalTexture.DATASOURCE_TEMP:
  55831. return;
  55832. case InternalTexture.DATASOURCE_URL:
  55833. proxy = this._engine.createTexture(this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function () {
  55834. proxy._swapAndDie(_this);
  55835. _this.isReady = true;
  55836. }, null, this._buffer, undefined, this.format);
  55837. return;
  55838. case InternalTexture.DATASOURCE_RAW:
  55839. proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  55840. proxy._swapAndDie(this);
  55841. this.isReady = true;
  55842. return;
  55843. case InternalTexture.DATASOURCE_RAW3D:
  55844. proxy = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  55845. proxy._swapAndDie(this);
  55846. this.isReady = true;
  55847. return;
  55848. case InternalTexture.DATASOURCE_DYNAMIC:
  55849. proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
  55850. proxy._swapAndDie(this);
  55851. this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, undefined, undefined, true);
  55852. // The engine will make sure to update content so no need to flag it as isReady = true
  55853. return;
  55854. case InternalTexture.DATASOURCE_RENDERTARGET:
  55855. var options = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__["RenderTargetCreationOptions"]();
  55856. options.generateDepthBuffer = this._generateDepthBuffer;
  55857. options.generateMipMaps = this.generateMipMaps;
  55858. options.generateStencilBuffer = this._generateStencilBuffer;
  55859. options.samplingMode = this.samplingMode;
  55860. options.type = this.type;
  55861. if (this.isCube) {
  55862. proxy = this._engine.createRenderTargetCubeTexture(this.width, options);
  55863. }
  55864. else {
  55865. var size = {
  55866. width: this.width,
  55867. height: this.height
  55868. };
  55869. proxy = this._engine.createRenderTargetTexture(size, options);
  55870. }
  55871. proxy._swapAndDie(this);
  55872. this.isReady = true;
  55873. return;
  55874. case InternalTexture.DATASOURCE_DEPTHTEXTURE:
  55875. var depthTextureOptions = {
  55876. bilinearFiltering: this.samplingMode !== _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  55877. comparisonFunction: this._comparisonFunction,
  55878. generateStencil: this._generateStencilBuffer,
  55879. isCube: this.isCube
  55880. };
  55881. proxy = this._engine.createDepthStencilTexture({ width: this.width, height: this.height }, depthTextureOptions);
  55882. proxy._swapAndDie(this);
  55883. this.isReady = true;
  55884. return;
  55885. case InternalTexture.DATASOURCE_CUBE:
  55886. proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {
  55887. proxy._swapAndDie(_this);
  55888. _this.isReady = true;
  55889. }, null, this.format, this._extension);
  55890. return;
  55891. case InternalTexture.DATASOURCE_CUBERAW:
  55892. proxy = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  55893. proxy._swapAndDie(this);
  55894. this.isReady = true;
  55895. return;
  55896. case InternalTexture.DATASOURCE_CUBERAW_RGBD:
  55897. proxy = this._engine.createRawCubeTexture(null, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  55898. InternalTexture._UpdateRGBDAsync(proxy, this._bufferViewArrayArray, this._sphericalPolynomial, this._lodGenerationScale, this._lodGenerationOffset).then(function () {
  55899. proxy._swapAndDie(_this);
  55900. _this.isReady = true;
  55901. });
  55902. return;
  55903. case InternalTexture.DATASOURCE_CUBEPREFILTERED:
  55904. proxy = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function (proxy) {
  55905. if (proxy) {
  55906. proxy._swapAndDie(_this);
  55907. }
  55908. _this.isReady = true;
  55909. }, null, this.format, this._extension);
  55910. proxy._sphericalPolynomial = this._sphericalPolynomial;
  55911. return;
  55912. }
  55913. };
  55914. /** @hidden */
  55915. InternalTexture.prototype._swapAndDie = function (target) {
  55916. target._webGLTexture = this._webGLTexture;
  55917. if (this._framebuffer) {
  55918. target._framebuffer = this._framebuffer;
  55919. }
  55920. if (this._depthStencilBuffer) {
  55921. target._depthStencilBuffer = this._depthStencilBuffer;
  55922. }
  55923. if (this._lodTextureHigh) {
  55924. if (target._lodTextureHigh) {
  55925. target._lodTextureHigh.dispose();
  55926. }
  55927. target._lodTextureHigh = this._lodTextureHigh;
  55928. }
  55929. if (this._lodTextureMid) {
  55930. if (target._lodTextureMid) {
  55931. target._lodTextureMid.dispose();
  55932. }
  55933. target._lodTextureMid = this._lodTextureMid;
  55934. }
  55935. if (this._lodTextureLow) {
  55936. if (target._lodTextureLow) {
  55937. target._lodTextureLow.dispose();
  55938. }
  55939. target._lodTextureLow = this._lodTextureLow;
  55940. }
  55941. var cache = this._engine.getLoadedTexturesCache();
  55942. var index = cache.indexOf(this);
  55943. if (index !== -1) {
  55944. cache.splice(index, 1);
  55945. }
  55946. };
  55947. /**
  55948. * Dispose the current allocated resources
  55949. */
  55950. InternalTexture.prototype.dispose = function () {
  55951. if (!this._webGLTexture) {
  55952. return;
  55953. }
  55954. this._references--;
  55955. if (this._references === 0) {
  55956. this._engine._releaseTexture(this);
  55957. this._webGLTexture = null;
  55958. this.previous = null;
  55959. this.next = null;
  55960. }
  55961. };
  55962. /** hidden */
  55963. InternalTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  55964. throw "environmentTextureTools needs to be imported before rebuilding RGBD textures.";
  55965. };
  55966. /**
  55967. * The source of the texture data is unknown
  55968. */
  55969. InternalTexture.DATASOURCE_UNKNOWN = 0;
  55970. /**
  55971. * Texture data comes from an URL
  55972. */
  55973. InternalTexture.DATASOURCE_URL = 1;
  55974. /**
  55975. * Texture data is only used for temporary storage
  55976. */
  55977. InternalTexture.DATASOURCE_TEMP = 2;
  55978. /**
  55979. * Texture data comes from raw data (ArrayBuffer)
  55980. */
  55981. InternalTexture.DATASOURCE_RAW = 3;
  55982. /**
  55983. * Texture content is dynamic (video or dynamic texture)
  55984. */
  55985. InternalTexture.DATASOURCE_DYNAMIC = 4;
  55986. /**
  55987. * Texture content is generated by rendering to it
  55988. */
  55989. InternalTexture.DATASOURCE_RENDERTARGET = 5;
  55990. /**
  55991. * Texture content is part of a multi render target process
  55992. */
  55993. InternalTexture.DATASOURCE_MULTIRENDERTARGET = 6;
  55994. /**
  55995. * Texture data comes from a cube data file
  55996. */
  55997. InternalTexture.DATASOURCE_CUBE = 7;
  55998. /**
  55999. * Texture data comes from a raw cube data
  56000. */
  56001. InternalTexture.DATASOURCE_CUBERAW = 8;
  56002. /**
  56003. * Texture data come from a prefiltered cube data file
  56004. */
  56005. InternalTexture.DATASOURCE_CUBEPREFILTERED = 9;
  56006. /**
  56007. * Texture content is raw 3D data
  56008. */
  56009. InternalTexture.DATASOURCE_RAW3D = 10;
  56010. /**
  56011. * Texture content is a depth texture
  56012. */
  56013. InternalTexture.DATASOURCE_DEPTHTEXTURE = 11;
  56014. /**
  56015. * Texture data comes from a raw cube data encoded with RGBD
  56016. */
  56017. InternalTexture.DATASOURCE_CUBERAW_RGBD = 12;
  56018. return InternalTexture;
  56019. }());
  56020. /***/ }),
  56021. /***/ "./Materials/Textures/internalTextureTracker.ts":
  56022. /*!******************************************************!*\
  56023. !*** ./Materials/Textures/internalTextureTracker.ts ***!
  56024. \******************************************************/
  56025. /*! exports provided: DummyInternalTextureTracker */
  56026. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56027. "use strict";
  56028. __webpack_require__.r(__webpack_exports__);
  56029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return DummyInternalTextureTracker; });
  56030. /**
  56031. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  56032. */
  56033. var DummyInternalTextureTracker = /** @class */ (function () {
  56034. function DummyInternalTextureTracker() {
  56035. /**
  56036. * Gets or set the previous tracker in the list
  56037. */
  56038. this.previous = null;
  56039. /**
  56040. * Gets or set the next tracker in the list
  56041. */
  56042. this.next = null;
  56043. }
  56044. return DummyInternalTextureTracker;
  56045. }());
  56046. /***/ }),
  56047. /***/ "./Materials/Textures/mirrorTexture.ts":
  56048. /*!*********************************************!*\
  56049. !*** ./Materials/Textures/mirrorTexture.ts ***!
  56050. \*********************************************/
  56051. /*! exports provided: MirrorTexture */
  56052. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56053. "use strict";
  56054. __webpack_require__.r(__webpack_exports__);
  56055. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return MirrorTexture; });
  56056. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56057. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56058. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56059. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56060. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  56061. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56062. /**
  56063. * Mirror texture can be used to simulate the view from a mirror in a scene.
  56064. * It will dynamically be rendered every frame to adapt to the camera point of view.
  56065. * You can then easily use it as a reflectionTexture on a flat surface.
  56066. * In case the surface is not a plane, please consider relying on reflection probes.
  56067. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  56068. */
  56069. var MirrorTexture = /** @class */ (function (_super) {
  56070. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MirrorTexture, _super);
  56071. /**
  56072. * Instantiates a Mirror Texture.
  56073. * Mirror texture can be used to simulate the view from a mirror in a scene.
  56074. * It will dynamically be rendered every frame to adapt to the camera point of view.
  56075. * You can then easily use it as a reflectionTexture on a flat surface.
  56076. * In case the surface is not a plane, please consider relying on reflection probes.
  56077. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  56078. * @param name
  56079. * @param size
  56080. * @param scene
  56081. * @param generateMipMaps
  56082. * @param type
  56083. * @param samplingMode
  56084. * @param generateDepthBuffer
  56085. */
  56086. function MirrorTexture(name, size, scene, generateMipMaps, type, samplingMode, generateDepthBuffer) {
  56087. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56088. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  56089. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  56090. var _this = _super.call(this, name, size, scene, generateMipMaps, true, type, false, samplingMode, generateDepthBuffer) || this;
  56091. _this.scene = scene;
  56092. /**
  56093. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  56094. * 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.
  56095. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  56096. */
  56097. _this.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  56098. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  56099. _this._mirrorMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  56100. _this._adaptiveBlurKernel = 0;
  56101. _this._blurKernelX = 0;
  56102. _this._blurKernelY = 0;
  56103. _this._blurRatio = 1.0;
  56104. _this.ignoreCameraViewport = true;
  56105. _this._updateGammaSpace();
  56106. _this._imageProcessingConfigChangeObserver = scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  56107. _this._updateGammaSpace;
  56108. });
  56109. _this.onBeforeRenderObservable.add(function () {
  56110. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ReflectionToRef(_this.mirrorPlane, _this._mirrorMatrix);
  56111. _this._savedViewMatrix = scene.getViewMatrix();
  56112. _this._mirrorMatrix.multiplyToRef(_this._savedViewMatrix, _this._transformMatrix);
  56113. scene.setTransformMatrix(_this._transformMatrix, scene.getProjectionMatrix());
  56114. scene.clipPlane = _this.mirrorPlane;
  56115. scene.getEngine().cullBackFaces = false;
  56116. scene._mirroredCameraPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(scene.activeCamera.globalPosition, _this._mirrorMatrix);
  56117. });
  56118. _this.onAfterRenderObservable.add(function () {
  56119. scene.setTransformMatrix(_this._savedViewMatrix, scene.getProjectionMatrix());
  56120. scene.getEngine().cullBackFaces = true;
  56121. scene._mirroredCameraPosition = null;
  56122. delete scene.clipPlane;
  56123. });
  56124. return _this;
  56125. }
  56126. Object.defineProperty(MirrorTexture.prototype, "blurRatio", {
  56127. get: function () {
  56128. return this._blurRatio;
  56129. },
  56130. /**
  56131. * Define the blur ratio used to blur the reflection if needed.
  56132. */
  56133. set: function (value) {
  56134. if (this._blurRatio === value) {
  56135. return;
  56136. }
  56137. this._blurRatio = value;
  56138. this._preparePostProcesses();
  56139. },
  56140. enumerable: true,
  56141. configurable: true
  56142. });
  56143. Object.defineProperty(MirrorTexture.prototype, "adaptiveBlurKernel", {
  56144. /**
  56145. * Define the adaptive blur kernel used to blur the reflection if needed.
  56146. * This will autocompute the closest best match for the `blurKernel`
  56147. */
  56148. set: function (value) {
  56149. this._adaptiveBlurKernel = value;
  56150. this._autoComputeBlurKernel();
  56151. },
  56152. enumerable: true,
  56153. configurable: true
  56154. });
  56155. Object.defineProperty(MirrorTexture.prototype, "blurKernel", {
  56156. /**
  56157. * Define the blur kernel used to blur the reflection if needed.
  56158. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  56159. */
  56160. set: function (value) {
  56161. this.blurKernelX = value;
  56162. this.blurKernelY = value;
  56163. },
  56164. enumerable: true,
  56165. configurable: true
  56166. });
  56167. Object.defineProperty(MirrorTexture.prototype, "blurKernelX", {
  56168. get: function () {
  56169. return this._blurKernelX;
  56170. },
  56171. /**
  56172. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  56173. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  56174. */
  56175. set: function (value) {
  56176. if (this._blurKernelX === value) {
  56177. return;
  56178. }
  56179. this._blurKernelX = value;
  56180. this._preparePostProcesses();
  56181. },
  56182. enumerable: true,
  56183. configurable: true
  56184. });
  56185. Object.defineProperty(MirrorTexture.prototype, "blurKernelY", {
  56186. get: function () {
  56187. return this._blurKernelY;
  56188. },
  56189. /**
  56190. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  56191. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  56192. */
  56193. set: function (value) {
  56194. if (this._blurKernelY === value) {
  56195. return;
  56196. }
  56197. this._blurKernelY = value;
  56198. this._preparePostProcesses();
  56199. },
  56200. enumerable: true,
  56201. configurable: true
  56202. });
  56203. MirrorTexture.prototype._autoComputeBlurKernel = function () {
  56204. var engine = this.getScene().getEngine();
  56205. var dw = this.getRenderWidth() / engine.getRenderWidth();
  56206. var dh = this.getRenderHeight() / engine.getRenderHeight();
  56207. this.blurKernelX = this._adaptiveBlurKernel * dw;
  56208. this.blurKernelY = this._adaptiveBlurKernel * dh;
  56209. };
  56210. MirrorTexture.prototype._onRatioRescale = function () {
  56211. if (this._sizeRatio) {
  56212. this.resize(this._initialSizeParameter);
  56213. if (!this._adaptiveBlurKernel) {
  56214. this._preparePostProcesses();
  56215. }
  56216. }
  56217. if (this._adaptiveBlurKernel) {
  56218. this._autoComputeBlurKernel();
  56219. }
  56220. };
  56221. MirrorTexture.prototype._updateGammaSpace = function () {
  56222. this.gammaSpace = !this.scene.imageProcessingConfiguration.isEnabled || !this.scene.imageProcessingConfiguration.applyByPostProcess;
  56223. };
  56224. MirrorTexture.prototype._preparePostProcesses = function () {
  56225. this.clearPostProcesses(true);
  56226. if (this._blurKernelX && this._blurKernelY) {
  56227. var engine = this.getScene().getEngine();
  56228. var textureType = engine.getCaps().textureFloatRender ? _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT : _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_HALF_FLOAT;
  56229. 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);
  56230. this._blurX.autoClear = false;
  56231. if (this._blurRatio === 1 && this.samples < 2 && this._texture) {
  56232. this._blurX.inputTexture = this._texture;
  56233. }
  56234. else {
  56235. this._blurX.alwaysForcePOT = true;
  56236. }
  56237. 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);
  56238. this._blurY.autoClear = false;
  56239. this._blurY.alwaysForcePOT = this._blurRatio !== 1;
  56240. this.addPostProcess(this._blurX);
  56241. this.addPostProcess(this._blurY);
  56242. }
  56243. else {
  56244. if (this._blurY) {
  56245. this.removePostProcess(this._blurY);
  56246. this._blurY.dispose();
  56247. this._blurY = null;
  56248. }
  56249. if (this._blurX) {
  56250. this.removePostProcess(this._blurX);
  56251. this._blurX.dispose();
  56252. this._blurX = null;
  56253. }
  56254. }
  56255. };
  56256. /**
  56257. * Clone the mirror texture.
  56258. * @returns the cloned texture
  56259. */
  56260. MirrorTexture.prototype.clone = function () {
  56261. var scene = this.getScene();
  56262. if (!scene) {
  56263. return this;
  56264. }
  56265. var textureSize = this.getSize();
  56266. var newTexture = new MirrorTexture(this.name, textureSize.width, scene, this._renderTargetOptions.generateMipMaps, this._renderTargetOptions.type, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer);
  56267. // Base texture
  56268. newTexture.hasAlpha = this.hasAlpha;
  56269. newTexture.level = this.level;
  56270. // Mirror Texture
  56271. newTexture.mirrorPlane = this.mirrorPlane.clone();
  56272. if (this.renderList) {
  56273. newTexture.renderList = this.renderList.slice(0);
  56274. }
  56275. return newTexture;
  56276. };
  56277. /**
  56278. * Serialize the texture to a JSON representation you could use in Parse later on
  56279. * @returns the serialized JSON representation
  56280. */
  56281. MirrorTexture.prototype.serialize = function () {
  56282. if (!this.name) {
  56283. return null;
  56284. }
  56285. var serializationObject = _super.prototype.serialize.call(this);
  56286. serializationObject.mirrorPlane = this.mirrorPlane.asArray();
  56287. return serializationObject;
  56288. };
  56289. /**
  56290. * Dispose the texture and release its associated resources.
  56291. */
  56292. MirrorTexture.prototype.dispose = function () {
  56293. _super.prototype.dispose.call(this);
  56294. this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver);
  56295. };
  56296. return MirrorTexture;
  56297. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]));
  56298. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  56299. return new MirrorTexture(name, renderTargetSize, scene, generateMipMaps);
  56300. };
  56301. /***/ }),
  56302. /***/ "./Materials/Textures/multiRenderTarget.ts":
  56303. /*!*************************************************!*\
  56304. !*** ./Materials/Textures/multiRenderTarget.ts ***!
  56305. \*************************************************/
  56306. /*! exports provided: MultiRenderTarget */
  56307. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56308. "use strict";
  56309. __webpack_require__.r(__webpack_exports__);
  56310. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return MultiRenderTarget; });
  56311. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56312. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56313. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56314. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56315. /**
  56316. * A multi render target, like a render target provides the ability to render to a texture.
  56317. * Unlike the render target, it can render to several draw buffers in one draw.
  56318. * This is specially interesting in deferred rendering or for any effects requiring more than
  56319. * just one color from a single pass.
  56320. */
  56321. var MultiRenderTarget = /** @class */ (function (_super) {
  56322. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiRenderTarget, _super);
  56323. /**
  56324. * Instantiate a new multi render target texture.
  56325. * A multi render target, like a render target provides the ability to render to a texture.
  56326. * Unlike the render target, it can render to several draw buffers in one draw.
  56327. * This is specially interesting in deferred rendering or for any effects requiring more than
  56328. * just one color from a single pass.
  56329. * @param name Define the name of the texture
  56330. * @param size Define the size of the buffers to render to
  56331. * @param count Define the number of target we are rendering into
  56332. * @param scene Define the scene the texture belongs to
  56333. * @param options Define the options used to create the multi render target
  56334. */
  56335. function MultiRenderTarget(name, size, count, scene, options) {
  56336. var _this = this;
  56337. var generateMipMaps = options && options.generateMipMaps ? options.generateMipMaps : false;
  56338. var generateDepthTexture = options && options.generateDepthTexture ? options.generateDepthTexture : false;
  56339. var doNotChangeAspectRatio = !options || options.doNotChangeAspectRatio === undefined ? true : options.doNotChangeAspectRatio;
  56340. _this = _super.call(this, name, size, scene, generateMipMaps, doNotChangeAspectRatio) || this;
  56341. _this._engine = scene.getEngine();
  56342. if (!_this.isSupported) {
  56343. _this.dispose();
  56344. return;
  56345. }
  56346. var types = [];
  56347. var samplingModes = [];
  56348. for (var i = 0; i < count; i++) {
  56349. if (options && options.types && options.types[i] !== undefined) {
  56350. types.push(options.types[i]);
  56351. }
  56352. else {
  56353. types.push(options && options.defaultType ? options.defaultType : _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  56354. }
  56355. if (options && options.samplingModes && options.samplingModes[i] !== undefined) {
  56356. samplingModes.push(options.samplingModes[i]);
  56357. }
  56358. else {
  56359. samplingModes.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE);
  56360. }
  56361. }
  56362. var generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  56363. var generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  56364. _this._size = size;
  56365. _this._multiRenderTargetOptions = {
  56366. samplingModes: samplingModes,
  56367. generateMipMaps: generateMipMaps,
  56368. generateDepthBuffer: generateDepthBuffer,
  56369. generateStencilBuffer: generateStencilBuffer,
  56370. generateDepthTexture: generateDepthTexture,
  56371. types: types,
  56372. textureCount: count
  56373. };
  56374. _this._createInternalTextures();
  56375. _this._createTextures();
  56376. return _this;
  56377. }
  56378. Object.defineProperty(MultiRenderTarget.prototype, "isSupported", {
  56379. /**
  56380. * Get if draw buffers are currently supported by the used hardware and browser.
  56381. */
  56382. get: function () {
  56383. return this._engine.webGLVersion > 1 || this._engine.getCaps().drawBuffersExtension;
  56384. },
  56385. enumerable: true,
  56386. configurable: true
  56387. });
  56388. Object.defineProperty(MultiRenderTarget.prototype, "textures", {
  56389. /**
  56390. * Get the list of textures generated by the multi render target.
  56391. */
  56392. get: function () {
  56393. return this._textures;
  56394. },
  56395. enumerable: true,
  56396. configurable: true
  56397. });
  56398. Object.defineProperty(MultiRenderTarget.prototype, "depthTexture", {
  56399. /**
  56400. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  56401. */
  56402. get: function () {
  56403. return this._textures[this._textures.length - 1];
  56404. },
  56405. enumerable: true,
  56406. configurable: true
  56407. });
  56408. Object.defineProperty(MultiRenderTarget.prototype, "wrapU", {
  56409. /**
  56410. * Set the wrapping mode on U of all the textures we are rendering to.
  56411. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  56412. */
  56413. set: function (wrap) {
  56414. if (this._textures) {
  56415. for (var i = 0; i < this._textures.length; i++) {
  56416. this._textures[i].wrapU = wrap;
  56417. }
  56418. }
  56419. },
  56420. enumerable: true,
  56421. configurable: true
  56422. });
  56423. Object.defineProperty(MultiRenderTarget.prototype, "wrapV", {
  56424. /**
  56425. * Set the wrapping mode on V of all the textures we are rendering to.
  56426. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  56427. */
  56428. set: function (wrap) {
  56429. if (this._textures) {
  56430. for (var i = 0; i < this._textures.length; i++) {
  56431. this._textures[i].wrapV = wrap;
  56432. }
  56433. }
  56434. },
  56435. enumerable: true,
  56436. configurable: true
  56437. });
  56438. /** @hidden */
  56439. MultiRenderTarget.prototype._rebuild = function () {
  56440. this.releaseInternalTextures();
  56441. this._createInternalTextures();
  56442. for (var i = 0; i < this._internalTextures.length; i++) {
  56443. var texture = this._textures[i];
  56444. texture._texture = this._internalTextures[i];
  56445. }
  56446. // Keeps references to frame buffer and stencil/depth buffer
  56447. this._texture = this._internalTextures[0];
  56448. };
  56449. MultiRenderTarget.prototype._createInternalTextures = function () {
  56450. this._internalTextures = this._engine.createMultipleRenderTarget(this._size, this._multiRenderTargetOptions);
  56451. };
  56452. MultiRenderTarget.prototype._createTextures = function () {
  56453. this._textures = [];
  56454. for (var i = 0; i < this._internalTextures.length; i++) {
  56455. var texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](null, this.getScene());
  56456. texture._texture = this._internalTextures[i];
  56457. this._textures.push(texture);
  56458. }
  56459. // Keeps references to frame buffer and stencil/depth buffer
  56460. this._texture = this._internalTextures[0];
  56461. };
  56462. Object.defineProperty(MultiRenderTarget.prototype, "samples", {
  56463. /**
  56464. * Define the number of samples used if MSAA is enabled.
  56465. */
  56466. get: function () {
  56467. return this._samples;
  56468. },
  56469. set: function (value) {
  56470. if (this._samples === value) {
  56471. return;
  56472. }
  56473. this._samples = this._engine.updateMultipleRenderTargetTextureSampleCount(this._internalTextures, value);
  56474. },
  56475. enumerable: true,
  56476. configurable: true
  56477. });
  56478. /**
  56479. * Resize all the textures in the multi render target.
  56480. * Be carrefull as it will recreate all the data in the new texture.
  56481. * @param size Define the new size
  56482. */
  56483. MultiRenderTarget.prototype.resize = function (size) {
  56484. this.releaseInternalTextures();
  56485. this._internalTextures = this._engine.createMultipleRenderTarget(size, this._multiRenderTargetOptions);
  56486. this._createInternalTextures();
  56487. };
  56488. MultiRenderTarget.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  56489. var _this = this;
  56490. engine.unBindMultiColorAttachmentFramebuffer(this._internalTextures, this.isCube, function () {
  56491. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  56492. });
  56493. };
  56494. /**
  56495. * Dispose the render targets and their associated resources
  56496. */
  56497. MultiRenderTarget.prototype.dispose = function () {
  56498. this.releaseInternalTextures();
  56499. _super.prototype.dispose.call(this);
  56500. };
  56501. /**
  56502. * Release all the underlying texture used as draw buffers.
  56503. */
  56504. MultiRenderTarget.prototype.releaseInternalTextures = function () {
  56505. if (!this._internalTextures) {
  56506. return;
  56507. }
  56508. for (var i = this._internalTextures.length - 1; i >= 0; i--) {
  56509. if (this._internalTextures[i] !== undefined) {
  56510. this._internalTextures[i].dispose();
  56511. this._internalTextures.splice(i, 1);
  56512. }
  56513. }
  56514. };
  56515. return MultiRenderTarget;
  56516. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  56517. /***/ }),
  56518. /***/ "./Materials/Textures/rawCubeTexture.ts":
  56519. /*!**********************************************!*\
  56520. !*** ./Materials/Textures/rawCubeTexture.ts ***!
  56521. \**********************************************/
  56522. /*! exports provided: RawCubeTexture */
  56523. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56524. "use strict";
  56525. __webpack_require__.r(__webpack_exports__);
  56526. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return RawCubeTexture; });
  56527. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56528. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  56529. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  56530. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  56531. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  56532. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56533. /**
  56534. * Raw cube texture where the raw buffers are passed in
  56535. */
  56536. var RawCubeTexture = /** @class */ (function (_super) {
  56537. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawCubeTexture, _super);
  56538. /**
  56539. * Creates a cube texture where the raw buffers are passed in.
  56540. * @param scene defines the scene the texture is attached to
  56541. * @param data defines the array of data to use to create each face
  56542. * @param size defines the size of the textures
  56543. * @param format defines the format of the data
  56544. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56545. * @param generateMipMaps defines if the engine should generate the mip levels
  56546. * @param invertY defines if data must be stored with Y axis inverted
  56547. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56548. * @param compression defines the compression used (null by default)
  56549. */
  56550. function RawCubeTexture(scene, data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  56551. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTUREFORMAT_RGBA; }
  56552. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56553. if (generateMipMaps === void 0) { generateMipMaps = false; }
  56554. if (invertY === void 0) { invertY = false; }
  56555. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  56556. if (compression === void 0) { compression = null; }
  56557. var _this = _super.call(this, "", scene) || this;
  56558. _this._texture = scene.getEngine().createRawCubeTexture(data, size, format, type, generateMipMaps, invertY, samplingMode, compression);
  56559. return _this;
  56560. }
  56561. /**
  56562. * Updates the raw cube texture.
  56563. * @param data defines the data to store
  56564. * @param format defines the data format
  56565. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56566. * @param invertY defines if data must be stored with Y axis inverted
  56567. * @param compression defines the compression used (null by default)
  56568. * @param level defines which level of the texture to update
  56569. */
  56570. RawCubeTexture.prototype.update = function (data, format, type, invertY, compression) {
  56571. if (compression === void 0) { compression = null; }
  56572. this._texture.getEngine().updateRawCubeTexture(this._texture, data, format, type, invertY, compression);
  56573. };
  56574. /**
  56575. * Updates a raw cube texture with RGBD encoded data.
  56576. * @param data defines the array of data [mipmap][face] to use to create each face
  56577. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56578. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56579. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56580. * @returns a promsie that resolves when the operation is complete
  56581. */
  56582. RawCubeTexture.prototype.updateRGBDAsync = function (data, sphericalPolynomial, lodScale, lodOffset) {
  56583. if (sphericalPolynomial === void 0) { sphericalPolynomial = null; }
  56584. if (lodScale === void 0) { lodScale = 0.8; }
  56585. if (lodOffset === void 0) { lodOffset = 0; }
  56586. return RawCubeTexture._UpdateRGBDAsync(this._texture, data, sphericalPolynomial, lodScale, lodOffset);
  56587. };
  56588. /**
  56589. * Clones the raw cube texture.
  56590. * @return a new cube texture
  56591. */
  56592. RawCubeTexture.prototype.clone = function () {
  56593. var _this = this;
  56594. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  56595. var scene = _this.getScene();
  56596. var internalTexture = _this._texture;
  56597. var texture = new RawCubeTexture(scene, internalTexture._bufferViewArray, internalTexture.width, internalTexture.format, internalTexture.type, internalTexture.generateMipMaps, internalTexture.invertY, internalTexture.samplingMode, internalTexture._compression);
  56598. if (internalTexture.dataSource === _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD) {
  56599. texture.updateRGBDAsync(internalTexture._bufferViewArrayArray, internalTexture._sphericalPolynomial, internalTexture._lodGenerationScale, internalTexture._lodGenerationOffset);
  56600. }
  56601. return texture;
  56602. }, this);
  56603. };
  56604. /** @hidden */
  56605. RawCubeTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  56606. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  56607. internalTexture._bufferViewArrayArray = data;
  56608. internalTexture._lodGenerationScale = lodScale;
  56609. internalTexture._lodGenerationOffset = lodOffset;
  56610. internalTexture._sphericalPolynomial = sphericalPolynomial;
  56611. return _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__["EnvironmentTextureTools"].UploadLevelsAsync(internalTexture, data).then(function () {
  56612. internalTexture.isReady = true;
  56613. });
  56614. };
  56615. return RawCubeTexture;
  56616. }(_Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__["CubeTexture"]));
  56617. /***/ }),
  56618. /***/ "./Materials/Textures/rawTexture.ts":
  56619. /*!******************************************!*\
  56620. !*** ./Materials/Textures/rawTexture.ts ***!
  56621. \******************************************/
  56622. /*! exports provided: RawTexture */
  56623. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56624. "use strict";
  56625. __webpack_require__.r(__webpack_exports__);
  56626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return RawTexture; });
  56627. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56628. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56629. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56630. /**
  56631. * Raw texture can help creating a texture directly from an array of data.
  56632. * This can be super useful if you either get the data from an uncompressed source or
  56633. * if you wish to create your texture pixel by pixel.
  56634. */
  56635. var RawTexture = /** @class */ (function (_super) {
  56636. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture, _super);
  56637. /**
  56638. * Instantiates a new RawTexture.
  56639. * Raw texture can help creating a texture directly from an array of data.
  56640. * This can be super useful if you either get the data from an uncompressed source or
  56641. * if you wish to create your texture pixel by pixel.
  56642. * @param data define the array of data to use to create the texture
  56643. * @param width define the width of the texture
  56644. * @param height define the height of the texture
  56645. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  56646. * @param scene define the scene the texture belongs to
  56647. * @param generateMipMaps define whether mip maps should be generated or not
  56648. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  56649. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  56650. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  56651. */
  56652. function RawTexture(data, width, height,
  56653. /**
  56654. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  56655. */
  56656. format, scene, generateMipMaps, invertY, samplingMode, type) {
  56657. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56658. if (invertY === void 0) { invertY = false; }
  56659. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  56660. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56661. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  56662. _this.format = format;
  56663. _this._engine = scene.getEngine();
  56664. _this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type);
  56665. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  56666. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  56667. return _this;
  56668. }
  56669. /**
  56670. * Updates the texture underlying data.
  56671. * @param data Define the new data of the texture
  56672. */
  56673. RawTexture.prototype.update = function (data) {
  56674. this._engine.updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  56675. };
  56676. /**
  56677. * Creates a luminance texture from some data.
  56678. * @param data Define the texture data
  56679. * @param width Define the width of the texture
  56680. * @param height Define the height of the texture
  56681. * @param scene Define the scene the texture belongs to
  56682. * @param generateMipMaps Define whether or not to create mip maps for the texture
  56683. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  56684. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  56685. * @returns the luminance texture
  56686. */
  56687. RawTexture.CreateLuminanceTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  56688. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56689. if (invertY === void 0) { invertY = false; }
  56690. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  56691. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE, scene, generateMipMaps, invertY, samplingMode);
  56692. };
  56693. /**
  56694. * Creates a luminance alpha texture from some data.
  56695. * @param data Define the texture data
  56696. * @param width Define the width of the texture
  56697. * @param height Define the height of the texture
  56698. * @param scene Define the scene the texture belongs to
  56699. * @param generateMipMaps Define whether or not to create mip maps for the texture
  56700. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  56701. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  56702. * @returns the luminance alpha texture
  56703. */
  56704. RawTexture.CreateLuminanceAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  56705. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56706. if (invertY === void 0) { invertY = false; }
  56707. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  56708. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  56709. };
  56710. /**
  56711. * Creates an alpha texture from some data.
  56712. * @param data Define the texture data
  56713. * @param width Define the width of the texture
  56714. * @param height Define the height of the texture
  56715. * @param scene Define the scene the texture belongs to
  56716. * @param generateMipMaps Define whether or not to create mip maps for the texture
  56717. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  56718. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  56719. * @returns the alpha texture
  56720. */
  56721. RawTexture.CreateAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  56722. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56723. if (invertY === void 0) { invertY = false; }
  56724. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  56725. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  56726. };
  56727. /**
  56728. * Creates a RGB texture from some data.
  56729. * @param data Define the texture data
  56730. * @param width Define the width of the texture
  56731. * @param height Define the height of the texture
  56732. * @param scene Define the scene the texture belongs to
  56733. * @param generateMipMaps Define whether or not to create mip maps for the texture
  56734. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  56735. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  56736. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  56737. * @returns the RGB alpha texture
  56738. */
  56739. RawTexture.CreateRGBTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  56740. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56741. if (invertY === void 0) { invertY = false; }
  56742. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  56743. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56744. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode, type);
  56745. };
  56746. /**
  56747. * Creates a RGBA texture from some data.
  56748. * @param data Define the texture data
  56749. * @param width Define the width of the texture
  56750. * @param height Define the height of the texture
  56751. * @param scene Define the scene the texture belongs to
  56752. * @param generateMipMaps Define whether or not to create mip maps for the texture
  56753. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  56754. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  56755. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  56756. * @returns the RGBA texture
  56757. */
  56758. RawTexture.CreateRGBATexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  56759. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56760. if (invertY === void 0) { invertY = false; }
  56761. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  56762. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56763. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);
  56764. };
  56765. /**
  56766. * Creates a R texture from some data.
  56767. * @param data Define the texture data
  56768. * @param width Define the width of the texture
  56769. * @param height Define the height of the texture
  56770. * @param scene Define the scene the texture belongs to
  56771. * @param generateMipMaps Define whether or not to create mip maps for the texture
  56772. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  56773. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  56774. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  56775. * @returns the R texture
  56776. */
  56777. RawTexture.CreateRTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  56778. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56779. if (invertY === void 0) { invertY = false; }
  56780. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  56781. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT; }
  56782. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_R, scene, generateMipMaps, invertY, samplingMode, type);
  56783. };
  56784. return RawTexture;
  56785. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  56786. /***/ }),
  56787. /***/ "./Materials/Textures/rawTexture3D.ts":
  56788. /*!********************************************!*\
  56789. !*** ./Materials/Textures/rawTexture3D.ts ***!
  56790. \********************************************/
  56791. /*! exports provided: RawTexture3D */
  56792. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56793. "use strict";
  56794. __webpack_require__.r(__webpack_exports__);
  56795. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return RawTexture3D; });
  56796. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56797. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56798. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56799. /**
  56800. * Class used to store 3D textures containing user data
  56801. */
  56802. var RawTexture3D = /** @class */ (function (_super) {
  56803. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture3D, _super);
  56804. /**
  56805. * Create a new RawTexture3D
  56806. * @param data defines the data of the texture
  56807. * @param width defines the width of the texture
  56808. * @param height defines the height of the texture
  56809. * @param depth defines the depth of the texture
  56810. * @param format defines the texture format to use
  56811. * @param scene defines the hosting scene
  56812. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56813. * @param invertY defines if texture must be stored with Y axis inverted
  56814. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56815. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56816. */
  56817. function RawTexture3D(data, width, height, depth,
  56818. /** Gets or sets the texture format to use */
  56819. format, scene, generateMipMaps, invertY, samplingMode, textureType) {
  56820. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56821. if (invertY === void 0) { invertY = false; }
  56822. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  56823. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56824. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  56825. _this.format = format;
  56826. _this._engine = scene.getEngine();
  56827. _this._texture = scene.getEngine().createRawTexture3D(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, undefined, textureType);
  56828. _this.is3D = true;
  56829. return _this;
  56830. }
  56831. /**
  56832. * Update the texture with new data
  56833. * @param data defines the data to store in the texture
  56834. */
  56835. RawTexture3D.prototype.update = function (data) {
  56836. if (!this._texture) {
  56837. return;
  56838. }
  56839. this._engine.updateRawTexture3D(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  56840. };
  56841. return RawTexture3D;
  56842. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  56843. /***/ }),
  56844. /***/ "./Materials/Textures/refractionTexture.ts":
  56845. /*!*************************************************!*\
  56846. !*** ./Materials/Textures/refractionTexture.ts ***!
  56847. \*************************************************/
  56848. /*! exports provided: RefractionTexture */
  56849. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56850. "use strict";
  56851. __webpack_require__.r(__webpack_exports__);
  56852. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return RefractionTexture; });
  56853. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56854. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56855. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56856. /**
  56857. * Creates a refraction texture used by refraction channel of the standard material.
  56858. * It is like a mirror but to see through a material.
  56859. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56860. */
  56861. var RefractionTexture = /** @class */ (function (_super) {
  56862. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionTexture, _super);
  56863. /**
  56864. * Creates a refraction texture used by refraction channel of the standard material.
  56865. * It is like a mirror but to see through a material.
  56866. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56867. * @param name Define the texture name
  56868. * @param size Define the size of the underlying texture
  56869. * @param scene Define the scene the refraction belongs to
  56870. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56871. */
  56872. function RefractionTexture(name, size, scene, generateMipMaps) {
  56873. var _this = _super.call(this, name, size, scene, generateMipMaps, true) || this;
  56874. /**
  56875. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56876. * 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.
  56877. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56878. */
  56879. _this.refractionPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  56880. /**
  56881. * Define how deep under the surface we should see.
  56882. */
  56883. _this.depth = 2.0;
  56884. _this.onBeforeRenderObservable.add(function () {
  56885. scene.clipPlane = _this.refractionPlane;
  56886. });
  56887. _this.onAfterRenderObservable.add(function () {
  56888. delete scene.clipPlane;
  56889. });
  56890. return _this;
  56891. }
  56892. /**
  56893. * Clone the refraction texture.
  56894. * @returns the cloned texture
  56895. */
  56896. RefractionTexture.prototype.clone = function () {
  56897. var scene = this.getScene();
  56898. if (!scene) {
  56899. return this;
  56900. }
  56901. var textureSize = this.getSize();
  56902. var newTexture = new RefractionTexture(this.name, textureSize.width, scene, this._generateMipMaps);
  56903. // Base texture
  56904. newTexture.hasAlpha = this.hasAlpha;
  56905. newTexture.level = this.level;
  56906. // Refraction Texture
  56907. newTexture.refractionPlane = this.refractionPlane.clone();
  56908. if (this.renderList) {
  56909. newTexture.renderList = this.renderList.slice(0);
  56910. }
  56911. newTexture.depth = this.depth;
  56912. return newTexture;
  56913. };
  56914. /**
  56915. * Serialize the texture to a JSON representation you could use in Parse later on
  56916. * @returns the serialized JSON representation
  56917. */
  56918. RefractionTexture.prototype.serialize = function () {
  56919. if (!this.name) {
  56920. return null;
  56921. }
  56922. var serializationObject = _super.prototype.serialize.call(this);
  56923. serializationObject.mirrorPlane = this.refractionPlane.asArray();
  56924. serializationObject.depth = this.depth;
  56925. return serializationObject;
  56926. };
  56927. return RefractionTexture;
  56928. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  56929. /***/ }),
  56930. /***/ "./Materials/Textures/renderTargetCreationOptions.ts":
  56931. /*!***********************************************************!*\
  56932. !*** ./Materials/Textures/renderTargetCreationOptions.ts ***!
  56933. \***********************************************************/
  56934. /*! exports provided: RenderTargetCreationOptions */
  56935. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56936. "use strict";
  56937. __webpack_require__.r(__webpack_exports__);
  56938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetCreationOptions", function() { return RenderTargetCreationOptions; });
  56939. /**
  56940. * Define options used to create a render target texture
  56941. */
  56942. var RenderTargetCreationOptions = /** @class */ (function () {
  56943. function RenderTargetCreationOptions() {
  56944. }
  56945. return RenderTargetCreationOptions;
  56946. }());
  56947. /***/ }),
  56948. /***/ "./Materials/Textures/renderTargetTexture.ts":
  56949. /*!***************************************************!*\
  56950. !*** ./Materials/Textures/renderTargetTexture.ts ***!
  56951. \***************************************************/
  56952. /*! exports provided: RenderTargetTexture */
  56953. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56954. "use strict";
  56955. __webpack_require__.r(__webpack_exports__);
  56956. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return RenderTargetTexture; });
  56957. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56958. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  56959. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  56960. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56961. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56962. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  56963. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  56964. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56965. /**
  56966. * This Helps creating a texture that will be created from a camera in your scene.
  56967. * It is basically a dynamic texture that could be used to create special effects for instance.
  56968. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  56969. */
  56970. var RenderTargetTexture = /** @class */ (function (_super) {
  56971. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetTexture, _super);
  56972. /**
  56973. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  56974. * or used a shadow, depth texture...
  56975. * @param name The friendly name of the texture
  56976. * @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)
  56977. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  56978. * @param generateMipMaps True if mip maps need to be generated after render.
  56979. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  56980. * @param type The type of the buffer in the RTT (int, half float, float...)
  56981. * @param isCube True if a cube texture needs to be created
  56982. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  56983. * @param generateDepthBuffer True to generate a depth buffer
  56984. * @param generateStencilBuffer True to generate a stencil buffer
  56985. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  56986. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  56987. * @param delayAllocation if the texture allocation should be delayed (default: false)
  56988. */
  56989. function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type, isCube, samplingMode, generateDepthBuffer, generateStencilBuffer, isMulti, format, delayAllocation) {
  56990. if (doNotChangeAspectRatio === void 0) { doNotChangeAspectRatio = true; }
  56991. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56992. if (isCube === void 0) { isCube = false; }
  56993. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  56994. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  56995. if (generateStencilBuffer === void 0) { generateStencilBuffer = false; }
  56996. if (isMulti === void 0) { isMulti = false; }
  56997. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA; }
  56998. if (delayAllocation === void 0) { delayAllocation = false; }
  56999. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  57000. _this.isCube = isCube;
  57001. /**
  57002. * Define if particles should be rendered in your texture.
  57003. */
  57004. _this.renderParticles = true;
  57005. /**
  57006. * Define if sprites should be rendered in your texture.
  57007. */
  57008. _this.renderSprites = false;
  57009. /**
  57010. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  57011. */
  57012. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].PROJECTION_MODE;
  57013. /**
  57014. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  57015. */
  57016. _this.ignoreCameraViewport = false;
  57017. /**
  57018. * An event triggered when the texture is unbind.
  57019. */
  57020. _this.onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57021. /**
  57022. * An event triggered when the texture is unbind.
  57023. */
  57024. _this.onAfterUnbindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57025. /**
  57026. * An event triggered before rendering the texture
  57027. */
  57028. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57029. /**
  57030. * An event triggered after rendering the texture
  57031. */
  57032. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57033. /**
  57034. * An event triggered after the texture clear
  57035. */
  57036. _this.onClearObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57037. _this._currentRefreshId = -1;
  57038. _this._refreshRate = 1;
  57039. _this._samples = 1;
  57040. /**
  57041. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  57042. * It must define where the camera used to render the texture is set
  57043. */
  57044. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  57045. scene = _this.getScene();
  57046. if (!scene) {
  57047. return _this;
  57048. }
  57049. _this.renderList = new Array();
  57050. _this._engine = scene.getEngine();
  57051. _this.name = name;
  57052. _this.isRenderTarget = true;
  57053. _this._initialSizeParameter = size;
  57054. _this._processSizeParameter(size);
  57055. _this._resizeObserver = _this.getScene().getEngine().onResizeObservable.add(function () {
  57056. });
  57057. _this._generateMipMaps = generateMipMaps ? true : false;
  57058. _this._doNotChangeAspectRatio = doNotChangeAspectRatio;
  57059. // Rendering groups
  57060. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__["RenderingManager"](scene);
  57061. _this._renderingManager._useSceneAutoClearSetup = true;
  57062. if (isMulti) {
  57063. return _this;
  57064. }
  57065. _this._renderTargetOptions = {
  57066. generateMipMaps: generateMipMaps,
  57067. type: type,
  57068. format: format,
  57069. samplingMode: samplingMode,
  57070. generateDepthBuffer: generateDepthBuffer,
  57071. generateStencilBuffer: generateStencilBuffer
  57072. };
  57073. if (samplingMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].NEAREST_SAMPLINGMODE) {
  57074. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  57075. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  57076. }
  57077. if (!delayAllocation) {
  57078. if (isCube) {
  57079. _this._texture = scene.getEngine().createRenderTargetCubeTexture(_this.getRenderSize(), _this._renderTargetOptions);
  57080. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].INVCUBIC_MODE;
  57081. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  57082. }
  57083. else {
  57084. _this._texture = scene.getEngine().createRenderTargetTexture(_this._size, _this._renderTargetOptions);
  57085. }
  57086. }
  57087. return _this;
  57088. }
  57089. Object.defineProperty(RenderTargetTexture.prototype, "renderList", {
  57090. /**
  57091. * Use this list to define the list of mesh you want to render.
  57092. */
  57093. get: function () {
  57094. return this._renderList;
  57095. },
  57096. set: function (value) {
  57097. this._renderList = value;
  57098. if (this._renderList) {
  57099. this._hookArray(this._renderList);
  57100. }
  57101. },
  57102. enumerable: true,
  57103. configurable: true
  57104. });
  57105. RenderTargetTexture.prototype._hookArray = function (array) {
  57106. var _this = this;
  57107. var oldPush = array.push;
  57108. array.push = function () {
  57109. var items = [];
  57110. for (var _i = 0; _i < arguments.length; _i++) {
  57111. items[_i] = arguments[_i];
  57112. }
  57113. var wasEmpty = array.length === 0;
  57114. var result = oldPush.apply(array, items);
  57115. if (wasEmpty) {
  57116. _this.getScene().meshes.forEach(function (mesh) {
  57117. mesh._markSubMeshesAsLightDirty();
  57118. });
  57119. }
  57120. return result;
  57121. };
  57122. var oldSplice = array.splice;
  57123. array.splice = function (index, deleteCount) {
  57124. var deleted = oldSplice.apply(array, [index, deleteCount]);
  57125. if (array.length === 0) {
  57126. _this.getScene().meshes.forEach(function (mesh) {
  57127. mesh._markSubMeshesAsLightDirty();
  57128. });
  57129. }
  57130. return deleted;
  57131. };
  57132. };
  57133. Object.defineProperty(RenderTargetTexture.prototype, "onAfterUnbind", {
  57134. /**
  57135. * Set a after unbind callback in the texture.
  57136. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  57137. */
  57138. set: function (callback) {
  57139. if (this._onAfterUnbindObserver) {
  57140. this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver);
  57141. }
  57142. this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(callback);
  57143. },
  57144. enumerable: true,
  57145. configurable: true
  57146. });
  57147. Object.defineProperty(RenderTargetTexture.prototype, "onBeforeRender", {
  57148. /**
  57149. * Set a before render callback in the texture.
  57150. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  57151. */
  57152. set: function (callback) {
  57153. if (this._onBeforeRenderObserver) {
  57154. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  57155. }
  57156. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  57157. },
  57158. enumerable: true,
  57159. configurable: true
  57160. });
  57161. Object.defineProperty(RenderTargetTexture.prototype, "onAfterRender", {
  57162. /**
  57163. * Set a after render callback in the texture.
  57164. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  57165. */
  57166. set: function (callback) {
  57167. if (this._onAfterRenderObserver) {
  57168. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  57169. }
  57170. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  57171. },
  57172. enumerable: true,
  57173. configurable: true
  57174. });
  57175. Object.defineProperty(RenderTargetTexture.prototype, "onClear", {
  57176. /**
  57177. * Set a clear callback in the texture.
  57178. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  57179. */
  57180. set: function (callback) {
  57181. if (this._onClearObserver) {
  57182. this.onClearObservable.remove(this._onClearObserver);
  57183. }
  57184. this._onClearObserver = this.onClearObservable.add(callback);
  57185. },
  57186. enumerable: true,
  57187. configurable: true
  57188. });
  57189. Object.defineProperty(RenderTargetTexture.prototype, "renderTargetOptions", {
  57190. /**
  57191. * Gets render target creation options that were used.
  57192. */
  57193. get: function () {
  57194. return this._renderTargetOptions;
  57195. },
  57196. enumerable: true,
  57197. configurable: true
  57198. });
  57199. RenderTargetTexture.prototype._onRatioRescale = function () {
  57200. if (this._sizeRatio) {
  57201. this.resize(this._initialSizeParameter);
  57202. }
  57203. };
  57204. Object.defineProperty(RenderTargetTexture.prototype, "boundingBoxSize", {
  57205. get: function () {
  57206. return this._boundingBoxSize;
  57207. },
  57208. /**
  57209. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  57210. * When defined, the cubemap will switch to local mode
  57211. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57212. * @example https://www.babylonjs-playground.com/#RNASML
  57213. */
  57214. set: function (value) {
  57215. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  57216. return;
  57217. }
  57218. this._boundingBoxSize = value;
  57219. var scene = this.getScene();
  57220. if (scene) {
  57221. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  57222. }
  57223. },
  57224. enumerable: true,
  57225. configurable: true
  57226. });
  57227. /**
  57228. * Creates a depth stencil texture.
  57229. * This is only available in WebGL 2 or with the depth texture extension available.
  57230. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  57231. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  57232. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  57233. */
  57234. RenderTargetTexture.prototype.createDepthStencilTexture = function (comparisonFunction, bilinearFiltering, generateStencil) {
  57235. if (comparisonFunction === void 0) { comparisonFunction = 0; }
  57236. if (bilinearFiltering === void 0) { bilinearFiltering = true; }
  57237. if (generateStencil === void 0) { generateStencil = false; }
  57238. if (!this.getScene()) {
  57239. return;
  57240. }
  57241. var engine = this.getScene().getEngine();
  57242. this.depthStencilTexture = engine.createDepthStencilTexture(this._size, {
  57243. bilinearFiltering: bilinearFiltering,
  57244. comparisonFunction: comparisonFunction,
  57245. generateStencil: generateStencil,
  57246. isCube: this.isCube
  57247. });
  57248. engine.setFrameBufferDepthStencilTexture(this);
  57249. };
  57250. RenderTargetTexture.prototype._processSizeParameter = function (size) {
  57251. if (size.ratio) {
  57252. this._sizeRatio = size.ratio;
  57253. this._size = {
  57254. width: this._bestReflectionRenderTargetDimension(this._engine.getRenderWidth(), this._sizeRatio),
  57255. height: this._bestReflectionRenderTargetDimension(this._engine.getRenderHeight(), this._sizeRatio)
  57256. };
  57257. }
  57258. else {
  57259. this._size = size;
  57260. }
  57261. };
  57262. Object.defineProperty(RenderTargetTexture.prototype, "samples", {
  57263. /**
  57264. * Define the number of samples to use in case of MSAA.
  57265. * It defaults to one meaning no MSAA has been enabled.
  57266. */
  57267. get: function () {
  57268. return this._samples;
  57269. },
  57270. set: function (value) {
  57271. if (this._samples === value) {
  57272. return;
  57273. }
  57274. var scene = this.getScene();
  57275. if (!scene) {
  57276. return;
  57277. }
  57278. this._samples = scene.getEngine().updateRenderTargetTextureSampleCount(this._texture, value);
  57279. },
  57280. enumerable: true,
  57281. configurable: true
  57282. });
  57283. /**
  57284. * Resets the refresh counter of the texture and start bak from scratch.
  57285. * Could be useful to regenerate the texture if it is setup to render only once.
  57286. */
  57287. RenderTargetTexture.prototype.resetRefreshCounter = function () {
  57288. this._currentRefreshId = -1;
  57289. };
  57290. Object.defineProperty(RenderTargetTexture.prototype, "refreshRate", {
  57291. /**
  57292. * Define the refresh rate of the texture or the rendering frequency.
  57293. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  57294. */
  57295. get: function () {
  57296. return this._refreshRate;
  57297. },
  57298. set: function (value) {
  57299. this._refreshRate = value;
  57300. this.resetRefreshCounter();
  57301. },
  57302. enumerable: true,
  57303. configurable: true
  57304. });
  57305. /**
  57306. * Adds a post process to the render target rendering passes.
  57307. * @param postProcess define the post process to add
  57308. */
  57309. RenderTargetTexture.prototype.addPostProcess = function (postProcess) {
  57310. if (!this._postProcessManager) {
  57311. var scene = this.getScene();
  57312. if (!scene) {
  57313. return;
  57314. }
  57315. this._postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__["PostProcessManager"](scene);
  57316. this._postProcesses = new Array();
  57317. }
  57318. this._postProcesses.push(postProcess);
  57319. this._postProcesses[0].autoClear = false;
  57320. };
  57321. /**
  57322. * Clear all the post processes attached to the render target
  57323. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  57324. */
  57325. RenderTargetTexture.prototype.clearPostProcesses = function (dispose) {
  57326. if (dispose === void 0) { dispose = false; }
  57327. if (!this._postProcesses) {
  57328. return;
  57329. }
  57330. if (dispose) {
  57331. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  57332. var postProcess = _a[_i];
  57333. postProcess.dispose();
  57334. }
  57335. }
  57336. this._postProcesses = [];
  57337. };
  57338. /**
  57339. * Remove one of the post process from the list of attached post processes to the texture
  57340. * @param postProcess define the post process to remove from the list
  57341. */
  57342. RenderTargetTexture.prototype.removePostProcess = function (postProcess) {
  57343. if (!this._postProcesses) {
  57344. return;
  57345. }
  57346. var index = this._postProcesses.indexOf(postProcess);
  57347. if (index === -1) {
  57348. return;
  57349. }
  57350. this._postProcesses.splice(index, 1);
  57351. if (this._postProcesses.length > 0) {
  57352. this._postProcesses[0].autoClear = false;
  57353. }
  57354. };
  57355. /** @hidden */
  57356. RenderTargetTexture.prototype._shouldRender = function () {
  57357. if (this._currentRefreshId === -1) { // At least render once
  57358. this._currentRefreshId = 1;
  57359. return true;
  57360. }
  57361. if (this.refreshRate === this._currentRefreshId) {
  57362. this._currentRefreshId = 1;
  57363. return true;
  57364. }
  57365. this._currentRefreshId++;
  57366. return false;
  57367. };
  57368. /**
  57369. * Gets the actual render size of the texture.
  57370. * @returns the width of the render size
  57371. */
  57372. RenderTargetTexture.prototype.getRenderSize = function () {
  57373. return this.getRenderWidth();
  57374. };
  57375. /**
  57376. * Gets the actual render width of the texture.
  57377. * @returns the width of the render size
  57378. */
  57379. RenderTargetTexture.prototype.getRenderWidth = function () {
  57380. if (this._size.width) {
  57381. return this._size.width;
  57382. }
  57383. return this._size;
  57384. };
  57385. /**
  57386. * Gets the actual render height of the texture.
  57387. * @returns the height of the render size
  57388. */
  57389. RenderTargetTexture.prototype.getRenderHeight = function () {
  57390. if (this._size.width) {
  57391. return this._size.height;
  57392. }
  57393. return this._size;
  57394. };
  57395. Object.defineProperty(RenderTargetTexture.prototype, "canRescale", {
  57396. /**
  57397. * Get if the texture can be rescaled or not.
  57398. */
  57399. get: function () {
  57400. return true;
  57401. },
  57402. enumerable: true,
  57403. configurable: true
  57404. });
  57405. /**
  57406. * Resize the texture using a ratio.
  57407. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  57408. */
  57409. RenderTargetTexture.prototype.scale = function (ratio) {
  57410. var newSize = this.getRenderSize() * ratio;
  57411. this.resize(newSize);
  57412. };
  57413. /**
  57414. * Get the texture reflection matrix used to rotate/transform the reflection.
  57415. * @returns the reflection matrix
  57416. */
  57417. RenderTargetTexture.prototype.getReflectionTextureMatrix = function () {
  57418. if (this.isCube) {
  57419. return this._textureMatrix;
  57420. }
  57421. return _super.prototype.getReflectionTextureMatrix.call(this);
  57422. };
  57423. /**
  57424. * Resize the texture to a new desired size.
  57425. * Be carrefull as it will recreate all the data in the new texture.
  57426. * @param size Define the new size. It can be:
  57427. * - a number for squared texture,
  57428. * - an object containing { width: number, height: number }
  57429. * - or an object containing a ratio { ratio: number }
  57430. */
  57431. RenderTargetTexture.prototype.resize = function (size) {
  57432. this.releaseInternalTexture();
  57433. var scene = this.getScene();
  57434. if (!scene) {
  57435. return;
  57436. }
  57437. this._processSizeParameter(size);
  57438. if (this.isCube) {
  57439. this._texture = scene.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions);
  57440. }
  57441. else {
  57442. this._texture = scene.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions);
  57443. }
  57444. };
  57445. /**
  57446. * Renders all the objects from the render list into the texture.
  57447. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  57448. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  57449. */
  57450. RenderTargetTexture.prototype.render = function (useCameraPostProcess, dumpForDebug) {
  57451. if (useCameraPostProcess === void 0) { useCameraPostProcess = false; }
  57452. if (dumpForDebug === void 0) { dumpForDebug = false; }
  57453. var scene = this.getScene();
  57454. if (!scene) {
  57455. return;
  57456. }
  57457. var engine = scene.getEngine();
  57458. if (this.useCameraPostProcesses !== undefined) {
  57459. useCameraPostProcess = this.useCameraPostProcesses;
  57460. }
  57461. if (this._waitingRenderList) {
  57462. this.renderList = [];
  57463. for (var index = 0; index < this._waitingRenderList.length; index++) {
  57464. var id = this._waitingRenderList[index];
  57465. var mesh_1 = scene.getMeshByID(id);
  57466. if (mesh_1) {
  57467. this.renderList.push(mesh_1);
  57468. }
  57469. }
  57470. delete this._waitingRenderList;
  57471. }
  57472. // Is predicate defined?
  57473. if (this.renderListPredicate) {
  57474. if (this.renderList) {
  57475. this.renderList.length = 0; // Clear previous renderList
  57476. }
  57477. else {
  57478. this.renderList = [];
  57479. }
  57480. var scene = this.getScene();
  57481. if (!scene) {
  57482. return;
  57483. }
  57484. var sceneMeshes = scene.meshes;
  57485. for (var index = 0; index < sceneMeshes.length; index++) {
  57486. var mesh = sceneMeshes[index];
  57487. if (this.renderListPredicate(mesh)) {
  57488. this.renderList.push(mesh);
  57489. }
  57490. }
  57491. }
  57492. this.onBeforeBindObservable.notifyObservers(this);
  57493. // Set custom projection.
  57494. // Needs to be before binding to prevent changing the aspect ratio.
  57495. var camera;
  57496. if (this.activeCamera) {
  57497. camera = this.activeCamera;
  57498. engine.setViewport(this.activeCamera.viewport, this.getRenderWidth(), this.getRenderHeight());
  57499. if (this.activeCamera !== scene.activeCamera) {
  57500. scene.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(true));
  57501. }
  57502. }
  57503. else {
  57504. camera = scene.activeCamera;
  57505. if (camera) {
  57506. engine.setViewport(camera.viewport, this.getRenderWidth(), this.getRenderHeight());
  57507. }
  57508. }
  57509. // Prepare renderingManager
  57510. this._renderingManager.reset();
  57511. var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
  57512. var currentRenderListLength = this.renderList ? this.renderList.length : scene.getActiveMeshes().length;
  57513. var sceneRenderId = scene.getRenderId();
  57514. for (var meshIndex = 0; meshIndex < currentRenderListLength; meshIndex++) {
  57515. var mesh = currentRenderList[meshIndex];
  57516. if (mesh) {
  57517. if (!mesh.isReady(this.refreshRate === 0)) {
  57518. this.resetRefreshCounter();
  57519. continue;
  57520. }
  57521. mesh._preActivateForIntermediateRendering(sceneRenderId);
  57522. var isMasked = void 0;
  57523. if (!this.renderList && camera) {
  57524. isMasked = ((mesh.layerMask & camera.layerMask) === 0);
  57525. }
  57526. else {
  57527. isMasked = false;
  57528. }
  57529. if (mesh.isEnabled() && mesh.isVisible && mesh.subMeshes && !isMasked) {
  57530. mesh._activate(sceneRenderId);
  57531. for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  57532. var subMesh = mesh.subMeshes[subIndex];
  57533. scene._activeIndices.addCount(subMesh.indexCount, false);
  57534. this._renderingManager.dispatch(subMesh, mesh);
  57535. }
  57536. }
  57537. }
  57538. }
  57539. for (var particleIndex = 0; particleIndex < scene.particleSystems.length; particleIndex++) {
  57540. var particleSystem = scene.particleSystems[particleIndex];
  57541. var emitter = particleSystem.emitter;
  57542. if (!particleSystem.isStarted() || !emitter || !emitter.position || !emitter.isEnabled()) {
  57543. continue;
  57544. }
  57545. if (currentRenderList.indexOf(emitter) >= 0) {
  57546. this._renderingManager.dispatchParticles(particleSystem);
  57547. }
  57548. }
  57549. if (this.isCube) {
  57550. for (var face = 0; face < 6; face++) {
  57551. this.renderToTarget(face, currentRenderList, useCameraPostProcess, dumpForDebug);
  57552. scene.incrementRenderId();
  57553. scene.resetCachedMaterial();
  57554. }
  57555. }
  57556. else {
  57557. this.renderToTarget(0, currentRenderList, useCameraPostProcess, dumpForDebug);
  57558. }
  57559. this.onAfterUnbindObservable.notifyObservers(this);
  57560. if (scene.activeCamera) {
  57561. if (this.activeCamera && this.activeCamera !== scene.activeCamera) {
  57562. scene.setTransformMatrix(scene.activeCamera.getViewMatrix(), scene.activeCamera.getProjectionMatrix(true));
  57563. }
  57564. engine.setViewport(scene.activeCamera.viewport);
  57565. }
  57566. scene.resetCachedMaterial();
  57567. };
  57568. RenderTargetTexture.prototype._bestReflectionRenderTargetDimension = function (renderDimension, scale) {
  57569. var minimum = 128;
  57570. var x = renderDimension * scale;
  57571. var curved = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].NearestPOT(x + (minimum * minimum / (minimum + x)));
  57572. // Ensure we don't exceed the render dimension (while staying POT)
  57573. return Math.min(_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].FloorPOT(renderDimension), curved);
  57574. };
  57575. RenderTargetTexture.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  57576. var _this = this;
  57577. if (!this._texture) {
  57578. return;
  57579. }
  57580. engine.unBindFramebuffer(this._texture, this.isCube, function () {
  57581. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  57582. });
  57583. };
  57584. RenderTargetTexture.prototype.renderToTarget = function (faceIndex, currentRenderList, useCameraPostProcess, dumpForDebug) {
  57585. var scene = this.getScene();
  57586. if (!scene) {
  57587. return;
  57588. }
  57589. var engine = scene.getEngine();
  57590. if (!this._texture) {
  57591. return;
  57592. }
  57593. // Bind
  57594. if (this._postProcessManager) {
  57595. this._postProcessManager._prepareFrame(this._texture, this._postProcesses);
  57596. }
  57597. else if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
  57598. if (this._texture) {
  57599. engine.bindFramebuffer(this._texture, this.isCube ? faceIndex : undefined, undefined, undefined, this.ignoreCameraViewport, this.depthStencilTexture ? this.depthStencilTexture : undefined);
  57600. }
  57601. }
  57602. this.onBeforeRenderObservable.notifyObservers(faceIndex);
  57603. // Clear
  57604. if (this.onClearObservable.hasObservers()) {
  57605. this.onClearObservable.notifyObservers(engine);
  57606. }
  57607. else {
  57608. engine.clear(this.clearColor || scene.clearColor, true, true, true);
  57609. }
  57610. if (!this._doNotChangeAspectRatio) {
  57611. scene.updateTransformMatrix(true);
  57612. }
  57613. // Before Camera Draw
  57614. for (var _i = 0, _a = scene._beforeRenderTargetDrawStage; _i < _a.length; _i++) {
  57615. var step = _a[_i];
  57616. step.action(this);
  57617. }
  57618. // Render
  57619. this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
  57620. // After Camera Draw
  57621. for (var _b = 0, _c = scene._afterRenderTargetDrawStage; _b < _c.length; _b++) {
  57622. var step = _c[_b];
  57623. step.action(this);
  57624. }
  57625. if (this._postProcessManager) {
  57626. this._postProcessManager._finalizeFrame(false, this._texture, faceIndex, this._postProcesses, this.ignoreCameraViewport);
  57627. }
  57628. else if (useCameraPostProcess) {
  57629. scene.postProcessManager._finalizeFrame(false, this._texture, faceIndex);
  57630. }
  57631. if (!this._doNotChangeAspectRatio) {
  57632. scene.updateTransformMatrix(true);
  57633. }
  57634. // Dump ?
  57635. if (dumpForDebug) {
  57636. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), engine);
  57637. }
  57638. // Unbind
  57639. if (!this.isCube || faceIndex === 5) {
  57640. if (this.isCube) {
  57641. if (faceIndex === 5) {
  57642. engine.generateMipMapsForCubemap(this._texture);
  57643. }
  57644. }
  57645. this.unbindFrameBuffer(engine, faceIndex);
  57646. }
  57647. else {
  57648. this.onAfterRenderObservable.notifyObservers(faceIndex);
  57649. }
  57650. };
  57651. /**
  57652. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  57653. * This allowed control for front to back rendering or reversly depending of the special needs.
  57654. *
  57655. * @param renderingGroupId The rendering group id corresponding to its index
  57656. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  57657. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  57658. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  57659. */
  57660. RenderTargetTexture.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  57661. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  57662. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  57663. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  57664. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  57665. };
  57666. /**
  57667. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  57668. *
  57669. * @param renderingGroupId The rendering group id corresponding to its index
  57670. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  57671. */
  57672. RenderTargetTexture.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  57673. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  57674. this._renderingManager._useSceneAutoClearSetup = false;
  57675. };
  57676. /**
  57677. * Clones the texture.
  57678. * @returns the cloned texture
  57679. */
  57680. RenderTargetTexture.prototype.clone = function () {
  57681. var textureSize = this.getSize();
  57682. 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);
  57683. // Base texture
  57684. newTexture.hasAlpha = this.hasAlpha;
  57685. newTexture.level = this.level;
  57686. // RenderTarget Texture
  57687. newTexture.coordinatesMode = this.coordinatesMode;
  57688. if (this.renderList) {
  57689. newTexture.renderList = this.renderList.slice(0);
  57690. }
  57691. return newTexture;
  57692. };
  57693. /**
  57694. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  57695. * @returns The JSON representation of the texture
  57696. */
  57697. RenderTargetTexture.prototype.serialize = function () {
  57698. if (!this.name) {
  57699. return null;
  57700. }
  57701. var serializationObject = _super.prototype.serialize.call(this);
  57702. serializationObject.renderTargetSize = this.getRenderSize();
  57703. serializationObject.renderList = [];
  57704. if (this.renderList) {
  57705. for (var index = 0; index < this.renderList.length; index++) {
  57706. serializationObject.renderList.push(this.renderList[index].id);
  57707. }
  57708. }
  57709. return serializationObject;
  57710. };
  57711. /**
  57712. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  57713. */
  57714. RenderTargetTexture.prototype.disposeFramebufferObjects = function () {
  57715. var objBuffer = this.getInternalTexture();
  57716. var scene = this.getScene();
  57717. if (objBuffer && scene) {
  57718. scene.getEngine()._releaseFramebufferObjects(objBuffer);
  57719. }
  57720. };
  57721. /**
  57722. * Dispose the texture and release its associated resources.
  57723. */
  57724. RenderTargetTexture.prototype.dispose = function () {
  57725. if (this._postProcessManager) {
  57726. this._postProcessManager.dispose();
  57727. this._postProcessManager = null;
  57728. }
  57729. this.clearPostProcesses(true);
  57730. if (this._resizeObserver) {
  57731. this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver);
  57732. this._resizeObserver = null;
  57733. }
  57734. this.renderList = null;
  57735. // Remove from custom render targets
  57736. var scene = this.getScene();
  57737. if (!scene) {
  57738. return;
  57739. }
  57740. var index = scene.customRenderTargets.indexOf(this);
  57741. if (index >= 0) {
  57742. scene.customRenderTargets.splice(index, 1);
  57743. }
  57744. for (var _i = 0, _a = scene.cameras; _i < _a.length; _i++) {
  57745. var camera = _a[_i];
  57746. index = camera.customRenderTargets.indexOf(this);
  57747. if (index >= 0) {
  57748. camera.customRenderTargets.splice(index, 1);
  57749. }
  57750. }
  57751. _super.prototype.dispose.call(this);
  57752. };
  57753. /** @hidden */
  57754. RenderTargetTexture.prototype._rebuild = function () {
  57755. if (this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE) {
  57756. this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;
  57757. }
  57758. if (this._postProcessManager) {
  57759. this._postProcessManager._rebuild();
  57760. }
  57761. };
  57762. /**
  57763. * Clear the info related to rendering groups preventing retention point in material dispose.
  57764. */
  57765. RenderTargetTexture.prototype.freeRenderingGroups = function () {
  57766. if (this._renderingManager) {
  57767. this._renderingManager.freeRenderingGroups();
  57768. }
  57769. };
  57770. /**
  57771. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  57772. */
  57773. RenderTargetTexture.REFRESHRATE_RENDER_ONCE = 0;
  57774. /**
  57775. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  57776. */
  57777. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME = 1;
  57778. /**
  57779. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  57780. * the central point of your effect and can save a lot of performances.
  57781. */
  57782. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2;
  57783. return RenderTargetTexture;
  57784. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  57785. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  57786. return new RenderTargetTexture(name, renderTargetSize, scene, generateMipMaps);
  57787. };
  57788. /***/ }),
  57789. /***/ "./Materials/Textures/texture.ts":
  57790. /*!***************************************!*\
  57791. !*** ./Materials/Textures/texture.ts ***!
  57792. \***************************************/
  57793. /*! exports provided: Texture */
  57794. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57795. "use strict";
  57796. __webpack_require__.r(__webpack_exports__);
  57797. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return Texture; });
  57798. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57799. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  57800. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  57801. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  57802. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57803. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  57804. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57805. /**
  57806. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  57807. * @see http://doc.babylonjs.com/babylon101/materials#texture
  57808. */
  57809. var Texture = /** @class */ (function (_super) {
  57810. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Texture, _super);
  57811. /**
  57812. * Instantiates a new texture.
  57813. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  57814. * @see http://doc.babylonjs.com/babylon101/materials#texture
  57815. * @param url define the url of the picture to load as a texture
  57816. * @param scene define the scene the texture will belong to
  57817. * @param noMipmap define if the texture will require mip maps or not
  57818. * @param invertY define if the texture needs to be inverted on the y axis during loading
  57819. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  57820. * @param onLoad define a callback triggered when the texture has been loaded
  57821. * @param onError define a callback triggered when an error occurred during the loading session
  57822. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  57823. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  57824. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  57825. */
  57826. function Texture(url, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format) {
  57827. if (noMipmap === void 0) { noMipmap = false; }
  57828. if (invertY === void 0) { invertY = true; }
  57829. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  57830. if (onLoad === void 0) { onLoad = null; }
  57831. if (onError === void 0) { onError = null; }
  57832. if (buffer === void 0) { buffer = null; }
  57833. if (deleteBuffer === void 0) { deleteBuffer = false; }
  57834. var _this = _super.call(this, scene) || this;
  57835. /**
  57836. * Define an offset on the texture to offset the u coordinates of the UVs
  57837. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  57838. */
  57839. _this.uOffset = 0;
  57840. /**
  57841. * Define an offset on the texture to offset the v coordinates of the UVs
  57842. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  57843. */
  57844. _this.vOffset = 0;
  57845. /**
  57846. * Define an offset on the texture to scale the u coordinates of the UVs
  57847. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  57848. */
  57849. _this.uScale = 1.0;
  57850. /**
  57851. * Define an offset on the texture to scale the v coordinates of the UVs
  57852. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  57853. */
  57854. _this.vScale = 1.0;
  57855. /**
  57856. * Define an offset on the texture to rotate around the u coordinates of the UVs
  57857. * @see http://doc.babylonjs.com/how_to/more_materials
  57858. */
  57859. _this.uAng = 0;
  57860. /**
  57861. * Define an offset on the texture to rotate around the v coordinates of the UVs
  57862. * @see http://doc.babylonjs.com/how_to/more_materials
  57863. */
  57864. _this.vAng = 0;
  57865. /**
  57866. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  57867. * @see http://doc.babylonjs.com/how_to/more_materials
  57868. */
  57869. _this.wAng = 0;
  57870. /**
  57871. * Defines the center of rotation (U)
  57872. */
  57873. _this.uRotationCenter = 0.5;
  57874. /**
  57875. * Defines the center of rotation (V)
  57876. */
  57877. _this.vRotationCenter = 0.5;
  57878. /**
  57879. * Defines the center of rotation (W)
  57880. */
  57881. _this.wRotationCenter = 0.5;
  57882. /** @hidden */
  57883. _this._initialSamplingMode = Texture.BILINEAR_SAMPLINGMODE;
  57884. /**
  57885. * Observable triggered once the texture has been loaded.
  57886. */
  57887. _this.onLoadObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  57888. _this._isBlocking = true;
  57889. _this.name = url || "";
  57890. _this.url = url;
  57891. _this._noMipmap = noMipmap;
  57892. _this._invertY = invertY;
  57893. _this._initialSamplingMode = samplingMode;
  57894. _this._buffer = buffer;
  57895. _this._deleteBuffer = deleteBuffer;
  57896. if (format) {
  57897. _this._format = format;
  57898. }
  57899. scene = _this.getScene();
  57900. if (!scene) {
  57901. return _this;
  57902. }
  57903. scene.getEngine().onBeforeTextureInitObservable.notifyObservers(_this);
  57904. var load = function () {
  57905. if (_this._texture && _this._texture._invertVScale) {
  57906. _this.vScale = -1;
  57907. }
  57908. if (_this.onLoadObservable.hasObservers()) {
  57909. _this.onLoadObservable.notifyObservers(_this);
  57910. }
  57911. if (onLoad) {
  57912. onLoad();
  57913. }
  57914. if (!_this.isBlocking && scene) {
  57915. scene.resetCachedMaterial();
  57916. }
  57917. };
  57918. if (!_this.url) {
  57919. _this._delayedOnLoad = load;
  57920. _this._delayedOnError = onError;
  57921. return _this;
  57922. }
  57923. _this._texture = _this._getFromCache(_this.url, noMipmap, samplingMode);
  57924. if (!_this._texture) {
  57925. if (!scene.useDelayedTextureLoading) {
  57926. _this._texture = scene.getEngine().createTexture(_this.url, noMipmap, invertY, scene, samplingMode, load, onError, _this._buffer, undefined, _this._format);
  57927. if (deleteBuffer) {
  57928. delete _this._buffer;
  57929. }
  57930. }
  57931. else {
  57932. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  57933. _this._delayedOnLoad = load;
  57934. _this._delayedOnError = onError;
  57935. }
  57936. }
  57937. else {
  57938. if (_this._texture.isReady) {
  57939. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(function () { return load(); });
  57940. }
  57941. else {
  57942. _this._texture.onLoadedObservable.add(load);
  57943. }
  57944. }
  57945. return _this;
  57946. }
  57947. Object.defineProperty(Texture.prototype, "noMipmap", {
  57948. /**
  57949. * Are mip maps generated for this texture or not.
  57950. */
  57951. get: function () {
  57952. return this._noMipmap;
  57953. },
  57954. enumerable: true,
  57955. configurable: true
  57956. });
  57957. Object.defineProperty(Texture.prototype, "isBlocking", {
  57958. get: function () {
  57959. return this._isBlocking;
  57960. },
  57961. /**
  57962. * Is the texture preventing material to render while loading.
  57963. * If false, a default texture will be used instead of the loading one during the preparation step.
  57964. */
  57965. set: function (value) {
  57966. this._isBlocking = value;
  57967. },
  57968. enumerable: true,
  57969. configurable: true
  57970. });
  57971. Object.defineProperty(Texture.prototype, "samplingMode", {
  57972. /**
  57973. * Get the current sampling mode associated with the texture.
  57974. */
  57975. get: function () {
  57976. if (!this._texture) {
  57977. return this._initialSamplingMode;
  57978. }
  57979. return this._texture.samplingMode;
  57980. },
  57981. enumerable: true,
  57982. configurable: true
  57983. });
  57984. Object.defineProperty(Texture.prototype, "invertY", {
  57985. /**
  57986. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  57987. */
  57988. get: function () {
  57989. return this._invertY;
  57990. },
  57991. enumerable: true,
  57992. configurable: true
  57993. });
  57994. /**
  57995. * Update the url (and optional buffer) of this texture if url was null during construction.
  57996. * @param url the url of the texture
  57997. * @param buffer the buffer of the texture (defaults to null)
  57998. * @param onLoad callback called when the texture is loaded (defaults to null)
  57999. */
  58000. Texture.prototype.updateURL = function (url, buffer, onLoad) {
  58001. if (buffer === void 0) { buffer = null; }
  58002. if (this.url) {
  58003. this.releaseInternalTexture();
  58004. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  58005. }
  58006. this.url = url;
  58007. this._buffer = buffer;
  58008. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  58009. if (onLoad) {
  58010. this._delayedOnLoad = onLoad;
  58011. }
  58012. this.delayLoad();
  58013. };
  58014. /**
  58015. * Finish the loading sequence of a texture flagged as delayed load.
  58016. * @hidden
  58017. */
  58018. Texture.prototype.delayLoad = function () {
  58019. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  58020. return;
  58021. }
  58022. var scene = this.getScene();
  58023. if (!scene) {
  58024. return;
  58025. }
  58026. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  58027. this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode);
  58028. if (!this._texture) {
  58029. this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format);
  58030. if (this._deleteBuffer) {
  58031. delete this._buffer;
  58032. }
  58033. }
  58034. else {
  58035. if (this._delayedOnLoad) {
  58036. if (this._texture.isReady) {
  58037. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(this._delayedOnLoad);
  58038. }
  58039. else {
  58040. this._texture.onLoadedObservable.add(this._delayedOnLoad);
  58041. }
  58042. }
  58043. }
  58044. this._delayedOnLoad = null;
  58045. this._delayedOnError = null;
  58046. };
  58047. Texture.prototype._prepareRowForTextureGeneration = function (x, y, z, t) {
  58048. x *= this.uScale;
  58049. y *= this.vScale;
  58050. x -= this.uRotationCenter * this.uScale;
  58051. y -= this.vRotationCenter * this.vScale;
  58052. z -= this.wRotationCenter;
  58053. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, this._rowGenerationMatrix, t);
  58054. t.x += this.uRotationCenter * this.uScale + this.uOffset;
  58055. t.y += this.vRotationCenter * this.vScale + this.vOffset;
  58056. t.z += this.wRotationCenter;
  58057. };
  58058. /**
  58059. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  58060. * @returns the transform matrix of the texture.
  58061. */
  58062. Texture.prototype.getTextureMatrix = function () {
  58063. var _this = this;
  58064. if (this.uOffset === this._cachedUOffset &&
  58065. this.vOffset === this._cachedVOffset &&
  58066. this.uScale === this._cachedUScale &&
  58067. this.vScale === this._cachedVScale &&
  58068. this.uAng === this._cachedUAng &&
  58069. this.vAng === this._cachedVAng &&
  58070. this.wAng === this._cachedWAng) {
  58071. return this._cachedTextureMatrix;
  58072. }
  58073. this._cachedUOffset = this.uOffset;
  58074. this._cachedVOffset = this.vOffset;
  58075. this._cachedUScale = this.uScale;
  58076. this._cachedVScale = this.vScale;
  58077. this._cachedUAng = this.uAng;
  58078. this._cachedVAng = this.vAng;
  58079. this._cachedWAng = this.wAng;
  58080. if (!this._cachedTextureMatrix) {
  58081. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  58082. this._rowGenerationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  58083. this._t0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  58084. this._t1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  58085. this._t2 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  58086. }
  58087. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix);
  58088. this._prepareRowForTextureGeneration(0, 0, 0, this._t0);
  58089. this._prepareRowForTextureGeneration(1.0, 0, 0, this._t1);
  58090. this._prepareRowForTextureGeneration(0, 1.0, 0, this._t2);
  58091. this._t1.subtractInPlace(this._t0);
  58092. this._t2.subtractInPlace(this._t0);
  58093. _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);
  58094. var scene = this.getScene();
  58095. if (!scene) {
  58096. return this._cachedTextureMatrix;
  58097. }
  58098. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  58099. return mat.hasTexture(_this);
  58100. });
  58101. return this._cachedTextureMatrix;
  58102. };
  58103. /**
  58104. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  58105. * @returns The reflection texture transform
  58106. */
  58107. Texture.prototype.getReflectionTextureMatrix = function () {
  58108. var _this = this;
  58109. var scene = this.getScene();
  58110. if (!scene) {
  58111. return this._cachedTextureMatrix;
  58112. }
  58113. if (this.uOffset === this._cachedUOffset &&
  58114. this.vOffset === this._cachedVOffset &&
  58115. this.uScale === this._cachedUScale &&
  58116. this.vScale === this._cachedVScale &&
  58117. this.coordinatesMode === this._cachedCoordinatesMode) {
  58118. if (this.coordinatesMode === Texture.PROJECTION_MODE) {
  58119. if (this._cachedProjectionMatrixId === scene.getProjectionMatrix().updateFlag) {
  58120. return this._cachedTextureMatrix;
  58121. }
  58122. }
  58123. else {
  58124. return this._cachedTextureMatrix;
  58125. }
  58126. }
  58127. if (!this._cachedTextureMatrix) {
  58128. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  58129. }
  58130. if (!this._projectionModeMatrix) {
  58131. this._projectionModeMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  58132. }
  58133. this._cachedUOffset = this.uOffset;
  58134. this._cachedVOffset = this.vOffset;
  58135. this._cachedUScale = this.uScale;
  58136. this._cachedVScale = this.vScale;
  58137. this._cachedCoordinatesMode = this.coordinatesMode;
  58138. switch (this.coordinatesMode) {
  58139. case Texture.PLANAR_MODE:
  58140. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  58141. this._cachedTextureMatrix[0] = this.uScale;
  58142. this._cachedTextureMatrix[5] = this.vScale;
  58143. this._cachedTextureMatrix[12] = this.uOffset;
  58144. this._cachedTextureMatrix[13] = this.vOffset;
  58145. break;
  58146. case Texture.PROJECTION_MODE:
  58147. _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);
  58148. var projectionMatrix = scene.getProjectionMatrix();
  58149. this._cachedProjectionMatrixId = projectionMatrix.updateFlag;
  58150. projectionMatrix.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
  58151. break;
  58152. default:
  58153. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  58154. break;
  58155. }
  58156. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  58157. return (mat.getActiveTextures().indexOf(_this) !== -1);
  58158. });
  58159. return this._cachedTextureMatrix;
  58160. };
  58161. /**
  58162. * Clones the texture.
  58163. * @returns the cloned texture
  58164. */
  58165. Texture.prototype.clone = function () {
  58166. var _this = this;
  58167. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  58168. return new Texture(_this._texture ? _this._texture.url : null, _this.getScene(), _this._noMipmap, _this._invertY, _this.samplingMode);
  58169. }, this);
  58170. };
  58171. /**
  58172. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  58173. * @returns The JSON representation of the texture
  58174. */
  58175. Texture.prototype.serialize = function () {
  58176. var serializationObject = _super.prototype.serialize.call(this);
  58177. if (typeof this._buffer === "string" && this._buffer.substr(0, 5) === "data:") {
  58178. serializationObject.base64String = this._buffer;
  58179. serializationObject.name = serializationObject.name.replace("data:", "");
  58180. }
  58181. serializationObject.invertY = this._invertY;
  58182. serializationObject.samplingMode = this.samplingMode;
  58183. return serializationObject;
  58184. };
  58185. /**
  58186. * Get the current class name of the texture useful for serialization or dynamic coding.
  58187. * @returns "Texture"
  58188. */
  58189. Texture.prototype.getClassName = function () {
  58190. return "Texture";
  58191. };
  58192. /**
  58193. * Dispose the texture and release its associated resources.
  58194. */
  58195. Texture.prototype.dispose = function () {
  58196. _super.prototype.dispose.call(this);
  58197. this.onLoadObservable.clear();
  58198. this._delayedOnLoad = null;
  58199. this._delayedOnError = null;
  58200. };
  58201. /**
  58202. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  58203. * @param parsedTexture Define the JSON representation of the texture
  58204. * @param scene Define the scene the parsed texture should be instantiated in
  58205. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58206. * @returns The parsed texture if successful
  58207. */
  58208. Texture.Parse = function (parsedTexture, scene, rootUrl) {
  58209. if (parsedTexture.customType) {
  58210. var customTexture = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Instantiate(parsedTexture.customType);
  58211. // Update Sampling Mode
  58212. var parsedCustomTexture = customTexture.Parse(parsedTexture, scene, rootUrl);
  58213. if (parsedTexture.samplingMode && parsedCustomTexture.updateSamplingMode && parsedCustomTexture._samplingMode) {
  58214. if (parsedCustomTexture._samplingMode !== parsedTexture.samplingMode) {
  58215. parsedCustomTexture.updateSamplingMode(parsedTexture.samplingMode);
  58216. }
  58217. }
  58218. return parsedCustomTexture;
  58219. }
  58220. if (parsedTexture.isCube && !parsedTexture.isRenderTarget) {
  58221. return Texture._CubeTextureParser(parsedTexture, scene, rootUrl);
  58222. }
  58223. if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
  58224. return null;
  58225. }
  58226. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  58227. var generateMipMaps = true;
  58228. if (parsedTexture.noMipmap) {
  58229. generateMipMaps = false;
  58230. }
  58231. if (parsedTexture.mirrorPlane) {
  58232. var mirrorTexture = Texture._CreateMirror(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  58233. mirrorTexture._waitingRenderList = parsedTexture.renderList;
  58234. mirrorTexture.mirrorPlane = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"].FromArray(parsedTexture.mirrorPlane);
  58235. return mirrorTexture;
  58236. }
  58237. else if (parsedTexture.isRenderTarget) {
  58238. var renderTargetTexture = null;
  58239. if (parsedTexture.isCube) {
  58240. // Search for an existing reflection probe (which contains a cube render target texture)
  58241. if (scene.reflectionProbes) {
  58242. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  58243. var probe = scene.reflectionProbes[index];
  58244. if (probe.name === parsedTexture.name) {
  58245. return probe.cubeTexture;
  58246. }
  58247. }
  58248. }
  58249. }
  58250. else {
  58251. renderTargetTexture = Texture._CreateRenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  58252. renderTargetTexture._waitingRenderList = parsedTexture.renderList;
  58253. }
  58254. return renderTargetTexture;
  58255. }
  58256. else {
  58257. var texture;
  58258. if (parsedTexture.base64String) {
  58259. texture = Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene, !generateMipMaps);
  58260. }
  58261. else {
  58262. var url = rootUrl + parsedTexture.name;
  58263. if (Texture.UseSerializedUrlIfAny && parsedTexture.url) {
  58264. url = parsedTexture.url;
  58265. }
  58266. texture = new Texture(url, scene, !generateMipMaps, parsedTexture.invertY);
  58267. }
  58268. return texture;
  58269. }
  58270. }, parsedTexture, scene);
  58271. // Update Sampling Mode
  58272. if (parsedTexture.samplingMode) {
  58273. var sampling = parsedTexture.samplingMode;
  58274. if (texture && texture.samplingMode !== sampling) {
  58275. texture.updateSamplingMode(sampling);
  58276. }
  58277. }
  58278. // Animations
  58279. if (texture && parsedTexture.animations) {
  58280. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  58281. var parsedAnimation = parsedTexture.animations[animationIndex];
  58282. texture.animations.push(Texture._AnimationParser(parsedAnimation));
  58283. }
  58284. }
  58285. return texture;
  58286. };
  58287. /**
  58288. * Creates a texture from its base 64 representation.
  58289. * @param data Define the base64 payload without the data: prefix
  58290. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  58291. * @param scene Define the scene the texture should belong to
  58292. * @param noMipmap Forces the texture to not create mip map information if true
  58293. * @param invertY define if the texture needs to be inverted on the y axis during loading
  58294. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  58295. * @param onLoad define a callback triggered when the texture has been loaded
  58296. * @param onError define a callback triggered when an error occurred during the loading session
  58297. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  58298. * @returns the created texture
  58299. */
  58300. Texture.CreateFromBase64String = function (data, name, scene, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  58301. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  58302. if (onLoad === void 0) { onLoad = null; }
  58303. if (onError === void 0) { onError = null; }
  58304. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  58305. return new Texture("data:" + name, scene, noMipmap, invertY, samplingMode, onLoad, onError, data, false, format);
  58306. };
  58307. /**
  58308. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  58309. * @param data Define the base64 payload without the data: prefix
  58310. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  58311. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  58312. * @param scene Define the scene the texture should belong to
  58313. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  58314. * @param noMipmap Forces the texture to not create mip map information if true
  58315. * @param invertY define if the texture needs to be inverted on the y axis during loading
  58316. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  58317. * @param onLoad define a callback triggered when the texture has been loaded
  58318. * @param onError define a callback triggered when an error occurred during the loading session
  58319. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  58320. * @returns the created texture
  58321. */
  58322. Texture.LoadFromDataString = function (name, buffer, scene, deleteBuffer, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  58323. if (deleteBuffer === void 0) { deleteBuffer = false; }
  58324. if (noMipmap === void 0) { noMipmap = false; }
  58325. if (invertY === void 0) { invertY = true; }
  58326. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  58327. if (onLoad === void 0) { onLoad = null; }
  58328. if (onError === void 0) { onError = null; }
  58329. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  58330. if (name.substr(0, 5) !== "data:") {
  58331. name = "data:" + name;
  58332. }
  58333. return new Texture(name, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format);
  58334. };
  58335. /** @hidden */
  58336. Texture._AnimationParser = function (jsonAnimation) {
  58337. throw "Animation needs to be imported before being deserialized.";
  58338. };
  58339. /** @hidden */
  58340. Texture._CubeTextureParser = function (jsonTexture, scene, rootUrl) {
  58341. throw "CubeTexture needs to be imported before being deserialized.";
  58342. };
  58343. /** @hidden */
  58344. Texture._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  58345. throw "MirrorTexture needs to be imported before being deserialized.";
  58346. };
  58347. /** @hidden */
  58348. Texture._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  58349. throw "RenderTargetTexture needs to be imported before being deserialized.";
  58350. };
  58351. /** nearest is mag = nearest and min = nearest and mip = linear */
  58352. Texture.NEAREST_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  58353. /** nearest is mag = nearest and min = nearest and mip = linear */
  58354. 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
  58355. /** Bilinear is mag = linear and min = linear and mip = nearest */
  58356. Texture.BILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  58357. /** Bilinear is mag = linear and min = linear and mip = nearest */
  58358. 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
  58359. /** Trilinear is mag = linear and min = linear and mip = linear */
  58360. Texture.TRILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  58361. /** Trilinear is mag = linear and min = linear and mip = linear */
  58362. 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
  58363. /** mag = nearest and min = nearest and mip = nearest */
  58364. Texture.NEAREST_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  58365. /** mag = nearest and min = linear and mip = nearest */
  58366. Texture.NEAREST_LINEAR_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  58367. /** mag = nearest and min = linear and mip = linear */
  58368. Texture.NEAREST_LINEAR_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  58369. /** mag = nearest and min = linear and mip = none */
  58370. Texture.NEAREST_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR;
  58371. /** mag = nearest and min = nearest and mip = none */
  58372. Texture.NEAREST_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST;
  58373. /** mag = linear and min = nearest and mip = nearest */
  58374. Texture.LINEAR_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  58375. /** mag = linear and min = nearest and mip = linear */
  58376. Texture.LINEAR_NEAREST_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  58377. /** mag = linear and min = linear and mip = none */
  58378. Texture.LINEAR_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR;
  58379. /** mag = linear and min = nearest and mip = none */
  58380. Texture.LINEAR_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST;
  58381. /** Explicit coordinates mode */
  58382. Texture.EXPLICIT_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EXPLICIT_MODE;
  58383. /** Spherical coordinates mode */
  58384. Texture.SPHERICAL_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SPHERICAL_MODE;
  58385. /** Planar coordinates mode */
  58386. Texture.PLANAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PLANAR_MODE;
  58387. /** Cubic coordinates mode */
  58388. Texture.CUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CUBIC_MODE;
  58389. /** Projection coordinates mode */
  58390. Texture.PROJECTION_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PROJECTION_MODE;
  58391. /** Inverse Cubic coordinates mode */
  58392. Texture.SKYBOX_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SKYBOX_MODE;
  58393. /** Inverse Cubic coordinates mode */
  58394. Texture.INVCUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_INVCUBIC_MODE;
  58395. /** Equirectangular coordinates mode */
  58396. Texture.EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  58397. /** Equirectangular Fixed coordinates mode */
  58398. Texture.FIXED_EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  58399. /** Equirectangular Fixed Mirrored coordinates mode */
  58400. Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  58401. /** Texture is not repeating outside of 0..1 UVs */
  58402. Texture.CLAMP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  58403. /** Texture is repeating outside of 0..1 UVs */
  58404. Texture.WRAP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  58405. /** Texture is repeating and mirrored */
  58406. Texture.MIRROR_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  58407. /**
  58408. * 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
  58409. */
  58410. Texture.UseSerializedUrlIfAny = false;
  58411. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58412. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58413. ], Texture.prototype, "url", void 0);
  58414. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58415. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58416. ], Texture.prototype, "uOffset", void 0);
  58417. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58418. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58419. ], Texture.prototype, "vOffset", void 0);
  58420. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58421. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58422. ], Texture.prototype, "uScale", void 0);
  58423. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58424. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58425. ], Texture.prototype, "vScale", void 0);
  58426. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58427. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58428. ], Texture.prototype, "uAng", void 0);
  58429. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58430. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58431. ], Texture.prototype, "vAng", void 0);
  58432. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58433. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58434. ], Texture.prototype, "wAng", void 0);
  58435. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58436. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58437. ], Texture.prototype, "uRotationCenter", void 0);
  58438. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58439. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58440. ], Texture.prototype, "vRotationCenter", void 0);
  58441. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58442. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58443. ], Texture.prototype, "wRotationCenter", void 0);
  58444. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58445. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58446. ], Texture.prototype, "isBlocking", null);
  58447. return Texture;
  58448. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]));
  58449. // References the dependencies.
  58450. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._TextureParser = Texture.Parse;
  58451. /***/ }),
  58452. /***/ "./Materials/Textures/videoTexture.ts":
  58453. /*!********************************************!*\
  58454. !*** ./Materials/Textures/videoTexture.ts ***!
  58455. \********************************************/
  58456. /*! exports provided: VideoTexture */
  58457. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58458. "use strict";
  58459. __webpack_require__.r(__webpack_exports__);
  58460. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return VideoTexture; });
  58461. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58462. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  58463. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  58464. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  58465. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58466. /**
  58467. * If you want to display a video in your scene, this is the special texture for that.
  58468. * This special texture works similar to other textures, with the exception of a few parameters.
  58469. * @see https://doc.babylonjs.com/how_to/video_texture
  58470. */
  58471. var VideoTexture = /** @class */ (function (_super) {
  58472. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoTexture, _super);
  58473. /**
  58474. * Creates a video texture.
  58475. * If you want to display a video in your scene, this is the special texture for that.
  58476. * This special texture works similar to other textures, with the exception of a few parameters.
  58477. * @see https://doc.babylonjs.com/how_to/video_texture
  58478. * @param name optional name, will detect from video source, if not defined
  58479. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  58480. * @param scene is obviously the current scene.
  58481. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  58482. * @param invertY is false by default but can be used to invert video on Y axis
  58483. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  58484. * @param settings allows finer control over video usage
  58485. */
  58486. function VideoTexture(name, src, scene, generateMipMaps, invertY, samplingMode, settings) {
  58487. if (generateMipMaps === void 0) { generateMipMaps = false; }
  58488. if (invertY === void 0) { invertY = false; }
  58489. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  58490. if (settings === void 0) { settings = {
  58491. autoPlay: true,
  58492. loop: true,
  58493. autoUpdateTexture: true,
  58494. }; }
  58495. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  58496. _this._onUserActionRequestedObservable = null;
  58497. _this._stillImageCaptured = false;
  58498. _this._displayingPosterTexture = false;
  58499. _this._createInternalTexture = function () {
  58500. if (_this._texture != null) {
  58501. if (_this._displayingPosterTexture) {
  58502. _this._texture.dispose();
  58503. _this._displayingPosterTexture = false;
  58504. }
  58505. else {
  58506. return;
  58507. }
  58508. }
  58509. if (!_this._engine.needPOTTextures ||
  58510. (_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoWidth) && _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoHeight))) {
  58511. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  58512. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  58513. }
  58514. else {
  58515. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  58516. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  58517. _this._generateMipMaps = false;
  58518. }
  58519. _this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this.samplingMode);
  58520. if (!_this.video.autoplay && !_this._settings.poster) {
  58521. var oldHandler_1 = _this.video.onplaying;
  58522. var error_1 = false;
  58523. _this.video.onplaying = function () {
  58524. _this.video.onplaying = oldHandler_1;
  58525. _this._texture.isReady = true;
  58526. _this._updateInternalTexture();
  58527. if (!error_1) {
  58528. _this.video.pause();
  58529. }
  58530. if (_this.onLoadObservable.hasObservers()) {
  58531. _this.onLoadObservable.notifyObservers(_this);
  58532. }
  58533. };
  58534. var playing = _this.video.play();
  58535. if (playing) {
  58536. playing.then(function () {
  58537. // Everything is good.
  58538. })
  58539. .catch(function () {
  58540. error_1 = true;
  58541. // On Chrome for instance, new policies might prevent playing without user interaction.
  58542. if (_this._onUserActionRequestedObservable && _this._onUserActionRequestedObservable.hasObservers()) {
  58543. _this._onUserActionRequestedObservable.notifyObservers(_this);
  58544. }
  58545. });
  58546. }
  58547. else {
  58548. _this.video.onplaying = oldHandler_1;
  58549. _this._texture.isReady = true;
  58550. _this._updateInternalTexture();
  58551. if (_this.onLoadObservable.hasObservers()) {
  58552. _this.onLoadObservable.notifyObservers(_this);
  58553. }
  58554. }
  58555. }
  58556. else {
  58557. _this._texture.isReady = true;
  58558. _this._updateInternalTexture();
  58559. if (_this.onLoadObservable.hasObservers()) {
  58560. _this.onLoadObservable.notifyObservers(_this);
  58561. }
  58562. }
  58563. };
  58564. _this.reset = function () {
  58565. if (_this._texture == null) {
  58566. return;
  58567. }
  58568. if (!_this._displayingPosterTexture) {
  58569. _this._texture.dispose();
  58570. _this._texture = null;
  58571. }
  58572. };
  58573. _this._updateInternalTexture = function () {
  58574. if (_this._texture == null || !_this._texture.isReady) {
  58575. return;
  58576. }
  58577. if (_this.video.readyState < _this.video.HAVE_CURRENT_DATA) {
  58578. return;
  58579. }
  58580. if (_this._displayingPosterTexture) {
  58581. return;
  58582. }
  58583. _this._engine.updateVideoTexture(_this._texture, _this.video, _this._invertY);
  58584. };
  58585. _this._engine = _this.getScene().getEngine();
  58586. _this._generateMipMaps = generateMipMaps;
  58587. _this._initialSamplingMode = samplingMode;
  58588. _this.autoUpdateTexture = settings.autoUpdateTexture;
  58589. _this.name = name || _this._getName(src);
  58590. _this.video = _this._getVideo(src);
  58591. _this._settings = settings;
  58592. if (settings.poster) {
  58593. _this.video.poster = settings.poster;
  58594. }
  58595. if (settings.autoPlay !== undefined) {
  58596. _this.video.autoplay = settings.autoPlay;
  58597. }
  58598. if (settings.loop !== undefined) {
  58599. _this.video.loop = settings.loop;
  58600. }
  58601. _this.video.setAttribute("playsinline", "");
  58602. _this.video.addEventListener("paused", _this._updateInternalTexture);
  58603. _this.video.addEventListener("seeked", _this._updateInternalTexture);
  58604. _this.video.addEventListener("emptied", _this.reset);
  58605. _this._createInternalTextureOnEvent = (settings.poster && !settings.autoPlay) ? "play" : "canplay";
  58606. _this.video.addEventListener(_this._createInternalTextureOnEvent, _this._createInternalTexture);
  58607. var videoHasEnoughData = (_this.video.readyState >= _this.video.HAVE_CURRENT_DATA);
  58608. if (settings.poster &&
  58609. (!settings.autoPlay || !videoHasEnoughData)) {
  58610. _this._texture = _this._engine.createTexture(settings.poster, false, true, scene);
  58611. _this._displayingPosterTexture = true;
  58612. }
  58613. else if (videoHasEnoughData) {
  58614. _this._createInternalTexture();
  58615. }
  58616. return _this;
  58617. }
  58618. Object.defineProperty(VideoTexture.prototype, "onUserActionRequestedObservable", {
  58619. /**
  58620. * Event triggerd when a dom action is required by the user to play the video.
  58621. * This happens due to recent changes in browser policies preventing video to auto start.
  58622. */
  58623. get: function () {
  58624. if (!this._onUserActionRequestedObservable) {
  58625. this._onUserActionRequestedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  58626. }
  58627. return this._onUserActionRequestedObservable;
  58628. },
  58629. enumerable: true,
  58630. configurable: true
  58631. });
  58632. VideoTexture.prototype._getName = function (src) {
  58633. if (src instanceof HTMLVideoElement) {
  58634. return src.currentSrc;
  58635. }
  58636. if (typeof src === "object") {
  58637. return src.toString();
  58638. }
  58639. return src;
  58640. };
  58641. VideoTexture.prototype._getVideo = function (src) {
  58642. if (src instanceof HTMLVideoElement) {
  58643. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src.currentSrc, src);
  58644. return src;
  58645. }
  58646. var video = document.createElement("video");
  58647. if (typeof src === "string") {
  58648. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src, video);
  58649. video.src = src;
  58650. }
  58651. else {
  58652. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src[0], video);
  58653. src.forEach(function (url) {
  58654. var source = document.createElement("source");
  58655. source.src = url;
  58656. video.appendChild(source);
  58657. });
  58658. }
  58659. return video;
  58660. };
  58661. /**
  58662. * @hidden Internal method to initiate `update`.
  58663. */
  58664. VideoTexture.prototype._rebuild = function () {
  58665. this.update();
  58666. };
  58667. /**
  58668. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  58669. */
  58670. VideoTexture.prototype.update = function () {
  58671. if (!this.autoUpdateTexture) {
  58672. // Expecting user to call `updateTexture` manually
  58673. return;
  58674. }
  58675. this.updateTexture(true);
  58676. };
  58677. /**
  58678. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  58679. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  58680. */
  58681. VideoTexture.prototype.updateTexture = function (isVisible) {
  58682. if (!isVisible) {
  58683. return;
  58684. }
  58685. if (this.video.paused && this._stillImageCaptured) {
  58686. return;
  58687. }
  58688. this._stillImageCaptured = true;
  58689. this._updateInternalTexture();
  58690. };
  58691. /**
  58692. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  58693. * @param url New url.
  58694. */
  58695. VideoTexture.prototype.updateURL = function (url) {
  58696. this.video.src = url;
  58697. };
  58698. /**
  58699. * Dispose the texture and release its associated resources.
  58700. */
  58701. VideoTexture.prototype.dispose = function () {
  58702. _super.prototype.dispose.call(this);
  58703. if (this._onUserActionRequestedObservable) {
  58704. this._onUserActionRequestedObservable.clear();
  58705. this._onUserActionRequestedObservable = null;
  58706. }
  58707. this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture);
  58708. this.video.removeEventListener("paused", this._updateInternalTexture);
  58709. this.video.removeEventListener("seeked", this._updateInternalTexture);
  58710. this.video.removeEventListener("emptied", this.reset);
  58711. this.video.pause();
  58712. };
  58713. /**
  58714. * Creates a video texture straight from your WebCam video feed.
  58715. * @param scene Define the scene the texture should be created in
  58716. * @param onReady Define a callback to triggered once the texture will be ready
  58717. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  58718. */
  58719. VideoTexture.CreateFromWebCam = function (scene, onReady, constraints) {
  58720. var video = document.createElement("video");
  58721. video.setAttribute('autoplay', '');
  58722. video.setAttribute('muted', '');
  58723. video.setAttribute('playsinline', '');
  58724. var constraintsDeviceId;
  58725. if (constraints && constraints.deviceId) {
  58726. constraintsDeviceId = {
  58727. exact: constraints.deviceId,
  58728. };
  58729. }
  58730. window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
  58731. if (navigator.mediaDevices) {
  58732. navigator.mediaDevices.getUserMedia({ video: constraints })
  58733. .then(function (stream) {
  58734. if (video.mozSrcObject !== undefined) {
  58735. // hack for Firefox < 19
  58736. video.mozSrcObject = stream;
  58737. }
  58738. else {
  58739. video.srcObject = stream;
  58740. }
  58741. var onPlaying = function () {
  58742. if (onReady) {
  58743. onReady(new VideoTexture("video", video, scene, true, true));
  58744. }
  58745. video.removeEventListener("playing", onPlaying);
  58746. };
  58747. video.addEventListener("playing", onPlaying);
  58748. video.play();
  58749. })
  58750. .catch(function (err) {
  58751. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(err.name);
  58752. });
  58753. }
  58754. else {
  58755. navigator.getUserMedia =
  58756. navigator.getUserMedia ||
  58757. navigator.webkitGetUserMedia ||
  58758. navigator.mozGetUserMedia ||
  58759. navigator.msGetUserMedia;
  58760. if (navigator.getUserMedia) {
  58761. navigator.getUserMedia({
  58762. video: {
  58763. deviceId: constraintsDeviceId,
  58764. width: {
  58765. min: (constraints && constraints.minWidth) || 256,
  58766. max: (constraints && constraints.maxWidth) || 640,
  58767. },
  58768. height: {
  58769. min: (constraints && constraints.minHeight) || 256,
  58770. max: (constraints && constraints.maxHeight) || 480,
  58771. },
  58772. },
  58773. }, function (stream) {
  58774. if (video.mozSrcObject !== undefined) {
  58775. // hack for Firefox < 19
  58776. video.mozSrcObject = stream;
  58777. }
  58778. else {
  58779. video.src = (window.URL && window.URL.createObjectURL(stream)) || stream;
  58780. }
  58781. video.play();
  58782. if (onReady) {
  58783. onReady(new VideoTexture("video", video, scene, true, true));
  58784. }
  58785. }, function (e) {
  58786. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(e.name);
  58787. });
  58788. }
  58789. }
  58790. };
  58791. return VideoTexture;
  58792. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  58793. /***/ }),
  58794. /***/ "./Materials/colorCurves.ts":
  58795. /*!**********************************!*\
  58796. !*** ./Materials/colorCurves.ts ***!
  58797. \**********************************/
  58798. /*! exports provided: ColorCurves */
  58799. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58800. "use strict";
  58801. __webpack_require__.r(__webpack_exports__);
  58802. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return ColorCurves; });
  58803. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58804. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  58805. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  58806. /**
  58807. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58808. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58809. * 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;
  58810. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58811. */
  58812. var ColorCurves = /** @class */ (function () {
  58813. function ColorCurves() {
  58814. this._dirty = true;
  58815. this._tempColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  58816. this._globalCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  58817. this._highlightsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  58818. this._midtonesCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  58819. this._shadowsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  58820. this._positiveCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  58821. this._negativeCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  58822. this._globalHue = 30;
  58823. this._globalDensity = 0;
  58824. this._globalSaturation = 0;
  58825. this._globalExposure = 0;
  58826. this._highlightsHue = 30;
  58827. this._highlightsDensity = 0;
  58828. this._highlightsSaturation = 0;
  58829. this._highlightsExposure = 0;
  58830. this._midtonesHue = 30;
  58831. this._midtonesDensity = 0;
  58832. this._midtonesSaturation = 0;
  58833. this._midtonesExposure = 0;
  58834. this._shadowsHue = 30;
  58835. this._shadowsDensity = 0;
  58836. this._shadowsSaturation = 0;
  58837. this._shadowsExposure = 0;
  58838. }
  58839. Object.defineProperty(ColorCurves.prototype, "globalHue", {
  58840. /**
  58841. * Gets the global Hue value.
  58842. * 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).
  58843. */
  58844. get: function () {
  58845. return this._globalHue;
  58846. },
  58847. /**
  58848. * Sets the global Hue value.
  58849. * 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).
  58850. */
  58851. set: function (value) {
  58852. this._globalHue = value;
  58853. this._dirty = true;
  58854. },
  58855. enumerable: true,
  58856. configurable: true
  58857. });
  58858. Object.defineProperty(ColorCurves.prototype, "globalDensity", {
  58859. /**
  58860. * Gets the global Density value.
  58861. * 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.
  58862. * Values less than zero provide a filter of opposite hue.
  58863. */
  58864. get: function () {
  58865. return this._globalDensity;
  58866. },
  58867. /**
  58868. * Sets the global Density value.
  58869. * 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.
  58870. * Values less than zero provide a filter of opposite hue.
  58871. */
  58872. set: function (value) {
  58873. this._globalDensity = value;
  58874. this._dirty = true;
  58875. },
  58876. enumerable: true,
  58877. configurable: true
  58878. });
  58879. Object.defineProperty(ColorCurves.prototype, "globalSaturation", {
  58880. /**
  58881. * Gets the global Saturation value.
  58882. * 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.
  58883. */
  58884. get: function () {
  58885. return this._globalSaturation;
  58886. },
  58887. /**
  58888. * Sets the global Saturation value.
  58889. * 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.
  58890. */
  58891. set: function (value) {
  58892. this._globalSaturation = value;
  58893. this._dirty = true;
  58894. },
  58895. enumerable: true,
  58896. configurable: true
  58897. });
  58898. Object.defineProperty(ColorCurves.prototype, "globalExposure", {
  58899. /**
  58900. * Gets the global Exposure value.
  58901. * 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.
  58902. */
  58903. get: function () {
  58904. return this._globalExposure;
  58905. },
  58906. /**
  58907. * Sets the global Exposure value.
  58908. * 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.
  58909. */
  58910. set: function (value) {
  58911. this._globalExposure = value;
  58912. this._dirty = true;
  58913. },
  58914. enumerable: true,
  58915. configurable: true
  58916. });
  58917. Object.defineProperty(ColorCurves.prototype, "highlightsHue", {
  58918. /**
  58919. * Gets the highlights Hue value.
  58920. * 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).
  58921. */
  58922. get: function () {
  58923. return this._highlightsHue;
  58924. },
  58925. /**
  58926. * Sets the highlights Hue value.
  58927. * 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).
  58928. */
  58929. set: function (value) {
  58930. this._highlightsHue = value;
  58931. this._dirty = true;
  58932. },
  58933. enumerable: true,
  58934. configurable: true
  58935. });
  58936. Object.defineProperty(ColorCurves.prototype, "highlightsDensity", {
  58937. /**
  58938. * Gets the highlights Density value.
  58939. * 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.
  58940. * Values less than zero provide a filter of opposite hue.
  58941. */
  58942. get: function () {
  58943. return this._highlightsDensity;
  58944. },
  58945. /**
  58946. * Sets the highlights Density value.
  58947. * 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.
  58948. * Values less than zero provide a filter of opposite hue.
  58949. */
  58950. set: function (value) {
  58951. this._highlightsDensity = value;
  58952. this._dirty = true;
  58953. },
  58954. enumerable: true,
  58955. configurable: true
  58956. });
  58957. Object.defineProperty(ColorCurves.prototype, "highlightsSaturation", {
  58958. /**
  58959. * Gets the highlights Saturation value.
  58960. * 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.
  58961. */
  58962. get: function () {
  58963. return this._highlightsSaturation;
  58964. },
  58965. /**
  58966. * Sets the highlights Saturation value.
  58967. * 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.
  58968. */
  58969. set: function (value) {
  58970. this._highlightsSaturation = value;
  58971. this._dirty = true;
  58972. },
  58973. enumerable: true,
  58974. configurable: true
  58975. });
  58976. Object.defineProperty(ColorCurves.prototype, "highlightsExposure", {
  58977. /**
  58978. * Gets the highlights Exposure value.
  58979. * 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.
  58980. */
  58981. get: function () {
  58982. return this._highlightsExposure;
  58983. },
  58984. /**
  58985. * Sets the highlights Exposure value.
  58986. * 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.
  58987. */
  58988. set: function (value) {
  58989. this._highlightsExposure = value;
  58990. this._dirty = true;
  58991. },
  58992. enumerable: true,
  58993. configurable: true
  58994. });
  58995. Object.defineProperty(ColorCurves.prototype, "midtonesHue", {
  58996. /**
  58997. * Gets the midtones Hue value.
  58998. * 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).
  58999. */
  59000. get: function () {
  59001. return this._midtonesHue;
  59002. },
  59003. /**
  59004. * Sets the midtones Hue value.
  59005. * 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).
  59006. */
  59007. set: function (value) {
  59008. this._midtonesHue = value;
  59009. this._dirty = true;
  59010. },
  59011. enumerable: true,
  59012. configurable: true
  59013. });
  59014. Object.defineProperty(ColorCurves.prototype, "midtonesDensity", {
  59015. /**
  59016. * Gets the midtones Density value.
  59017. * 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.
  59018. * Values less than zero provide a filter of opposite hue.
  59019. */
  59020. get: function () {
  59021. return this._midtonesDensity;
  59022. },
  59023. /**
  59024. * Sets the midtones Density value.
  59025. * 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.
  59026. * Values less than zero provide a filter of opposite hue.
  59027. */
  59028. set: function (value) {
  59029. this._midtonesDensity = value;
  59030. this._dirty = true;
  59031. },
  59032. enumerable: true,
  59033. configurable: true
  59034. });
  59035. Object.defineProperty(ColorCurves.prototype, "midtonesSaturation", {
  59036. /**
  59037. * Gets the midtones Saturation value.
  59038. * 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.
  59039. */
  59040. get: function () {
  59041. return this._midtonesSaturation;
  59042. },
  59043. /**
  59044. * Sets the midtones Saturation value.
  59045. * 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.
  59046. */
  59047. set: function (value) {
  59048. this._midtonesSaturation = value;
  59049. this._dirty = true;
  59050. },
  59051. enumerable: true,
  59052. configurable: true
  59053. });
  59054. Object.defineProperty(ColorCurves.prototype, "midtonesExposure", {
  59055. /**
  59056. * Gets the midtones Exposure value.
  59057. * 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.
  59058. */
  59059. get: function () {
  59060. return this._midtonesExposure;
  59061. },
  59062. /**
  59063. * Sets the midtones Exposure value.
  59064. * 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.
  59065. */
  59066. set: function (value) {
  59067. this._midtonesExposure = value;
  59068. this._dirty = true;
  59069. },
  59070. enumerable: true,
  59071. configurable: true
  59072. });
  59073. Object.defineProperty(ColorCurves.prototype, "shadowsHue", {
  59074. /**
  59075. * Gets the shadows Hue value.
  59076. * 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).
  59077. */
  59078. get: function () {
  59079. return this._shadowsHue;
  59080. },
  59081. /**
  59082. * Sets the shadows Hue value.
  59083. * 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).
  59084. */
  59085. set: function (value) {
  59086. this._shadowsHue = value;
  59087. this._dirty = true;
  59088. },
  59089. enumerable: true,
  59090. configurable: true
  59091. });
  59092. Object.defineProperty(ColorCurves.prototype, "shadowsDensity", {
  59093. /**
  59094. * Gets the shadows Density value.
  59095. * 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.
  59096. * Values less than zero provide a filter of opposite hue.
  59097. */
  59098. get: function () {
  59099. return this._shadowsDensity;
  59100. },
  59101. /**
  59102. * Sets the shadows Density value.
  59103. * 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.
  59104. * Values less than zero provide a filter of opposite hue.
  59105. */
  59106. set: function (value) {
  59107. this._shadowsDensity = value;
  59108. this._dirty = true;
  59109. },
  59110. enumerable: true,
  59111. configurable: true
  59112. });
  59113. Object.defineProperty(ColorCurves.prototype, "shadowsSaturation", {
  59114. /**
  59115. * Gets the shadows Saturation value.
  59116. * 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.
  59117. */
  59118. get: function () {
  59119. return this._shadowsSaturation;
  59120. },
  59121. /**
  59122. * Sets the shadows Saturation value.
  59123. * 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.
  59124. */
  59125. set: function (value) {
  59126. this._shadowsSaturation = value;
  59127. this._dirty = true;
  59128. },
  59129. enumerable: true,
  59130. configurable: true
  59131. });
  59132. Object.defineProperty(ColorCurves.prototype, "shadowsExposure", {
  59133. /**
  59134. * Gets the shadows Exposure value.
  59135. * 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.
  59136. */
  59137. get: function () {
  59138. return this._shadowsExposure;
  59139. },
  59140. /**
  59141. * Sets the shadows Exposure value.
  59142. * 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.
  59143. */
  59144. set: function (value) {
  59145. this._shadowsExposure = value;
  59146. this._dirty = true;
  59147. },
  59148. enumerable: true,
  59149. configurable: true
  59150. });
  59151. /**
  59152. * Returns the class name
  59153. * @returns The class name
  59154. */
  59155. ColorCurves.prototype.getClassName = function () {
  59156. return "ColorCurves";
  59157. };
  59158. /**
  59159. * Binds the color curves to the shader.
  59160. * @param colorCurves The color curve to bind
  59161. * @param effect The effect to bind to
  59162. * @param positiveUniform The positive uniform shader parameter
  59163. * @param neutralUniform The neutral uniform shader parameter
  59164. * @param negativeUniform The negative uniform shader parameter
  59165. */
  59166. ColorCurves.Bind = function (colorCurves, effect, positiveUniform, neutralUniform, negativeUniform) {
  59167. if (positiveUniform === void 0) { positiveUniform = "vCameraColorCurvePositive"; }
  59168. if (neutralUniform === void 0) { neutralUniform = "vCameraColorCurveNeutral"; }
  59169. if (negativeUniform === void 0) { negativeUniform = "vCameraColorCurveNegative"; }
  59170. if (colorCurves._dirty) {
  59171. colorCurves._dirty = false;
  59172. // Fill in global info.
  59173. colorCurves.getColorGradingDataToRef(colorCurves._globalHue, colorCurves._globalDensity, colorCurves._globalSaturation, colorCurves._globalExposure, colorCurves._globalCurve);
  59174. // Compute highlights info.
  59175. colorCurves.getColorGradingDataToRef(colorCurves._highlightsHue, colorCurves._highlightsDensity, colorCurves._highlightsSaturation, colorCurves._highlightsExposure, colorCurves._tempColor);
  59176. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._highlightsCurve);
  59177. // Compute midtones info.
  59178. colorCurves.getColorGradingDataToRef(colorCurves._midtonesHue, colorCurves._midtonesDensity, colorCurves._midtonesSaturation, colorCurves._midtonesExposure, colorCurves._tempColor);
  59179. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._midtonesCurve);
  59180. // Compute shadows info.
  59181. colorCurves.getColorGradingDataToRef(colorCurves._shadowsHue, colorCurves._shadowsDensity, colorCurves._shadowsSaturation, colorCurves._shadowsExposure, colorCurves._tempColor);
  59182. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._shadowsCurve);
  59183. // Compute deltas (neutral is midtones).
  59184. colorCurves._highlightsCurve.subtractToRef(colorCurves._midtonesCurve, colorCurves._positiveCurve);
  59185. colorCurves._midtonesCurve.subtractToRef(colorCurves._shadowsCurve, colorCurves._negativeCurve);
  59186. }
  59187. if (effect) {
  59188. effect.setFloat4(positiveUniform, colorCurves._positiveCurve.r, colorCurves._positiveCurve.g, colorCurves._positiveCurve.b, colorCurves._positiveCurve.a);
  59189. effect.setFloat4(neutralUniform, colorCurves._midtonesCurve.r, colorCurves._midtonesCurve.g, colorCurves._midtonesCurve.b, colorCurves._midtonesCurve.a);
  59190. effect.setFloat4(negativeUniform, colorCurves._negativeCurve.r, colorCurves._negativeCurve.g, colorCurves._negativeCurve.b, colorCurves._negativeCurve.a);
  59191. }
  59192. };
  59193. /**
  59194. * Prepare the list of uniforms associated with the ColorCurves effects.
  59195. * @param uniformsList The list of uniforms used in the effect
  59196. */
  59197. ColorCurves.PrepareUniforms = function (uniformsList) {
  59198. uniformsList.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative");
  59199. };
  59200. /**
  59201. * Returns color grading data based on a hue, density, saturation and exposure value.
  59202. * @param filterHue The hue of the color filter.
  59203. * @param filterDensity The density of the color filter.
  59204. * @param saturation The saturation.
  59205. * @param exposure The exposure.
  59206. * @param result The result data container.
  59207. */
  59208. ColorCurves.prototype.getColorGradingDataToRef = function (hue, density, saturation, exposure, result) {
  59209. if (hue == null) {
  59210. return;
  59211. }
  59212. hue = ColorCurves.clamp(hue, 0, 360);
  59213. density = ColorCurves.clamp(density, -100, 100);
  59214. saturation = ColorCurves.clamp(saturation, -100, 100);
  59215. exposure = ColorCurves.clamp(exposure, -100, 100);
  59216. // Remap the slider/config filter density with non-linear mapping and also scale by half
  59217. // so that the maximum filter density is only 50% control. This provides fine control
  59218. // for small values and reasonable range.
  59219. density = ColorCurves.applyColorGradingSliderNonlinear(density);
  59220. density *= 0.5;
  59221. exposure = ColorCurves.applyColorGradingSliderNonlinear(exposure);
  59222. if (density < 0) {
  59223. density *= -1;
  59224. hue = (hue + 180) % 360;
  59225. }
  59226. ColorCurves.fromHSBToRef(hue, density, 50 + 0.25 * exposure, result);
  59227. result.scaleToRef(2, result);
  59228. result.a = 1 + 0.01 * saturation;
  59229. };
  59230. /**
  59231. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  59232. * @param value The input slider value in range [-100,100].
  59233. * @returns Adjusted value.
  59234. */
  59235. ColorCurves.applyColorGradingSliderNonlinear = function (value) {
  59236. value /= 100;
  59237. var x = Math.abs(value);
  59238. x = Math.pow(x, 2);
  59239. if (value < 0) {
  59240. x *= -1;
  59241. }
  59242. x *= 100;
  59243. return x;
  59244. };
  59245. /**
  59246. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  59247. * @param hue The hue (H) input.
  59248. * @param saturation The saturation (S) input.
  59249. * @param brightness The brightness (B) input.
  59250. * @result An RGBA color represented as Vector4.
  59251. */
  59252. ColorCurves.fromHSBToRef = function (hue, saturation, brightness, result) {
  59253. var h = ColorCurves.clamp(hue, 0, 360);
  59254. var s = ColorCurves.clamp(saturation / 100, 0, 1);
  59255. var v = ColorCurves.clamp(brightness / 100, 0, 1);
  59256. if (s === 0) {
  59257. result.r = v;
  59258. result.g = v;
  59259. result.b = v;
  59260. }
  59261. else {
  59262. // sector 0 to 5
  59263. h /= 60;
  59264. var i = Math.floor(h);
  59265. // fractional part of h
  59266. var f = h - i;
  59267. var p = v * (1 - s);
  59268. var q = v * (1 - s * f);
  59269. var t = v * (1 - s * (1 - f));
  59270. switch (i) {
  59271. case 0:
  59272. result.r = v;
  59273. result.g = t;
  59274. result.b = p;
  59275. break;
  59276. case 1:
  59277. result.r = q;
  59278. result.g = v;
  59279. result.b = p;
  59280. break;
  59281. case 2:
  59282. result.r = p;
  59283. result.g = v;
  59284. result.b = t;
  59285. break;
  59286. case 3:
  59287. result.r = p;
  59288. result.g = q;
  59289. result.b = v;
  59290. break;
  59291. case 4:
  59292. result.r = t;
  59293. result.g = p;
  59294. result.b = v;
  59295. break;
  59296. default: // case 5:
  59297. result.r = v;
  59298. result.g = p;
  59299. result.b = q;
  59300. break;
  59301. }
  59302. }
  59303. result.a = 1;
  59304. };
  59305. /**
  59306. * Returns a value clamped between min and max
  59307. * @param value The value to clamp
  59308. * @param min The minimum of value
  59309. * @param max The maximum of value
  59310. * @returns The clamped value.
  59311. */
  59312. ColorCurves.clamp = function (value, min, max) {
  59313. return Math.min(Math.max(value, min), max);
  59314. };
  59315. /**
  59316. * Clones the current color curve instance.
  59317. * @return The cloned curves
  59318. */
  59319. ColorCurves.prototype.clone = function () {
  59320. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ColorCurves(); }, this);
  59321. };
  59322. /**
  59323. * Serializes the current color curve instance to a json representation.
  59324. * @return a JSON representation
  59325. */
  59326. ColorCurves.prototype.serialize = function () {
  59327. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  59328. };
  59329. /**
  59330. * Parses the color curve from a json representation.
  59331. * @param source the JSON source to parse
  59332. * @return The parsed curves
  59333. */
  59334. ColorCurves.Parse = function (source) {
  59335. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ColorCurves(); }, source, null, null);
  59336. };
  59337. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59338. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59339. ], ColorCurves.prototype, "_globalHue", void 0);
  59340. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59341. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59342. ], ColorCurves.prototype, "_globalDensity", void 0);
  59343. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59344. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59345. ], ColorCurves.prototype, "_globalSaturation", void 0);
  59346. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59347. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59348. ], ColorCurves.prototype, "_globalExposure", void 0);
  59349. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59350. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59351. ], ColorCurves.prototype, "_highlightsHue", void 0);
  59352. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59353. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59354. ], ColorCurves.prototype, "_highlightsDensity", void 0);
  59355. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59356. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59357. ], ColorCurves.prototype, "_highlightsSaturation", void 0);
  59358. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59359. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59360. ], ColorCurves.prototype, "_highlightsExposure", void 0);
  59361. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59362. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59363. ], ColorCurves.prototype, "_midtonesHue", void 0);
  59364. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59365. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59366. ], ColorCurves.prototype, "_midtonesDensity", void 0);
  59367. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59368. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59369. ], ColorCurves.prototype, "_midtonesSaturation", void 0);
  59370. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59371. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59372. ], ColorCurves.prototype, "_midtonesExposure", void 0);
  59373. return ColorCurves;
  59374. }());
  59375. // References the dependencies.
  59376. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ColorCurvesParser = ColorCurves.Parse;
  59377. /***/ }),
  59378. /***/ "./Materials/effect.ts":
  59379. /*!*****************************!*\
  59380. !*** ./Materials/effect.ts ***!
  59381. \*****************************/
  59382. /*! exports provided: EffectFallbacks, EffectCreationOptions, Effect */
  59383. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59384. "use strict";
  59385. __webpack_require__.r(__webpack_exports__);
  59386. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return EffectFallbacks; });
  59387. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return EffectCreationOptions; });
  59388. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return Effect; });
  59389. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  59390. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  59391. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  59392. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  59393. /**
  59394. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  59395. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  59396. */
  59397. var EffectFallbacks = /** @class */ (function () {
  59398. function EffectFallbacks() {
  59399. this._defines = {};
  59400. this._currentRank = 32;
  59401. this._maxRank = -1;
  59402. }
  59403. /**
  59404. * Removes the fallback from the bound mesh.
  59405. */
  59406. EffectFallbacks.prototype.unBindMesh = function () {
  59407. this._mesh = null;
  59408. };
  59409. /**
  59410. * Adds a fallback on the specified property.
  59411. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  59412. * @param define The name of the define in the shader
  59413. */
  59414. EffectFallbacks.prototype.addFallback = function (rank, define) {
  59415. if (!this._defines[rank]) {
  59416. if (rank < this._currentRank) {
  59417. this._currentRank = rank;
  59418. }
  59419. if (rank > this._maxRank) {
  59420. this._maxRank = rank;
  59421. }
  59422. this._defines[rank] = new Array();
  59423. }
  59424. this._defines[rank].push(define);
  59425. };
  59426. /**
  59427. * Sets the mesh to use CPU skinning when needing to fallback.
  59428. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  59429. * @param mesh The mesh to use the fallbacks.
  59430. */
  59431. EffectFallbacks.prototype.addCPUSkinningFallback = function (rank, mesh) {
  59432. this._mesh = mesh;
  59433. if (rank < this._currentRank) {
  59434. this._currentRank = rank;
  59435. }
  59436. if (rank > this._maxRank) {
  59437. this._maxRank = rank;
  59438. }
  59439. };
  59440. Object.defineProperty(EffectFallbacks.prototype, "isMoreFallbacks", {
  59441. /**
  59442. * Checks to see if more fallbacks are still availible.
  59443. */
  59444. get: function () {
  59445. return this._currentRank <= this._maxRank;
  59446. },
  59447. enumerable: true,
  59448. configurable: true
  59449. });
  59450. /**
  59451. * Removes the defines that shoould be removed when falling back.
  59452. * @param currentDefines defines the current define statements for the shader.
  59453. * @param effect defines the current effect we try to compile
  59454. * @returns The resulting defines with defines of the current rank removed.
  59455. */
  59456. EffectFallbacks.prototype.reduce = function (currentDefines, effect) {
  59457. // First we try to switch to CPU skinning
  59458. if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0 && this._mesh.material) {
  59459. this._mesh.computeBonesUsingShaders = false;
  59460. currentDefines = currentDefines.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0");
  59461. effect._bonesComputationForcedToCPU = true;
  59462. var scene = this._mesh.getScene();
  59463. for (var index = 0; index < scene.meshes.length; index++) {
  59464. var otherMesh = scene.meshes[index];
  59465. if (!otherMesh.material) {
  59466. continue;
  59467. }
  59468. if (!otherMesh.computeBonesUsingShaders || otherMesh.numBoneInfluencers === 0) {
  59469. continue;
  59470. }
  59471. if (otherMesh.material.getEffect() === effect) {
  59472. otherMesh.computeBonesUsingShaders = false;
  59473. }
  59474. else if (otherMesh.subMeshes) {
  59475. for (var _i = 0, _a = otherMesh.subMeshes; _i < _a.length; _i++) {
  59476. var subMesh = _a[_i];
  59477. var subMeshEffect = subMesh.effect;
  59478. if (subMeshEffect === effect) {
  59479. otherMesh.computeBonesUsingShaders = false;
  59480. break;
  59481. }
  59482. }
  59483. }
  59484. }
  59485. }
  59486. else {
  59487. var currentFallbacks = this._defines[this._currentRank];
  59488. if (currentFallbacks) {
  59489. for (var index = 0; index < currentFallbacks.length; index++) {
  59490. currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
  59491. }
  59492. }
  59493. this._currentRank++;
  59494. }
  59495. return currentDefines;
  59496. };
  59497. return EffectFallbacks;
  59498. }());
  59499. /**
  59500. * Options to be used when creating an effect.
  59501. */
  59502. var EffectCreationOptions = /** @class */ (function () {
  59503. function EffectCreationOptions() {
  59504. }
  59505. return EffectCreationOptions;
  59506. }());
  59507. /**
  59508. * Effect containing vertex and fragment shader that can be executed on an object.
  59509. */
  59510. var Effect = /** @class */ (function () {
  59511. /**
  59512. * Instantiates an effect.
  59513. * An effect can be used to create/manage/execute vertex and fragment shaders.
  59514. * @param baseName Name of the effect.
  59515. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  59516. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  59517. * @param samplers List of sampler variables that will be passed to the shader.
  59518. * @param engine Engine to be used to render the effect
  59519. * @param defines Define statements to be added to the shader.
  59520. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  59521. * @param onCompiled Callback that will be called when the shader is compiled.
  59522. * @param onError Callback that will be called if an error occurs during shader compilation.
  59523. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  59524. */
  59525. function Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, engine, defines, fallbacks, onCompiled, onError, indexParameters) {
  59526. if (samplers === void 0) { samplers = null; }
  59527. if (defines === void 0) { defines = null; }
  59528. if (fallbacks === void 0) { fallbacks = null; }
  59529. if (onCompiled === void 0) { onCompiled = null; }
  59530. if (onError === void 0) { onError = null; }
  59531. var _this = this;
  59532. /**
  59533. * Unique ID of the effect.
  59534. */
  59535. this.uniqueId = 0;
  59536. /**
  59537. * Observable that will be called when the shader is compiled.
  59538. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  59539. */
  59540. this.onCompileObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  59541. /**
  59542. * Observable that will be called if an error occurs during shader compilation.
  59543. */
  59544. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  59545. /** @hidden */
  59546. this._bonesComputationForcedToCPU = false;
  59547. this._uniformBuffersNames = {};
  59548. this._isReady = false;
  59549. this._compilationError = "";
  59550. this.name = baseName;
  59551. if (attributesNamesOrOptions.attributes) {
  59552. var options = attributesNamesOrOptions;
  59553. this._engine = uniformsNamesOrEngine;
  59554. this._attributesNames = options.attributes;
  59555. this._uniformsNames = options.uniformsNames.concat(options.samplers);
  59556. this._samplers = options.samplers.slice();
  59557. this.defines = options.defines;
  59558. this.onError = options.onError;
  59559. this.onCompiled = options.onCompiled;
  59560. this._fallbacks = options.fallbacks;
  59561. this._indexParameters = options.indexParameters;
  59562. this._transformFeedbackVaryings = options.transformFeedbackVaryings;
  59563. if (options.uniformBuffersNames) {
  59564. for (var i = 0; i < options.uniformBuffersNames.length; i++) {
  59565. this._uniformBuffersNames[options.uniformBuffersNames[i]] = i;
  59566. }
  59567. }
  59568. }
  59569. else {
  59570. this._engine = engine;
  59571. this.defines = defines;
  59572. this._uniformsNames = uniformsNamesOrEngine.concat(samplers);
  59573. this._samplers = samplers ? samplers.slice() : [];
  59574. this._attributesNames = attributesNamesOrOptions;
  59575. this.onError = onError;
  59576. this.onCompiled = onCompiled;
  59577. this._indexParameters = indexParameters;
  59578. this._fallbacks = fallbacks;
  59579. }
  59580. this.uniqueId = Effect._uniqueIdSeed++;
  59581. var vertexSource;
  59582. var fragmentSource;
  59583. if (baseName.vertexElement) {
  59584. vertexSource = document.getElementById(baseName.vertexElement);
  59585. if (!vertexSource) {
  59586. vertexSource = baseName.vertexElement;
  59587. }
  59588. }
  59589. else {
  59590. vertexSource = baseName.vertex || baseName;
  59591. }
  59592. if (baseName.fragmentElement) {
  59593. fragmentSource = document.getElementById(baseName.fragmentElement);
  59594. if (!fragmentSource) {
  59595. fragmentSource = baseName.fragmentElement;
  59596. }
  59597. }
  59598. else {
  59599. fragmentSource = baseName.fragment || baseName;
  59600. }
  59601. this._loadVertexShader(vertexSource, function (vertexCode) {
  59602. _this._processIncludes(vertexCode, function (vertexCodeWithIncludes) {
  59603. _this._processShaderConversion(vertexCodeWithIncludes, false, function (migratedVertexCode) {
  59604. _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
  59605. _this._processIncludes(fragmentCode, function (fragmentCodeWithIncludes) {
  59606. _this._processShaderConversion(fragmentCodeWithIncludes, true, function (migratedFragmentCode) {
  59607. if (baseName) {
  59608. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  59609. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  59610. _this._vertexSourceCode = "#define SHADER_NAME vertex:" + vertex + "\n" + migratedVertexCode;
  59611. _this._fragmentSourceCode = "#define SHADER_NAME fragment:" + fragment + "\n" + migratedFragmentCode;
  59612. }
  59613. else {
  59614. _this._vertexSourceCode = migratedVertexCode;
  59615. _this._fragmentSourceCode = migratedFragmentCode;
  59616. }
  59617. _this._prepareEffect();
  59618. });
  59619. });
  59620. });
  59621. });
  59622. });
  59623. });
  59624. }
  59625. Object.defineProperty(Effect.prototype, "onBindObservable", {
  59626. /**
  59627. * Observable that will be called when effect is bound.
  59628. */
  59629. get: function () {
  59630. if (!this._onBindObservable) {
  59631. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  59632. }
  59633. return this._onBindObservable;
  59634. },
  59635. enumerable: true,
  59636. configurable: true
  59637. });
  59638. Object.defineProperty(Effect.prototype, "key", {
  59639. /**
  59640. * Unique key for this effect
  59641. */
  59642. get: function () {
  59643. return this._key;
  59644. },
  59645. enumerable: true,
  59646. configurable: true
  59647. });
  59648. /**
  59649. * If the effect has been compiled and prepared.
  59650. * @returns if the effect is compiled and prepared.
  59651. */
  59652. Effect.prototype.isReady = function () {
  59653. if (!this._isReady && this._program && this._program.isParallelCompiled) {
  59654. return this._engine._isProgramCompiled(this._program);
  59655. }
  59656. return this._isReady;
  59657. };
  59658. /**
  59659. * The engine the effect was initialized with.
  59660. * @returns the engine.
  59661. */
  59662. Effect.prototype.getEngine = function () {
  59663. return this._engine;
  59664. };
  59665. /**
  59666. * The compiled webGL program for the effect
  59667. * @returns the webGL program.
  59668. */
  59669. Effect.prototype.getProgram = function () {
  59670. return this._program;
  59671. };
  59672. /**
  59673. * The set of names of attribute variables for the shader.
  59674. * @returns An array of attribute names.
  59675. */
  59676. Effect.prototype.getAttributesNames = function () {
  59677. return this._attributesNames;
  59678. };
  59679. /**
  59680. * Returns the attribute at the given index.
  59681. * @param index The index of the attribute.
  59682. * @returns The location of the attribute.
  59683. */
  59684. Effect.prototype.getAttributeLocation = function (index) {
  59685. return this._attributes[index];
  59686. };
  59687. /**
  59688. * Returns the attribute based on the name of the variable.
  59689. * @param name of the attribute to look up.
  59690. * @returns the attribute location.
  59691. */
  59692. Effect.prototype.getAttributeLocationByName = function (name) {
  59693. var index = this._attributesNames.indexOf(name);
  59694. return this._attributes[index];
  59695. };
  59696. /**
  59697. * The number of attributes.
  59698. * @returns the numnber of attributes.
  59699. */
  59700. Effect.prototype.getAttributesCount = function () {
  59701. return this._attributes.length;
  59702. };
  59703. /**
  59704. * Gets the index of a uniform variable.
  59705. * @param uniformName of the uniform to look up.
  59706. * @returns the index.
  59707. */
  59708. Effect.prototype.getUniformIndex = function (uniformName) {
  59709. return this._uniformsNames.indexOf(uniformName);
  59710. };
  59711. /**
  59712. * Returns the attribute based on the name of the variable.
  59713. * @param uniformName of the uniform to look up.
  59714. * @returns the location of the uniform.
  59715. */
  59716. Effect.prototype.getUniform = function (uniformName) {
  59717. return this._uniforms[this._uniformsNames.indexOf(uniformName)];
  59718. };
  59719. /**
  59720. * Returns an array of sampler variable names
  59721. * @returns The array of sampler variable neames.
  59722. */
  59723. Effect.prototype.getSamplers = function () {
  59724. return this._samplers;
  59725. };
  59726. /**
  59727. * The error from the last compilation.
  59728. * @returns the error string.
  59729. */
  59730. Effect.prototype.getCompilationError = function () {
  59731. return this._compilationError;
  59732. };
  59733. /**
  59734. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  59735. * @param func The callback to be used.
  59736. */
  59737. Effect.prototype.executeWhenCompiled = function (func) {
  59738. var _this = this;
  59739. if (this.isReady()) {
  59740. func(this);
  59741. return;
  59742. }
  59743. this.onCompileObservable.add(function (effect) {
  59744. func(effect);
  59745. });
  59746. if (!this._program || this._program.isParallelCompiled) {
  59747. setTimeout(function () {
  59748. _this._checkIsReady();
  59749. }, 16);
  59750. }
  59751. };
  59752. Effect.prototype._checkIsReady = function () {
  59753. var _this = this;
  59754. if (this.isReady()) {
  59755. return;
  59756. }
  59757. setTimeout(function () {
  59758. _this._checkIsReady();
  59759. }, 16);
  59760. };
  59761. /** @hidden */
  59762. Effect.prototype._loadVertexShader = function (vertex, callback) {
  59763. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  59764. // DOM element ?
  59765. if (vertex instanceof HTMLElement) {
  59766. var vertexCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(vertex);
  59767. callback(vertexCode);
  59768. return;
  59769. }
  59770. }
  59771. // Base64 encoded ?
  59772. if (vertex.substr(0, 7) === "base64:") {
  59773. var vertexBinary = window.atob(vertex.substr(7));
  59774. callback(vertexBinary);
  59775. return;
  59776. }
  59777. // Is in local store ?
  59778. if (Effect.ShadersStore[vertex + "VertexShader"]) {
  59779. callback(Effect.ShadersStore[vertex + "VertexShader"]);
  59780. return;
  59781. }
  59782. var vertexShaderUrl;
  59783. if (vertex[0] === "." || vertex[0] === "/" || vertex.indexOf("http") > -1) {
  59784. vertexShaderUrl = vertex;
  59785. }
  59786. else {
  59787. vertexShaderUrl = Effect.ShadersRepository + vertex;
  59788. }
  59789. // Vertex shader
  59790. this._engine._loadFile(vertexShaderUrl + ".vertex.fx", callback);
  59791. };
  59792. /** @hidden */
  59793. Effect.prototype._loadFragmentShader = function (fragment, callback) {
  59794. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  59795. // DOM element ?
  59796. if (fragment instanceof HTMLElement) {
  59797. var fragmentCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(fragment);
  59798. callback(fragmentCode);
  59799. return;
  59800. }
  59801. }
  59802. // Base64 encoded ?
  59803. if (fragment.substr(0, 7) === "base64:") {
  59804. var fragmentBinary = window.atob(fragment.substr(7));
  59805. callback(fragmentBinary);
  59806. return;
  59807. }
  59808. // Is in local store ?
  59809. if (Effect.ShadersStore[fragment + "PixelShader"]) {
  59810. callback(Effect.ShadersStore[fragment + "PixelShader"]);
  59811. return;
  59812. }
  59813. if (Effect.ShadersStore[fragment + "FragmentShader"]) {
  59814. callback(Effect.ShadersStore[fragment + "FragmentShader"]);
  59815. return;
  59816. }
  59817. var fragmentShaderUrl;
  59818. if (fragment[0] === "." || fragment[0] === "/" || fragment.indexOf("http") > -1) {
  59819. fragmentShaderUrl = fragment;
  59820. }
  59821. else {
  59822. fragmentShaderUrl = Effect.ShadersRepository + fragment;
  59823. }
  59824. // Fragment shader
  59825. this._engine._loadFile(fragmentShaderUrl + ".fragment.fx", callback);
  59826. };
  59827. /** @hidden */
  59828. Effect.prototype._dumpShadersSource = function (vertexCode, fragmentCode, defines) {
  59829. // Rebuild shaders source code
  59830. var shaderVersion = (this._engine.webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  59831. var prefix = shaderVersion + (defines ? defines + "\n" : "");
  59832. vertexCode = prefix + vertexCode;
  59833. fragmentCode = prefix + fragmentCode;
  59834. // Number lines of shaders source code
  59835. var i = 2;
  59836. var regex = /\n/gm;
  59837. var formattedVertexCode = "\n1\t" + vertexCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  59838. i = 2;
  59839. var formattedFragmentCode = "\n1\t" + fragmentCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  59840. // Dump shaders name and formatted source code
  59841. if (this.name.vertexElement) {
  59842. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertexElement + formattedVertexCode);
  59843. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragmentElement + formattedFragmentCode);
  59844. }
  59845. else if (this.name.vertex) {
  59846. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertex + formattedVertexCode);
  59847. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragment + formattedFragmentCode);
  59848. }
  59849. else {
  59850. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name + formattedVertexCode);
  59851. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name + formattedFragmentCode);
  59852. }
  59853. };
  59854. Effect.prototype._processShaderConversion = function (sourceCode, isFragment, callback) {
  59855. var preparedSourceCode = this._processPrecision(sourceCode);
  59856. if (this._engine.webGLVersion == 1) {
  59857. callback(preparedSourceCode);
  59858. return;
  59859. }
  59860. // Already converted
  59861. if (preparedSourceCode.indexOf("#version 3") !== -1) {
  59862. callback(preparedSourceCode.replace("#version 300 es", ""));
  59863. return;
  59864. }
  59865. var hasDrawBuffersExtension = preparedSourceCode.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;
  59866. // Remove extensions
  59867. // #extension GL_OES_standard_derivatives : enable
  59868. // #extension GL_EXT_shader_texture_lod : enable
  59869. // #extension GL_EXT_frag_depth : enable
  59870. // #extension GL_EXT_draw_buffers : require
  59871. var regex = /#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
  59872. var result = preparedSourceCode.replace(regex, "");
  59873. // Migrate to GLSL v300
  59874. result = result.replace(/varying(?![\n\r])\s/g, isFragment ? "in " : "out ");
  59875. result = result.replace(/attribute[ \t]/g, "in ");
  59876. result = result.replace(/[ \t]attribute/g, " in");
  59877. result = result.replace(/texture2D\s*\(/g, "texture(");
  59878. if (isFragment) {
  59879. result = result.replace(/texture2DLodEXT\s*\(/g, "textureLod(");
  59880. result = result.replace(/textureCubeLodEXT\s*\(/g, "textureLod(");
  59881. result = result.replace(/textureCube\s*\(/g, "texture(");
  59882. result = result.replace(/gl_FragDepthEXT/g, "gl_FragDepth");
  59883. result = result.replace(/gl_FragColor/g, "glFragColor");
  59884. result = result.replace(/gl_FragData/g, "glFragData");
  59885. result = result.replace(/void\s+?main\s*\(/g, (hasDrawBuffersExtension ? "" : "out vec4 glFragColor;\n") + "void main(");
  59886. }
  59887. callback(result);
  59888. };
  59889. Effect.prototype._processIncludes = function (sourceCode, callback) {
  59890. var _this = this;
  59891. var regex = /#include<(.+)>(\((.*)\))*(\[(.*)\])*/g;
  59892. var match = regex.exec(sourceCode);
  59893. var returnValue = new String(sourceCode);
  59894. while (match != null) {
  59895. var includeFile = match[1];
  59896. // Uniform declaration
  59897. if (includeFile.indexOf("__decl__") !== -1) {
  59898. includeFile = includeFile.replace(/__decl__/, "");
  59899. if (this._engine.supportsUniformBuffers) {
  59900. includeFile = includeFile.replace(/Vertex/, "Ubo");
  59901. includeFile = includeFile.replace(/Fragment/, "Ubo");
  59902. }
  59903. includeFile = includeFile + "Declaration";
  59904. }
  59905. if (Effect.IncludesShadersStore[includeFile]) {
  59906. // Substitution
  59907. var includeContent = Effect.IncludesShadersStore[includeFile];
  59908. if (match[2]) {
  59909. var splits = match[3].split(",");
  59910. for (var index = 0; index < splits.length; index += 2) {
  59911. var source = new RegExp(splits[index], "g");
  59912. var dest = splits[index + 1];
  59913. includeContent = includeContent.replace(source, dest);
  59914. }
  59915. }
  59916. if (match[4]) {
  59917. var indexString = match[5];
  59918. if (indexString.indexOf("..") !== -1) {
  59919. var indexSplits = indexString.split("..");
  59920. var minIndex = parseInt(indexSplits[0]);
  59921. var maxIndex = parseInt(indexSplits[1]);
  59922. var sourceIncludeContent = includeContent.slice(0);
  59923. includeContent = "";
  59924. if (isNaN(maxIndex)) {
  59925. maxIndex = this._indexParameters[indexSplits[1]];
  59926. }
  59927. for (var i = minIndex; i < maxIndex; i++) {
  59928. if (!this._engine.supportsUniformBuffers) {
  59929. // Ubo replacement
  59930. sourceIncludeContent = sourceIncludeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  59931. return p1 + "{X}";
  59932. });
  59933. }
  59934. includeContent += sourceIncludeContent.replace(/\{X\}/g, i.toString()) + "\n";
  59935. }
  59936. }
  59937. else {
  59938. if (!this._engine.supportsUniformBuffers) {
  59939. // Ubo replacement
  59940. includeContent = includeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  59941. return p1 + "{X}";
  59942. });
  59943. }
  59944. includeContent = includeContent.replace(/\{X\}/g, indexString);
  59945. }
  59946. }
  59947. // Replace
  59948. returnValue = returnValue.replace(match[0], includeContent);
  59949. }
  59950. else {
  59951. var includeShaderUrl = Effect.ShadersRepository + "ShadersInclude/" + includeFile + ".fx";
  59952. this._engine._loadFile(includeShaderUrl, function (fileContent) {
  59953. Effect.IncludesShadersStore[includeFile] = fileContent;
  59954. _this._processIncludes(returnValue, callback);
  59955. });
  59956. return;
  59957. }
  59958. match = regex.exec(sourceCode);
  59959. }
  59960. callback(returnValue);
  59961. };
  59962. Effect.prototype._processPrecision = function (source) {
  59963. if (source.indexOf("precision highp float") === -1) {
  59964. if (!this._engine.getCaps().highPrecisionShaderSupported) {
  59965. source = "precision mediump float;\n" + source;
  59966. }
  59967. else {
  59968. source = "precision highp float;\n" + source;
  59969. }
  59970. }
  59971. else {
  59972. if (!this._engine.getCaps().highPrecisionShaderSupported) { // Moving highp to mediump
  59973. source = source.replace("precision highp float", "precision mediump float");
  59974. }
  59975. }
  59976. return source;
  59977. };
  59978. /**
  59979. * Recompiles the webGL program
  59980. * @param vertexSourceCode The source code for the vertex shader.
  59981. * @param fragmentSourceCode The source code for the fragment shader.
  59982. * @param onCompiled Callback called when completed.
  59983. * @param onError Callback called on error.
  59984. * @hidden
  59985. */
  59986. Effect.prototype._rebuildProgram = function (vertexSourceCode, fragmentSourceCode, onCompiled, onError) {
  59987. var _this = this;
  59988. this._isReady = false;
  59989. this._vertexSourceCodeOverride = vertexSourceCode;
  59990. this._fragmentSourceCodeOverride = fragmentSourceCode;
  59991. this.onError = function (effect, error) {
  59992. if (onError) {
  59993. onError(error);
  59994. }
  59995. };
  59996. this.onCompiled = function () {
  59997. var scenes = _this.getEngine().scenes;
  59998. for (var i = 0; i < scenes.length; i++) {
  59999. scenes[i].markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  60000. }
  60001. if (onCompiled) {
  60002. onCompiled(_this._program);
  60003. }
  60004. };
  60005. this._fallbacks = null;
  60006. this._prepareEffect();
  60007. };
  60008. /**
  60009. * Gets the uniform locations of the the specified variable names
  60010. * @param names THe names of the variables to lookup.
  60011. * @returns Array of locations in the same order as variable names.
  60012. */
  60013. Effect.prototype.getSpecificUniformLocations = function (names) {
  60014. var engine = this._engine;
  60015. return engine.getUniforms(this._program, names);
  60016. };
  60017. /**
  60018. * Prepares the effect
  60019. * @hidden
  60020. */
  60021. Effect.prototype._prepareEffect = function () {
  60022. var _this = this;
  60023. var attributesNames = this._attributesNames;
  60024. var defines = this.defines;
  60025. var fallbacks = this._fallbacks;
  60026. this._valueCache = {};
  60027. var previousProgram = this._program;
  60028. try {
  60029. var engine_1 = this._engine;
  60030. if (this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride) {
  60031. this._program = engine_1.createRawShaderProgram(this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, undefined, this._transformFeedbackVaryings);
  60032. }
  60033. else {
  60034. this._program = engine_1.createShaderProgram(this._vertexSourceCode, this._fragmentSourceCode, defines, undefined, this._transformFeedbackVaryings);
  60035. }
  60036. this._program.__SPECTOR_rebuildProgram = this._rebuildProgram.bind(this);
  60037. engine_1._executeWhenProgramIsCompiled(this._program, function () {
  60038. if (engine_1.supportsUniformBuffers) {
  60039. for (var name in _this._uniformBuffersNames) {
  60040. _this.bindUniformBlock(name, _this._uniformBuffersNames[name]);
  60041. }
  60042. }
  60043. _this._uniforms = engine_1.getUniforms(_this._program, _this._uniformsNames);
  60044. _this._attributes = engine_1.getAttributes(_this._program, attributesNames);
  60045. var index;
  60046. for (index = 0; index < _this._samplers.length; index++) {
  60047. var sampler = _this.getUniform(_this._samplers[index]);
  60048. if (sampler == null) {
  60049. _this._samplers.splice(index, 1);
  60050. index--;
  60051. }
  60052. }
  60053. engine_1.bindSamplers(_this);
  60054. _this._compilationError = "";
  60055. _this._isReady = true;
  60056. if (_this.onCompiled) {
  60057. _this.onCompiled(_this);
  60058. }
  60059. _this.onCompileObservable.notifyObservers(_this);
  60060. _this.onCompileObservable.clear();
  60061. // Unbind mesh reference in fallbacks
  60062. if (_this._fallbacks) {
  60063. _this._fallbacks.unBindMesh();
  60064. }
  60065. if (previousProgram) {
  60066. _this.getEngine()._deleteProgram(previousProgram);
  60067. }
  60068. });
  60069. if (this._program.isParallelCompiled) {
  60070. this._checkIsReady();
  60071. }
  60072. }
  60073. catch (e) {
  60074. this._compilationError = e.message;
  60075. // Let's go through fallbacks then
  60076. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Unable to compile effect:");
  60077. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Uniforms: " + this._uniformsNames.map(function (uniform) {
  60078. return " " + uniform;
  60079. }));
  60080. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Attributes: " + attributesNames.map(function (attribute) {
  60081. return " " + attribute;
  60082. }));
  60083. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Error: " + this._compilationError);
  60084. if (previousProgram) {
  60085. this._program = previousProgram;
  60086. this._isReady = true;
  60087. if (this.onError) {
  60088. this.onError(this, this._compilationError);
  60089. }
  60090. this.onErrorObservable.notifyObservers(this);
  60091. }
  60092. if (fallbacks && fallbacks.isMoreFallbacks) {
  60093. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Trying next fallback.");
  60094. this.defines = fallbacks.reduce(this.defines, this);
  60095. this._prepareEffect();
  60096. }
  60097. else { // Sorry we did everything we can
  60098. if (this.onError) {
  60099. this.onError(this, this._compilationError);
  60100. }
  60101. this.onErrorObservable.notifyObservers(this);
  60102. this.onErrorObservable.clear();
  60103. // Unbind mesh reference in fallbacks
  60104. if (this._fallbacks) {
  60105. this._fallbacks.unBindMesh();
  60106. }
  60107. }
  60108. }
  60109. };
  60110. Object.defineProperty(Effect.prototype, "isSupported", {
  60111. /**
  60112. * Checks if the effect is supported. (Must be called after compilation)
  60113. */
  60114. get: function () {
  60115. return this._compilationError === "";
  60116. },
  60117. enumerable: true,
  60118. configurable: true
  60119. });
  60120. /**
  60121. * Binds a texture to the engine to be used as output of the shader.
  60122. * @param channel Name of the output variable.
  60123. * @param texture Texture to bind.
  60124. * @hidden
  60125. */
  60126. Effect.prototype._bindTexture = function (channel, texture) {
  60127. this._engine._bindTexture(this._samplers.indexOf(channel), texture);
  60128. };
  60129. /**
  60130. * Sets a texture on the engine to be used in the shader.
  60131. * @param channel Name of the sampler variable.
  60132. * @param texture Texture to set.
  60133. */
  60134. Effect.prototype.setTexture = function (channel, texture) {
  60135. this._engine.setTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  60136. };
  60137. /**
  60138. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  60139. * @param channel Name of the sampler variable.
  60140. * @param texture Texture to set.
  60141. */
  60142. Effect.prototype.setDepthStencilTexture = function (channel, texture) {
  60143. this._engine.setDepthStencilTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  60144. };
  60145. /**
  60146. * Sets an array of textures on the engine to be used in the shader.
  60147. * @param channel Name of the variable.
  60148. * @param textures Textures to set.
  60149. */
  60150. Effect.prototype.setTextureArray = function (channel, textures) {
  60151. if (this._samplers.indexOf(channel + "Ex") === -1) {
  60152. var initialPos = this._samplers.indexOf(channel);
  60153. for (var index = 1; index < textures.length; index++) {
  60154. this._samplers.splice(initialPos + index, 0, channel + "Ex");
  60155. }
  60156. }
  60157. this._engine.setTextureArray(this._samplers.indexOf(channel), this.getUniform(channel), textures);
  60158. };
  60159. /**
  60160. * 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)
  60161. * @param channel Name of the sampler variable.
  60162. * @param postProcess Post process to get the input texture from.
  60163. */
  60164. Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  60165. this._engine.setTextureFromPostProcess(this._samplers.indexOf(channel), postProcess);
  60166. };
  60167. /**
  60168. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  60169. * 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)
  60170. * @param channel Name of the sampler variable.
  60171. * @param postProcess Post process to get the output texture from.
  60172. */
  60173. Effect.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  60174. this._engine.setTextureFromPostProcessOutput(this._samplers.indexOf(channel), postProcess);
  60175. };
  60176. /** @hidden */
  60177. Effect.prototype._cacheMatrix = function (uniformName, matrix) {
  60178. var cache = this._valueCache[uniformName];
  60179. var flag = matrix.updateFlag;
  60180. if (cache !== undefined && cache === flag) {
  60181. return false;
  60182. }
  60183. this._valueCache[uniformName] = flag;
  60184. return true;
  60185. };
  60186. /** @hidden */
  60187. Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
  60188. var cache = this._valueCache[uniformName];
  60189. if (!cache) {
  60190. cache = [x, y];
  60191. this._valueCache[uniformName] = cache;
  60192. return true;
  60193. }
  60194. var changed = false;
  60195. if (cache[0] !== x) {
  60196. cache[0] = x;
  60197. changed = true;
  60198. }
  60199. if (cache[1] !== y) {
  60200. cache[1] = y;
  60201. changed = true;
  60202. }
  60203. return changed;
  60204. };
  60205. /** @hidden */
  60206. Effect.prototype._cacheFloat3 = function (uniformName, x, y, z) {
  60207. var cache = this._valueCache[uniformName];
  60208. if (!cache) {
  60209. cache = [x, y, z];
  60210. this._valueCache[uniformName] = cache;
  60211. return true;
  60212. }
  60213. var changed = false;
  60214. if (cache[0] !== x) {
  60215. cache[0] = x;
  60216. changed = true;
  60217. }
  60218. if (cache[1] !== y) {
  60219. cache[1] = y;
  60220. changed = true;
  60221. }
  60222. if (cache[2] !== z) {
  60223. cache[2] = z;
  60224. changed = true;
  60225. }
  60226. return changed;
  60227. };
  60228. /** @hidden */
  60229. Effect.prototype._cacheFloat4 = function (uniformName, x, y, z, w) {
  60230. var cache = this._valueCache[uniformName];
  60231. if (!cache) {
  60232. cache = [x, y, z, w];
  60233. this._valueCache[uniformName] = cache;
  60234. return true;
  60235. }
  60236. var changed = false;
  60237. if (cache[0] !== x) {
  60238. cache[0] = x;
  60239. changed = true;
  60240. }
  60241. if (cache[1] !== y) {
  60242. cache[1] = y;
  60243. changed = true;
  60244. }
  60245. if (cache[2] !== z) {
  60246. cache[2] = z;
  60247. changed = true;
  60248. }
  60249. if (cache[3] !== w) {
  60250. cache[3] = w;
  60251. changed = true;
  60252. }
  60253. return changed;
  60254. };
  60255. /**
  60256. * Binds a buffer to a uniform.
  60257. * @param buffer Buffer to bind.
  60258. * @param name Name of the uniform variable to bind to.
  60259. */
  60260. Effect.prototype.bindUniformBuffer = function (buffer, name) {
  60261. var bufferName = this._uniformBuffersNames[name];
  60262. if (bufferName === undefined || Effect._baseCache[bufferName] === buffer) {
  60263. return;
  60264. }
  60265. Effect._baseCache[bufferName] = buffer;
  60266. this._engine.bindUniformBufferBase(buffer, bufferName);
  60267. };
  60268. /**
  60269. * Binds block to a uniform.
  60270. * @param blockName Name of the block to bind.
  60271. * @param index Index to bind.
  60272. */
  60273. Effect.prototype.bindUniformBlock = function (blockName, index) {
  60274. this._engine.bindUniformBlock(this._program, blockName, index);
  60275. };
  60276. /**
  60277. * Sets an interger value on a uniform variable.
  60278. * @param uniformName Name of the variable.
  60279. * @param value Value to be set.
  60280. * @returns this effect.
  60281. */
  60282. Effect.prototype.setInt = function (uniformName, value) {
  60283. var cache = this._valueCache[uniformName];
  60284. if (cache !== undefined && cache === value) {
  60285. return this;
  60286. }
  60287. this._valueCache[uniformName] = value;
  60288. this._engine.setInt(this.getUniform(uniformName), value);
  60289. return this;
  60290. };
  60291. /**
  60292. * Sets an int array on a uniform variable.
  60293. * @param uniformName Name of the variable.
  60294. * @param array array to be set.
  60295. * @returns this effect.
  60296. */
  60297. Effect.prototype.setIntArray = function (uniformName, array) {
  60298. this._valueCache[uniformName] = null;
  60299. this._engine.setIntArray(this.getUniform(uniformName), array);
  60300. return this;
  60301. };
  60302. /**
  60303. * 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)
  60304. * @param uniformName Name of the variable.
  60305. * @param array array to be set.
  60306. * @returns this effect.
  60307. */
  60308. Effect.prototype.setIntArray2 = function (uniformName, array) {
  60309. this._valueCache[uniformName] = null;
  60310. this._engine.setIntArray2(this.getUniform(uniformName), array);
  60311. return this;
  60312. };
  60313. /**
  60314. * 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)
  60315. * @param uniformName Name of the variable.
  60316. * @param array array to be set.
  60317. * @returns this effect.
  60318. */
  60319. Effect.prototype.setIntArray3 = function (uniformName, array) {
  60320. this._valueCache[uniformName] = null;
  60321. this._engine.setIntArray3(this.getUniform(uniformName), array);
  60322. return this;
  60323. };
  60324. /**
  60325. * 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)
  60326. * @param uniformName Name of the variable.
  60327. * @param array array to be set.
  60328. * @returns this effect.
  60329. */
  60330. Effect.prototype.setIntArray4 = function (uniformName, array) {
  60331. this._valueCache[uniformName] = null;
  60332. this._engine.setIntArray4(this.getUniform(uniformName), array);
  60333. return this;
  60334. };
  60335. /**
  60336. * Sets an float array on a uniform variable.
  60337. * @param uniformName Name of the variable.
  60338. * @param array array to be set.
  60339. * @returns this effect.
  60340. */
  60341. Effect.prototype.setFloatArray = function (uniformName, array) {
  60342. this._valueCache[uniformName] = null;
  60343. this._engine.setFloatArray(this.getUniform(uniformName), array);
  60344. return this;
  60345. };
  60346. /**
  60347. * 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)
  60348. * @param uniformName Name of the variable.
  60349. * @param array array to be set.
  60350. * @returns this effect.
  60351. */
  60352. Effect.prototype.setFloatArray2 = function (uniformName, array) {
  60353. this._valueCache[uniformName] = null;
  60354. this._engine.setFloatArray2(this.getUniform(uniformName), array);
  60355. return this;
  60356. };
  60357. /**
  60358. * 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)
  60359. * @param uniformName Name of the variable.
  60360. * @param array array to be set.
  60361. * @returns this effect.
  60362. */
  60363. Effect.prototype.setFloatArray3 = function (uniformName, array) {
  60364. this._valueCache[uniformName] = null;
  60365. this._engine.setFloatArray3(this.getUniform(uniformName), array);
  60366. return this;
  60367. };
  60368. /**
  60369. * 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)
  60370. * @param uniformName Name of the variable.
  60371. * @param array array to be set.
  60372. * @returns this effect.
  60373. */
  60374. Effect.prototype.setFloatArray4 = function (uniformName, array) {
  60375. this._valueCache[uniformName] = null;
  60376. this._engine.setFloatArray4(this.getUniform(uniformName), array);
  60377. return this;
  60378. };
  60379. /**
  60380. * Sets an array on a uniform variable.
  60381. * @param uniformName Name of the variable.
  60382. * @param array array to be set.
  60383. * @returns this effect.
  60384. */
  60385. Effect.prototype.setArray = function (uniformName, array) {
  60386. this._valueCache[uniformName] = null;
  60387. this._engine.setArray(this.getUniform(uniformName), array);
  60388. return this;
  60389. };
  60390. /**
  60391. * 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)
  60392. * @param uniformName Name of the variable.
  60393. * @param array array to be set.
  60394. * @returns this effect.
  60395. */
  60396. Effect.prototype.setArray2 = function (uniformName, array) {
  60397. this._valueCache[uniformName] = null;
  60398. this._engine.setArray2(this.getUniform(uniformName), array);
  60399. return this;
  60400. };
  60401. /**
  60402. * 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)
  60403. * @param uniformName Name of the variable.
  60404. * @param array array to be set.
  60405. * @returns this effect.
  60406. */
  60407. Effect.prototype.setArray3 = function (uniformName, array) {
  60408. this._valueCache[uniformName] = null;
  60409. this._engine.setArray3(this.getUniform(uniformName), array);
  60410. return this;
  60411. };
  60412. /**
  60413. * 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)
  60414. * @param uniformName Name of the variable.
  60415. * @param array array to be set.
  60416. * @returns this effect.
  60417. */
  60418. Effect.prototype.setArray4 = function (uniformName, array) {
  60419. this._valueCache[uniformName] = null;
  60420. this._engine.setArray4(this.getUniform(uniformName), array);
  60421. return this;
  60422. };
  60423. /**
  60424. * Sets matrices on a uniform variable.
  60425. * @param uniformName Name of the variable.
  60426. * @param matrices matrices to be set.
  60427. * @returns this effect.
  60428. */
  60429. Effect.prototype.setMatrices = function (uniformName, matrices) {
  60430. if (!matrices) {
  60431. return this;
  60432. }
  60433. this._valueCache[uniformName] = null;
  60434. this._engine.setMatrices(this.getUniform(uniformName), matrices);
  60435. return this;
  60436. };
  60437. /**
  60438. * Sets matrix on a uniform variable.
  60439. * @param uniformName Name of the variable.
  60440. * @param matrix matrix to be set.
  60441. * @returns this effect.
  60442. */
  60443. Effect.prototype.setMatrix = function (uniformName, matrix) {
  60444. if (this._cacheMatrix(uniformName, matrix)) {
  60445. this._engine.setMatrix(this.getUniform(uniformName), matrix);
  60446. }
  60447. return this;
  60448. };
  60449. /**
  60450. * 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)
  60451. * @param uniformName Name of the variable.
  60452. * @param matrix matrix to be set.
  60453. * @returns this effect.
  60454. */
  60455. Effect.prototype.setMatrix3x3 = function (uniformName, matrix) {
  60456. this._valueCache[uniformName] = null;
  60457. this._engine.setMatrix3x3(this.getUniform(uniformName), matrix);
  60458. return this;
  60459. };
  60460. /**
  60461. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  60462. * @param uniformName Name of the variable.
  60463. * @param matrix matrix to be set.
  60464. * @returns this effect.
  60465. */
  60466. Effect.prototype.setMatrix2x2 = function (uniformName, matrix) {
  60467. this._valueCache[uniformName] = null;
  60468. this._engine.setMatrix2x2(this.getUniform(uniformName), matrix);
  60469. return this;
  60470. };
  60471. /**
  60472. * Sets a float on a uniform variable.
  60473. * @param uniformName Name of the variable.
  60474. * @param value value to be set.
  60475. * @returns this effect.
  60476. */
  60477. Effect.prototype.setFloat = function (uniformName, value) {
  60478. var cache = this._valueCache[uniformName];
  60479. if (cache !== undefined && cache === value) {
  60480. return this;
  60481. }
  60482. this._valueCache[uniformName] = value;
  60483. this._engine.setFloat(this.getUniform(uniformName), value);
  60484. return this;
  60485. };
  60486. /**
  60487. * Sets a boolean on a uniform variable.
  60488. * @param uniformName Name of the variable.
  60489. * @param bool value to be set.
  60490. * @returns this effect.
  60491. */
  60492. Effect.prototype.setBool = function (uniformName, bool) {
  60493. var cache = this._valueCache[uniformName];
  60494. if (cache !== undefined && cache === bool) {
  60495. return this;
  60496. }
  60497. this._valueCache[uniformName] = bool;
  60498. this._engine.setBool(this.getUniform(uniformName), bool ? 1 : 0);
  60499. return this;
  60500. };
  60501. /**
  60502. * Sets a Vector2 on a uniform variable.
  60503. * @param uniformName Name of the variable.
  60504. * @param vector2 vector2 to be set.
  60505. * @returns this effect.
  60506. */
  60507. Effect.prototype.setVector2 = function (uniformName, vector2) {
  60508. if (this._cacheFloat2(uniformName, vector2.x, vector2.y)) {
  60509. this._engine.setFloat2(this.getUniform(uniformName), vector2.x, vector2.y);
  60510. }
  60511. return this;
  60512. };
  60513. /**
  60514. * Sets a float2 on a uniform variable.
  60515. * @param uniformName Name of the variable.
  60516. * @param x First float in float2.
  60517. * @param y Second float in float2.
  60518. * @returns this effect.
  60519. */
  60520. Effect.prototype.setFloat2 = function (uniformName, x, y) {
  60521. if (this._cacheFloat2(uniformName, x, y)) {
  60522. this._engine.setFloat2(this.getUniform(uniformName), x, y);
  60523. }
  60524. return this;
  60525. };
  60526. /**
  60527. * Sets a Vector3 on a uniform variable.
  60528. * @param uniformName Name of the variable.
  60529. * @param vector3 Value to be set.
  60530. * @returns this effect.
  60531. */
  60532. Effect.prototype.setVector3 = function (uniformName, vector3) {
  60533. if (this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z)) {
  60534. this._engine.setFloat3(this.getUniform(uniformName), vector3.x, vector3.y, vector3.z);
  60535. }
  60536. return this;
  60537. };
  60538. /**
  60539. * Sets a float3 on a uniform variable.
  60540. * @param uniformName Name of the variable.
  60541. * @param x First float in float3.
  60542. * @param y Second float in float3.
  60543. * @param z Third float in float3.
  60544. * @returns this effect.
  60545. */
  60546. Effect.prototype.setFloat3 = function (uniformName, x, y, z) {
  60547. if (this._cacheFloat3(uniformName, x, y, z)) {
  60548. this._engine.setFloat3(this.getUniform(uniformName), x, y, z);
  60549. }
  60550. return this;
  60551. };
  60552. /**
  60553. * Sets a Vector4 on a uniform variable.
  60554. * @param uniformName Name of the variable.
  60555. * @param vector4 Value to be set.
  60556. * @returns this effect.
  60557. */
  60558. Effect.prototype.setVector4 = function (uniformName, vector4) {
  60559. if (this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w)) {
  60560. this._engine.setFloat4(this.getUniform(uniformName), vector4.x, vector4.y, vector4.z, vector4.w);
  60561. }
  60562. return this;
  60563. };
  60564. /**
  60565. * Sets a float4 on a uniform variable.
  60566. * @param uniformName Name of the variable.
  60567. * @param x First float in float4.
  60568. * @param y Second float in float4.
  60569. * @param z Third float in float4.
  60570. * @param w Fourth float in float4.
  60571. * @returns this effect.
  60572. */
  60573. Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
  60574. if (this._cacheFloat4(uniformName, x, y, z, w)) {
  60575. this._engine.setFloat4(this.getUniform(uniformName), x, y, z, w);
  60576. }
  60577. return this;
  60578. };
  60579. /**
  60580. * Sets a Color3 on a uniform variable.
  60581. * @param uniformName Name of the variable.
  60582. * @param color3 Value to be set.
  60583. * @returns this effect.
  60584. */
  60585. Effect.prototype.setColor3 = function (uniformName, color3) {
  60586. if (this._cacheFloat3(uniformName, color3.r, color3.g, color3.b)) {
  60587. this._engine.setColor3(this.getUniform(uniformName), color3);
  60588. }
  60589. return this;
  60590. };
  60591. /**
  60592. * Sets a Color4 on a uniform variable.
  60593. * @param uniformName Name of the variable.
  60594. * @param color3 Value to be set.
  60595. * @param alpha Alpha value to be set.
  60596. * @returns this effect.
  60597. */
  60598. Effect.prototype.setColor4 = function (uniformName, color3, alpha) {
  60599. if (this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha)) {
  60600. this._engine.setColor4(this.getUniform(uniformName), color3, alpha);
  60601. }
  60602. return this;
  60603. };
  60604. /**
  60605. * Sets a Color4 on a uniform variable
  60606. * @param uniformName defines the name of the variable
  60607. * @param color4 defines the value to be set
  60608. * @returns this effect.
  60609. */
  60610. Effect.prototype.setDirectColor4 = function (uniformName, color4) {
  60611. if (this._cacheFloat4(uniformName, color4.r, color4.g, color4.b, color4.a)) {
  60612. this._engine.setDirectColor4(this.getUniform(uniformName), color4);
  60613. }
  60614. return this;
  60615. };
  60616. /**
  60617. * This function will add a new shader to the shader store
  60618. * @param name the name of the shader
  60619. * @param pixelShader optional pixel shader content
  60620. * @param vertexShader optional vertex shader content
  60621. */
  60622. Effect.RegisterShader = function (name, pixelShader, vertexShader) {
  60623. if (pixelShader) {
  60624. Effect.ShadersStore[name + "PixelShader"] = pixelShader;
  60625. }
  60626. if (vertexShader) {
  60627. Effect.ShadersStore[name + "VertexShader"] = vertexShader;
  60628. }
  60629. };
  60630. /**
  60631. * Resets the cache of effects.
  60632. */
  60633. Effect.ResetCache = function () {
  60634. Effect._baseCache = {};
  60635. };
  60636. /**
  60637. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  60638. */
  60639. Effect.ShadersRepository = "src/Shaders/";
  60640. Effect._uniqueIdSeed = 0;
  60641. Effect._baseCache = {};
  60642. /**
  60643. * Store of each shader (The can be looked up using effect.key)
  60644. */
  60645. Effect.ShadersStore = {};
  60646. /**
  60647. * Store of each included file for a shader (The can be looked up using effect.key)
  60648. */
  60649. Effect.IncludesShadersStore = {};
  60650. return Effect;
  60651. }());
  60652. /***/ }),
  60653. /***/ "./Materials/fresnelParameters.ts":
  60654. /*!****************************************!*\
  60655. !*** ./Materials/fresnelParameters.ts ***!
  60656. \****************************************/
  60657. /*! exports provided: FresnelParameters */
  60658. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60659. "use strict";
  60660. __webpack_require__.r(__webpack_exports__);
  60661. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return FresnelParameters; });
  60662. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  60663. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  60664. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  60665. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  60666. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  60667. /**
  60668. * This represents all the required information to add a fresnel effect on a material:
  60669. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  60670. */
  60671. var FresnelParameters = /** @class */ (function () {
  60672. function FresnelParameters() {
  60673. this._isEnabled = true;
  60674. /**
  60675. * Define the color used on edges (grazing angle)
  60676. */
  60677. this.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].White();
  60678. /**
  60679. * Define the color used on center
  60680. */
  60681. this.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  60682. /**
  60683. * Define bias applied to computed fresnel term
  60684. */
  60685. this.bias = 0;
  60686. /**
  60687. * Defined the power exponent applied to fresnel term
  60688. */
  60689. this.power = 1;
  60690. }
  60691. Object.defineProperty(FresnelParameters.prototype, "isEnabled", {
  60692. /**
  60693. * Define if the fresnel effect is enable or not.
  60694. */
  60695. get: function () {
  60696. return this._isEnabled;
  60697. },
  60698. set: function (value) {
  60699. if (this._isEnabled === value) {
  60700. return;
  60701. }
  60702. this._isEnabled = value;
  60703. _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);
  60704. },
  60705. enumerable: true,
  60706. configurable: true
  60707. });
  60708. /**
  60709. * Clones the current fresnel and its valuues
  60710. * @returns a clone fresnel configuration
  60711. */
  60712. FresnelParameters.prototype.clone = function () {
  60713. var newFresnelParameters = new FresnelParameters();
  60714. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newFresnelParameters);
  60715. return newFresnelParameters;
  60716. };
  60717. /**
  60718. * Serializes the current fresnel parameters to a JSON representation.
  60719. * @return the JSON serialization
  60720. */
  60721. FresnelParameters.prototype.serialize = function () {
  60722. var serializationObject = {};
  60723. serializationObject.isEnabled = this.isEnabled;
  60724. serializationObject.leftColor = this.leftColor.asArray();
  60725. serializationObject.rightColor = this.rightColor.asArray();
  60726. serializationObject.bias = this.bias;
  60727. serializationObject.power = this.power;
  60728. return serializationObject;
  60729. };
  60730. /**
  60731. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  60732. * @param parsedFresnelParameters Define the JSON representation
  60733. * @returns the parsed parameters
  60734. */
  60735. FresnelParameters.Parse = function (parsedFresnelParameters) {
  60736. var fresnelParameters = new FresnelParameters();
  60737. fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
  60738. fresnelParameters.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.leftColor);
  60739. fresnelParameters.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.rightColor);
  60740. fresnelParameters.bias = parsedFresnelParameters.bias;
  60741. fresnelParameters.power = parsedFresnelParameters.power || 1.0;
  60742. return fresnelParameters;
  60743. };
  60744. return FresnelParameters;
  60745. }());
  60746. // References the dependencies.
  60747. _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]._FresnelParametersParser = FresnelParameters.Parse;
  60748. /***/ }),
  60749. /***/ "./Materials/imageProcessingConfiguration.ts":
  60750. /*!***************************************************!*\
  60751. !*** ./Materials/imageProcessingConfiguration.ts ***!
  60752. \***************************************************/
  60753. /*! exports provided: ImageProcessingConfigurationDefines, ImageProcessingConfiguration */
  60754. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60755. "use strict";
  60756. __webpack_require__.r(__webpack_exports__);
  60757. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return ImageProcessingConfigurationDefines; });
  60758. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return ImageProcessingConfiguration; });
  60759. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60760. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  60761. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  60762. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  60763. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  60764. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  60765. /* harmony import */ var _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/colorCurves */ "./Materials/colorCurves.ts");
  60766. /**
  60767. * @hidden
  60768. */
  60769. var ImageProcessingConfigurationDefines = /** @class */ (function (_super) {
  60770. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingConfigurationDefines, _super);
  60771. function ImageProcessingConfigurationDefines() {
  60772. var _this = _super.call(this) || this;
  60773. _this.IMAGEPROCESSING = false;
  60774. _this.VIGNETTE = false;
  60775. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  60776. _this.VIGNETTEBLENDMODEOPAQUE = false;
  60777. _this.TONEMAPPING = false;
  60778. _this.TONEMAPPING_ACES = false;
  60779. _this.CONTRAST = false;
  60780. _this.COLORCURVES = false;
  60781. _this.COLORGRADING = false;
  60782. _this.COLORGRADING3D = false;
  60783. _this.SAMPLER3DGREENDEPTH = false;
  60784. _this.SAMPLER3DBGRMAP = false;
  60785. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  60786. _this.EXPOSURE = false;
  60787. _this.rebuild();
  60788. return _this;
  60789. }
  60790. return ImageProcessingConfigurationDefines;
  60791. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__["MaterialDefines"]));
  60792. /**
  60793. * This groups together the common properties used for image processing either in direct forward pass
  60794. * or through post processing effect depending on the use of the image processing pipeline in your scene
  60795. * or not.
  60796. */
  60797. var ImageProcessingConfiguration = /** @class */ (function () {
  60798. function ImageProcessingConfiguration() {
  60799. /**
  60800. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  60801. */
  60802. this.colorCurves = new _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"]();
  60803. this._colorCurvesEnabled = false;
  60804. this._colorGradingEnabled = false;
  60805. this._colorGradingWithGreenDepth = true;
  60806. this._colorGradingBGR = true;
  60807. /** @hidden */
  60808. this._exposure = 1.0;
  60809. this._toneMappingEnabled = false;
  60810. this._toneMappingType = ImageProcessingConfiguration.TONEMAPPING_STANDARD;
  60811. this._contrast = 1.0;
  60812. /**
  60813. * Vignette stretch size.
  60814. */
  60815. this.vignetteStretch = 0;
  60816. /**
  60817. * Vignette centre X Offset.
  60818. */
  60819. this.vignetteCentreX = 0;
  60820. /**
  60821. * Vignette centre Y Offset.
  60822. */
  60823. this.vignetteCentreY = 0;
  60824. /**
  60825. * Vignette weight or intensity of the vignette effect.
  60826. */
  60827. this.vignetteWeight = 1.5;
  60828. /**
  60829. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  60830. * if vignetteEnabled is set to true.
  60831. */
  60832. this.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  60833. /**
  60834. * Camera field of view used by the Vignette effect.
  60835. */
  60836. this.vignetteCameraFov = 0.5;
  60837. this._vignetteBlendMode = ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;
  60838. this._vignetteEnabled = false;
  60839. this._applyByPostProcess = false;
  60840. this._isEnabled = true;
  60841. /**
  60842. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  60843. */
  60844. this.onUpdateParameters = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  60845. }
  60846. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorCurvesEnabled", {
  60847. /**
  60848. * Gets wether the color curves effect is enabled.
  60849. */
  60850. get: function () {
  60851. return this._colorCurvesEnabled;
  60852. },
  60853. /**
  60854. * Sets wether the color curves effect is enabled.
  60855. */
  60856. set: function (value) {
  60857. if (this._colorCurvesEnabled === value) {
  60858. return;
  60859. }
  60860. this._colorCurvesEnabled = value;
  60861. this._updateParameters();
  60862. },
  60863. enumerable: true,
  60864. configurable: true
  60865. });
  60866. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingTexture", {
  60867. /**
  60868. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  60869. */
  60870. get: function () {
  60871. return this._colorGradingTexture;
  60872. },
  60873. /**
  60874. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  60875. */
  60876. set: function (value) {
  60877. if (this._colorGradingTexture === value) {
  60878. return;
  60879. }
  60880. this._colorGradingTexture = value;
  60881. this._updateParameters();
  60882. },
  60883. enumerable: true,
  60884. configurable: true
  60885. });
  60886. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingEnabled", {
  60887. /**
  60888. * Gets wether the color grading effect is enabled.
  60889. */
  60890. get: function () {
  60891. return this._colorGradingEnabled;
  60892. },
  60893. /**
  60894. * Sets wether the color grading effect is enabled.
  60895. */
  60896. set: function (value) {
  60897. if (this._colorGradingEnabled === value) {
  60898. return;
  60899. }
  60900. this._colorGradingEnabled = value;
  60901. this._updateParameters();
  60902. },
  60903. enumerable: true,
  60904. configurable: true
  60905. });
  60906. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingWithGreenDepth", {
  60907. /**
  60908. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  60909. */
  60910. get: function () {
  60911. return this._colorGradingWithGreenDepth;
  60912. },
  60913. /**
  60914. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  60915. */
  60916. set: function (value) {
  60917. if (this._colorGradingWithGreenDepth === value) {
  60918. return;
  60919. }
  60920. this._colorGradingWithGreenDepth = value;
  60921. this._updateParameters();
  60922. },
  60923. enumerable: true,
  60924. configurable: true
  60925. });
  60926. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingBGR", {
  60927. /**
  60928. * Gets wether the color grading texture contains BGR values.
  60929. */
  60930. get: function () {
  60931. return this._colorGradingBGR;
  60932. },
  60933. /**
  60934. * Sets wether the color grading texture contains BGR values.
  60935. */
  60936. set: function (value) {
  60937. if (this._colorGradingBGR === value) {
  60938. return;
  60939. }
  60940. this._colorGradingBGR = value;
  60941. this._updateParameters();
  60942. },
  60943. enumerable: true,
  60944. configurable: true
  60945. });
  60946. Object.defineProperty(ImageProcessingConfiguration.prototype, "exposure", {
  60947. /**
  60948. * Gets the Exposure used in the effect.
  60949. */
  60950. get: function () {
  60951. return this._exposure;
  60952. },
  60953. /**
  60954. * Sets the Exposure used in the effect.
  60955. */
  60956. set: function (value) {
  60957. if (this._exposure === value) {
  60958. return;
  60959. }
  60960. this._exposure = value;
  60961. this._updateParameters();
  60962. },
  60963. enumerable: true,
  60964. configurable: true
  60965. });
  60966. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingEnabled", {
  60967. /**
  60968. * Gets wether the tone mapping effect is enabled.
  60969. */
  60970. get: function () {
  60971. return this._toneMappingEnabled;
  60972. },
  60973. /**
  60974. * Sets wether the tone mapping effect is enabled.
  60975. */
  60976. set: function (value) {
  60977. if (this._toneMappingEnabled === value) {
  60978. return;
  60979. }
  60980. this._toneMappingEnabled = value;
  60981. this._updateParameters();
  60982. },
  60983. enumerable: true,
  60984. configurable: true
  60985. });
  60986. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingType", {
  60987. /**
  60988. * Gets the type of tone mapping effect.
  60989. */
  60990. get: function () {
  60991. return this._toneMappingType;
  60992. },
  60993. /**
  60994. * Sets the type of tone mapping effect used in BabylonJS.
  60995. */
  60996. set: function (value) {
  60997. if (this._toneMappingType === value) {
  60998. return;
  60999. }
  61000. this._toneMappingType = value;
  61001. this._updateParameters();
  61002. },
  61003. enumerable: true,
  61004. configurable: true
  61005. });
  61006. Object.defineProperty(ImageProcessingConfiguration.prototype, "contrast", {
  61007. /**
  61008. * Gets the contrast used in the effect.
  61009. */
  61010. get: function () {
  61011. return this._contrast;
  61012. },
  61013. /**
  61014. * Sets the contrast used in the effect.
  61015. */
  61016. set: function (value) {
  61017. if (this._contrast === value) {
  61018. return;
  61019. }
  61020. this._contrast = value;
  61021. this._updateParameters();
  61022. },
  61023. enumerable: true,
  61024. configurable: true
  61025. });
  61026. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteBlendMode", {
  61027. /**
  61028. * Gets the vignette blend mode allowing different kind of effect.
  61029. */
  61030. get: function () {
  61031. return this._vignetteBlendMode;
  61032. },
  61033. /**
  61034. * Sets the vignette blend mode allowing different kind of effect.
  61035. */
  61036. set: function (value) {
  61037. if (this._vignetteBlendMode === value) {
  61038. return;
  61039. }
  61040. this._vignetteBlendMode = value;
  61041. this._updateParameters();
  61042. },
  61043. enumerable: true,
  61044. configurable: true
  61045. });
  61046. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteEnabled", {
  61047. /**
  61048. * Gets wether the vignette effect is enabled.
  61049. */
  61050. get: function () {
  61051. return this._vignetteEnabled;
  61052. },
  61053. /**
  61054. * Sets wether the vignette effect is enabled.
  61055. */
  61056. set: function (value) {
  61057. if (this._vignetteEnabled === value) {
  61058. return;
  61059. }
  61060. this._vignetteEnabled = value;
  61061. this._updateParameters();
  61062. },
  61063. enumerable: true,
  61064. configurable: true
  61065. });
  61066. Object.defineProperty(ImageProcessingConfiguration.prototype, "applyByPostProcess", {
  61067. /**
  61068. * Gets wether the image processing is applied through a post process or not.
  61069. */
  61070. get: function () {
  61071. return this._applyByPostProcess;
  61072. },
  61073. /**
  61074. * Sets wether the image processing is applied through a post process or not.
  61075. */
  61076. set: function (value) {
  61077. if (this._applyByPostProcess === value) {
  61078. return;
  61079. }
  61080. this._applyByPostProcess = value;
  61081. this._updateParameters();
  61082. },
  61083. enumerable: true,
  61084. configurable: true
  61085. });
  61086. Object.defineProperty(ImageProcessingConfiguration.prototype, "isEnabled", {
  61087. /**
  61088. * Gets wether the image processing is enabled or not.
  61089. */
  61090. get: function () {
  61091. return this._isEnabled;
  61092. },
  61093. /**
  61094. * Sets wether the image processing is enabled or not.
  61095. */
  61096. set: function (value) {
  61097. if (this._isEnabled === value) {
  61098. return;
  61099. }
  61100. this._isEnabled = value;
  61101. this._updateParameters();
  61102. },
  61103. enumerable: true,
  61104. configurable: true
  61105. });
  61106. /**
  61107. * Method called each time the image processing information changes requires to recompile the effect.
  61108. */
  61109. ImageProcessingConfiguration.prototype._updateParameters = function () {
  61110. this.onUpdateParameters.notifyObservers(this);
  61111. };
  61112. /**
  61113. * Gets the current class name.
  61114. * @return "ImageProcessingConfiguration"
  61115. */
  61116. ImageProcessingConfiguration.prototype.getClassName = function () {
  61117. return "ImageProcessingConfiguration";
  61118. };
  61119. /**
  61120. * Prepare the list of uniforms associated with the Image Processing effects.
  61121. * @param uniforms The list of uniforms used in the effect
  61122. * @param defines the list of defines currently in use
  61123. */
  61124. ImageProcessingConfiguration.PrepareUniforms = function (uniforms, defines) {
  61125. if (defines.EXPOSURE) {
  61126. uniforms.push("exposureLinear");
  61127. }
  61128. if (defines.CONTRAST) {
  61129. uniforms.push("contrast");
  61130. }
  61131. if (defines.COLORGRADING) {
  61132. uniforms.push("colorTransformSettings");
  61133. }
  61134. if (defines.VIGNETTE) {
  61135. uniforms.push("vInverseScreenSize");
  61136. uniforms.push("vignetteSettings1");
  61137. uniforms.push("vignetteSettings2");
  61138. }
  61139. if (defines.COLORCURVES) {
  61140. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].PrepareUniforms(uniforms);
  61141. }
  61142. };
  61143. /**
  61144. * Prepare the list of samplers associated with the Image Processing effects.
  61145. * @param samplersList The list of uniforms used in the effect
  61146. * @param defines the list of defines currently in use
  61147. */
  61148. ImageProcessingConfiguration.PrepareSamplers = function (samplersList, defines) {
  61149. if (defines.COLORGRADING) {
  61150. samplersList.push("txColorTransform");
  61151. }
  61152. };
  61153. /**
  61154. * Prepare the list of defines associated to the shader.
  61155. * @param defines the list of defines to complete
  61156. * @param forPostProcess Define if we are currently in post process mode or not
  61157. */
  61158. ImageProcessingConfiguration.prototype.prepareDefines = function (defines, forPostProcess) {
  61159. if (forPostProcess === void 0) { forPostProcess = false; }
  61160. if (forPostProcess !== this.applyByPostProcess || !this._isEnabled) {
  61161. defines.VIGNETTE = false;
  61162. defines.TONEMAPPING = false;
  61163. defines.TONEMAPPING_ACES = false;
  61164. defines.CONTRAST = false;
  61165. defines.EXPOSURE = false;
  61166. defines.COLORCURVES = false;
  61167. defines.COLORGRADING = false;
  61168. defines.COLORGRADING3D = false;
  61169. defines.IMAGEPROCESSING = false;
  61170. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled;
  61171. return;
  61172. }
  61173. defines.VIGNETTE = this.vignetteEnabled;
  61174. defines.VIGNETTEBLENDMODEMULTIPLY = (this.vignetteBlendMode === ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY);
  61175. defines.VIGNETTEBLENDMODEOPAQUE = !defines.VIGNETTEBLENDMODEMULTIPLY;
  61176. defines.TONEMAPPING = this.toneMappingEnabled;
  61177. switch (this._toneMappingType) {
  61178. case ImageProcessingConfiguration.TONEMAPPING_ACES:
  61179. defines.TONEMAPPING_ACES = true;
  61180. break;
  61181. default:
  61182. defines.TONEMAPPING_ACES = false;
  61183. break;
  61184. }
  61185. defines.CONTRAST = (this.contrast !== 1.0);
  61186. defines.EXPOSURE = (this.exposure !== 1.0);
  61187. defines.COLORCURVES = (this.colorCurvesEnabled && !!this.colorCurves);
  61188. defines.COLORGRADING = (this.colorGradingEnabled && !!this.colorGradingTexture);
  61189. if (defines.COLORGRADING) {
  61190. defines.COLORGRADING3D = this.colorGradingTexture.is3D;
  61191. }
  61192. else {
  61193. defines.COLORGRADING3D = false;
  61194. }
  61195. defines.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth;
  61196. defines.SAMPLER3DBGRMAP = this.colorGradingBGR;
  61197. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess;
  61198. defines.IMAGEPROCESSING = defines.VIGNETTE || defines.TONEMAPPING || defines.CONTRAST || defines.EXPOSURE || defines.COLORCURVES || defines.COLORGRADING;
  61199. };
  61200. /**
  61201. * Returns true if all the image processing information are ready.
  61202. * @returns True if ready, otherwise, false
  61203. */
  61204. ImageProcessingConfiguration.prototype.isReady = function () {
  61205. // Color Grading texure can not be none blocking.
  61206. return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady();
  61207. };
  61208. /**
  61209. * Binds the image processing to the shader.
  61210. * @param effect The effect to bind to
  61211. * @param aspectRatio Define the current aspect ratio of the effect
  61212. */
  61213. ImageProcessingConfiguration.prototype.bind = function (effect, aspectRatio) {
  61214. if (aspectRatio === void 0) { aspectRatio = 1; }
  61215. // Color Curves
  61216. if (this._colorCurvesEnabled && this.colorCurves) {
  61217. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].Bind(this.colorCurves, effect);
  61218. }
  61219. // Vignette
  61220. if (this._vignetteEnabled) {
  61221. var inverseWidth = 1 / effect.getEngine().getRenderWidth();
  61222. var inverseHeight = 1 / effect.getEngine().getRenderHeight();
  61223. effect.setFloat2("vInverseScreenSize", inverseWidth, inverseHeight);
  61224. var vignetteScaleY = Math.tan(this.vignetteCameraFov * 0.5);
  61225. var vignetteScaleX = vignetteScaleY * aspectRatio;
  61226. var vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY);
  61227. vignetteScaleX = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleX, vignetteScaleGeometricMean, this.vignetteStretch);
  61228. vignetteScaleY = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleY, vignetteScaleGeometricMean, this.vignetteStretch);
  61229. effect.setFloat4("vignetteSettings1", vignetteScaleX, vignetteScaleY, -vignetteScaleX * this.vignetteCentreX, -vignetteScaleY * this.vignetteCentreY);
  61230. var vignettePower = -2.0 * this.vignetteWeight;
  61231. effect.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, vignettePower);
  61232. }
  61233. // Exposure
  61234. effect.setFloat("exposureLinear", this.exposure);
  61235. // Contrast
  61236. effect.setFloat("contrast", this.contrast);
  61237. // Color transform settings
  61238. if (this.colorGradingTexture) {
  61239. effect.setTexture("txColorTransform", this.colorGradingTexture);
  61240. var textureSize = this.colorGradingTexture.getSize().height;
  61241. effect.setFloat4("colorTransformSettings", (textureSize - 1) / textureSize, // textureScale
  61242. 0.5 / textureSize, // textureOffset
  61243. textureSize, // textureSize
  61244. this.colorGradingTexture.level // weight
  61245. );
  61246. }
  61247. };
  61248. /**
  61249. * Clones the current image processing instance.
  61250. * @return The cloned image processing
  61251. */
  61252. ImageProcessingConfiguration.prototype.clone = function () {
  61253. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ImageProcessingConfiguration(); }, this);
  61254. };
  61255. /**
  61256. * Serializes the current image processing instance to a json representation.
  61257. * @return a JSON representation
  61258. */
  61259. ImageProcessingConfiguration.prototype.serialize = function () {
  61260. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  61261. };
  61262. /**
  61263. * Parses the image processing from a json representation.
  61264. * @param source the JSON source to parse
  61265. * @return The parsed image processing
  61266. */
  61267. ImageProcessingConfiguration.Parse = function (source) {
  61268. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ImageProcessingConfiguration(); }, source, null, null);
  61269. };
  61270. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_MULTIPLY", {
  61271. /**
  61272. * Used to apply the vignette as a mix with the pixel color.
  61273. */
  61274. get: function () {
  61275. return this._VIGNETTEMODE_MULTIPLY;
  61276. },
  61277. enumerable: true,
  61278. configurable: true
  61279. });
  61280. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_OPAQUE", {
  61281. /**
  61282. * Used to apply the vignette as a replacement of the pixel color.
  61283. */
  61284. get: function () {
  61285. return this._VIGNETTEMODE_OPAQUE;
  61286. },
  61287. enumerable: true,
  61288. configurable: true
  61289. });
  61290. /**
  61291. * Default tone mapping applied in BabylonJS.
  61292. */
  61293. ImageProcessingConfiguration.TONEMAPPING_STANDARD = 0;
  61294. /**
  61295. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  61296. * to other engines rendering to increase portability.
  61297. */
  61298. ImageProcessingConfiguration.TONEMAPPING_ACES = 1;
  61299. // Static constants associated to the image processing.
  61300. ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY = 0;
  61301. ImageProcessingConfiguration._VIGNETTEMODE_OPAQUE = 1;
  61302. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61303. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColorCurves"])()
  61304. ], ImageProcessingConfiguration.prototype, "colorCurves", void 0);
  61305. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61306. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61307. ], ImageProcessingConfiguration.prototype, "_colorCurvesEnabled", void 0);
  61308. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61309. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("colorGradingTexture")
  61310. ], ImageProcessingConfiguration.prototype, "_colorGradingTexture", void 0);
  61311. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61312. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61313. ], ImageProcessingConfiguration.prototype, "_colorGradingEnabled", void 0);
  61314. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61315. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61316. ], ImageProcessingConfiguration.prototype, "_colorGradingWithGreenDepth", void 0);
  61317. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61318. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61319. ], ImageProcessingConfiguration.prototype, "_colorGradingBGR", void 0);
  61320. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61321. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61322. ], ImageProcessingConfiguration.prototype, "_exposure", void 0);
  61323. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61324. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61325. ], ImageProcessingConfiguration.prototype, "_toneMappingEnabled", void 0);
  61326. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61327. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61328. ], ImageProcessingConfiguration.prototype, "_toneMappingType", void 0);
  61329. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61330. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61331. ], ImageProcessingConfiguration.prototype, "_contrast", void 0);
  61332. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61333. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61334. ], ImageProcessingConfiguration.prototype, "vignetteStretch", void 0);
  61335. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61336. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61337. ], ImageProcessingConfiguration.prototype, "vignetteCentreX", void 0);
  61338. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61339. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61340. ], ImageProcessingConfiguration.prototype, "vignetteCentreY", void 0);
  61341. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61342. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61343. ], ImageProcessingConfiguration.prototype, "vignetteWeight", void 0);
  61344. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61345. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  61346. ], ImageProcessingConfiguration.prototype, "vignetteColor", void 0);
  61347. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61348. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61349. ], ImageProcessingConfiguration.prototype, "vignetteCameraFov", void 0);
  61350. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61351. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61352. ], ImageProcessingConfiguration.prototype, "_vignetteBlendMode", void 0);
  61353. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61354. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61355. ], ImageProcessingConfiguration.prototype, "_vignetteEnabled", void 0);
  61356. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61357. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61358. ], ImageProcessingConfiguration.prototype, "_applyByPostProcess", void 0);
  61359. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61360. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61361. ], ImageProcessingConfiguration.prototype, "_isEnabled", void 0);
  61362. return ImageProcessingConfiguration;
  61363. }());
  61364. // References the dependencies.
  61365. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ImageProcessingConfigurationParser = ImageProcessingConfiguration.Parse;
  61366. /***/ }),
  61367. /***/ "./Materials/index.ts":
  61368. /*!****************************!*\
  61369. !*** ./Materials/index.ts ***!
  61370. \****************************/
  61371. /*! 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 */
  61372. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61373. "use strict";
  61374. __webpack_require__.r(__webpack_exports__);
  61375. /* harmony import */ var _Background_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Background/index */ "./Materials/Background/index.ts");
  61376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Background_index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  61377. /* harmony import */ var _colorCurves__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorCurves */ "./Materials/colorCurves.ts");
  61378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _colorCurves__WEBPACK_IMPORTED_MODULE_1__["ColorCurves"]; });
  61379. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  61380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectFallbacks"]; });
  61381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectCreationOptions"]; });
  61382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["Effect"]; });
  61383. /* harmony import */ var _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fresnelParameters */ "./Materials/fresnelParameters.ts");
  61384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__["FresnelParameters"]; });
  61385. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  61386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfigurationDefines"]; });
  61387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfiguration"]; });
  61388. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  61389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _material__WEBPACK_IMPORTED_MODULE_5__["Material"]; });
  61390. /* harmony import */ var _materialDefines__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./materialDefines */ "./Materials/materialDefines.ts");
  61391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _materialDefines__WEBPACK_IMPORTED_MODULE_6__["MaterialDefines"]; });
  61392. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  61393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"]; });
  61394. /* harmony import */ var _multiMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./multiMaterial */ "./Materials/multiMaterial.ts");
  61395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _multiMaterial__WEBPACK_IMPORTED_MODULE_8__["MultiMaterial"]; });
  61396. /* harmony import */ var _PBR_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./PBR/index */ "./Materials/PBR/index.ts");
  61397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseMaterial"]; });
  61398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseSimpleMaterial"]; });
  61399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterial"]; });
  61400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMetallicRoughnessMaterial"]; });
  61401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRSpecularGlossinessMaterial"]; });
  61402. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  61403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _pushMaterial__WEBPACK_IMPORTED_MODULE_10__["PushMaterial"]; });
  61404. /* harmony import */ var _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shaderMaterial */ "./Materials/shaderMaterial.ts");
  61405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__["ShaderMaterial"]; });
  61406. /* harmony import */ var _standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./standardMaterial */ "./Materials/standardMaterial.ts");
  61407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterialDefines"]; });
  61408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]; });
  61409. /* harmony import */ var _Textures_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Textures/index */ "./Materials/Textures/index.ts");
  61410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["BaseTexture"]; });
  61411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CubeTexture"]; });
  61412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["HDRCubeTexture"]; });
  61413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["InternalTexture"]; });
  61414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DummyInternalTextureTracker"]; });
  61415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MirrorTexture"]; });
  61416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MultiRenderTarget"]; });
  61417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture"]; });
  61418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RenderTargetTexture"]; });
  61419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["Texture"]; });
  61420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ColorGradingTexture"]; });
  61421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DynamicTexture"]; });
  61422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTexture"]; });
  61423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawCubeTexture"]; });
  61424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  61425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RefractionTexture"]; });
  61426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["VideoTexture"]; });
  61427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_DDSTextureLoader"]; });
  61428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_ENVTextureLoader"]; });
  61429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_KTXTextureLoader"]; });
  61430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_TGATextureLoader"]; });
  61431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CustomProceduralTexture"]; });
  61432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["NoiseProceduralTexture"]; });
  61433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTextureSceneComponent"]; });
  61434. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  61435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__["UniformBuffer"]; });
  61436. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  61437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _materialFlags__WEBPACK_IMPORTED_MODULE_15__["MaterialFlags"]; });
  61438. /***/ }),
  61439. /***/ "./Materials/material.ts":
  61440. /*!*******************************!*\
  61441. !*** ./Materials/material.ts ***!
  61442. \*******************************/
  61443. /*! exports provided: Material */
  61444. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61445. "use strict";
  61446. __webpack_require__.r(__webpack_exports__);
  61447. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return Material; });
  61448. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61449. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  61450. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  61451. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  61452. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  61453. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  61454. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  61455. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  61456. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  61457. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  61458. /**
  61459. * Base class for the main features of a material in Babylon.js
  61460. */
  61461. var Material = /** @class */ (function () {
  61462. /**
  61463. * Creates a material instance
  61464. * @param name defines the name of the material
  61465. * @param scene defines the scene to reference
  61466. * @param doNotAdd specifies if the material should be added to the scene
  61467. */
  61468. function Material(name, scene, doNotAdd) {
  61469. /**
  61470. * Gets or sets user defined metadata
  61471. */
  61472. this.metadata = null;
  61473. /**
  61474. * For internal use only. Please do not use.
  61475. */
  61476. this.reservedDataStore = null;
  61477. /**
  61478. * Specifies if the ready state should be checked on each call
  61479. */
  61480. this.checkReadyOnEveryCall = false;
  61481. /**
  61482. * Specifies if the ready state should be checked once
  61483. */
  61484. this.checkReadyOnlyOnce = false;
  61485. /**
  61486. * The state of the material
  61487. */
  61488. this.state = "";
  61489. /**
  61490. * The alpha value of the material
  61491. */
  61492. this._alpha = 1.0;
  61493. /**
  61494. * Specifies if back face culling is enabled
  61495. */
  61496. this._backFaceCulling = true;
  61497. /**
  61498. * Specifies if the material should be serialized
  61499. */
  61500. this.doNotSerialize = false;
  61501. /**
  61502. * @hidden
  61503. */
  61504. this._storeEffectOnSubMeshes = false;
  61505. /**
  61506. * An event triggered when the material is disposed
  61507. */
  61508. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  61509. /**
  61510. * Stores the value of the alpha mode
  61511. */
  61512. this._alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  61513. /**
  61514. * Stores the state of the need depth pre-pass value
  61515. */
  61516. this._needDepthPrePass = false;
  61517. /**
  61518. * Specifies if depth writing should be disabled
  61519. */
  61520. this.disableDepthWrite = false;
  61521. /**
  61522. * Specifies if depth writing should be forced
  61523. */
  61524. this.forceDepthWrite = false;
  61525. /**
  61526. * Specifies if there should be a separate pass for culling
  61527. */
  61528. this.separateCullingPass = false;
  61529. /**
  61530. * Stores the state specifing if fog should be enabled
  61531. */
  61532. this._fogEnabled = true;
  61533. /**
  61534. * Stores the size of points
  61535. */
  61536. this.pointSize = 1.0;
  61537. /**
  61538. * Stores the z offset value
  61539. */
  61540. this.zOffset = 0;
  61541. /**
  61542. * @hidden
  61543. * Specifies if the material was previously ready
  61544. */
  61545. this._wasPreviouslyReady = false;
  61546. /**
  61547. * Stores the fill mode state
  61548. */
  61549. this._fillMode = Material.TriangleFillMode;
  61550. /** @hidden */
  61551. this._indexInSceneMaterialArray = -1;
  61552. this.name = name;
  61553. this.id = name || _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RandomId();
  61554. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  61555. this.uniqueId = this._scene.getUniqueId();
  61556. if (this._scene.useRightHandedSystem) {
  61557. this.sideOrientation = Material.ClockWiseSideOrientation;
  61558. }
  61559. else {
  61560. this.sideOrientation = Material.CounterClockWiseSideOrientation;
  61561. }
  61562. this._uniformBuffer = new _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__["UniformBuffer"](this._scene.getEngine());
  61563. this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
  61564. if (!doNotAdd) {
  61565. this._scene.addMaterial(this);
  61566. }
  61567. if (this._scene.useMaterialMeshMap) {
  61568. this.meshMap = {};
  61569. }
  61570. }
  61571. Object.defineProperty(Material.prototype, "alpha", {
  61572. /**
  61573. * Gets the alpha value of the material
  61574. */
  61575. get: function () {
  61576. return this._alpha;
  61577. },
  61578. /**
  61579. * Sets the alpha value of the material
  61580. */
  61581. set: function (value) {
  61582. if (this._alpha === value) {
  61583. return;
  61584. }
  61585. this._alpha = value;
  61586. this.markAsDirty(Material.MiscDirtyFlag);
  61587. },
  61588. enumerable: true,
  61589. configurable: true
  61590. });
  61591. Object.defineProperty(Material.prototype, "backFaceCulling", {
  61592. /**
  61593. * Gets the back-face culling state
  61594. */
  61595. get: function () {
  61596. return this._backFaceCulling;
  61597. },
  61598. /**
  61599. * Sets the back-face culling state
  61600. */
  61601. set: function (value) {
  61602. if (this._backFaceCulling === value) {
  61603. return;
  61604. }
  61605. this._backFaceCulling = value;
  61606. this.markAsDirty(Material.TextureDirtyFlag);
  61607. },
  61608. enumerable: true,
  61609. configurable: true
  61610. });
  61611. Object.defineProperty(Material.prototype, "hasRenderTargetTextures", {
  61612. /**
  61613. * Gets a boolean indicating that current material needs to register RTT
  61614. */
  61615. get: function () {
  61616. return false;
  61617. },
  61618. enumerable: true,
  61619. configurable: true
  61620. });
  61621. Object.defineProperty(Material.prototype, "onDispose", {
  61622. /**
  61623. * Called during a dispose event
  61624. */
  61625. set: function (callback) {
  61626. if (this._onDisposeObserver) {
  61627. this.onDisposeObservable.remove(this._onDisposeObserver);
  61628. }
  61629. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  61630. },
  61631. enumerable: true,
  61632. configurable: true
  61633. });
  61634. Object.defineProperty(Material.prototype, "onBindObservable", {
  61635. /**
  61636. * An event triggered when the material is bound
  61637. */
  61638. get: function () {
  61639. if (!this._onBindObservable) {
  61640. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  61641. }
  61642. return this._onBindObservable;
  61643. },
  61644. enumerable: true,
  61645. configurable: true
  61646. });
  61647. Object.defineProperty(Material.prototype, "onBind", {
  61648. /**
  61649. * Called during a bind event
  61650. */
  61651. set: function (callback) {
  61652. if (this._onBindObserver) {
  61653. this.onBindObservable.remove(this._onBindObserver);
  61654. }
  61655. this._onBindObserver = this.onBindObservable.add(callback);
  61656. },
  61657. enumerable: true,
  61658. configurable: true
  61659. });
  61660. Object.defineProperty(Material.prototype, "onUnBindObservable", {
  61661. /**
  61662. * An event triggered when the material is unbound
  61663. */
  61664. get: function () {
  61665. if (!this._onUnBindObservable) {
  61666. this._onUnBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  61667. }
  61668. return this._onUnBindObservable;
  61669. },
  61670. enumerable: true,
  61671. configurable: true
  61672. });
  61673. Object.defineProperty(Material.prototype, "alphaMode", {
  61674. /**
  61675. * Gets the value of the alpha mode
  61676. */
  61677. get: function () {
  61678. return this._alphaMode;
  61679. },
  61680. /**
  61681. * Sets the value of the alpha mode.
  61682. *
  61683. * | Value | Type | Description |
  61684. * | --- | --- | --- |
  61685. * | 0 | ALPHA_DISABLE | |
  61686. * | 1 | ALPHA_ADD | |
  61687. * | 2 | ALPHA_COMBINE | |
  61688. * | 3 | ALPHA_SUBTRACT | |
  61689. * | 4 | ALPHA_MULTIPLY | |
  61690. * | 5 | ALPHA_MAXIMIZED | |
  61691. * | 6 | ALPHA_ONEONE | |
  61692. * | 7 | ALPHA_PREMULTIPLIED | |
  61693. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  61694. * | 9 | ALPHA_INTERPOLATE | |
  61695. * | 10 | ALPHA_SCREENMODE | |
  61696. *
  61697. */
  61698. set: function (value) {
  61699. if (this._alphaMode === value) {
  61700. return;
  61701. }
  61702. this._alphaMode = value;
  61703. this.markAsDirty(Material.TextureDirtyFlag);
  61704. },
  61705. enumerable: true,
  61706. configurable: true
  61707. });
  61708. Object.defineProperty(Material.prototype, "needDepthPrePass", {
  61709. /**
  61710. * Gets the depth pre-pass value
  61711. */
  61712. get: function () {
  61713. return this._needDepthPrePass;
  61714. },
  61715. /**
  61716. * Sets the need depth pre-pass value
  61717. */
  61718. set: function (value) {
  61719. if (this._needDepthPrePass === value) {
  61720. return;
  61721. }
  61722. this._needDepthPrePass = value;
  61723. if (this._needDepthPrePass) {
  61724. this.checkReadyOnEveryCall = true;
  61725. }
  61726. },
  61727. enumerable: true,
  61728. configurable: true
  61729. });
  61730. Object.defineProperty(Material.prototype, "fogEnabled", {
  61731. /**
  61732. * Gets the value of the fog enabled state
  61733. */
  61734. get: function () {
  61735. return this._fogEnabled;
  61736. },
  61737. /**
  61738. * Sets the state for enabling fog
  61739. */
  61740. set: function (value) {
  61741. if (this._fogEnabled === value) {
  61742. return;
  61743. }
  61744. this._fogEnabled = value;
  61745. this.markAsDirty(Material.MiscDirtyFlag);
  61746. },
  61747. enumerable: true,
  61748. configurable: true
  61749. });
  61750. Object.defineProperty(Material.prototype, "wireframe", {
  61751. /**
  61752. * Gets a value specifying if wireframe mode is enabled
  61753. */
  61754. get: function () {
  61755. switch (this._fillMode) {
  61756. case Material.WireFrameFillMode:
  61757. case Material.LineListDrawMode:
  61758. case Material.LineLoopDrawMode:
  61759. case Material.LineStripDrawMode:
  61760. return true;
  61761. }
  61762. return this._scene.forceWireframe;
  61763. },
  61764. /**
  61765. * Sets the state of wireframe mode
  61766. */
  61767. set: function (value) {
  61768. this.fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
  61769. },
  61770. enumerable: true,
  61771. configurable: true
  61772. });
  61773. Object.defineProperty(Material.prototype, "pointsCloud", {
  61774. /**
  61775. * Gets the value specifying if point clouds are enabled
  61776. */
  61777. get: function () {
  61778. switch (this._fillMode) {
  61779. case Material.PointFillMode:
  61780. case Material.PointListDrawMode:
  61781. return true;
  61782. }
  61783. return this._scene.forcePointsCloud;
  61784. },
  61785. /**
  61786. * Sets the state of point cloud mode
  61787. */
  61788. set: function (value) {
  61789. this.fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
  61790. },
  61791. enumerable: true,
  61792. configurable: true
  61793. });
  61794. Object.defineProperty(Material.prototype, "fillMode", {
  61795. /**
  61796. * Gets the material fill mode
  61797. */
  61798. get: function () {
  61799. return this._fillMode;
  61800. },
  61801. /**
  61802. * Sets the material fill mode
  61803. */
  61804. set: function (value) {
  61805. if (this._fillMode === value) {
  61806. return;
  61807. }
  61808. this._fillMode = value;
  61809. this.markAsDirty(Material.MiscDirtyFlag);
  61810. },
  61811. enumerable: true,
  61812. configurable: true
  61813. });
  61814. /**
  61815. * Returns a string representation of the current material
  61816. * @param fullDetails defines a boolean indicating which levels of logging is desired
  61817. * @returns a string with material information
  61818. */
  61819. Material.prototype.toString = function (fullDetails) {
  61820. var ret = "Name: " + this.name;
  61821. if (fullDetails) {
  61822. }
  61823. return ret;
  61824. };
  61825. /**
  61826. * Gets the class name of the material
  61827. * @returns a string with the class name of the material
  61828. */
  61829. Material.prototype.getClassName = function () {
  61830. return "Material";
  61831. };
  61832. Object.defineProperty(Material.prototype, "isFrozen", {
  61833. /**
  61834. * Specifies if updates for the material been locked
  61835. */
  61836. get: function () {
  61837. return this.checkReadyOnlyOnce;
  61838. },
  61839. enumerable: true,
  61840. configurable: true
  61841. });
  61842. /**
  61843. * Locks updates for the material
  61844. */
  61845. Material.prototype.freeze = function () {
  61846. this.checkReadyOnlyOnce = true;
  61847. };
  61848. /**
  61849. * Unlocks updates for the material
  61850. */
  61851. Material.prototype.unfreeze = function () {
  61852. this.checkReadyOnlyOnce = false;
  61853. };
  61854. /**
  61855. * Specifies if the material is ready to be used
  61856. * @param mesh defines the mesh to check
  61857. * @param useInstances specifies if instances should be used
  61858. * @returns a boolean indicating if the material is ready to be used
  61859. */
  61860. Material.prototype.isReady = function (mesh, useInstances) {
  61861. return true;
  61862. };
  61863. /**
  61864. * Specifies that the submesh is ready to be used
  61865. * @param mesh defines the mesh to check
  61866. * @param subMesh defines which submesh to check
  61867. * @param useInstances specifies that instances should be used
  61868. * @returns a boolean indicating that the submesh is ready or not
  61869. */
  61870. Material.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  61871. return false;
  61872. };
  61873. /**
  61874. * Returns the material effect
  61875. * @returns the effect associated with the material
  61876. */
  61877. Material.prototype.getEffect = function () {
  61878. return this._effect;
  61879. };
  61880. /**
  61881. * Returns the current scene
  61882. * @returns a Scene
  61883. */
  61884. Material.prototype.getScene = function () {
  61885. return this._scene;
  61886. };
  61887. /**
  61888. * Specifies if the material will require alpha blending
  61889. * @returns a boolean specifying if alpha blending is needed
  61890. */
  61891. Material.prototype.needAlphaBlending = function () {
  61892. return (this.alpha < 1.0);
  61893. };
  61894. /**
  61895. * Specifies if the mesh will require alpha blending
  61896. * @param mesh defines the mesh to check
  61897. * @returns a boolean specifying if alpha blending is needed for the mesh
  61898. */
  61899. Material.prototype.needAlphaBlendingForMesh = function (mesh) {
  61900. return this.needAlphaBlending() || (mesh.visibility < 1.0) || mesh.hasVertexAlpha;
  61901. };
  61902. /**
  61903. * Specifies if this material should be rendered in alpha test mode
  61904. * @returns a boolean specifying if an alpha test is needed.
  61905. */
  61906. Material.prototype.needAlphaTesting = function () {
  61907. return false;
  61908. };
  61909. /**
  61910. * Gets the texture used for the alpha test
  61911. * @returns the texture to use for alpha testing
  61912. */
  61913. Material.prototype.getAlphaTestTexture = function () {
  61914. return null;
  61915. };
  61916. /**
  61917. * Marks the material to indicate that it needs to be re-calculated
  61918. */
  61919. Material.prototype.markDirty = function () {
  61920. this._wasPreviouslyReady = false;
  61921. };
  61922. /** @hidden */
  61923. Material.prototype._preBind = function (effect, overrideOrientation) {
  61924. if (overrideOrientation === void 0) { overrideOrientation = null; }
  61925. var engine = this._scene.getEngine();
  61926. var orientation = (overrideOrientation == null) ? this.sideOrientation : overrideOrientation;
  61927. var reverse = orientation === Material.ClockWiseSideOrientation;
  61928. engine.enableEffect(effect ? effect : this._effect);
  61929. engine.setState(this.backFaceCulling, this.zOffset, false, reverse);
  61930. return reverse;
  61931. };
  61932. /**
  61933. * Binds the material to the mesh
  61934. * @param world defines the world transformation matrix
  61935. * @param mesh defines the mesh to bind the material to
  61936. */
  61937. Material.prototype.bind = function (world, mesh) {
  61938. };
  61939. /**
  61940. * Binds the submesh to the material
  61941. * @param world defines the world transformation matrix
  61942. * @param mesh defines the mesh containing the submesh
  61943. * @param subMesh defines the submesh to bind the material to
  61944. */
  61945. Material.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  61946. };
  61947. /**
  61948. * Binds the world matrix to the material
  61949. * @param world defines the world transformation matrix
  61950. */
  61951. Material.prototype.bindOnlyWorldMatrix = function (world) {
  61952. };
  61953. /**
  61954. * Binds the scene's uniform buffer to the effect.
  61955. * @param effect defines the effect to bind to the scene uniform buffer
  61956. * @param sceneUbo defines the uniform buffer storing scene data
  61957. */
  61958. Material.prototype.bindSceneUniformBuffer = function (effect, sceneUbo) {
  61959. sceneUbo.bindToEffect(effect, "Scene");
  61960. };
  61961. /**
  61962. * Binds the view matrix to the effect
  61963. * @param effect defines the effect to bind the view matrix to
  61964. */
  61965. Material.prototype.bindView = function (effect) {
  61966. if (!this._useUBO) {
  61967. effect.setMatrix("view", this.getScene().getViewMatrix());
  61968. }
  61969. else {
  61970. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  61971. }
  61972. };
  61973. /**
  61974. * Binds the view projection matrix to the effect
  61975. * @param effect defines the effect to bind the view projection matrix to
  61976. */
  61977. Material.prototype.bindViewProjection = function (effect) {
  61978. if (!this._useUBO) {
  61979. effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  61980. }
  61981. else {
  61982. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  61983. }
  61984. };
  61985. /**
  61986. * Specifies if material alpha testing should be turned on for the mesh
  61987. * @param mesh defines the mesh to check
  61988. */
  61989. Material.prototype._shouldTurnAlphaTestOn = function (mesh) {
  61990. return (!this.needAlphaBlendingForMesh(mesh) && this.needAlphaTesting());
  61991. };
  61992. /**
  61993. * Processes to execute after binding the material to a mesh
  61994. * @param mesh defines the rendered mesh
  61995. */
  61996. Material.prototype._afterBind = function (mesh) {
  61997. this._scene._cachedMaterial = this;
  61998. if (mesh) {
  61999. this._scene._cachedVisibility = mesh.visibility;
  62000. }
  62001. else {
  62002. this._scene._cachedVisibility = 1;
  62003. }
  62004. if (this._onBindObservable && mesh) {
  62005. this._onBindObservable.notifyObservers(mesh);
  62006. }
  62007. if (this.disableDepthWrite) {
  62008. var engine = this._scene.getEngine();
  62009. this._cachedDepthWriteState = engine.getDepthWrite();
  62010. engine.setDepthWrite(false);
  62011. }
  62012. };
  62013. /**
  62014. * Unbinds the material from the mesh
  62015. */
  62016. Material.prototype.unbind = function () {
  62017. if (this._onUnBindObservable) {
  62018. this._onUnBindObservable.notifyObservers(this);
  62019. }
  62020. if (this.disableDepthWrite) {
  62021. var engine = this._scene.getEngine();
  62022. engine.setDepthWrite(this._cachedDepthWriteState);
  62023. }
  62024. };
  62025. /**
  62026. * Gets the active textures from the material
  62027. * @returns an array of textures
  62028. */
  62029. Material.prototype.getActiveTextures = function () {
  62030. return [];
  62031. };
  62032. /**
  62033. * Specifies if the material uses a texture
  62034. * @param texture defines the texture to check against the material
  62035. * @returns a boolean specifying if the material uses the texture
  62036. */
  62037. Material.prototype.hasTexture = function (texture) {
  62038. return false;
  62039. };
  62040. /**
  62041. * Makes a duplicate of the material, and gives it a new name
  62042. * @param name defines the new name for the duplicated material
  62043. * @returns the cloned material
  62044. */
  62045. Material.prototype.clone = function (name) {
  62046. return null;
  62047. };
  62048. /**
  62049. * Gets the meshes bound to the material
  62050. * @returns an array of meshes bound to the material
  62051. */
  62052. Material.prototype.getBindedMeshes = function () {
  62053. var _this = this;
  62054. if (this.meshMap) {
  62055. var result = new Array();
  62056. for (var meshId in this.meshMap) {
  62057. var mesh = this.meshMap[meshId];
  62058. if (mesh) {
  62059. result.push(mesh);
  62060. }
  62061. }
  62062. return result;
  62063. }
  62064. else {
  62065. var meshes = this._scene.meshes;
  62066. return meshes.filter(function (mesh) { return mesh.material === _this; });
  62067. }
  62068. };
  62069. /**
  62070. * Force shader compilation
  62071. * @param mesh defines the mesh associated with this material
  62072. * @param onCompiled defines a function to execute once the material is compiled
  62073. * @param options defines the options to configure the compilation
  62074. */
  62075. Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
  62076. var _this = this;
  62077. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  62078. var subMesh = new _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__["BaseSubMesh"]();
  62079. var scene = this.getScene();
  62080. var checkReady = function () {
  62081. if (!_this._scene || !_this._scene.getEngine()) {
  62082. return;
  62083. }
  62084. if (subMesh._materialDefines) {
  62085. subMesh._materialDefines._renderId = -1;
  62086. }
  62087. var clipPlaneState = scene.clipPlane;
  62088. if (localOptions.clipPlane) {
  62089. scene.clipPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"](0, 0, 0, 1);
  62090. }
  62091. if (_this._storeEffectOnSubMeshes) {
  62092. if (_this.isReadyForSubMesh(mesh, subMesh)) {
  62093. if (onCompiled) {
  62094. onCompiled(_this);
  62095. }
  62096. }
  62097. else {
  62098. setTimeout(checkReady, 16);
  62099. }
  62100. }
  62101. else {
  62102. if (_this.isReady()) {
  62103. if (onCompiled) {
  62104. onCompiled(_this);
  62105. }
  62106. }
  62107. else {
  62108. setTimeout(checkReady, 16);
  62109. }
  62110. }
  62111. if (localOptions.clipPlane) {
  62112. scene.clipPlane = clipPlaneState;
  62113. }
  62114. };
  62115. checkReady();
  62116. };
  62117. /**
  62118. * Force shader compilation
  62119. * @param mesh defines the mesh that will use this material
  62120. * @param options defines additional options for compiling the shaders
  62121. * @returns a promise that resolves when the compilation completes
  62122. */
  62123. Material.prototype.forceCompilationAsync = function (mesh, options) {
  62124. var _this = this;
  62125. return new Promise(function (resolve) {
  62126. _this.forceCompilation(mesh, function () {
  62127. resolve();
  62128. }, options);
  62129. });
  62130. };
  62131. /**
  62132. * Marks a define in the material to indicate that it needs to be re-computed
  62133. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  62134. */
  62135. Material.prototype.markAsDirty = function (flag) {
  62136. if (this.getScene().blockMaterialDirtyMechanism) {
  62137. return;
  62138. }
  62139. Material._DirtyCallbackArray.length = 0;
  62140. if (flag & Material.TextureDirtyFlag) {
  62141. Material._DirtyCallbackArray.push(Material._TextureDirtyCallBack);
  62142. }
  62143. if (flag & Material.LightDirtyFlag) {
  62144. Material._DirtyCallbackArray.push(Material._LightsDirtyCallBack);
  62145. }
  62146. if (flag & Material.FresnelDirtyFlag) {
  62147. Material._DirtyCallbackArray.push(Material._FresnelDirtyCallBack);
  62148. }
  62149. if (flag & Material.AttributesDirtyFlag) {
  62150. Material._DirtyCallbackArray.push(Material._AttributeDirtyCallBack);
  62151. }
  62152. if (flag & Material.MiscDirtyFlag) {
  62153. Material._DirtyCallbackArray.push(Material._MiscDirtyCallBack);
  62154. }
  62155. if (Material._DirtyCallbackArray.length) {
  62156. this._markAllSubMeshesAsDirty(Material._RunDirtyCallBacks);
  62157. }
  62158. this.getScene().resetCachedMaterial();
  62159. };
  62160. /**
  62161. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  62162. * @param func defines a function which checks material defines against the submeshes
  62163. */
  62164. Material.prototype._markAllSubMeshesAsDirty = function (func) {
  62165. if (this.getScene().blockMaterialDirtyMechanism) {
  62166. return;
  62167. }
  62168. var meshes = this.getScene().meshes;
  62169. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  62170. var mesh = meshes_1[_i];
  62171. if (!mesh.subMeshes) {
  62172. continue;
  62173. }
  62174. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  62175. var subMesh = _b[_a];
  62176. if (subMesh.getMaterial() !== this) {
  62177. continue;
  62178. }
  62179. if (!subMesh._materialDefines) {
  62180. continue;
  62181. }
  62182. func(subMesh._materialDefines);
  62183. }
  62184. }
  62185. };
  62186. /**
  62187. * Indicates that image processing needs to be re-calculated for all submeshes
  62188. */
  62189. Material.prototype._markAllSubMeshesAsImageProcessingDirty = function () {
  62190. this._markAllSubMeshesAsDirty(Material._ImageProcessingDirtyCallBack);
  62191. };
  62192. /**
  62193. * Indicates that textures need to be re-calculated for all submeshes
  62194. */
  62195. Material.prototype._markAllSubMeshesAsTexturesDirty = function () {
  62196. this._markAllSubMeshesAsDirty(Material._TextureDirtyCallBack);
  62197. };
  62198. /**
  62199. * Indicates that fresnel needs to be re-calculated for all submeshes
  62200. */
  62201. Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
  62202. this._markAllSubMeshesAsDirty(Material._FresnelDirtyCallBack);
  62203. };
  62204. /**
  62205. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  62206. */
  62207. Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
  62208. this._markAllSubMeshesAsDirty(Material._FresnelAndMiscDirtyCallBack);
  62209. };
  62210. /**
  62211. * Indicates that lights need to be re-calculated for all submeshes
  62212. */
  62213. Material.prototype._markAllSubMeshesAsLightsDirty = function () {
  62214. this._markAllSubMeshesAsDirty(Material._LightsDirtyCallBack);
  62215. };
  62216. /**
  62217. * Indicates that attributes need to be re-calculated for all submeshes
  62218. */
  62219. Material.prototype._markAllSubMeshesAsAttributesDirty = function () {
  62220. this._markAllSubMeshesAsDirty(Material._AttributeDirtyCallBack);
  62221. };
  62222. /**
  62223. * Indicates that misc needs to be re-calculated for all submeshes
  62224. */
  62225. Material.prototype._markAllSubMeshesAsMiscDirty = function () {
  62226. this._markAllSubMeshesAsDirty(Material._MiscDirtyCallBack);
  62227. };
  62228. /**
  62229. * Indicates that textures and misc need to be re-calculated for all submeshes
  62230. */
  62231. Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
  62232. this._markAllSubMeshesAsDirty(Material._TextureAndMiscDirtyCallBack);
  62233. };
  62234. /**
  62235. * Disposes the material
  62236. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  62237. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  62238. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  62239. */
  62240. Material.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  62241. var scene = this.getScene();
  62242. // Animations
  62243. scene.stopAnimation(this);
  62244. scene.freeProcessedMaterials();
  62245. // Remove from scene
  62246. scene.removeMaterial(this);
  62247. if (notBoundToMesh !== true) {
  62248. // Remove from meshes
  62249. if (this.meshMap) {
  62250. for (var meshId in this.meshMap) {
  62251. var mesh = this.meshMap[meshId];
  62252. if (mesh) {
  62253. mesh.material = null; // will set the entry in the map to undefined
  62254. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  62255. }
  62256. }
  62257. }
  62258. else {
  62259. var meshes = scene.meshes;
  62260. for (var _i = 0, meshes_2 = meshes; _i < meshes_2.length; _i++) {
  62261. var mesh = meshes_2[_i];
  62262. if (mesh.material === this) {
  62263. mesh.material = null;
  62264. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  62265. }
  62266. }
  62267. }
  62268. }
  62269. this._uniformBuffer.dispose();
  62270. // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
  62271. if (forceDisposeEffect && this._effect) {
  62272. if (!this._storeEffectOnSubMeshes) {
  62273. scene.getEngine()._releaseEffect(this._effect);
  62274. }
  62275. this._effect = null;
  62276. }
  62277. // Callback
  62278. this.onDisposeObservable.notifyObservers(this);
  62279. this.onDisposeObservable.clear();
  62280. if (this._onBindObservable) {
  62281. this._onBindObservable.clear();
  62282. }
  62283. if (this._onUnBindObservable) {
  62284. this._onUnBindObservable.clear();
  62285. }
  62286. };
  62287. /** @hidden */
  62288. Material.prototype.releaseVertexArrayObject = function (mesh, forceDisposeEffect) {
  62289. if (mesh.geometry) {
  62290. var geometry = (mesh.geometry);
  62291. var scene = this.getScene();
  62292. if (this._storeEffectOnSubMeshes) {
  62293. for (var _i = 0, _a = mesh.subMeshes; _i < _a.length; _i++) {
  62294. var subMesh = _a[_i];
  62295. geometry._releaseVertexArrayObject(subMesh._materialEffect);
  62296. if (forceDisposeEffect && subMesh._materialEffect) {
  62297. scene.getEngine()._releaseEffect(subMesh._materialEffect);
  62298. }
  62299. }
  62300. }
  62301. else {
  62302. geometry._releaseVertexArrayObject(this._effect);
  62303. }
  62304. }
  62305. };
  62306. /**
  62307. * Serializes this material
  62308. * @returns the serialized material object
  62309. */
  62310. Material.prototype.serialize = function () {
  62311. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  62312. };
  62313. /**
  62314. * Creates a material from parsed material data
  62315. * @param parsedMaterial defines parsed material data
  62316. * @param scene defines the hosting scene
  62317. * @param rootUrl defines the root URL to use to load textures
  62318. * @returns a new material
  62319. */
  62320. Material.Parse = function (parsedMaterial, scene, rootUrl) {
  62321. if (!parsedMaterial.customType) {
  62322. parsedMaterial.customType = "BABYLON.StandardMaterial";
  62323. }
  62324. else if (parsedMaterial.customType === "BABYLON.PBRMaterial" && parsedMaterial.overloadedAlbedo) {
  62325. parsedMaterial.customType = "BABYLON.LegacyPBRMaterial";
  62326. if (!BABYLON.LegacyPBRMaterial) {
  62327. _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.");
  62328. return;
  62329. }
  62330. }
  62331. var materialType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedMaterial.customType);
  62332. return materialType.Parse(parsedMaterial, scene, rootUrl);
  62333. };
  62334. /**
  62335. * Returns the triangle fill mode
  62336. */
  62337. Material.TriangleFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFillMode;
  62338. /**
  62339. * Returns the wireframe mode
  62340. */
  62341. Material.WireFrameFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_WireFrameFillMode;
  62342. /**
  62343. * Returns the point fill mode
  62344. */
  62345. Material.PointFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointFillMode;
  62346. /**
  62347. * Returns the point list draw mode
  62348. */
  62349. Material.PointListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointListDrawMode;
  62350. /**
  62351. * Returns the line list draw mode
  62352. */
  62353. Material.LineListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineListDrawMode;
  62354. /**
  62355. * Returns the line loop draw mode
  62356. */
  62357. Material.LineLoopDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineLoopDrawMode;
  62358. /**
  62359. * Returns the line strip draw mode
  62360. */
  62361. Material.LineStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineStripDrawMode;
  62362. /**
  62363. * Returns the triangle strip draw mode
  62364. */
  62365. Material.TriangleStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleStripDrawMode;
  62366. /**
  62367. * Returns the triangle fan draw mode
  62368. */
  62369. Material.TriangleFanDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFanDrawMode;
  62370. /**
  62371. * Stores the clock-wise side orientation
  62372. */
  62373. Material.ClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_ClockWiseSideOrientation;
  62374. /**
  62375. * Stores the counter clock-wise side orientation
  62376. */
  62377. Material.CounterClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_CounterClockWiseSideOrientation;
  62378. /**
  62379. * The dirty texture flag value
  62380. */
  62381. Material.TextureDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TextureDirtyFlag;
  62382. /**
  62383. * The dirty light flag value
  62384. */
  62385. Material.LightDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LightDirtyFlag;
  62386. /**
  62387. * The dirty fresnel flag value
  62388. */
  62389. Material.FresnelDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_FresnelDirtyFlag;
  62390. /**
  62391. * The dirty attribute flag value
  62392. */
  62393. Material.AttributesDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AttributesDirtyFlag;
  62394. /**
  62395. * The dirty misc flag value
  62396. */
  62397. Material.MiscDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_MiscDirtyFlag;
  62398. /**
  62399. * The all dirty flag value
  62400. */
  62401. Material.AllDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AllDirtyFlag;
  62402. Material._ImageProcessingDirtyCallBack = function (defines) { return defines.markAsImageProcessingDirty(); };
  62403. Material._TextureDirtyCallBack = function (defines) { return defines.markAsTexturesDirty(); };
  62404. Material._FresnelDirtyCallBack = function (defines) { return defines.markAsFresnelDirty(); };
  62405. Material._MiscDirtyCallBack = function (defines) { return defines.markAsMiscDirty(); };
  62406. Material._LightsDirtyCallBack = function (defines) { return defines.markAsLightDirty(); };
  62407. Material._AttributeDirtyCallBack = function (defines) { return defines.markAsAttributesDirty(); };
  62408. Material._FresnelAndMiscDirtyCallBack = function (defines) {
  62409. Material._FresnelDirtyCallBack(defines);
  62410. Material._MiscDirtyCallBack(defines);
  62411. };
  62412. Material._TextureAndMiscDirtyCallBack = function (defines) {
  62413. Material._TextureDirtyCallBack(defines);
  62414. Material._MiscDirtyCallBack(defines);
  62415. };
  62416. Material._DirtyCallbackArray = [];
  62417. Material._RunDirtyCallBacks = function (defines) {
  62418. for (var _i = 0, _a = Material._DirtyCallbackArray; _i < _a.length; _i++) {
  62419. var cb = _a[_i];
  62420. cb(defines);
  62421. }
  62422. };
  62423. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62424. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62425. ], Material.prototype, "id", void 0);
  62426. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62427. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62428. ], Material.prototype, "uniqueId", void 0);
  62429. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62430. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62431. ], Material.prototype, "name", void 0);
  62432. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62433. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62434. ], Material.prototype, "checkReadyOnEveryCall", void 0);
  62435. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62436. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62437. ], Material.prototype, "checkReadyOnlyOnce", void 0);
  62438. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62439. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62440. ], Material.prototype, "state", void 0);
  62441. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62442. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alpha")
  62443. ], Material.prototype, "_alpha", void 0);
  62444. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62445. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("backFaceCulling")
  62446. ], Material.prototype, "_backFaceCulling", void 0);
  62447. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62448. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62449. ], Material.prototype, "sideOrientation", void 0);
  62450. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62451. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alphaMode")
  62452. ], Material.prototype, "_alphaMode", void 0);
  62453. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62454. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62455. ], Material.prototype, "_needDepthPrePass", void 0);
  62456. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62457. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62458. ], Material.prototype, "disableDepthWrite", void 0);
  62459. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62460. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62461. ], Material.prototype, "forceDepthWrite", void 0);
  62462. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62463. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62464. ], Material.prototype, "separateCullingPass", void 0);
  62465. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62466. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("fogEnabled")
  62467. ], Material.prototype, "_fogEnabled", void 0);
  62468. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62469. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62470. ], Material.prototype, "pointSize", void 0);
  62471. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62472. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62473. ], Material.prototype, "zOffset", void 0);
  62474. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62475. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62476. ], Material.prototype, "wireframe", null);
  62477. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62478. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62479. ], Material.prototype, "pointsCloud", null);
  62480. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62481. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62482. ], Material.prototype, "fillMode", null);
  62483. return Material;
  62484. }());
  62485. /***/ }),
  62486. /***/ "./Materials/materialDefines.ts":
  62487. /*!**************************************!*\
  62488. !*** ./Materials/materialDefines.ts ***!
  62489. \**************************************/
  62490. /*! exports provided: MaterialDefines */
  62491. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62492. "use strict";
  62493. __webpack_require__.r(__webpack_exports__);
  62494. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return MaterialDefines; });
  62495. /**
  62496. * Manages the defines for the Material
  62497. */
  62498. var MaterialDefines = /** @class */ (function () {
  62499. function MaterialDefines() {
  62500. this._isDirty = true;
  62501. /** @hidden */
  62502. this._areLightsDirty = true;
  62503. /** @hidden */
  62504. this._areAttributesDirty = true;
  62505. /** @hidden */
  62506. this._areTexturesDirty = true;
  62507. /** @hidden */
  62508. this._areFresnelDirty = true;
  62509. /** @hidden */
  62510. this._areMiscDirty = true;
  62511. /** @hidden */
  62512. this._areImageProcessingDirty = true;
  62513. /** @hidden */
  62514. this._normals = false;
  62515. /** @hidden */
  62516. this._uvs = false;
  62517. /** @hidden */
  62518. this._needNormals = false;
  62519. /** @hidden */
  62520. this._needUVs = false;
  62521. }
  62522. Object.defineProperty(MaterialDefines.prototype, "isDirty", {
  62523. /**
  62524. * Specifies if the material needs to be re-calculated
  62525. */
  62526. get: function () {
  62527. return this._isDirty;
  62528. },
  62529. enumerable: true,
  62530. configurable: true
  62531. });
  62532. /**
  62533. * Marks the material to indicate that it has been re-calculated
  62534. */
  62535. MaterialDefines.prototype.markAsProcessed = function () {
  62536. this._isDirty = false;
  62537. this._areAttributesDirty = false;
  62538. this._areTexturesDirty = false;
  62539. this._areFresnelDirty = false;
  62540. this._areLightsDirty = false;
  62541. this._areMiscDirty = false;
  62542. this._areImageProcessingDirty = false;
  62543. };
  62544. /**
  62545. * Marks the material to indicate that it needs to be re-calculated
  62546. */
  62547. MaterialDefines.prototype.markAsUnprocessed = function () {
  62548. this._isDirty = true;
  62549. };
  62550. /**
  62551. * Marks the material to indicate all of its defines need to be re-calculated
  62552. */
  62553. MaterialDefines.prototype.markAllAsDirty = function () {
  62554. this._areTexturesDirty = true;
  62555. this._areAttributesDirty = true;
  62556. this._areLightsDirty = true;
  62557. this._areFresnelDirty = true;
  62558. this._areMiscDirty = true;
  62559. this._areImageProcessingDirty = true;
  62560. this._isDirty = true;
  62561. };
  62562. /**
  62563. * Marks the material to indicate that image processing needs to be re-calculated
  62564. */
  62565. MaterialDefines.prototype.markAsImageProcessingDirty = function () {
  62566. this._areImageProcessingDirty = true;
  62567. this._isDirty = true;
  62568. };
  62569. /**
  62570. * Marks the material to indicate the lights need to be re-calculated
  62571. */
  62572. MaterialDefines.prototype.markAsLightDirty = function () {
  62573. this._areLightsDirty = true;
  62574. this._isDirty = true;
  62575. };
  62576. /**
  62577. * Marks the attribute state as changed
  62578. */
  62579. MaterialDefines.prototype.markAsAttributesDirty = function () {
  62580. this._areAttributesDirty = true;
  62581. this._isDirty = true;
  62582. };
  62583. /**
  62584. * Marks the texture state as changed
  62585. */
  62586. MaterialDefines.prototype.markAsTexturesDirty = function () {
  62587. this._areTexturesDirty = true;
  62588. this._isDirty = true;
  62589. };
  62590. /**
  62591. * Marks the fresnel state as changed
  62592. */
  62593. MaterialDefines.prototype.markAsFresnelDirty = function () {
  62594. this._areFresnelDirty = true;
  62595. this._isDirty = true;
  62596. };
  62597. /**
  62598. * Marks the misc state as changed
  62599. */
  62600. MaterialDefines.prototype.markAsMiscDirty = function () {
  62601. this._areMiscDirty = true;
  62602. this._isDirty = true;
  62603. };
  62604. /**
  62605. * Rebuilds the material defines
  62606. */
  62607. MaterialDefines.prototype.rebuild = function () {
  62608. if (this._keys) {
  62609. delete this._keys;
  62610. }
  62611. this._keys = [];
  62612. for (var _i = 0, _a = Object.keys(this); _i < _a.length; _i++) {
  62613. var key = _a[_i];
  62614. if (key[0] === "_") {
  62615. continue;
  62616. }
  62617. this._keys.push(key);
  62618. }
  62619. };
  62620. /**
  62621. * Specifies if two material defines are equal
  62622. * @param other - A material define instance to compare to
  62623. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  62624. */
  62625. MaterialDefines.prototype.isEqual = function (other) {
  62626. if (this._keys.length !== other._keys.length) {
  62627. return false;
  62628. }
  62629. for (var index = 0; index < this._keys.length; index++) {
  62630. var prop = this._keys[index];
  62631. if (this[prop] !== other[prop]) {
  62632. return false;
  62633. }
  62634. }
  62635. return true;
  62636. };
  62637. /**
  62638. * Clones this instance's defines to another instance
  62639. * @param other - material defines to clone values to
  62640. */
  62641. MaterialDefines.prototype.cloneTo = function (other) {
  62642. if (this._keys.length !== other._keys.length) {
  62643. other._keys = this._keys.slice(0);
  62644. }
  62645. for (var index = 0; index < this._keys.length; index++) {
  62646. var prop = this._keys[index];
  62647. other[prop] = this[prop];
  62648. }
  62649. };
  62650. /**
  62651. * Resets the material define values
  62652. */
  62653. MaterialDefines.prototype.reset = function () {
  62654. for (var index = 0; index < this._keys.length; index++) {
  62655. var prop = this._keys[index];
  62656. var type = typeof this[prop];
  62657. switch (type) {
  62658. case "number":
  62659. this[prop] = 0;
  62660. break;
  62661. case "string":
  62662. this[prop] = "";
  62663. break;
  62664. default:
  62665. this[prop] = false;
  62666. break;
  62667. }
  62668. }
  62669. };
  62670. /**
  62671. * Converts the material define values to a string
  62672. * @returns - String of material define information
  62673. */
  62674. MaterialDefines.prototype.toString = function () {
  62675. var result = "";
  62676. for (var index = 0; index < this._keys.length; index++) {
  62677. var prop = this._keys[index];
  62678. var value = this[prop];
  62679. var type = typeof value;
  62680. switch (type) {
  62681. case "number":
  62682. case "string":
  62683. result += "#define " + prop + " " + value + "\n";
  62684. break;
  62685. default:
  62686. if (value) {
  62687. result += "#define " + prop + "\n";
  62688. }
  62689. break;
  62690. }
  62691. }
  62692. return result;
  62693. };
  62694. return MaterialDefines;
  62695. }());
  62696. /***/ }),
  62697. /***/ "./Materials/materialFlags.ts":
  62698. /*!************************************!*\
  62699. !*** ./Materials/materialFlags.ts ***!
  62700. \************************************/
  62701. /*! exports provided: MaterialFlags */
  62702. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62703. "use strict";
  62704. __webpack_require__.r(__webpack_exports__);
  62705. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return MaterialFlags; });
  62706. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  62707. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  62708. /**
  62709. * This groups all the flags used to control the materials channel.
  62710. */
  62711. var MaterialFlags = /** @class */ (function () {
  62712. function MaterialFlags() {
  62713. }
  62714. Object.defineProperty(MaterialFlags, "DiffuseTextureEnabled", {
  62715. /**
  62716. * Are diffuse textures enabled in the application.
  62717. */
  62718. get: function () {
  62719. return this._DiffuseTextureEnabled;
  62720. },
  62721. set: function (value) {
  62722. if (this._DiffuseTextureEnabled === value) {
  62723. return;
  62724. }
  62725. this._DiffuseTextureEnabled = value;
  62726. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62727. },
  62728. enumerable: true,
  62729. configurable: true
  62730. });
  62731. Object.defineProperty(MaterialFlags, "AmbientTextureEnabled", {
  62732. /**
  62733. * Are ambient textures enabled in the application.
  62734. */
  62735. get: function () {
  62736. return this._AmbientTextureEnabled;
  62737. },
  62738. set: function (value) {
  62739. if (this._AmbientTextureEnabled === value) {
  62740. return;
  62741. }
  62742. this._AmbientTextureEnabled = value;
  62743. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62744. },
  62745. enumerable: true,
  62746. configurable: true
  62747. });
  62748. Object.defineProperty(MaterialFlags, "OpacityTextureEnabled", {
  62749. /**
  62750. * Are opacity textures enabled in the application.
  62751. */
  62752. get: function () {
  62753. return this._OpacityTextureEnabled;
  62754. },
  62755. set: function (value) {
  62756. if (this._OpacityTextureEnabled === value) {
  62757. return;
  62758. }
  62759. this._OpacityTextureEnabled = value;
  62760. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62761. },
  62762. enumerable: true,
  62763. configurable: true
  62764. });
  62765. Object.defineProperty(MaterialFlags, "ReflectionTextureEnabled", {
  62766. /**
  62767. * Are reflection textures enabled in the application.
  62768. */
  62769. get: function () {
  62770. return this._ReflectionTextureEnabled;
  62771. },
  62772. set: function (value) {
  62773. if (this._ReflectionTextureEnabled === value) {
  62774. return;
  62775. }
  62776. this._ReflectionTextureEnabled = value;
  62777. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62778. },
  62779. enumerable: true,
  62780. configurable: true
  62781. });
  62782. Object.defineProperty(MaterialFlags, "EmissiveTextureEnabled", {
  62783. /**
  62784. * Are emissive textures enabled in the application.
  62785. */
  62786. get: function () {
  62787. return this._EmissiveTextureEnabled;
  62788. },
  62789. set: function (value) {
  62790. if (this._EmissiveTextureEnabled === value) {
  62791. return;
  62792. }
  62793. this._EmissiveTextureEnabled = value;
  62794. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62795. },
  62796. enumerable: true,
  62797. configurable: true
  62798. });
  62799. Object.defineProperty(MaterialFlags, "SpecularTextureEnabled", {
  62800. /**
  62801. * Are specular textures enabled in the application.
  62802. */
  62803. get: function () {
  62804. return this._SpecularTextureEnabled;
  62805. },
  62806. set: function (value) {
  62807. if (this._SpecularTextureEnabled === value) {
  62808. return;
  62809. }
  62810. this._SpecularTextureEnabled = value;
  62811. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62812. },
  62813. enumerable: true,
  62814. configurable: true
  62815. });
  62816. Object.defineProperty(MaterialFlags, "BumpTextureEnabled", {
  62817. /**
  62818. * Are bump textures enabled in the application.
  62819. */
  62820. get: function () {
  62821. return this._BumpTextureEnabled;
  62822. },
  62823. set: function (value) {
  62824. if (this._BumpTextureEnabled === value) {
  62825. return;
  62826. }
  62827. this._BumpTextureEnabled = value;
  62828. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62829. },
  62830. enumerable: true,
  62831. configurable: true
  62832. });
  62833. Object.defineProperty(MaterialFlags, "LightmapTextureEnabled", {
  62834. /**
  62835. * Are lightmap textures enabled in the application.
  62836. */
  62837. get: function () {
  62838. return this._LightmapTextureEnabled;
  62839. },
  62840. set: function (value) {
  62841. if (this._LightmapTextureEnabled === value) {
  62842. return;
  62843. }
  62844. this._LightmapTextureEnabled = value;
  62845. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62846. },
  62847. enumerable: true,
  62848. configurable: true
  62849. });
  62850. Object.defineProperty(MaterialFlags, "RefractionTextureEnabled", {
  62851. /**
  62852. * Are refraction textures enabled in the application.
  62853. */
  62854. get: function () {
  62855. return this._RefractionTextureEnabled;
  62856. },
  62857. set: function (value) {
  62858. if (this._RefractionTextureEnabled === value) {
  62859. return;
  62860. }
  62861. this._RefractionTextureEnabled = value;
  62862. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62863. },
  62864. enumerable: true,
  62865. configurable: true
  62866. });
  62867. Object.defineProperty(MaterialFlags, "ColorGradingTextureEnabled", {
  62868. /**
  62869. * Are color grading textures enabled in the application.
  62870. */
  62871. get: function () {
  62872. return this._ColorGradingTextureEnabled;
  62873. },
  62874. set: function (value) {
  62875. if (this._ColorGradingTextureEnabled === value) {
  62876. return;
  62877. }
  62878. this._ColorGradingTextureEnabled = value;
  62879. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62880. },
  62881. enumerable: true,
  62882. configurable: true
  62883. });
  62884. Object.defineProperty(MaterialFlags, "FresnelEnabled", {
  62885. /**
  62886. * Are fresnels enabled in the application.
  62887. */
  62888. get: function () {
  62889. return this._FresnelEnabled;
  62890. },
  62891. set: function (value) {
  62892. if (this._FresnelEnabled === value) {
  62893. return;
  62894. }
  62895. this._FresnelEnabled = value;
  62896. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_FresnelDirtyFlag);
  62897. },
  62898. enumerable: true,
  62899. configurable: true
  62900. });
  62901. // Flags used to enable or disable a type of texture for all Standard Materials
  62902. MaterialFlags._DiffuseTextureEnabled = true;
  62903. MaterialFlags._AmbientTextureEnabled = true;
  62904. MaterialFlags._OpacityTextureEnabled = true;
  62905. MaterialFlags._ReflectionTextureEnabled = true;
  62906. MaterialFlags._EmissiveTextureEnabled = true;
  62907. MaterialFlags._SpecularTextureEnabled = true;
  62908. MaterialFlags._BumpTextureEnabled = true;
  62909. MaterialFlags._LightmapTextureEnabled = true;
  62910. MaterialFlags._RefractionTextureEnabled = true;
  62911. MaterialFlags._ColorGradingTextureEnabled = true;
  62912. MaterialFlags._FresnelEnabled = true;
  62913. return MaterialFlags;
  62914. }());
  62915. /***/ }),
  62916. /***/ "./Materials/materialHelper.ts":
  62917. /*!*************************************!*\
  62918. !*** ./Materials/materialHelper.ts ***!
  62919. \*************************************/
  62920. /*! exports provided: MaterialHelper */
  62921. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62922. "use strict";
  62923. __webpack_require__.r(__webpack_exports__);
  62924. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return MaterialHelper; });
  62925. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  62926. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  62927. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  62928. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  62929. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  62930. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Lights/light */ "./Lights/light.ts");
  62931. /**
  62932. * "Static Class" containing the most commonly used helper while dealing with material for
  62933. * rendering purpose.
  62934. *
  62935. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  62936. *
  62937. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  62938. */
  62939. var MaterialHelper = /** @class */ (function () {
  62940. function MaterialHelper() {
  62941. }
  62942. /**
  62943. * Bind the current view position to an effect.
  62944. * @param effect The effect to be bound
  62945. * @param scene The scene the eyes position is used from
  62946. */
  62947. MaterialHelper.BindEyePosition = function (effect, scene) {
  62948. if (scene._forcedViewPosition) {
  62949. effect.setVector3("vEyePosition", scene._forcedViewPosition);
  62950. return;
  62951. }
  62952. effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  62953. };
  62954. /**
  62955. * Helps preparing the defines values about the UVs in used in the effect.
  62956. * UVs are shared as much as we can accross channels in the shaders.
  62957. * @param texture The texture we are preparing the UVs for
  62958. * @param defines The defines to update
  62959. * @param key The channel key "diffuse", "specular"... used in the shader
  62960. */
  62961. MaterialHelper.PrepareDefinesForMergedUV = function (texture, defines, key) {
  62962. defines._needUVs = true;
  62963. defines[key] = true;
  62964. if (texture.getTextureMatrix().isIdentityAs3x2()) {
  62965. defines[key + "DIRECTUV"] = texture.coordinatesIndex + 1;
  62966. if (texture.coordinatesIndex === 0) {
  62967. defines["MAINUV1"] = true;
  62968. }
  62969. else {
  62970. defines["MAINUV2"] = true;
  62971. }
  62972. }
  62973. else {
  62974. defines[key + "DIRECTUV"] = 0;
  62975. }
  62976. };
  62977. /**
  62978. * Binds a texture matrix value to its corrsponding uniform
  62979. * @param texture The texture to bind the matrix for
  62980. * @param uniformBuffer The uniform buffer receivin the data
  62981. * @param key The channel key "diffuse", "specular"... used in the shader
  62982. */
  62983. MaterialHelper.BindTextureMatrix = function (texture, uniformBuffer, key) {
  62984. var matrix = texture.getTextureMatrix();
  62985. if (!matrix.isIdentityAs3x2()) {
  62986. uniformBuffer.updateMatrix(key + "Matrix", matrix);
  62987. }
  62988. };
  62989. /**
  62990. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  62991. * @param mesh defines the current mesh
  62992. * @param scene defines the current scene
  62993. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  62994. * @param pointsCloud defines if point cloud rendering has to be turned on
  62995. * @param fogEnabled defines if fog has to be turned on
  62996. * @param alphaTest defines if alpha testing has to be turned on
  62997. * @param defines defines the current list of defines
  62998. */
  62999. MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines) {
  63000. if (defines._areMiscDirty) {
  63001. defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
  63002. defines["POINTSIZE"] = pointsCloud;
  63003. defines["FOG"] = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE && fogEnabled);
  63004. defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
  63005. defines["ALPHATEST"] = alphaTest;
  63006. }
  63007. };
  63008. /**
  63009. * Helper used to prepare the list of defines associated with frame values for shader compilation
  63010. * @param scene defines the current scene
  63011. * @param engine defines the current engine
  63012. * @param defines specifies the list of active defines
  63013. * @param useInstances defines if instances have to be turned on
  63014. * @param useClipPlane defines if clip plane have to be turned on
  63015. */
  63016. MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances, useClipPlane) {
  63017. if (useClipPlane === void 0) { useClipPlane = null; }
  63018. var changed = false;
  63019. var useClipPlane1 = false;
  63020. var useClipPlane2 = false;
  63021. var useClipPlane3 = false;
  63022. var useClipPlane4 = false;
  63023. useClipPlane1 = useClipPlane == null ? (scene.clipPlane !== undefined && scene.clipPlane !== null) : useClipPlane;
  63024. useClipPlane2 = useClipPlane == null ? (scene.clipPlane2 !== undefined && scene.clipPlane2 !== null) : useClipPlane;
  63025. useClipPlane3 = useClipPlane == null ? (scene.clipPlane3 !== undefined && scene.clipPlane3 !== null) : useClipPlane;
  63026. useClipPlane4 = useClipPlane == null ? (scene.clipPlane4 !== undefined && scene.clipPlane4 !== null) : useClipPlane;
  63027. if (defines["CLIPPLANE"] !== useClipPlane1) {
  63028. defines["CLIPPLANE"] = useClipPlane1;
  63029. changed = true;
  63030. }
  63031. if (defines["CLIPPLANE2"] !== useClipPlane2) {
  63032. defines["CLIPPLANE2"] = useClipPlane2;
  63033. changed = true;
  63034. }
  63035. if (defines["CLIPPLANE3"] !== useClipPlane3) {
  63036. defines["CLIPPLANE3"] = useClipPlane3;
  63037. changed = true;
  63038. }
  63039. if (defines["CLIPPLANE4"] !== useClipPlane4) {
  63040. defines["CLIPPLANE4"] = useClipPlane4;
  63041. changed = true;
  63042. }
  63043. if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
  63044. defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
  63045. changed = true;
  63046. }
  63047. if (defines["INSTANCES"] !== useInstances) {
  63048. defines["INSTANCES"] = useInstances;
  63049. changed = true;
  63050. }
  63051. if (changed) {
  63052. defines.markAsUnprocessed();
  63053. }
  63054. };
  63055. /**
  63056. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  63057. * @param mesh The mesh containing the geometry data we will draw
  63058. * @param defines The defines to update
  63059. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  63060. * @param useBones Precise whether bones should be used or not (override mesh info)
  63061. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  63062. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  63063. * @returns false if defines are considered not dirty and have not been checked
  63064. */
  63065. MaterialHelper.PrepareDefinesForAttributes = function (mesh, defines, useVertexColor, useBones, useMorphTargets, useVertexAlpha) {
  63066. if (useMorphTargets === void 0) { useMorphTargets = false; }
  63067. if (useVertexAlpha === void 0) { useVertexAlpha = true; }
  63068. if (!defines._areAttributesDirty && defines._needNormals === defines._normals && defines._needUVs === defines._uvs) {
  63069. return false;
  63070. }
  63071. defines._normals = defines._needNormals;
  63072. defines._uvs = defines._needUVs;
  63073. defines["NORMAL"] = (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind));
  63074. if (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind)) {
  63075. defines["TANGENT"] = true;
  63076. }
  63077. if (defines._needUVs) {
  63078. defines["UV1"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  63079. defines["UV2"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  63080. }
  63081. else {
  63082. defines["UV1"] = false;
  63083. defines["UV2"] = false;
  63084. }
  63085. if (useVertexColor) {
  63086. var hasVertexColors = mesh.useVertexColors && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  63087. defines["VERTEXCOLOR"] = hasVertexColors;
  63088. defines["VERTEXALPHA"] = mesh.hasVertexAlpha && hasVertexColors && useVertexAlpha;
  63089. }
  63090. if (useBones) {
  63091. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  63092. defines["NUM_BONE_INFLUENCERS"] = mesh.numBoneInfluencers;
  63093. var materialSupportsBoneTexture = defines["BONETEXTURE"] !== undefined;
  63094. if (mesh.skeleton.isUsingTextureForMatrices && materialSupportsBoneTexture) {
  63095. defines["BONETEXTURE"] = true;
  63096. }
  63097. else {
  63098. defines["BonesPerMesh"] = (mesh.skeleton.bones.length + 1);
  63099. defines["BONETEXTURE"] = materialSupportsBoneTexture ? false : undefined;
  63100. }
  63101. }
  63102. else {
  63103. defines["NUM_BONE_INFLUENCERS"] = 0;
  63104. defines["BonesPerMesh"] = 0;
  63105. }
  63106. }
  63107. if (useMorphTargets) {
  63108. var manager = mesh.morphTargetManager;
  63109. if (manager) {
  63110. defines["MORPHTARGETS_TANGENT"] = manager.supportsTangents && defines["TANGENT"];
  63111. defines["MORPHTARGETS_NORMAL"] = manager.supportsNormals && defines["NORMAL"];
  63112. defines["MORPHTARGETS"] = (manager.numInfluencers > 0);
  63113. defines["NUM_MORPH_INFLUENCERS"] = manager.numInfluencers;
  63114. }
  63115. else {
  63116. defines["MORPHTARGETS_TANGENT"] = false;
  63117. defines["MORPHTARGETS_NORMAL"] = false;
  63118. defines["MORPHTARGETS"] = false;
  63119. defines["NUM_MORPH_INFLUENCERS"] = 0;
  63120. }
  63121. }
  63122. return true;
  63123. };
  63124. /**
  63125. * Prepares the defines related to the light information passed in parameter
  63126. * @param scene The scene we are intending to draw
  63127. * @param mesh The mesh the effect is compiling for
  63128. * @param defines The defines to update
  63129. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  63130. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  63131. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  63132. * @returns true if normals will be required for the rest of the effect
  63133. */
  63134. MaterialHelper.PrepareDefinesForLights = function (scene, mesh, defines, specularSupported, maxSimultaneousLights, disableLighting) {
  63135. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  63136. if (disableLighting === void 0) { disableLighting = false; }
  63137. if (!defines._areLightsDirty) {
  63138. return defines._needNormals;
  63139. }
  63140. var lightIndex = 0;
  63141. var needNormals = false;
  63142. var needRebuild = false;
  63143. var lightmapMode = false;
  63144. var shadowEnabled = false;
  63145. var specularEnabled = false;
  63146. if (scene.lightsEnabled && !disableLighting) {
  63147. for (var _i = 0, _a = mesh._lightSources; _i < _a.length; _i++) {
  63148. var light = _a[_i];
  63149. needNormals = true;
  63150. if (defines["LIGHT" + lightIndex] === undefined) {
  63151. needRebuild = true;
  63152. }
  63153. defines["LIGHT" + lightIndex] = true;
  63154. defines["SPOTLIGHT" + lightIndex] = false;
  63155. defines["HEMILIGHT" + lightIndex] = false;
  63156. defines["POINTLIGHT" + lightIndex] = false;
  63157. defines["DIRLIGHT" + lightIndex] = false;
  63158. light.prepareLightSpecificDefines(defines, lightIndex);
  63159. // FallOff.
  63160. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = false;
  63161. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = false;
  63162. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = false;
  63163. switch (light.falloffType) {
  63164. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_GLTF:
  63165. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = true;
  63166. break;
  63167. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_PHYSICAL:
  63168. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = true;
  63169. break;
  63170. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_STANDARD:
  63171. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = true;
  63172. break;
  63173. }
  63174. // Specular
  63175. if (specularSupported && !light.specular.equalsFloats(0, 0, 0)) {
  63176. specularEnabled = true;
  63177. }
  63178. // Shadows
  63179. defines["SHADOW" + lightIndex] = false;
  63180. defines["SHADOWPCF" + lightIndex] = false;
  63181. defines["SHADOWPCSS" + lightIndex] = false;
  63182. defines["SHADOWPOISSON" + lightIndex] = false;
  63183. defines["SHADOWESM" + lightIndex] = false;
  63184. defines["SHADOWCUBE" + lightIndex] = false;
  63185. defines["SHADOWLOWQUALITY" + lightIndex] = false;
  63186. defines["SHADOWMEDIUMQUALITY" + lightIndex] = false;
  63187. if (mesh && mesh.receiveShadows && scene.shadowsEnabled && light.shadowEnabled) {
  63188. var shadowGenerator = light.getShadowGenerator();
  63189. if (shadowGenerator) {
  63190. var shadowMap = shadowGenerator.getShadowMap();
  63191. if (shadowMap) {
  63192. if (shadowMap.renderList && shadowMap.renderList.length > 0) {
  63193. shadowEnabled = true;
  63194. shadowGenerator.prepareDefines(defines, lightIndex);
  63195. }
  63196. }
  63197. }
  63198. }
  63199. if (light.lightmapMode != _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_DEFAULT) {
  63200. lightmapMode = true;
  63201. defines["LIGHTMAPEXCLUDED" + lightIndex] = true;
  63202. defines["LIGHTMAPNOSPECULAR" + lightIndex] = (light.lightmapMode == _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_SHADOWSONLY);
  63203. }
  63204. else {
  63205. defines["LIGHTMAPEXCLUDED" + lightIndex] = false;
  63206. defines["LIGHTMAPNOSPECULAR" + lightIndex] = false;
  63207. }
  63208. lightIndex++;
  63209. if (lightIndex === maxSimultaneousLights) {
  63210. break;
  63211. }
  63212. }
  63213. }
  63214. defines["SPECULARTERM"] = specularEnabled;
  63215. defines["SHADOWS"] = shadowEnabled;
  63216. // Resetting all other lights if any
  63217. for (var index = lightIndex; index < maxSimultaneousLights; index++) {
  63218. if (defines["LIGHT" + index] !== undefined) {
  63219. defines["LIGHT" + index] = false;
  63220. defines["HEMILIGHT" + lightIndex] = false;
  63221. defines["POINTLIGHT" + lightIndex] = false;
  63222. defines["DIRLIGHT" + lightIndex] = false;
  63223. defines["SPOTLIGHT" + lightIndex] = false;
  63224. defines["SHADOW" + lightIndex] = false;
  63225. }
  63226. }
  63227. var caps = scene.getEngine().getCaps();
  63228. if (defines["SHADOWFLOAT"] === undefined) {
  63229. needRebuild = true;
  63230. }
  63231. defines["SHADOWFLOAT"] = shadowEnabled &&
  63232. ((caps.textureFloatRender && caps.textureFloatLinearFiltering) ||
  63233. (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering));
  63234. defines["LIGHTMAPEXCLUDED"] = lightmapMode;
  63235. if (needRebuild) {
  63236. defines.rebuild();
  63237. }
  63238. return needNormals;
  63239. };
  63240. /**
  63241. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  63242. * that won t be acctive due to defines being turned off.
  63243. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  63244. * @param samplersList The samplers list
  63245. * @param defines The defines helping in the list generation
  63246. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  63247. */
  63248. MaterialHelper.PrepareUniformsAndSamplersList = function (uniformsListOrOptions, samplersList, defines, maxSimultaneousLights) {
  63249. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  63250. var uniformsList;
  63251. var uniformBuffersList = null;
  63252. if (uniformsListOrOptions.uniformsNames) {
  63253. var options = uniformsListOrOptions;
  63254. uniformsList = options.uniformsNames;
  63255. uniformBuffersList = options.uniformBuffersNames;
  63256. samplersList = options.samplers;
  63257. defines = options.defines;
  63258. maxSimultaneousLights = options.maxSimultaneousLights;
  63259. }
  63260. else {
  63261. uniformsList = uniformsListOrOptions;
  63262. if (!samplersList) {
  63263. samplersList = [];
  63264. }
  63265. }
  63266. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  63267. if (!defines["LIGHT" + lightIndex]) {
  63268. break;
  63269. }
  63270. uniformsList.push("vLightData" + lightIndex, "vLightDiffuse" + lightIndex, "vLightSpecular" + lightIndex, "vLightDirection" + lightIndex, "vLightFalloff" + lightIndex, "vLightGround" + lightIndex, "lightMatrix" + lightIndex, "shadowsInfo" + lightIndex, "depthValues" + lightIndex);
  63271. if (uniformBuffersList) {
  63272. uniformBuffersList.push("Light" + lightIndex);
  63273. }
  63274. samplersList.push("shadowSampler" + lightIndex);
  63275. samplersList.push("depthSampler" + lightIndex);
  63276. if (defines["PROJECTEDLIGHTTEXTURE" + lightIndex]) {
  63277. samplersList.push("projectionLightSampler" + lightIndex);
  63278. uniformsList.push("textureProjectionMatrix" + lightIndex);
  63279. }
  63280. }
  63281. if (defines["NUM_MORPH_INFLUENCERS"]) {
  63282. uniformsList.push("morphTargetInfluences");
  63283. }
  63284. };
  63285. /**
  63286. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  63287. * @param defines The defines to update while falling back
  63288. * @param fallbacks The authorized effect fallbacks
  63289. * @param maxSimultaneousLights The maximum number of lights allowed
  63290. * @param rank the current rank of the Effect
  63291. * @returns The newly affected rank
  63292. */
  63293. MaterialHelper.HandleFallbacksForShadows = function (defines, fallbacks, maxSimultaneousLights, rank) {
  63294. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  63295. if (rank === void 0) { rank = 0; }
  63296. var lightFallbackRank = 0;
  63297. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  63298. if (!defines["LIGHT" + lightIndex]) {
  63299. break;
  63300. }
  63301. if (lightIndex > 0) {
  63302. lightFallbackRank = rank + lightIndex;
  63303. fallbacks.addFallback(lightFallbackRank, "LIGHT" + lightIndex);
  63304. }
  63305. if (!defines["SHADOWS"]) {
  63306. if (defines["SHADOW" + lightIndex]) {
  63307. fallbacks.addFallback(rank, "SHADOW" + lightIndex);
  63308. }
  63309. if (defines["SHADOWPCF" + lightIndex]) {
  63310. fallbacks.addFallback(rank, "SHADOWPCF" + lightIndex);
  63311. }
  63312. if (defines["SHADOWPCSS" + lightIndex]) {
  63313. fallbacks.addFallback(rank, "SHADOWPCSS" + lightIndex);
  63314. }
  63315. if (defines["SHADOWPOISSON" + lightIndex]) {
  63316. fallbacks.addFallback(rank, "SHADOWPOISSON" + lightIndex);
  63317. }
  63318. if (defines["SHADOWESM" + lightIndex]) {
  63319. fallbacks.addFallback(rank, "SHADOWESM" + lightIndex);
  63320. }
  63321. }
  63322. }
  63323. return lightFallbackRank++;
  63324. };
  63325. /**
  63326. * Prepares the list of attributes required for morph targets according to the effect defines.
  63327. * @param attribs The current list of supported attribs
  63328. * @param mesh The mesh to prepare the morph targets attributes for
  63329. * @param defines The current Defines of the effect
  63330. */
  63331. MaterialHelper.PrepareAttributesForMorphTargets = function (attribs, mesh, defines) {
  63332. var influencers = defines["NUM_MORPH_INFLUENCERS"];
  63333. if (influencers > 0 && _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine) {
  63334. var maxAttributesCount = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine.getCaps().maxVertexAttribs;
  63335. var manager = mesh.morphTargetManager;
  63336. var normal = manager && manager.supportsNormals && defines["NORMAL"];
  63337. var tangent = manager && manager.supportsTangents && defines["TANGENT"];
  63338. for (var index = 0; index < influencers; index++) {
  63339. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind + index);
  63340. if (normal) {
  63341. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind + index);
  63342. }
  63343. if (tangent) {
  63344. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind + index);
  63345. }
  63346. if (attribs.length > maxAttributesCount) {
  63347. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add more vertex attributes for mesh " + mesh.name);
  63348. }
  63349. }
  63350. }
  63351. };
  63352. /**
  63353. * Prepares the list of attributes required for bones according to the effect defines.
  63354. * @param attribs The current list of supported attribs
  63355. * @param mesh The mesh to prepare the bones attributes for
  63356. * @param defines The current Defines of the effect
  63357. * @param fallbacks The current efffect fallback strategy
  63358. */
  63359. MaterialHelper.PrepareAttributesForBones = function (attribs, mesh, defines, fallbacks) {
  63360. if (defines["NUM_BONE_INFLUENCERS"] > 0) {
  63361. fallbacks.addCPUSkinningFallback(0, mesh);
  63362. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  63363. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  63364. if (defines["NUM_BONE_INFLUENCERS"] > 4) {
  63365. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesExtraKind);
  63366. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsExtraKind);
  63367. }
  63368. }
  63369. };
  63370. /**
  63371. * Prepares the list of attributes required for instances according to the effect defines.
  63372. * @param attribs The current list of supported attribs
  63373. * @param defines The current Defines of the effect
  63374. */
  63375. MaterialHelper.PrepareAttributesForInstances = function (attribs, defines) {
  63376. if (defines["INSTANCES"]) {
  63377. attribs.push("world0");
  63378. attribs.push("world1");
  63379. attribs.push("world2");
  63380. attribs.push("world3");
  63381. }
  63382. };
  63383. /**
  63384. * Binds the light shadow information to the effect for the given mesh.
  63385. * @param light The light containing the generator
  63386. * @param scene The scene the lights belongs to
  63387. * @param mesh The mesh we are binding the information to render
  63388. * @param lightIndex The light index in the effect used to render the mesh
  63389. * @param effect The effect we are binding the data to
  63390. */
  63391. MaterialHelper.BindLightShadow = function (light, mesh, lightIndex, effect) {
  63392. if (light.shadowEnabled && mesh.receiveShadows) {
  63393. var shadowGenerator = light.getShadowGenerator();
  63394. if (shadowGenerator) {
  63395. shadowGenerator.bindShadowLight(lightIndex, effect);
  63396. }
  63397. }
  63398. };
  63399. /**
  63400. * Binds the light information to the effect.
  63401. * @param light The light containing the generator
  63402. * @param effect The effect we are binding the data to
  63403. * @param lightIndex The light index in the effect used to render
  63404. */
  63405. MaterialHelper.BindLightProperties = function (light, effect, lightIndex) {
  63406. light.transferToEffect(effect, lightIndex + "");
  63407. };
  63408. /**
  63409. * Binds the lights information from the scene to the effect for the given mesh.
  63410. * @param scene The scene the lights belongs to
  63411. * @param mesh The mesh we are binding the information to render
  63412. * @param effect The effect we are binding the data to
  63413. * @param defines The generated defines for the effect
  63414. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  63415. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  63416. */
  63417. MaterialHelper.BindLights = function (scene, mesh, effect, defines, maxSimultaneousLights, usePhysicalLightFalloff) {
  63418. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  63419. if (usePhysicalLightFalloff === void 0) { usePhysicalLightFalloff = false; }
  63420. var len = Math.min(mesh._lightSources.length, maxSimultaneousLights);
  63421. for (var i = 0; i < len; i++) {
  63422. var light = mesh._lightSources[i];
  63423. var iAsString = i.toString();
  63424. var scaledIntensity = light.getScaledIntensity();
  63425. light._uniformBuffer.bindToEffect(effect, "Light" + i);
  63426. MaterialHelper.BindLightProperties(light, effect, i);
  63427. light.diffuse.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0]);
  63428. light._uniformBuffer.updateColor4("vLightDiffuse", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0], usePhysicalLightFalloff ? light.radius : light.range, iAsString);
  63429. if (defines["SPECULARTERM"]) {
  63430. light.specular.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1]);
  63431. light._uniformBuffer.updateColor3("vLightSpecular", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1], iAsString);
  63432. }
  63433. // Shadows
  63434. if (scene.shadowsEnabled) {
  63435. this.BindLightShadow(light, mesh, iAsString, effect);
  63436. }
  63437. light._uniformBuffer.update();
  63438. }
  63439. };
  63440. /**
  63441. * Binds the fog information from the scene to the effect for the given mesh.
  63442. * @param scene The scene the lights belongs to
  63443. * @param mesh The mesh we are binding the information to render
  63444. * @param effect The effect we are binding the data to
  63445. * @param linearSpace Defines if the fog effect is applied in linear space
  63446. */
  63447. MaterialHelper.BindFogParameters = function (scene, mesh, effect, linearSpace) {
  63448. if (linearSpace === void 0) { linearSpace = false; }
  63449. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
  63450. effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
  63451. // Convert fog color to linear space if used in a linear space computed shader.
  63452. if (linearSpace) {
  63453. scene.fogColor.toLinearSpaceToRef(this._tempFogColor);
  63454. effect.setColor3("vFogColor", this._tempFogColor);
  63455. }
  63456. else {
  63457. effect.setColor3("vFogColor", scene.fogColor);
  63458. }
  63459. }
  63460. };
  63461. /**
  63462. * Binds the bones information from the mesh to the effect.
  63463. * @param mesh The mesh we are binding the information to render
  63464. * @param effect The effect we are binding the data to
  63465. */
  63466. MaterialHelper.BindBonesParameters = function (mesh, effect) {
  63467. if (!effect || !mesh) {
  63468. return;
  63469. }
  63470. if (mesh.computeBonesUsingShaders && effect._bonesComputationForcedToCPU) {
  63471. mesh.computeBonesUsingShaders = false;
  63472. }
  63473. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  63474. var skeleton = mesh.skeleton;
  63475. if (skeleton.isUsingTextureForMatrices && effect.getUniformIndex("boneTextureWidth") > -1) {
  63476. var boneTexture = skeleton.getTransformMatrixTexture();
  63477. effect.setTexture("boneSampler", boneTexture);
  63478. effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  63479. }
  63480. else {
  63481. var matrices = skeleton.getTransformMatrices(mesh);
  63482. if (matrices) {
  63483. effect.setMatrices("mBones", matrices);
  63484. }
  63485. }
  63486. }
  63487. };
  63488. /**
  63489. * Binds the morph targets information from the mesh to the effect.
  63490. * @param abstractMesh The mesh we are binding the information to render
  63491. * @param effect The effect we are binding the data to
  63492. */
  63493. MaterialHelper.BindMorphTargetParameters = function (abstractMesh, effect) {
  63494. var manager = abstractMesh.morphTargetManager;
  63495. if (!abstractMesh || !manager) {
  63496. return;
  63497. }
  63498. effect.setFloatArray("morphTargetInfluences", manager.influences);
  63499. };
  63500. /**
  63501. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  63502. * @param defines The generated defines used in the effect
  63503. * @param effect The effect we are binding the data to
  63504. * @param scene The scene we are willing to render with logarithmic scale for
  63505. */
  63506. MaterialHelper.BindLogDepth = function (defines, effect, scene) {
  63507. if (defines["LOGARITHMICDEPTH"]) {
  63508. effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  63509. }
  63510. };
  63511. /**
  63512. * Binds the clip plane information from the scene to the effect.
  63513. * @param scene The scene the clip plane information are extracted from
  63514. * @param effect The effect we are binding the data to
  63515. */
  63516. MaterialHelper.BindClipPlane = function (effect, scene) {
  63517. if (scene.clipPlane) {
  63518. var clipPlane = scene.clipPlane;
  63519. effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  63520. }
  63521. if (scene.clipPlane2) {
  63522. var clipPlane = scene.clipPlane2;
  63523. effect.setFloat4("vClipPlane2", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  63524. }
  63525. if (scene.clipPlane3) {
  63526. var clipPlane = scene.clipPlane3;
  63527. effect.setFloat4("vClipPlane3", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  63528. }
  63529. if (scene.clipPlane4) {
  63530. var clipPlane = scene.clipPlane4;
  63531. effect.setFloat4("vClipPlane4", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  63532. }
  63533. };
  63534. MaterialHelper._tempFogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  63535. return MaterialHelper;
  63536. }());
  63537. /***/ }),
  63538. /***/ "./Materials/multiMaterial.ts":
  63539. /*!************************************!*\
  63540. !*** ./Materials/multiMaterial.ts ***!
  63541. \************************************/
  63542. /*! exports provided: MultiMaterial */
  63543. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63544. "use strict";
  63545. __webpack_require__.r(__webpack_exports__);
  63546. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return MultiMaterial; });
  63547. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  63548. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  63549. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  63550. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  63551. /**
  63552. * A multi-material is used to apply different materials to different parts of the same object without the need of
  63553. * separate meshes. This can be use to improve performances.
  63554. * @see http://doc.babylonjs.com/how_to/multi_materials
  63555. */
  63556. var MultiMaterial = /** @class */ (function (_super) {
  63557. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiMaterial, _super);
  63558. /**
  63559. * Instantiates a new Multi Material
  63560. * A multi-material is used to apply different materials to different parts of the same object without the need of
  63561. * separate meshes. This can be use to improve performances.
  63562. * @see http://doc.babylonjs.com/how_to/multi_materials
  63563. * @param name Define the name in the scene
  63564. * @param scene Define the scene the material belongs to
  63565. */
  63566. function MultiMaterial(name, scene) {
  63567. var _this = _super.call(this, name, scene, true) || this;
  63568. scene.multiMaterials.push(_this);
  63569. _this.subMaterials = new Array();
  63570. _this._storeEffectOnSubMeshes = true; // multimaterial is considered like a push material
  63571. return _this;
  63572. }
  63573. Object.defineProperty(MultiMaterial.prototype, "subMaterials", {
  63574. /**
  63575. * Gets or Sets the list of Materials used within the multi material.
  63576. * They need to be ordered according to the submeshes order in the associated mesh
  63577. */
  63578. get: function () {
  63579. return this._subMaterials;
  63580. },
  63581. set: function (value) {
  63582. this._subMaterials = value;
  63583. this._hookArray(value);
  63584. },
  63585. enumerable: true,
  63586. configurable: true
  63587. });
  63588. /**
  63589. * Function used to align with Node.getChildren()
  63590. * @returns the list of Materials used within the multi material
  63591. */
  63592. MultiMaterial.prototype.getChildren = function () {
  63593. return this.subMaterials;
  63594. };
  63595. MultiMaterial.prototype._hookArray = function (array) {
  63596. var _this = this;
  63597. var oldPush = array.push;
  63598. array.push = function () {
  63599. var items = [];
  63600. for (var _i = 0; _i < arguments.length; _i++) {
  63601. items[_i] = arguments[_i];
  63602. }
  63603. var result = oldPush.apply(array, items);
  63604. _this._markAllSubMeshesAsTexturesDirty();
  63605. return result;
  63606. };
  63607. var oldSplice = array.splice;
  63608. array.splice = function (index, deleteCount) {
  63609. var deleted = oldSplice.apply(array, [index, deleteCount]);
  63610. _this._markAllSubMeshesAsTexturesDirty();
  63611. return deleted;
  63612. };
  63613. };
  63614. /**
  63615. * Get one of the submaterial by its index in the submaterials array
  63616. * @param index The index to look the sub material at
  63617. * @returns The Material if the index has been defined
  63618. */
  63619. MultiMaterial.prototype.getSubMaterial = function (index) {
  63620. if (index < 0 || index >= this.subMaterials.length) {
  63621. return this.getScene().defaultMaterial;
  63622. }
  63623. return this.subMaterials[index];
  63624. };
  63625. /**
  63626. * Get the list of active textures for the whole sub materials list.
  63627. * @returns All the textures that will be used during the rendering
  63628. */
  63629. MultiMaterial.prototype.getActiveTextures = function () {
  63630. var _a;
  63631. return (_a = _super.prototype.getActiveTextures.call(this)).concat.apply(_a, this.subMaterials.map(function (subMaterial) {
  63632. if (subMaterial) {
  63633. return subMaterial.getActiveTextures();
  63634. }
  63635. else {
  63636. return [];
  63637. }
  63638. }));
  63639. };
  63640. /**
  63641. * Gets the current class name of the material e.g. "MultiMaterial"
  63642. * Mainly use in serialization.
  63643. * @returns the class name
  63644. */
  63645. MultiMaterial.prototype.getClassName = function () {
  63646. return "MultiMaterial";
  63647. };
  63648. /**
  63649. * Checks if the material is ready to render the requested sub mesh
  63650. * @param mesh Define the mesh the submesh belongs to
  63651. * @param subMesh Define the sub mesh to look readyness for
  63652. * @param useInstances Define whether or not the material is used with instances
  63653. * @returns true if ready, otherwise false
  63654. */
  63655. MultiMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  63656. for (var index = 0; index < this.subMaterials.length; index++) {
  63657. var subMaterial = this.subMaterials[index];
  63658. if (subMaterial) {
  63659. if (subMaterial._storeEffectOnSubMeshes) {
  63660. if (!subMaterial.isReadyForSubMesh(mesh, subMesh, useInstances)) {
  63661. return false;
  63662. }
  63663. continue;
  63664. }
  63665. if (!subMaterial.isReady(mesh)) {
  63666. return false;
  63667. }
  63668. }
  63669. }
  63670. return true;
  63671. };
  63672. /**
  63673. * Clones the current material and its related sub materials
  63674. * @param name Define the name of the newly cloned material
  63675. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  63676. * @returns the cloned material
  63677. */
  63678. MultiMaterial.prototype.clone = function (name, cloneChildren) {
  63679. var newMultiMaterial = new MultiMaterial(name, this.getScene());
  63680. for (var index = 0; index < this.subMaterials.length; index++) {
  63681. var subMaterial = null;
  63682. var current = this.subMaterials[index];
  63683. if (cloneChildren && current) {
  63684. subMaterial = current.clone(name + "-" + current.name);
  63685. }
  63686. else {
  63687. subMaterial = this.subMaterials[index];
  63688. }
  63689. newMultiMaterial.subMaterials.push(subMaterial);
  63690. }
  63691. return newMultiMaterial;
  63692. };
  63693. /**
  63694. * Serializes the materials into a JSON representation.
  63695. * @returns the JSON representation
  63696. */
  63697. MultiMaterial.prototype.serialize = function () {
  63698. var serializationObject = {};
  63699. serializationObject.name = this.name;
  63700. serializationObject.id = this.id;
  63701. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  63702. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].GetTags(this);
  63703. }
  63704. serializationObject.materials = [];
  63705. for (var matIndex = 0; matIndex < this.subMaterials.length; matIndex++) {
  63706. var subMat = this.subMaterials[matIndex];
  63707. if (subMat) {
  63708. serializationObject.materials.push(subMat.id);
  63709. }
  63710. else {
  63711. serializationObject.materials.push(null);
  63712. }
  63713. }
  63714. return serializationObject;
  63715. };
  63716. /**
  63717. * Dispose the material and release its associated resources
  63718. * @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)
  63719. * @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)
  63720. * @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)
  63721. */
  63722. MultiMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, forceDisposeChildren) {
  63723. var scene = this.getScene();
  63724. if (!scene) {
  63725. return;
  63726. }
  63727. if (forceDisposeChildren) {
  63728. for (var index = 0; index < this.subMaterials.length; index++) {
  63729. var subMaterial = this.subMaterials[index];
  63730. if (subMaterial) {
  63731. subMaterial.dispose(forceDisposeEffect, forceDisposeTextures);
  63732. }
  63733. }
  63734. }
  63735. var index = scene.multiMaterials.indexOf(this);
  63736. if (index >= 0) {
  63737. scene.multiMaterials.splice(index, 1);
  63738. }
  63739. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  63740. };
  63741. /**
  63742. * Creates a MultiMaterial from parsed MultiMaterial data.
  63743. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  63744. * @param scene defines the hosting scene
  63745. * @returns a new MultiMaterial
  63746. */
  63747. MultiMaterial.ParseMultiMaterial = function (parsedMultiMaterial, scene) {
  63748. var multiMaterial = new MultiMaterial(parsedMultiMaterial.name, scene);
  63749. multiMaterial.id = parsedMultiMaterial.id;
  63750. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  63751. _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].AddTagsTo(multiMaterial, parsedMultiMaterial.tags);
  63752. }
  63753. for (var matIndex = 0; matIndex < parsedMultiMaterial.materials.length; matIndex++) {
  63754. var subMatId = parsedMultiMaterial.materials[matIndex];
  63755. if (subMatId) {
  63756. multiMaterial.subMaterials.push(scene.getMaterialByID(subMatId));
  63757. }
  63758. else {
  63759. multiMaterial.subMaterials.push(null);
  63760. }
  63761. }
  63762. return multiMaterial;
  63763. };
  63764. return MultiMaterial;
  63765. }(_Materials_material__WEBPACK_IMPORTED_MODULE_1__["Material"]));
  63766. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.MultiMaterial"] = MultiMaterial;
  63767. /***/ }),
  63768. /***/ "./Materials/pushMaterial.ts":
  63769. /*!***********************************!*\
  63770. !*** ./Materials/pushMaterial.ts ***!
  63771. \***********************************/
  63772. /*! exports provided: PushMaterial */
  63773. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63774. "use strict";
  63775. __webpack_require__.r(__webpack_exports__);
  63776. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return PushMaterial; });
  63777. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  63778. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  63779. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  63780. /**
  63781. * Base class of materials working in push mode in babylon JS
  63782. * @hidden
  63783. */
  63784. var PushMaterial = /** @class */ (function (_super) {
  63785. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PushMaterial, _super);
  63786. function PushMaterial(name, scene) {
  63787. var _this = _super.call(this, name, scene) || this;
  63788. _this._normalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  63789. /**
  63790. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  63791. * This means that the material can keep using a previous shader while a new one is being compiled.
  63792. * This is mostly used when shader parallel compilation is supported (true by default)
  63793. */
  63794. _this.allowShaderHotSwapping = true;
  63795. _this._storeEffectOnSubMeshes = true;
  63796. return _this;
  63797. }
  63798. PushMaterial.prototype.getEffect = function () {
  63799. return this._activeEffect;
  63800. };
  63801. PushMaterial.prototype.isReady = function (mesh, useInstances) {
  63802. if (!mesh) {
  63803. return false;
  63804. }
  63805. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  63806. return true;
  63807. }
  63808. return this.isReadyForSubMesh(mesh, mesh.subMeshes[0], useInstances);
  63809. };
  63810. /**
  63811. * Binds the given world matrix to the active effect
  63812. *
  63813. * @param world the matrix to bind
  63814. */
  63815. PushMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  63816. this._activeEffect.setMatrix("world", world);
  63817. };
  63818. /**
  63819. * Binds the given normal matrix to the active effect
  63820. *
  63821. * @param normalMatrix the matrix to bind
  63822. */
  63823. PushMaterial.prototype.bindOnlyNormalMatrix = function (normalMatrix) {
  63824. this._activeEffect.setMatrix("normalMatrix", normalMatrix);
  63825. };
  63826. PushMaterial.prototype.bind = function (world, mesh) {
  63827. if (!mesh) {
  63828. return;
  63829. }
  63830. this.bindForSubMesh(world, mesh, mesh.subMeshes[0]);
  63831. };
  63832. PushMaterial.prototype._afterBind = function (mesh, effect) {
  63833. if (effect === void 0) { effect = null; }
  63834. _super.prototype._afterBind.call(this, mesh);
  63835. this.getScene()._cachedEffect = effect;
  63836. };
  63837. PushMaterial.prototype._mustRebind = function (scene, effect, visibility) {
  63838. if (visibility === void 0) { visibility = 1; }
  63839. return scene.isCachedMaterialInvalid(this, effect, visibility);
  63840. };
  63841. return PushMaterial;
  63842. }(_Materials_material__WEBPACK_IMPORTED_MODULE_2__["Material"]));
  63843. /***/ }),
  63844. /***/ "./Materials/shaderMaterial.ts":
  63845. /*!*************************************!*\
  63846. !*** ./Materials/shaderMaterial.ts ***!
  63847. \*************************************/
  63848. /*! exports provided: ShaderMaterial */
  63849. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63850. "use strict";
  63851. __webpack_require__.r(__webpack_exports__);
  63852. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return ShaderMaterial; });
  63853. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  63854. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  63855. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  63856. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  63857. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  63858. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  63859. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  63860. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  63861. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  63862. /**
  63863. * 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.
  63864. *
  63865. * This returned material effects how the mesh will look based on the code in the shaders.
  63866. *
  63867. * @see http://doc.babylonjs.com/how_to/shader_material
  63868. */
  63869. var ShaderMaterial = /** @class */ (function (_super) {
  63870. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderMaterial, _super);
  63871. /**
  63872. * Instantiate a new shader material.
  63873. * 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.
  63874. * This returned material effects how the mesh will look based on the code in the shaders.
  63875. * @see http://doc.babylonjs.com/how_to/shader_material
  63876. * @param name Define the name of the material in the scene
  63877. * @param scene Define the scene the material belongs to
  63878. * @param shaderPath Defines the route to the shader code in one of three ways:
  63879. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  63880. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  63881. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  63882. * @param options Define the options used to create the shader
  63883. */
  63884. function ShaderMaterial(name, scene, shaderPath, options) {
  63885. if (options === void 0) { options = {}; }
  63886. var _this = _super.call(this, name, scene) || this;
  63887. _this._textures = {};
  63888. _this._textureArrays = {};
  63889. _this._floats = {};
  63890. _this._ints = {};
  63891. _this._floatsArrays = {};
  63892. _this._colors3 = {};
  63893. _this._colors3Arrays = {};
  63894. _this._colors4 = {};
  63895. _this._vectors2 = {};
  63896. _this._vectors3 = {};
  63897. _this._vectors4 = {};
  63898. _this._matrices = {};
  63899. _this._matrices3x3 = {};
  63900. _this._matrices2x2 = {};
  63901. _this._vectors2Arrays = {};
  63902. _this._vectors3Arrays = {};
  63903. _this._cachedWorldViewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  63904. _this._shaderPath = shaderPath;
  63905. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ needAlphaBlending: false, needAlphaTesting: false, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection"], uniformBuffers: [], samplers: [], defines: [] }, options);
  63906. return _this;
  63907. }
  63908. /**
  63909. * Gets the current class name of the material e.g. "ShaderMaterial"
  63910. * Mainly use in serialization.
  63911. * @returns the class name
  63912. */
  63913. ShaderMaterial.prototype.getClassName = function () {
  63914. return "ShaderMaterial";
  63915. };
  63916. /**
  63917. * Specifies if the material will require alpha blending
  63918. * @returns a boolean specifying if alpha blending is needed
  63919. */
  63920. ShaderMaterial.prototype.needAlphaBlending = function () {
  63921. return (this.alpha < 1.0) || this._options.needAlphaBlending;
  63922. };
  63923. /**
  63924. * Specifies if this material should be rendered in alpha test mode
  63925. * @returns a boolean specifying if an alpha test is needed.
  63926. */
  63927. ShaderMaterial.prototype.needAlphaTesting = function () {
  63928. return this._options.needAlphaTesting;
  63929. };
  63930. ShaderMaterial.prototype._checkUniform = function (uniformName) {
  63931. if (this._options.uniforms.indexOf(uniformName) === -1) {
  63932. this._options.uniforms.push(uniformName);
  63933. }
  63934. };
  63935. /**
  63936. * Set a texture in the shader.
  63937. * @param name Define the name of the uniform samplers as defined in the shader
  63938. * @param texture Define the texture to bind to this sampler
  63939. * @return the material itself allowing "fluent" like uniform updates
  63940. */
  63941. ShaderMaterial.prototype.setTexture = function (name, texture) {
  63942. if (this._options.samplers.indexOf(name) === -1) {
  63943. this._options.samplers.push(name);
  63944. }
  63945. this._textures[name] = texture;
  63946. return this;
  63947. };
  63948. /**
  63949. * Set a texture array in the shader.
  63950. * @param name Define the name of the uniform sampler array as defined in the shader
  63951. * @param textures Define the list of textures to bind to this sampler
  63952. * @return the material itself allowing "fluent" like uniform updates
  63953. */
  63954. ShaderMaterial.prototype.setTextureArray = function (name, textures) {
  63955. if (this._options.samplers.indexOf(name) === -1) {
  63956. this._options.samplers.push(name);
  63957. }
  63958. this._checkUniform(name);
  63959. this._textureArrays[name] = textures;
  63960. return this;
  63961. };
  63962. /**
  63963. * Set a float in the shader.
  63964. * @param name Define the name of the uniform as defined in the shader
  63965. * @param value Define the value to give to the uniform
  63966. * @return the material itself allowing "fluent" like uniform updates
  63967. */
  63968. ShaderMaterial.prototype.setFloat = function (name, value) {
  63969. this._checkUniform(name);
  63970. this._floats[name] = value;
  63971. return this;
  63972. };
  63973. /**
  63974. * Set a int in the shader.
  63975. * @param name Define the name of the uniform as defined in the shader
  63976. * @param value Define the value to give to the uniform
  63977. * @return the material itself allowing "fluent" like uniform updates
  63978. */
  63979. ShaderMaterial.prototype.setInt = function (name, value) {
  63980. this._checkUniform(name);
  63981. this._ints[name] = value;
  63982. return this;
  63983. };
  63984. /**
  63985. * Set an array of floats in the shader.
  63986. * @param name Define the name of the uniform as defined in the shader
  63987. * @param value Define the value to give to the uniform
  63988. * @return the material itself allowing "fluent" like uniform updates
  63989. */
  63990. ShaderMaterial.prototype.setFloats = function (name, value) {
  63991. this._checkUniform(name);
  63992. this._floatsArrays[name] = value;
  63993. return this;
  63994. };
  63995. /**
  63996. * Set a vec3 in the shader from a Color3.
  63997. * @param name Define the name of the uniform as defined in the shader
  63998. * @param value Define the value to give to the uniform
  63999. * @return the material itself allowing "fluent" like uniform updates
  64000. */
  64001. ShaderMaterial.prototype.setColor3 = function (name, value) {
  64002. this._checkUniform(name);
  64003. this._colors3[name] = value;
  64004. return this;
  64005. };
  64006. /**
  64007. * Set a vec3 array in the shader from a Color3 array.
  64008. * @param name Define the name of the uniform as defined in the shader
  64009. * @param value Define the value to give to the uniform
  64010. * @return the material itself allowing "fluent" like uniform updates
  64011. */
  64012. ShaderMaterial.prototype.setColor3Array = function (name, value) {
  64013. this._checkUniform(name);
  64014. this._colors3Arrays[name] = value.reduce(function (arr, color) {
  64015. color.toArray(arr, arr.length);
  64016. return arr;
  64017. }, []);
  64018. return this;
  64019. };
  64020. /**
  64021. * Set a vec4 in the shader from a Color4.
  64022. * @param name Define the name of the uniform as defined in the shader
  64023. * @param value Define the value to give to the uniform
  64024. * @return the material itself allowing "fluent" like uniform updates
  64025. */
  64026. ShaderMaterial.prototype.setColor4 = function (name, value) {
  64027. this._checkUniform(name);
  64028. this._colors4[name] = value;
  64029. return this;
  64030. };
  64031. /**
  64032. * Set a vec2 in the shader from a Vector2.
  64033. * @param name Define the name of the uniform as defined in the shader
  64034. * @param value Define the value to give to the uniform
  64035. * @return the material itself allowing "fluent" like uniform updates
  64036. */
  64037. ShaderMaterial.prototype.setVector2 = function (name, value) {
  64038. this._checkUniform(name);
  64039. this._vectors2[name] = value;
  64040. return this;
  64041. };
  64042. /**
  64043. * Set a vec3 in the shader from a Vector3.
  64044. * @param name Define the name of the uniform as defined in the shader
  64045. * @param value Define the value to give to the uniform
  64046. * @return the material itself allowing "fluent" like uniform updates
  64047. */
  64048. ShaderMaterial.prototype.setVector3 = function (name, value) {
  64049. this._checkUniform(name);
  64050. this._vectors3[name] = value;
  64051. return this;
  64052. };
  64053. /**
  64054. * Set a vec4 in the shader from a Vector4.
  64055. * @param name Define the name of the uniform as defined in the shader
  64056. * @param value Define the value to give to the uniform
  64057. * @return the material itself allowing "fluent" like uniform updates
  64058. */
  64059. ShaderMaterial.prototype.setVector4 = function (name, value) {
  64060. this._checkUniform(name);
  64061. this._vectors4[name] = value;
  64062. return this;
  64063. };
  64064. /**
  64065. * Set a mat4 in the shader from a Matrix.
  64066. * @param name Define the name of the uniform as defined in the shader
  64067. * @param value Define the value to give to the uniform
  64068. * @return the material itself allowing "fluent" like uniform updates
  64069. */
  64070. ShaderMaterial.prototype.setMatrix = function (name, value) {
  64071. this._checkUniform(name);
  64072. this._matrices[name] = value;
  64073. return this;
  64074. };
  64075. /**
  64076. * Set a mat3 in the shader from a Float32Array.
  64077. * @param name Define the name of the uniform as defined in the shader
  64078. * @param value Define the value to give to the uniform
  64079. * @return the material itself allowing "fluent" like uniform updates
  64080. */
  64081. ShaderMaterial.prototype.setMatrix3x3 = function (name, value) {
  64082. this._checkUniform(name);
  64083. this._matrices3x3[name] = value;
  64084. return this;
  64085. };
  64086. /**
  64087. * Set a mat2 in the shader from a Float32Array.
  64088. * @param name Define the name of the uniform as defined in the shader
  64089. * @param value Define the value to give to the uniform
  64090. * @return the material itself allowing "fluent" like uniform updates
  64091. */
  64092. ShaderMaterial.prototype.setMatrix2x2 = function (name, value) {
  64093. this._checkUniform(name);
  64094. this._matrices2x2[name] = value;
  64095. return this;
  64096. };
  64097. /**
  64098. * Set a vec2 array in the shader from a number array.
  64099. * @param name Define the name of the uniform as defined in the shader
  64100. * @param value Define the value to give to the uniform
  64101. * @return the material itself allowing "fluent" like uniform updates
  64102. */
  64103. ShaderMaterial.prototype.setArray2 = function (name, value) {
  64104. this._checkUniform(name);
  64105. this._vectors2Arrays[name] = value;
  64106. return this;
  64107. };
  64108. /**
  64109. * Set a vec3 array in the shader from a number array.
  64110. * @param name Define the name of the uniform as defined in the shader
  64111. * @param value Define the value to give to the uniform
  64112. * @return the material itself allowing "fluent" like uniform updates
  64113. */
  64114. ShaderMaterial.prototype.setArray3 = function (name, value) {
  64115. this._checkUniform(name);
  64116. this._vectors3Arrays[name] = value;
  64117. return this;
  64118. };
  64119. ShaderMaterial.prototype._checkCache = function (mesh, useInstances) {
  64120. if (!mesh) {
  64121. return true;
  64122. }
  64123. if (this._effect && (this._effect.defines.indexOf("#define INSTANCES") !== -1) !== useInstances) {
  64124. return false;
  64125. }
  64126. return false;
  64127. };
  64128. /**
  64129. * Checks if the material is ready to render the requested mesh
  64130. * @param mesh Define the mesh to render
  64131. * @param useInstances Define whether or not the material is used with instances
  64132. * @returns true if ready, otherwise false
  64133. */
  64134. ShaderMaterial.prototype.isReady = function (mesh, useInstances) {
  64135. var scene = this.getScene();
  64136. var engine = scene.getEngine();
  64137. if (!this.checkReadyOnEveryCall) {
  64138. if (this._renderId === scene.getRenderId()) {
  64139. if (this._checkCache(mesh, useInstances)) {
  64140. return true;
  64141. }
  64142. }
  64143. }
  64144. // Instances
  64145. var defines = [];
  64146. var attribs = [];
  64147. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  64148. for (var index = 0; index < this._options.defines.length; index++) {
  64149. defines.push(this._options.defines[index]);
  64150. }
  64151. for (var index = 0; index < this._options.attributes.length; index++) {
  64152. attribs.push(this._options.attributes[index]);
  64153. }
  64154. if (mesh && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  64155. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  64156. defines.push("#define VERTEXCOLOR");
  64157. }
  64158. if (useInstances) {
  64159. defines.push("#define INSTANCES");
  64160. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  64161. }
  64162. // Bones
  64163. if (mesh && mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  64164. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  64165. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  64166. if (mesh.numBoneInfluencers > 4) {
  64167. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  64168. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind);
  64169. }
  64170. var skeleton = mesh.skeleton;
  64171. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  64172. fallbacks.addCPUSkinningFallback(0, mesh);
  64173. if (skeleton.isUsingTextureForMatrices) {
  64174. defines.push("#define BONETEXTURE");
  64175. if (this._options.uniforms.indexOf("boneTextureWidth") === -1) {
  64176. this._options.uniforms.push("boneTextureWidth");
  64177. }
  64178. if (this._options.samplers.indexOf("boneSampler") === -1) {
  64179. this._options.samplers.push("boneSampler");
  64180. }
  64181. }
  64182. else {
  64183. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  64184. if (this._options.uniforms.indexOf("mBones") === -1) {
  64185. this._options.uniforms.push("mBones");
  64186. }
  64187. }
  64188. }
  64189. else {
  64190. defines.push("#define NUM_BONE_INFLUENCERS 0");
  64191. }
  64192. // Textures
  64193. for (var name in this._textures) {
  64194. if (!this._textures[name].isReady()) {
  64195. return false;
  64196. }
  64197. }
  64198. // Alpha test
  64199. if (mesh && this._shouldTurnAlphaTestOn(mesh)) {
  64200. defines.push("#define ALPHATEST");
  64201. }
  64202. var previousEffect = this._effect;
  64203. var join = defines.join("\n");
  64204. this._effect = engine.createEffect(this._shaderPath, {
  64205. attributes: attribs,
  64206. uniformsNames: this._options.uniforms,
  64207. uniformBuffersNames: this._options.uniformBuffers,
  64208. samplers: this._options.samplers,
  64209. defines: join,
  64210. fallbacks: fallbacks,
  64211. onCompiled: this.onCompiled,
  64212. onError: this.onError
  64213. }, engine);
  64214. if (!this._effect.isReady()) {
  64215. return false;
  64216. }
  64217. if (previousEffect !== this._effect) {
  64218. scene.resetCachedMaterial();
  64219. }
  64220. this._renderId = scene.getRenderId();
  64221. return true;
  64222. };
  64223. /**
  64224. * Binds the world matrix to the material
  64225. * @param world defines the world transformation matrix
  64226. */
  64227. ShaderMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  64228. var scene = this.getScene();
  64229. if (!this._effect) {
  64230. return;
  64231. }
  64232. if (this._options.uniforms.indexOf("world") !== -1) {
  64233. this._effect.setMatrix("world", world);
  64234. }
  64235. if (this._options.uniforms.indexOf("worldView") !== -1) {
  64236. world.multiplyToRef(scene.getViewMatrix(), this._cachedWorldViewMatrix);
  64237. this._effect.setMatrix("worldView", this._cachedWorldViewMatrix);
  64238. }
  64239. if (this._options.uniforms.indexOf("worldViewProjection") !== -1) {
  64240. this._effect.setMatrix("worldViewProjection", world.multiply(scene.getTransformMatrix()));
  64241. }
  64242. };
  64243. /**
  64244. * Binds the material to the mesh
  64245. * @param world defines the world transformation matrix
  64246. * @param mesh defines the mesh to bind the material to
  64247. */
  64248. ShaderMaterial.prototype.bind = function (world, mesh) {
  64249. // Std values
  64250. this.bindOnlyWorldMatrix(world);
  64251. if (this._effect && this.getScene().getCachedMaterial() !== this) {
  64252. if (this._options.uniforms.indexOf("view") !== -1) {
  64253. this._effect.setMatrix("view", this.getScene().getViewMatrix());
  64254. }
  64255. if (this._options.uniforms.indexOf("projection") !== -1) {
  64256. this._effect.setMatrix("projection", this.getScene().getProjectionMatrix());
  64257. }
  64258. if (this._options.uniforms.indexOf("viewProjection") !== -1) {
  64259. this._effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  64260. }
  64261. // Bones
  64262. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindBonesParameters(mesh, this._effect);
  64263. var name;
  64264. // Texture
  64265. for (name in this._textures) {
  64266. this._effect.setTexture(name, this._textures[name]);
  64267. }
  64268. // Texture arrays
  64269. for (name in this._textureArrays) {
  64270. this._effect.setTextureArray(name, this._textureArrays[name]);
  64271. }
  64272. // Int
  64273. for (name in this._ints) {
  64274. this._effect.setInt(name, this._ints[name]);
  64275. }
  64276. // Float
  64277. for (name in this._floats) {
  64278. this._effect.setFloat(name, this._floats[name]);
  64279. }
  64280. // Floats
  64281. for (name in this._floatsArrays) {
  64282. this._effect.setArray(name, this._floatsArrays[name]);
  64283. }
  64284. // Color3
  64285. for (name in this._colors3) {
  64286. this._effect.setColor3(name, this._colors3[name]);
  64287. }
  64288. for (name in this._colors3Arrays) {
  64289. this._effect.setArray3(name, this._colors3Arrays[name]);
  64290. }
  64291. // Color4
  64292. for (name in this._colors4) {
  64293. var color = this._colors4[name];
  64294. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  64295. }
  64296. // Vector2
  64297. for (name in this._vectors2) {
  64298. this._effect.setVector2(name, this._vectors2[name]);
  64299. }
  64300. // Vector3
  64301. for (name in this._vectors3) {
  64302. this._effect.setVector3(name, this._vectors3[name]);
  64303. }
  64304. // Vector4
  64305. for (name in this._vectors4) {
  64306. this._effect.setVector4(name, this._vectors4[name]);
  64307. }
  64308. // Matrix
  64309. for (name in this._matrices) {
  64310. this._effect.setMatrix(name, this._matrices[name]);
  64311. }
  64312. // Matrix 3x3
  64313. for (name in this._matrices3x3) {
  64314. this._effect.setMatrix3x3(name, this._matrices3x3[name]);
  64315. }
  64316. // Matrix 2x2
  64317. for (name in this._matrices2x2) {
  64318. this._effect.setMatrix2x2(name, this._matrices2x2[name]);
  64319. }
  64320. // Vector2Array
  64321. for (name in this._vectors2Arrays) {
  64322. this._effect.setArray2(name, this._vectors2Arrays[name]);
  64323. }
  64324. // Vector3Array
  64325. for (name in this._vectors3Arrays) {
  64326. this._effect.setArray3(name, this._vectors3Arrays[name]);
  64327. }
  64328. }
  64329. this._afterBind(mesh);
  64330. };
  64331. /**
  64332. * Gets the active textures from the material
  64333. * @returns an array of textures
  64334. */
  64335. ShaderMaterial.prototype.getActiveTextures = function () {
  64336. var activeTextures = _super.prototype.getActiveTextures.call(this);
  64337. for (var name in this._textures) {
  64338. activeTextures.push(this._textures[name]);
  64339. }
  64340. for (var name in this._textureArrays) {
  64341. var array = this._textureArrays[name];
  64342. for (var index = 0; index < array.length; index++) {
  64343. activeTextures.push(array[index]);
  64344. }
  64345. }
  64346. return activeTextures;
  64347. };
  64348. /**
  64349. * Specifies if the material uses a texture
  64350. * @param texture defines the texture to check against the material
  64351. * @returns a boolean specifying if the material uses the texture
  64352. */
  64353. ShaderMaterial.prototype.hasTexture = function (texture) {
  64354. if (_super.prototype.hasTexture.call(this, texture)) {
  64355. return true;
  64356. }
  64357. for (var name in this._textures) {
  64358. if (this._textures[name] === texture) {
  64359. return true;
  64360. }
  64361. }
  64362. for (var name in this._textureArrays) {
  64363. var array = this._textureArrays[name];
  64364. for (var index = 0; index < array.length; index++) {
  64365. if (array[index] === texture) {
  64366. return true;
  64367. }
  64368. }
  64369. }
  64370. return false;
  64371. };
  64372. /**
  64373. * Makes a duplicate of the material, and gives it a new name
  64374. * @param name defines the new name for the duplicated material
  64375. * @returns the cloned material
  64376. */
  64377. ShaderMaterial.prototype.clone = function (name) {
  64378. var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
  64379. return newShaderMaterial;
  64380. };
  64381. /**
  64382. * Disposes the material
  64383. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  64384. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  64385. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  64386. */
  64387. ShaderMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  64388. if (forceDisposeTextures) {
  64389. var name;
  64390. for (name in this._textures) {
  64391. this._textures[name].dispose();
  64392. }
  64393. for (name in this._textureArrays) {
  64394. var array = this._textureArrays[name];
  64395. for (var index = 0; index < array.length; index++) {
  64396. array[index].dispose();
  64397. }
  64398. }
  64399. }
  64400. this._textures = {};
  64401. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures, notBoundToMesh);
  64402. };
  64403. /**
  64404. * Serializes this material in a JSON representation
  64405. * @returns the serialized material object
  64406. */
  64407. ShaderMaterial.prototype.serialize = function () {
  64408. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  64409. serializationObject.customType = "ShaderMaterial";
  64410. serializationObject.options = this._options;
  64411. serializationObject.shaderPath = this._shaderPath;
  64412. var name;
  64413. // Texture
  64414. serializationObject.textures = {};
  64415. for (name in this._textures) {
  64416. serializationObject.textures[name] = this._textures[name].serialize();
  64417. }
  64418. // Texture arrays
  64419. serializationObject.textureArrays = {};
  64420. for (name in this._textureArrays) {
  64421. serializationObject.textureArrays[name] = [];
  64422. var array = this._textureArrays[name];
  64423. for (var index = 0; index < array.length; index++) {
  64424. serializationObject.textureArrays[name].push(array[index].serialize());
  64425. }
  64426. }
  64427. // Float
  64428. serializationObject.floats = {};
  64429. for (name in this._floats) {
  64430. serializationObject.floats[name] = this._floats[name];
  64431. }
  64432. // Float s
  64433. serializationObject.FloatArrays = {};
  64434. for (name in this._floatsArrays) {
  64435. serializationObject.FloatArrays[name] = this._floatsArrays[name];
  64436. }
  64437. // Color3
  64438. serializationObject.colors3 = {};
  64439. for (name in this._colors3) {
  64440. serializationObject.colors3[name] = this._colors3[name].asArray();
  64441. }
  64442. // Color3 array
  64443. serializationObject.colors3Arrays = {};
  64444. for (name in this._colors3Arrays) {
  64445. serializationObject.colors3Arrays[name] = this._colors3Arrays[name];
  64446. }
  64447. // Color4
  64448. serializationObject.colors4 = {};
  64449. for (name in this._colors4) {
  64450. serializationObject.colors4[name] = this._colors4[name].asArray();
  64451. }
  64452. // Vector2
  64453. serializationObject.vectors2 = {};
  64454. for (name in this._vectors2) {
  64455. serializationObject.vectors2[name] = this._vectors2[name].asArray();
  64456. }
  64457. // Vector3
  64458. serializationObject.vectors3 = {};
  64459. for (name in this._vectors3) {
  64460. serializationObject.vectors3[name] = this._vectors3[name].asArray();
  64461. }
  64462. // Vector4
  64463. serializationObject.vectors4 = {};
  64464. for (name in this._vectors4) {
  64465. serializationObject.vectors4[name] = this._vectors4[name].asArray();
  64466. }
  64467. // Matrix
  64468. serializationObject.matrices = {};
  64469. for (name in this._matrices) {
  64470. serializationObject.matrices[name] = this._matrices[name].asArray();
  64471. }
  64472. // Matrix 3x3
  64473. serializationObject.matrices3x3 = {};
  64474. for (name in this._matrices3x3) {
  64475. serializationObject.matrices3x3[name] = this._matrices3x3[name];
  64476. }
  64477. // Matrix 2x2
  64478. serializationObject.matrices2x2 = {};
  64479. for (name in this._matrices2x2) {
  64480. serializationObject.matrices2x2[name] = this._matrices2x2[name];
  64481. }
  64482. // Vector2Array
  64483. serializationObject.vectors2Arrays = {};
  64484. for (name in this._vectors2Arrays) {
  64485. serializationObject.vectors2Arrays[name] = this._vectors2Arrays[name];
  64486. }
  64487. // Vector3Array
  64488. serializationObject.vectors3Arrays = {};
  64489. for (name in this._vectors3Arrays) {
  64490. serializationObject.vectors3Arrays[name] = this._vectors3Arrays[name];
  64491. }
  64492. return serializationObject;
  64493. };
  64494. /**
  64495. * Creates a shader material from parsed shader material data
  64496. * @param source defines the JSON represnetation of the material
  64497. * @param scene defines the hosting scene
  64498. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  64499. * @returns a new material
  64500. */
  64501. ShaderMaterial.Parse = function (source, scene, rootUrl) {
  64502. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ShaderMaterial(source.name, scene, source.shaderPath, source.options); }, source, scene, rootUrl);
  64503. var name;
  64504. // Texture
  64505. for (name in source.textures) {
  64506. material.setTexture(name, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(source.textures[name], scene, rootUrl));
  64507. }
  64508. // Texture arrays
  64509. for (name in source.textureArrays) {
  64510. var array = source.textureArrays[name];
  64511. var textureArray = new Array();
  64512. for (var index = 0; index < array.length; index++) {
  64513. textureArray.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(array[index], scene, rootUrl));
  64514. }
  64515. material.setTextureArray(name, textureArray);
  64516. }
  64517. // Float
  64518. for (name in source.floats) {
  64519. material.setFloat(name, source.floats[name]);
  64520. }
  64521. // Float s
  64522. for (name in source.floatsArrays) {
  64523. material.setFloats(name, source.floatsArrays[name]);
  64524. }
  64525. // Color3
  64526. for (name in source.colors3) {
  64527. material.setColor3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(source.colors3[name]));
  64528. }
  64529. // Color3 arrays
  64530. for (name in source.colors3Arrays) {
  64531. var colors = source.colors3Arrays[name].reduce(function (arr, num, i) {
  64532. if (i % 3 === 0) {
  64533. arr.push([num]);
  64534. }
  64535. else {
  64536. arr[arr.length - 1].push(num);
  64537. }
  64538. return arr;
  64539. }, []).map(function (color) { return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(color); });
  64540. material.setColor3Array(name, colors);
  64541. }
  64542. // Color4
  64543. for (name in source.colors4) {
  64544. material.setColor4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(source.colors4[name]));
  64545. }
  64546. // Vector2
  64547. for (name in source.vectors2) {
  64548. material.setVector2(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"].FromArray(source.vectors2[name]));
  64549. }
  64550. // Vector3
  64551. for (name in source.vectors3) {
  64552. material.setVector3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(source.vectors3[name]));
  64553. }
  64554. // Vector4
  64555. for (name in source.vectors4) {
  64556. material.setVector4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector4"].FromArray(source.vectors4[name]));
  64557. }
  64558. // Matrix
  64559. for (name in source.matrices) {
  64560. material.setMatrix(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(source.matrices[name]));
  64561. }
  64562. // Matrix 3x3
  64563. for (name in source.matrices3x3) {
  64564. material.setMatrix3x3(name, source.matrices3x3[name]);
  64565. }
  64566. // Matrix 2x2
  64567. for (name in source.matrices2x2) {
  64568. material.setMatrix2x2(name, source.matrices2x2[name]);
  64569. }
  64570. // Vector2Array
  64571. for (name in source.vectors2Arrays) {
  64572. material.setArray2(name, source.vectors2Arrays[name]);
  64573. }
  64574. // Vector3Array
  64575. for (name in source.vectors3Arrays) {
  64576. material.setArray3(name, source.vectors3Arrays[name]);
  64577. }
  64578. return material;
  64579. };
  64580. return ShaderMaterial;
  64581. }(_material__WEBPACK_IMPORTED_MODULE_7__["Material"]));
  64582. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.ShaderMaterial"] = ShaderMaterial;
  64583. /***/ }),
  64584. /***/ "./Materials/standardMaterial.ts":
  64585. /*!***************************************!*\
  64586. !*** ./Materials/standardMaterial.ts ***!
  64587. \***************************************/
  64588. /*! exports provided: StandardMaterialDefines, StandardMaterial */
  64589. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64590. "use strict";
  64591. __webpack_require__.r(__webpack_exports__);
  64592. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return StandardMaterialDefines; });
  64593. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return StandardMaterial; });
  64594. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64595. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  64596. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  64597. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  64598. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64599. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  64600. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  64601. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  64602. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  64603. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  64604. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  64605. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  64606. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  64607. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  64608. /* harmony import */ var _Shaders_default_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/default.fragment */ "./Shaders/default.fragment.ts");
  64609. /* harmony import */ var _Shaders_default_vertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/default.vertex */ "./Shaders/default.vertex.ts");
  64610. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  64611. /** @hidden */
  64612. var StandardMaterialDefines = /** @class */ (function (_super) {
  64613. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterialDefines, _super);
  64614. function StandardMaterialDefines() {
  64615. var _this = _super.call(this) || this;
  64616. _this.MAINUV1 = false;
  64617. _this.MAINUV2 = false;
  64618. _this.DIFFUSE = false;
  64619. _this.DIFFUSEDIRECTUV = 0;
  64620. _this.AMBIENT = false;
  64621. _this.AMBIENTDIRECTUV = 0;
  64622. _this.OPACITY = false;
  64623. _this.OPACITYDIRECTUV = 0;
  64624. _this.OPACITYRGB = false;
  64625. _this.REFLECTION = false;
  64626. _this.EMISSIVE = false;
  64627. _this.EMISSIVEDIRECTUV = 0;
  64628. _this.SPECULAR = false;
  64629. _this.SPECULARDIRECTUV = 0;
  64630. _this.BUMP = false;
  64631. _this.BUMPDIRECTUV = 0;
  64632. _this.PARALLAX = false;
  64633. _this.PARALLAXOCCLUSION = false;
  64634. _this.SPECULAROVERALPHA = false;
  64635. _this.CLIPPLANE = false;
  64636. _this.CLIPPLANE2 = false;
  64637. _this.CLIPPLANE3 = false;
  64638. _this.CLIPPLANE4 = false;
  64639. _this.ALPHATEST = false;
  64640. _this.DEPTHPREPASS = false;
  64641. _this.ALPHAFROMDIFFUSE = false;
  64642. _this.POINTSIZE = false;
  64643. _this.FOG = false;
  64644. _this.SPECULARTERM = false;
  64645. _this.DIFFUSEFRESNEL = false;
  64646. _this.OPACITYFRESNEL = false;
  64647. _this.REFLECTIONFRESNEL = false;
  64648. _this.REFRACTIONFRESNEL = false;
  64649. _this.EMISSIVEFRESNEL = false;
  64650. _this.FRESNEL = false;
  64651. _this.NORMAL = false;
  64652. _this.UV1 = false;
  64653. _this.UV2 = false;
  64654. _this.VERTEXCOLOR = false;
  64655. _this.VERTEXALPHA = false;
  64656. _this.NUM_BONE_INFLUENCERS = 0;
  64657. _this.BonesPerMesh = 0;
  64658. _this.BONETEXTURE = false;
  64659. _this.INSTANCES = false;
  64660. _this.GLOSSINESS = false;
  64661. _this.ROUGHNESS = false;
  64662. _this.EMISSIVEASILLUMINATION = false;
  64663. _this.LINKEMISSIVEWITHDIFFUSE = false;
  64664. _this.REFLECTIONFRESNELFROMSPECULAR = false;
  64665. _this.LIGHTMAP = false;
  64666. _this.LIGHTMAPDIRECTUV = 0;
  64667. _this.OBJECTSPACE_NORMALMAP = false;
  64668. _this.USELIGHTMAPASSHADOWMAP = false;
  64669. _this.REFLECTIONMAP_3D = false;
  64670. _this.REFLECTIONMAP_SPHERICAL = false;
  64671. _this.REFLECTIONMAP_PLANAR = false;
  64672. _this.REFLECTIONMAP_CUBIC = false;
  64673. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  64674. _this.REFLECTIONMAP_PROJECTION = false;
  64675. _this.REFLECTIONMAP_SKYBOX = false;
  64676. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  64677. _this.REFLECTIONMAP_EXPLICIT = false;
  64678. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  64679. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  64680. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  64681. _this.INVERTCUBICMAP = false;
  64682. _this.LOGARITHMICDEPTH = false;
  64683. _this.REFRACTION = false;
  64684. _this.REFRACTIONMAP_3D = false;
  64685. _this.REFLECTIONOVERALPHA = false;
  64686. _this.TWOSIDEDLIGHTING = false;
  64687. _this.SHADOWFLOAT = false;
  64688. _this.MORPHTARGETS = false;
  64689. _this.MORPHTARGETS_NORMAL = false;
  64690. _this.MORPHTARGETS_TANGENT = false;
  64691. _this.NUM_MORPH_INFLUENCERS = 0;
  64692. _this.NONUNIFORMSCALING = false; // https://playground.babylonjs.com#V6DWIH
  64693. _this.PREMULTIPLYALPHA = false; // https://playground.babylonjs.com#LNVJJ7
  64694. _this.IMAGEPROCESSING = false;
  64695. _this.VIGNETTE = false;
  64696. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  64697. _this.VIGNETTEBLENDMODEOPAQUE = false;
  64698. _this.TONEMAPPING = false;
  64699. _this.TONEMAPPING_ACES = false;
  64700. _this.CONTRAST = false;
  64701. _this.COLORCURVES = false;
  64702. _this.COLORGRADING = false;
  64703. _this.COLORGRADING3D = false;
  64704. _this.SAMPLER3DGREENDEPTH = false;
  64705. _this.SAMPLER3DBGRMAP = false;
  64706. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  64707. /**
  64708. * If the reflection texture on this material is in linear color space
  64709. * @hidden
  64710. */
  64711. _this.IS_REFLECTION_LINEAR = false;
  64712. /**
  64713. * If the refraction texture on this material is in linear color space
  64714. * @hidden
  64715. */
  64716. _this.IS_REFRACTION_LINEAR = false;
  64717. _this.EXPOSURE = false;
  64718. _this.rebuild();
  64719. return _this;
  64720. }
  64721. StandardMaterialDefines.prototype.setReflectionMode = function (modeToEnable) {
  64722. var modes = [
  64723. "REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR",
  64724. "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX",
  64725. "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED",
  64726. "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"
  64727. ];
  64728. for (var _i = 0, modes_1 = modes; _i < modes_1.length; _i++) {
  64729. var mode = modes_1[_i];
  64730. this[mode] = (mode === modeToEnable);
  64731. }
  64732. };
  64733. return StandardMaterialDefines;
  64734. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  64735. /**
  64736. * This is the default material used in Babylon. It is the best trade off between quality
  64737. * and performances.
  64738. * @see http://doc.babylonjs.com/babylon101/materials
  64739. */
  64740. var StandardMaterial = /** @class */ (function (_super) {
  64741. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterial, _super);
  64742. /**
  64743. * Instantiates a new standard material.
  64744. * This is the default material used in Babylon. It is the best trade off between quality
  64745. * and performances.
  64746. * @see http://doc.babylonjs.com/babylon101/materials
  64747. * @param name Define the name of the material in the scene
  64748. * @param scene Define the scene the material belong to
  64749. */
  64750. function StandardMaterial(name, scene) {
  64751. var _this = _super.call(this, name, scene) || this;
  64752. /**
  64753. * The color of the material lit by the environmental background lighting.
  64754. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  64755. */
  64756. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  64757. /**
  64758. * The basic color of the material as viewed under a light.
  64759. */
  64760. _this.diffuseColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  64761. /**
  64762. * Define how the color and intensity of the highlight given by the light in the material.
  64763. */
  64764. _this.specularColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  64765. /**
  64766. * Define the color of the material as if self lit.
  64767. * This will be mixed in the final result even in the absence of light.
  64768. */
  64769. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  64770. /**
  64771. * Defines how sharp are the highlights in the material.
  64772. * The bigger the value the sharper giving a more glossy feeling to the result.
  64773. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  64774. */
  64775. _this.specularPower = 64;
  64776. _this._useAlphaFromDiffuseTexture = false;
  64777. _this._useEmissiveAsIllumination = false;
  64778. _this._linkEmissiveWithDiffuse = false;
  64779. _this._useSpecularOverAlpha = false;
  64780. _this._useReflectionOverAlpha = false;
  64781. _this._disableLighting = false;
  64782. _this._useObjectSpaceNormalMap = false;
  64783. _this._useParallax = false;
  64784. _this._useParallaxOcclusion = false;
  64785. /**
  64786. * 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.
  64787. */
  64788. _this.parallaxScaleBias = 0.05;
  64789. _this._roughness = 0;
  64790. /**
  64791. * In case of refraction, define the value of the indice of refraction.
  64792. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  64793. */
  64794. _this.indexOfRefraction = 0.98;
  64795. /**
  64796. * Invert the refraction texture alongside the y axis.
  64797. * It can be useful with procedural textures or probe for instance.
  64798. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  64799. */
  64800. _this.invertRefractionY = true;
  64801. /**
  64802. * Defines the alpha limits in alpha test mode.
  64803. */
  64804. _this.alphaCutOff = 0.4;
  64805. _this._useLightmapAsShadowmap = false;
  64806. _this._useReflectionFresnelFromSpecular = false;
  64807. _this._useGlossinessFromSpecularMapAlpha = false;
  64808. _this._maxSimultaneousLights = 4;
  64809. _this._invertNormalMapX = false;
  64810. _this._invertNormalMapY = false;
  64811. _this._twoSidedLighting = false;
  64812. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  64813. _this._worldViewProjectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  64814. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  64815. // Setup the default processing configuration to the scene.
  64816. _this._attachImageProcessingConfiguration(null);
  64817. _this.getRenderTargetTextures = function () {
  64818. _this._renderTargets.reset();
  64819. if (StandardMaterial.ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  64820. _this._renderTargets.push(_this._reflectionTexture);
  64821. }
  64822. if (StandardMaterial.RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  64823. _this._renderTargets.push(_this._refractionTexture);
  64824. }
  64825. return _this._renderTargets;
  64826. };
  64827. return _this;
  64828. }
  64829. Object.defineProperty(StandardMaterial.prototype, "imageProcessingConfiguration", {
  64830. /**
  64831. * Gets the image processing configuration used either in this material.
  64832. */
  64833. get: function () {
  64834. return this._imageProcessingConfiguration;
  64835. },
  64836. /**
  64837. * Sets the Default image processing configuration used either in the this material.
  64838. *
  64839. * If sets to null, the scene one is in use.
  64840. */
  64841. set: function (value) {
  64842. this._attachImageProcessingConfiguration(value);
  64843. // Ensure the effect will be rebuilt.
  64844. this._markAllSubMeshesAsTexturesDirty();
  64845. },
  64846. enumerable: true,
  64847. configurable: true
  64848. });
  64849. /**
  64850. * Attaches a new image processing configuration to the Standard Material.
  64851. * @param configuration
  64852. */
  64853. StandardMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  64854. var _this = this;
  64855. if (configuration === this._imageProcessingConfiguration) {
  64856. return;
  64857. }
  64858. // Detaches observer.
  64859. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  64860. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  64861. }
  64862. // Pick the scene configuration if needed.
  64863. if (!configuration) {
  64864. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  64865. }
  64866. else {
  64867. this._imageProcessingConfiguration = configuration;
  64868. }
  64869. // Attaches observer.
  64870. if (this._imageProcessingConfiguration) {
  64871. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  64872. _this._markAllSubMeshesAsImageProcessingDirty();
  64873. });
  64874. }
  64875. };
  64876. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurvesEnabled", {
  64877. /**
  64878. * Gets wether the color curves effect is enabled.
  64879. */
  64880. get: function () {
  64881. return this.imageProcessingConfiguration.colorCurvesEnabled;
  64882. },
  64883. /**
  64884. * Sets wether the color curves effect is enabled.
  64885. */
  64886. set: function (value) {
  64887. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  64888. },
  64889. enumerable: true,
  64890. configurable: true
  64891. });
  64892. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingEnabled", {
  64893. /**
  64894. * Gets wether the color grading effect is enabled.
  64895. */
  64896. get: function () {
  64897. return this.imageProcessingConfiguration.colorGradingEnabled;
  64898. },
  64899. /**
  64900. * Gets wether the color grading effect is enabled.
  64901. */
  64902. set: function (value) {
  64903. this.imageProcessingConfiguration.colorGradingEnabled = value;
  64904. },
  64905. enumerable: true,
  64906. configurable: true
  64907. });
  64908. Object.defineProperty(StandardMaterial.prototype, "cameraToneMappingEnabled", {
  64909. /**
  64910. * Gets wether tonemapping is enabled or not.
  64911. */
  64912. get: function () {
  64913. return this._imageProcessingConfiguration.toneMappingEnabled;
  64914. },
  64915. /**
  64916. * Sets wether tonemapping is enabled or not
  64917. */
  64918. set: function (value) {
  64919. this._imageProcessingConfiguration.toneMappingEnabled = value;
  64920. },
  64921. enumerable: true,
  64922. configurable: true
  64923. });
  64924. Object.defineProperty(StandardMaterial.prototype, "cameraExposure", {
  64925. /**
  64926. * The camera exposure used on this material.
  64927. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  64928. * This corresponds to a photographic exposure.
  64929. */
  64930. get: function () {
  64931. return this._imageProcessingConfiguration.exposure;
  64932. },
  64933. /**
  64934. * The camera exposure used on this material.
  64935. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  64936. * This corresponds to a photographic exposure.
  64937. */
  64938. set: function (value) {
  64939. this._imageProcessingConfiguration.exposure = value;
  64940. },
  64941. enumerable: true,
  64942. configurable: true
  64943. });
  64944. Object.defineProperty(StandardMaterial.prototype, "cameraContrast", {
  64945. /**
  64946. * Gets The camera contrast used on this material.
  64947. */
  64948. get: function () {
  64949. return this._imageProcessingConfiguration.contrast;
  64950. },
  64951. /**
  64952. * Sets The camera contrast used on this material.
  64953. */
  64954. set: function (value) {
  64955. this._imageProcessingConfiguration.contrast = value;
  64956. },
  64957. enumerable: true,
  64958. configurable: true
  64959. });
  64960. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingTexture", {
  64961. /**
  64962. * Gets the Color Grading 2D Lookup Texture.
  64963. */
  64964. get: function () {
  64965. return this._imageProcessingConfiguration.colorGradingTexture;
  64966. },
  64967. /**
  64968. * Sets the Color Grading 2D Lookup Texture.
  64969. */
  64970. set: function (value) {
  64971. this._imageProcessingConfiguration.colorGradingTexture = value;
  64972. },
  64973. enumerable: true,
  64974. configurable: true
  64975. });
  64976. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurves", {
  64977. /**
  64978. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  64979. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  64980. * 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;
  64981. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  64982. */
  64983. get: function () {
  64984. return this._imageProcessingConfiguration.colorCurves;
  64985. },
  64986. /**
  64987. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  64988. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  64989. * 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;
  64990. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  64991. */
  64992. set: function (value) {
  64993. this._imageProcessingConfiguration.colorCurves = value;
  64994. },
  64995. enumerable: true,
  64996. configurable: true
  64997. });
  64998. Object.defineProperty(StandardMaterial.prototype, "hasRenderTargetTextures", {
  64999. /**
  65000. * Gets a boolean indicating that current material needs to register RTT
  65001. */
  65002. get: function () {
  65003. if (StandardMaterial.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  65004. return true;
  65005. }
  65006. if (StandardMaterial.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  65007. return true;
  65008. }
  65009. return false;
  65010. },
  65011. enumerable: true,
  65012. configurable: true
  65013. });
  65014. /**
  65015. * Gets the current class name of the material e.g. "StandardMaterial"
  65016. * Mainly use in serialization.
  65017. * @returns the class name
  65018. */
  65019. StandardMaterial.prototype.getClassName = function () {
  65020. return "StandardMaterial";
  65021. };
  65022. Object.defineProperty(StandardMaterial.prototype, "useLogarithmicDepth", {
  65023. /**
  65024. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  65025. * You can try switching to logarithmic depth.
  65026. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  65027. */
  65028. get: function () {
  65029. return this._useLogarithmicDepth;
  65030. },
  65031. set: function (value) {
  65032. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  65033. this._markAllSubMeshesAsMiscDirty();
  65034. },
  65035. enumerable: true,
  65036. configurable: true
  65037. });
  65038. /**
  65039. * Specifies if the material will require alpha blending
  65040. * @returns a boolean specifying if alpha blending is needed
  65041. */
  65042. StandardMaterial.prototype.needAlphaBlending = function () {
  65043. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled;
  65044. };
  65045. /**
  65046. * Specifies if this material should be rendered in alpha test mode
  65047. * @returns a boolean specifying if an alpha test is needed.
  65048. */
  65049. StandardMaterial.prototype.needAlphaTesting = function () {
  65050. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha;
  65051. };
  65052. StandardMaterial.prototype._shouldUseAlphaFromDiffuseTexture = function () {
  65053. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture;
  65054. };
  65055. /**
  65056. * Get the texture used for alpha test purpose.
  65057. * @returns the diffuse texture in case of the standard material.
  65058. */
  65059. StandardMaterial.prototype.getAlphaTestTexture = function () {
  65060. return this._diffuseTexture;
  65061. };
  65062. /**
  65063. * Get if the submesh is ready to be used and all its information available.
  65064. * Child classes can use it to update shaders
  65065. * @param mesh defines the mesh to check
  65066. * @param subMesh defines which submesh to check
  65067. * @param useInstances specifies that instances should be used
  65068. * @returns a boolean indicating that the submesh is ready or not
  65069. */
  65070. StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  65071. if (useInstances === void 0) { useInstances = false; }
  65072. if (subMesh.effect && this.isFrozen) {
  65073. if (this._wasPreviouslyReady) {
  65074. return true;
  65075. }
  65076. }
  65077. if (!subMesh._materialDefines) {
  65078. subMesh._materialDefines = new StandardMaterialDefines();
  65079. }
  65080. var scene = this.getScene();
  65081. var defines = subMesh._materialDefines;
  65082. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  65083. if (defines._renderId === scene.getRenderId()) {
  65084. return true;
  65085. }
  65086. }
  65087. var engine = scene.getEngine();
  65088. // Lights
  65089. defines._needNormals = _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  65090. // Textures
  65091. if (defines._areTexturesDirty) {
  65092. defines._needUVs = false;
  65093. defines.MAINUV1 = false;
  65094. defines.MAINUV2 = false;
  65095. if (scene.texturesEnabled) {
  65096. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  65097. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  65098. return false;
  65099. }
  65100. else {
  65101. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  65102. }
  65103. }
  65104. else {
  65105. defines.DIFFUSE = false;
  65106. }
  65107. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  65108. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  65109. return false;
  65110. }
  65111. else {
  65112. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  65113. }
  65114. }
  65115. else {
  65116. defines.AMBIENT = false;
  65117. }
  65118. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  65119. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  65120. return false;
  65121. }
  65122. else {
  65123. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  65124. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  65125. }
  65126. }
  65127. else {
  65128. defines.OPACITY = false;
  65129. }
  65130. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  65131. if (!this._reflectionTexture.isReadyOrNotBlocking()) {
  65132. return false;
  65133. }
  65134. else {
  65135. defines._needNormals = true;
  65136. defines.REFLECTION = true;
  65137. defines.ROUGHNESS = (this._roughness > 0);
  65138. defines.REFLECTIONOVERALPHA = this._useReflectionOverAlpha;
  65139. defines.INVERTCUBICMAP = (this._reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE);
  65140. defines.REFLECTIONMAP_3D = this._reflectionTexture.isCube;
  65141. switch (this._reflectionTexture.coordinatesMode) {
  65142. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  65143. defines.setReflectionMode("REFLECTIONMAP_EXPLICIT");
  65144. break;
  65145. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  65146. defines.setReflectionMode("REFLECTIONMAP_PLANAR");
  65147. break;
  65148. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  65149. defines.setReflectionMode("REFLECTIONMAP_PROJECTION");
  65150. break;
  65151. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  65152. defines.setReflectionMode("REFLECTIONMAP_SKYBOX");
  65153. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !this._reflectionTexture.getReflectionTextureMatrix().isIdentity();
  65154. break;
  65155. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  65156. defines.setReflectionMode("REFLECTIONMAP_SPHERICAL");
  65157. break;
  65158. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  65159. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
  65160. break;
  65161. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  65162. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
  65163. break;
  65164. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  65165. defines.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
  65166. break;
  65167. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  65168. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  65169. default:
  65170. defines.setReflectionMode("REFLECTIONMAP_CUBIC");
  65171. break;
  65172. }
  65173. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = this._reflectionTexture.boundingBoxSize ? true : false;
  65174. }
  65175. }
  65176. else {
  65177. defines.REFLECTION = false;
  65178. }
  65179. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  65180. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  65181. return false;
  65182. }
  65183. else {
  65184. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  65185. }
  65186. }
  65187. else {
  65188. defines.EMISSIVE = false;
  65189. }
  65190. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  65191. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  65192. return false;
  65193. }
  65194. else {
  65195. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  65196. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  65197. }
  65198. }
  65199. else {
  65200. defines.LIGHTMAP = false;
  65201. }
  65202. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  65203. if (!this._specularTexture.isReadyOrNotBlocking()) {
  65204. return false;
  65205. }
  65206. else {
  65207. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._specularTexture, defines, "SPECULAR");
  65208. defines.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
  65209. }
  65210. }
  65211. else {
  65212. defines.SPECULAR = false;
  65213. }
  65214. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && StandardMaterial.BumpTextureEnabled) {
  65215. // Bump texure can not be not blocking.
  65216. if (!this._bumpTexture.isReady()) {
  65217. return false;
  65218. }
  65219. else {
  65220. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  65221. defines.PARALLAX = this._useParallax;
  65222. defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
  65223. }
  65224. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  65225. }
  65226. else {
  65227. defines.BUMP = false;
  65228. }
  65229. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  65230. if (!this._refractionTexture.isReadyOrNotBlocking()) {
  65231. return false;
  65232. }
  65233. else {
  65234. defines._needUVs = true;
  65235. defines.REFRACTION = true;
  65236. defines.REFRACTIONMAP_3D = this._refractionTexture.isCube;
  65237. }
  65238. }
  65239. else {
  65240. defines.REFRACTION = false;
  65241. }
  65242. defines.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting;
  65243. }
  65244. else {
  65245. defines.DIFFUSE = false;
  65246. defines.AMBIENT = false;
  65247. defines.OPACITY = false;
  65248. defines.REFLECTION = false;
  65249. defines.EMISSIVE = false;
  65250. defines.LIGHTMAP = false;
  65251. defines.BUMP = false;
  65252. defines.REFRACTION = false;
  65253. }
  65254. defines.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture();
  65255. defines.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination;
  65256. defines.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse;
  65257. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  65258. 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);
  65259. }
  65260. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  65261. if (!this._imageProcessingConfiguration.isReady()) {
  65262. return false;
  65263. }
  65264. this._imageProcessingConfiguration.prepareDefines(defines);
  65265. defines.IS_REFLECTION_LINEAR = (this.reflectionTexture != null && !this.reflectionTexture.gammaSpace);
  65266. defines.IS_REFRACTION_LINEAR = (this.refractionTexture != null && !this.refractionTexture.gammaSpace);
  65267. }
  65268. if (defines._areFresnelDirty) {
  65269. if (StandardMaterial.FresnelEnabled) {
  65270. // Fresnel
  65271. if (this._diffuseFresnelParameters || this._opacityFresnelParameters ||
  65272. this._emissiveFresnelParameters || this._refractionFresnelParameters ||
  65273. this._reflectionFresnelParameters) {
  65274. defines.DIFFUSEFRESNEL = (this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled);
  65275. defines.OPACITYFRESNEL = (this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled);
  65276. defines.REFLECTIONFRESNEL = (this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled);
  65277. defines.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular;
  65278. defines.REFRACTIONFRESNEL = (this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled);
  65279. defines.EMISSIVEFRESNEL = (this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled);
  65280. defines._needNormals = true;
  65281. defines.FRESNEL = true;
  65282. }
  65283. }
  65284. else {
  65285. defines.FRESNEL = false;
  65286. }
  65287. }
  65288. // Misc.
  65289. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  65290. // Attribs
  65291. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true);
  65292. // Values that need to be evaluated on every frame
  65293. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  65294. // Get correct effect
  65295. if (defines.isDirty) {
  65296. defines.markAsProcessed();
  65297. // Fallbacks
  65298. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_7__["EffectFallbacks"]();
  65299. if (defines.REFLECTION) {
  65300. fallbacks.addFallback(0, "REFLECTION");
  65301. }
  65302. if (defines.SPECULAR) {
  65303. fallbacks.addFallback(0, "SPECULAR");
  65304. }
  65305. if (defines.BUMP) {
  65306. fallbacks.addFallback(0, "BUMP");
  65307. }
  65308. if (defines.PARALLAX) {
  65309. fallbacks.addFallback(1, "PARALLAX");
  65310. }
  65311. if (defines.PARALLAXOCCLUSION) {
  65312. fallbacks.addFallback(0, "PARALLAXOCCLUSION");
  65313. }
  65314. if (defines.SPECULAROVERALPHA) {
  65315. fallbacks.addFallback(0, "SPECULAROVERALPHA");
  65316. }
  65317. if (defines.FOG) {
  65318. fallbacks.addFallback(1, "FOG");
  65319. }
  65320. if (defines.POINTSIZE) {
  65321. fallbacks.addFallback(0, "POINTSIZE");
  65322. }
  65323. if (defines.LOGARITHMICDEPTH) {
  65324. fallbacks.addFallback(0, "LOGARITHMICDEPTH");
  65325. }
  65326. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  65327. if (defines.SPECULARTERM) {
  65328. fallbacks.addFallback(0, "SPECULARTERM");
  65329. }
  65330. if (defines.DIFFUSEFRESNEL) {
  65331. fallbacks.addFallback(1, "DIFFUSEFRESNEL");
  65332. }
  65333. if (defines.OPACITYFRESNEL) {
  65334. fallbacks.addFallback(2, "OPACITYFRESNEL");
  65335. }
  65336. if (defines.REFLECTIONFRESNEL) {
  65337. fallbacks.addFallback(3, "REFLECTIONFRESNEL");
  65338. }
  65339. if (defines.EMISSIVEFRESNEL) {
  65340. fallbacks.addFallback(4, "EMISSIVEFRESNEL");
  65341. }
  65342. if (defines.FRESNEL) {
  65343. fallbacks.addFallback(4, "FRESNEL");
  65344. }
  65345. //Attributes
  65346. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  65347. if (defines.NORMAL) {
  65348. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  65349. }
  65350. if (defines.UV1) {
  65351. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  65352. }
  65353. if (defines.UV2) {
  65354. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  65355. }
  65356. if (defines.VERTEXCOLOR) {
  65357. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind);
  65358. }
  65359. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  65360. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  65361. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  65362. var shaderName = "default";
  65363. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor",
  65364. "vFogInfos", "vFogColor", "pointSize",
  65365. "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  65366. "mBones",
  65367. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix",
  65368. "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
  65369. "vReflectionPosition", "vReflectionSize",
  65370. "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth"
  65371. ];
  65372. var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler",
  65373. "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler",
  65374. "refractionCubeSampler", "refraction2DSampler", "boneSampler"];
  65375. var uniformBuffers = ["Material", "Scene"];
  65376. if (_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"]) {
  65377. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  65378. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  65379. }
  65380. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareUniformsAndSamplersList({
  65381. uniformsNames: uniforms,
  65382. uniformBuffersNames: uniformBuffers,
  65383. samplers: samplers,
  65384. defines: defines,
  65385. maxSimultaneousLights: this._maxSimultaneousLights
  65386. });
  65387. if (this.customShaderNameResolve) {
  65388. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  65389. }
  65390. var join = defines.toString();
  65391. var previousEffect = subMesh.effect;
  65392. var effect = scene.getEngine().createEffect(shaderName, {
  65393. attributes: attribs,
  65394. uniformsNames: uniforms,
  65395. uniformBuffersNames: uniformBuffers,
  65396. samplers: samplers,
  65397. defines: join,
  65398. fallbacks: fallbacks,
  65399. onCompiled: this.onCompiled,
  65400. onError: this.onError,
  65401. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  65402. }, engine);
  65403. if (effect) {
  65404. // Use previous effect while new one is compiling
  65405. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  65406. effect = previousEffect;
  65407. defines.markAsUnprocessed();
  65408. }
  65409. else {
  65410. scene.resetCachedMaterial();
  65411. subMesh.setEffect(effect, defines);
  65412. this.buildUniformLayout();
  65413. }
  65414. }
  65415. }
  65416. if (!subMesh.effect || !subMesh.effect.isReady()) {
  65417. return false;
  65418. }
  65419. defines._renderId = scene.getRenderId();
  65420. this._wasPreviouslyReady = true;
  65421. return true;
  65422. };
  65423. /**
  65424. * Builds the material UBO layouts.
  65425. * Used internally during the effect preparation.
  65426. */
  65427. StandardMaterial.prototype.buildUniformLayout = function () {
  65428. // Order is important !
  65429. this._uniformBuffer.addUniform("diffuseLeftColor", 4);
  65430. this._uniformBuffer.addUniform("diffuseRightColor", 4);
  65431. this._uniformBuffer.addUniform("opacityParts", 4);
  65432. this._uniformBuffer.addUniform("reflectionLeftColor", 4);
  65433. this._uniformBuffer.addUniform("reflectionRightColor", 4);
  65434. this._uniformBuffer.addUniform("refractionLeftColor", 4);
  65435. this._uniformBuffer.addUniform("refractionRightColor", 4);
  65436. this._uniformBuffer.addUniform("emissiveLeftColor", 4);
  65437. this._uniformBuffer.addUniform("emissiveRightColor", 4);
  65438. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  65439. this._uniformBuffer.addUniform("vAmbientInfos", 2);
  65440. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  65441. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  65442. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  65443. this._uniformBuffer.addUniform("vReflectionSize", 3);
  65444. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  65445. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  65446. this._uniformBuffer.addUniform("vSpecularInfos", 2);
  65447. this._uniformBuffer.addUniform("vBumpInfos", 3);
  65448. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  65449. this._uniformBuffer.addUniform("ambientMatrix", 16);
  65450. this._uniformBuffer.addUniform("opacityMatrix", 16);
  65451. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  65452. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  65453. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  65454. this._uniformBuffer.addUniform("specularMatrix", 16);
  65455. this._uniformBuffer.addUniform("bumpMatrix", 16);
  65456. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  65457. this._uniformBuffer.addUniform("refractionMatrix", 16);
  65458. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  65459. this._uniformBuffer.addUniform("vSpecularColor", 4);
  65460. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  65461. this._uniformBuffer.addUniform("vDiffuseColor", 4);
  65462. this._uniformBuffer.addUniform("pointSize", 1);
  65463. this._uniformBuffer.create();
  65464. };
  65465. /**
  65466. * Unbinds the material from the mesh
  65467. */
  65468. StandardMaterial.prototype.unbind = function () {
  65469. if (this._activeEffect) {
  65470. var needFlag = false;
  65471. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  65472. this._activeEffect.setTexture("reflection2DSampler", null);
  65473. needFlag = true;
  65474. }
  65475. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  65476. this._activeEffect.setTexture("refraction2DSampler", null);
  65477. needFlag = true;
  65478. }
  65479. if (needFlag) {
  65480. this._markAllSubMeshesAsTexturesDirty();
  65481. }
  65482. }
  65483. _super.prototype.unbind.call(this);
  65484. };
  65485. /**
  65486. * Binds the submesh to this material by preparing the effect and shader to draw
  65487. * @param world defines the world transformation matrix
  65488. * @param mesh defines the mesh containing the submesh
  65489. * @param subMesh defines the submesh to bind the material to
  65490. */
  65491. StandardMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  65492. var scene = this.getScene();
  65493. var defines = subMesh._materialDefines;
  65494. if (!defines) {
  65495. return;
  65496. }
  65497. var effect = subMesh.effect;
  65498. if (!effect) {
  65499. return;
  65500. }
  65501. this._activeEffect = effect;
  65502. // Matrices
  65503. this.bindOnlyWorldMatrix(world);
  65504. // Normal Matrix
  65505. if (defines.OBJECTSPACE_NORMALMAP) {
  65506. world.toNormalMatrix(this._normalMatrix);
  65507. this.bindOnlyNormalMatrix(this._normalMatrix);
  65508. }
  65509. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  65510. // Bones
  65511. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindBonesParameters(mesh, effect);
  65512. if (mustRebind) {
  65513. this._uniformBuffer.bindToEffect(effect, "Material");
  65514. this.bindViewProjection(effect);
  65515. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  65516. if (StandardMaterial.FresnelEnabled && defines.FRESNEL) {
  65517. // Fresnel
  65518. if (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled) {
  65519. this._uniformBuffer.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power);
  65520. this._uniformBuffer.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias);
  65521. }
  65522. if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) {
  65523. 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);
  65524. }
  65525. if (this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
  65526. this._uniformBuffer.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power);
  65527. this._uniformBuffer.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias);
  65528. }
  65529. if (this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled) {
  65530. this._uniformBuffer.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power);
  65531. this._uniformBuffer.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias);
  65532. }
  65533. if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) {
  65534. this._uniformBuffer.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power);
  65535. this._uniformBuffer.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias);
  65536. }
  65537. }
  65538. // Textures
  65539. if (scene.texturesEnabled) {
  65540. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  65541. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  65542. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  65543. if (this._diffuseTexture.hasAlpha) {
  65544. effect.setFloat("alphaCutOff", this.alphaCutOff);
  65545. }
  65546. }
  65547. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  65548. this._uniformBuffer.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level);
  65549. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  65550. }
  65551. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  65552. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  65553. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  65554. }
  65555. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  65556. this._uniformBuffer.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness);
  65557. this._uniformBuffer.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix());
  65558. if (this._reflectionTexture.boundingBoxSize) {
  65559. var cubeTexture = this._reflectionTexture;
  65560. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  65561. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  65562. }
  65563. }
  65564. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  65565. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  65566. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  65567. }
  65568. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  65569. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  65570. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  65571. }
  65572. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  65573. this._uniformBuffer.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level);
  65574. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._specularTexture, this._uniformBuffer, "specular");
  65575. }
  65576. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  65577. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
  65578. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  65579. if (scene._mirroredCameraPosition) {
  65580. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  65581. }
  65582. else {
  65583. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  65584. }
  65585. }
  65586. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  65587. var depth = 1.0;
  65588. if (!this._refractionTexture.isCube) {
  65589. this._uniformBuffer.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix());
  65590. if (this._refractionTexture.depth) {
  65591. depth = this._refractionTexture.depth;
  65592. }
  65593. }
  65594. this._uniformBuffer.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, depth, this.invertRefractionY ? -1 : 1);
  65595. }
  65596. }
  65597. // Point size
  65598. if (this.pointsCloud) {
  65599. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  65600. }
  65601. if (defines.SPECULARTERM) {
  65602. this._uniformBuffer.updateColor4("vSpecularColor", this.specularColor, this.specularPower);
  65603. }
  65604. this._uniformBuffer.updateColor3("vEmissiveColor", StandardMaterial.EmissiveTextureEnabled ? this.emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].BlackReadOnly);
  65605. // Diffuse
  65606. this._uniformBuffer.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  65607. }
  65608. // Textures
  65609. if (scene.texturesEnabled) {
  65610. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  65611. effect.setTexture("diffuseSampler", this._diffuseTexture);
  65612. }
  65613. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  65614. effect.setTexture("ambientSampler", this._ambientTexture);
  65615. }
  65616. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  65617. effect.setTexture("opacitySampler", this._opacityTexture);
  65618. }
  65619. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  65620. if (this._reflectionTexture.isCube) {
  65621. effect.setTexture("reflectionCubeSampler", this._reflectionTexture);
  65622. }
  65623. else {
  65624. effect.setTexture("reflection2DSampler", this._reflectionTexture);
  65625. }
  65626. }
  65627. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  65628. effect.setTexture("emissiveSampler", this._emissiveTexture);
  65629. }
  65630. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  65631. effect.setTexture("lightmapSampler", this._lightmapTexture);
  65632. }
  65633. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  65634. effect.setTexture("specularSampler", this._specularTexture);
  65635. }
  65636. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  65637. effect.setTexture("bumpSampler", this._bumpTexture);
  65638. }
  65639. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  65640. var depth = 1.0;
  65641. if (this._refractionTexture.isCube) {
  65642. effect.setTexture("refractionCubeSampler", this._refractionTexture);
  65643. }
  65644. else {
  65645. effect.setTexture("refraction2DSampler", this._refractionTexture);
  65646. }
  65647. }
  65648. }
  65649. // Clip plane
  65650. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindClipPlane(effect, scene);
  65651. // Colors
  65652. scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
  65653. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindEyePosition(effect, scene);
  65654. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  65655. }
  65656. if (mustRebind || !this.isFrozen) {
  65657. // Lights
  65658. if (scene.lightsEnabled && !this._disableLighting) {
  65659. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLights(scene, mesh, effect, defines, this._maxSimultaneousLights);
  65660. }
  65661. // View
  65662. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].FOGMODE_NONE || this._reflectionTexture || this._refractionTexture) {
  65663. this.bindView(effect);
  65664. }
  65665. // Fog
  65666. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindFogParameters(scene, mesh, effect);
  65667. // Morph targets
  65668. if (defines.NUM_MORPH_INFLUENCERS) {
  65669. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, effect);
  65670. }
  65671. // Log. depth
  65672. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLogDepth(defines, effect, scene);
  65673. // image processing
  65674. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  65675. this._imageProcessingConfiguration.bind(this._activeEffect);
  65676. }
  65677. }
  65678. this._uniformBuffer.update();
  65679. this._afterBind(mesh, this._activeEffect);
  65680. };
  65681. /**
  65682. * Get the list of animatables in the material.
  65683. * @returns the list of animatables object used in the material
  65684. */
  65685. StandardMaterial.prototype.getAnimatables = function () {
  65686. var results = [];
  65687. if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
  65688. results.push(this._diffuseTexture);
  65689. }
  65690. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  65691. results.push(this._ambientTexture);
  65692. }
  65693. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  65694. results.push(this._opacityTexture);
  65695. }
  65696. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  65697. results.push(this._reflectionTexture);
  65698. }
  65699. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  65700. results.push(this._emissiveTexture);
  65701. }
  65702. if (this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0) {
  65703. results.push(this._specularTexture);
  65704. }
  65705. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  65706. results.push(this._bumpTexture);
  65707. }
  65708. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  65709. results.push(this._lightmapTexture);
  65710. }
  65711. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  65712. results.push(this._refractionTexture);
  65713. }
  65714. return results;
  65715. };
  65716. /**
  65717. * Gets the active textures from the material
  65718. * @returns an array of textures
  65719. */
  65720. StandardMaterial.prototype.getActiveTextures = function () {
  65721. var activeTextures = _super.prototype.getActiveTextures.call(this);
  65722. if (this._diffuseTexture) {
  65723. activeTextures.push(this._diffuseTexture);
  65724. }
  65725. if (this._ambientTexture) {
  65726. activeTextures.push(this._ambientTexture);
  65727. }
  65728. if (this._opacityTexture) {
  65729. activeTextures.push(this._opacityTexture);
  65730. }
  65731. if (this._reflectionTexture) {
  65732. activeTextures.push(this._reflectionTexture);
  65733. }
  65734. if (this._emissiveTexture) {
  65735. activeTextures.push(this._emissiveTexture);
  65736. }
  65737. if (this._specularTexture) {
  65738. activeTextures.push(this._specularTexture);
  65739. }
  65740. if (this._bumpTexture) {
  65741. activeTextures.push(this._bumpTexture);
  65742. }
  65743. if (this._lightmapTexture) {
  65744. activeTextures.push(this._lightmapTexture);
  65745. }
  65746. if (this._refractionTexture) {
  65747. activeTextures.push(this._refractionTexture);
  65748. }
  65749. return activeTextures;
  65750. };
  65751. /**
  65752. * Specifies if the material uses a texture
  65753. * @param texture defines the texture to check against the material
  65754. * @returns a boolean specifying if the material uses the texture
  65755. */
  65756. StandardMaterial.prototype.hasTexture = function (texture) {
  65757. if (_super.prototype.hasTexture.call(this, texture)) {
  65758. return true;
  65759. }
  65760. if (this._diffuseTexture === texture) {
  65761. return true;
  65762. }
  65763. if (this._ambientTexture === texture) {
  65764. return true;
  65765. }
  65766. if (this._opacityTexture === texture) {
  65767. return true;
  65768. }
  65769. if (this._reflectionTexture === texture) {
  65770. return true;
  65771. }
  65772. if (this._emissiveTexture === texture) {
  65773. return true;
  65774. }
  65775. if (this._specularTexture === texture) {
  65776. return true;
  65777. }
  65778. if (this._bumpTexture === texture) {
  65779. return true;
  65780. }
  65781. if (this._lightmapTexture === texture) {
  65782. return true;
  65783. }
  65784. if (this._refractionTexture === texture) {
  65785. return true;
  65786. }
  65787. return false;
  65788. };
  65789. /**
  65790. * Disposes the material
  65791. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  65792. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  65793. */
  65794. StandardMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  65795. if (forceDisposeTextures) {
  65796. if (this._diffuseTexture) {
  65797. this._diffuseTexture.dispose();
  65798. }
  65799. if (this._ambientTexture) {
  65800. this._ambientTexture.dispose();
  65801. }
  65802. if (this._opacityTexture) {
  65803. this._opacityTexture.dispose();
  65804. }
  65805. if (this._reflectionTexture) {
  65806. this._reflectionTexture.dispose();
  65807. }
  65808. if (this._emissiveTexture) {
  65809. this._emissiveTexture.dispose();
  65810. }
  65811. if (this._specularTexture) {
  65812. this._specularTexture.dispose();
  65813. }
  65814. if (this._bumpTexture) {
  65815. this._bumpTexture.dispose();
  65816. }
  65817. if (this._lightmapTexture) {
  65818. this._lightmapTexture.dispose();
  65819. }
  65820. if (this._refractionTexture) {
  65821. this._refractionTexture.dispose();
  65822. }
  65823. }
  65824. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  65825. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  65826. }
  65827. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  65828. };
  65829. /**
  65830. * Makes a duplicate of the material, and gives it a new name
  65831. * @param name defines the new name for the duplicated material
  65832. * @returns the cloned material
  65833. */
  65834. StandardMaterial.prototype.clone = function (name) {
  65835. var _this = this;
  65836. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new StandardMaterial(name, _this.getScene()); }, this);
  65837. result.name = name;
  65838. result.id = name;
  65839. return result;
  65840. };
  65841. /**
  65842. * Serializes this material in a JSON representation
  65843. * @returns the serialized material object
  65844. */
  65845. StandardMaterial.prototype.serialize = function () {
  65846. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  65847. };
  65848. /**
  65849. * Creates a standard material from parsed material data
  65850. * @param source defines the JSON representation of the material
  65851. * @param scene defines the hosting scene
  65852. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  65853. * @returns a new standard material
  65854. */
  65855. StandardMaterial.Parse = function (source, scene, rootUrl) {
  65856. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardMaterial(source.name, scene); }, source, scene, rootUrl);
  65857. };
  65858. Object.defineProperty(StandardMaterial, "DiffuseTextureEnabled", {
  65859. // Flags used to enable or disable a type of texture for all Standard Materials
  65860. /**
  65861. * Are diffuse textures enabled in the application.
  65862. */
  65863. get: function () {
  65864. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled;
  65865. },
  65866. set: function (value) {
  65867. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled = value;
  65868. },
  65869. enumerable: true,
  65870. configurable: true
  65871. });
  65872. Object.defineProperty(StandardMaterial, "AmbientTextureEnabled", {
  65873. /**
  65874. * Are ambient textures enabled in the application.
  65875. */
  65876. get: function () {
  65877. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled;
  65878. },
  65879. set: function (value) {
  65880. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled = value;
  65881. },
  65882. enumerable: true,
  65883. configurable: true
  65884. });
  65885. Object.defineProperty(StandardMaterial, "OpacityTextureEnabled", {
  65886. /**
  65887. * Are opacity textures enabled in the application.
  65888. */
  65889. get: function () {
  65890. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled;
  65891. },
  65892. set: function (value) {
  65893. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled = value;
  65894. },
  65895. enumerable: true,
  65896. configurable: true
  65897. });
  65898. Object.defineProperty(StandardMaterial, "ReflectionTextureEnabled", {
  65899. /**
  65900. * Are reflection textures enabled in the application.
  65901. */
  65902. get: function () {
  65903. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled;
  65904. },
  65905. set: function (value) {
  65906. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled = value;
  65907. },
  65908. enumerable: true,
  65909. configurable: true
  65910. });
  65911. Object.defineProperty(StandardMaterial, "EmissiveTextureEnabled", {
  65912. /**
  65913. * Are emissive textures enabled in the application.
  65914. */
  65915. get: function () {
  65916. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled;
  65917. },
  65918. set: function (value) {
  65919. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled = value;
  65920. },
  65921. enumerable: true,
  65922. configurable: true
  65923. });
  65924. Object.defineProperty(StandardMaterial, "SpecularTextureEnabled", {
  65925. /**
  65926. * Are specular textures enabled in the application.
  65927. */
  65928. get: function () {
  65929. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled;
  65930. },
  65931. set: function (value) {
  65932. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled = value;
  65933. },
  65934. enumerable: true,
  65935. configurable: true
  65936. });
  65937. Object.defineProperty(StandardMaterial, "BumpTextureEnabled", {
  65938. /**
  65939. * Are bump textures enabled in the application.
  65940. */
  65941. get: function () {
  65942. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled;
  65943. },
  65944. set: function (value) {
  65945. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled = value;
  65946. },
  65947. enumerable: true,
  65948. configurable: true
  65949. });
  65950. Object.defineProperty(StandardMaterial, "LightmapTextureEnabled", {
  65951. /**
  65952. * Are lightmap textures enabled in the application.
  65953. */
  65954. get: function () {
  65955. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled;
  65956. },
  65957. set: function (value) {
  65958. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled = value;
  65959. },
  65960. enumerable: true,
  65961. configurable: true
  65962. });
  65963. Object.defineProperty(StandardMaterial, "RefractionTextureEnabled", {
  65964. /**
  65965. * Are refraction textures enabled in the application.
  65966. */
  65967. get: function () {
  65968. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled;
  65969. },
  65970. set: function (value) {
  65971. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled = value;
  65972. },
  65973. enumerable: true,
  65974. configurable: true
  65975. });
  65976. Object.defineProperty(StandardMaterial, "ColorGradingTextureEnabled", {
  65977. /**
  65978. * Are color grading textures enabled in the application.
  65979. */
  65980. get: function () {
  65981. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled;
  65982. },
  65983. set: function (value) {
  65984. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled = value;
  65985. },
  65986. enumerable: true,
  65987. configurable: true
  65988. });
  65989. Object.defineProperty(StandardMaterial, "FresnelEnabled", {
  65990. /**
  65991. * Are fresnels enabled in the application.
  65992. */
  65993. get: function () {
  65994. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled;
  65995. },
  65996. set: function (value) {
  65997. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled = value;
  65998. },
  65999. enumerable: true,
  66000. configurable: true
  66001. });
  66002. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66003. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
  66004. ], StandardMaterial.prototype, "_diffuseTexture", void 0);
  66005. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66006. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  66007. ], StandardMaterial.prototype, "diffuseTexture", void 0);
  66008. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66009. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("ambientTexture")
  66010. ], StandardMaterial.prototype, "_ambientTexture", void 0);
  66011. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66012. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66013. ], StandardMaterial.prototype, "ambientTexture", void 0);
  66014. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66015. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("opacityTexture")
  66016. ], StandardMaterial.prototype, "_opacityTexture", void 0);
  66017. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66018. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  66019. ], StandardMaterial.prototype, "opacityTexture", void 0);
  66020. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66021. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("reflectionTexture")
  66022. ], StandardMaterial.prototype, "_reflectionTexture", void 0);
  66023. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66024. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66025. ], StandardMaterial.prototype, "reflectionTexture", void 0);
  66026. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66027. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("emissiveTexture")
  66028. ], StandardMaterial.prototype, "_emissiveTexture", void 0);
  66029. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66030. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66031. ], StandardMaterial.prototype, "emissiveTexture", void 0);
  66032. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66033. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("specularTexture")
  66034. ], StandardMaterial.prototype, "_specularTexture", void 0);
  66035. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66036. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66037. ], StandardMaterial.prototype, "specularTexture", void 0);
  66038. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66039. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("bumpTexture")
  66040. ], StandardMaterial.prototype, "_bumpTexture", void 0);
  66041. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66042. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66043. ], StandardMaterial.prototype, "bumpTexture", void 0);
  66044. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66045. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lightmapTexture")
  66046. ], StandardMaterial.prototype, "_lightmapTexture", void 0);
  66047. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66048. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66049. ], StandardMaterial.prototype, "lightmapTexture", void 0);
  66050. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66051. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("refractionTexture")
  66052. ], StandardMaterial.prototype, "_refractionTexture", void 0);
  66053. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66054. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66055. ], StandardMaterial.prototype, "refractionTexture", void 0);
  66056. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66057. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient")
  66058. ], StandardMaterial.prototype, "ambientColor", void 0);
  66059. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66060. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse")
  66061. ], StandardMaterial.prototype, "diffuseColor", void 0);
  66062. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66063. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular")
  66064. ], StandardMaterial.prototype, "specularColor", void 0);
  66065. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66066. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive")
  66067. ], StandardMaterial.prototype, "emissiveColor", void 0);
  66068. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66069. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66070. ], StandardMaterial.prototype, "specularPower", void 0);
  66071. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66072. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useAlphaFromDiffuseTexture")
  66073. ], StandardMaterial.prototype, "_useAlphaFromDiffuseTexture", void 0);
  66074. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66075. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66076. ], StandardMaterial.prototype, "useAlphaFromDiffuseTexture", void 0);
  66077. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66078. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useEmissiveAsIllumination")
  66079. ], StandardMaterial.prototype, "_useEmissiveAsIllumination", void 0);
  66080. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66081. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66082. ], StandardMaterial.prototype, "useEmissiveAsIllumination", void 0);
  66083. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66084. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("linkEmissiveWithDiffuse")
  66085. ], StandardMaterial.prototype, "_linkEmissiveWithDiffuse", void 0);
  66086. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66087. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66088. ], StandardMaterial.prototype, "linkEmissiveWithDiffuse", void 0);
  66089. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66090. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useSpecularOverAlpha")
  66091. ], StandardMaterial.prototype, "_useSpecularOverAlpha", void 0);
  66092. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66093. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66094. ], StandardMaterial.prototype, "useSpecularOverAlpha", void 0);
  66095. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66096. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionOverAlpha")
  66097. ], StandardMaterial.prototype, "_useReflectionOverAlpha", void 0);
  66098. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66099. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66100. ], StandardMaterial.prototype, "useReflectionOverAlpha", void 0);
  66101. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66102. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
  66103. ], StandardMaterial.prototype, "_disableLighting", void 0);
  66104. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66105. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  66106. ], StandardMaterial.prototype, "disableLighting", void 0);
  66107. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66108. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useObjectSpaceNormalMap")
  66109. ], StandardMaterial.prototype, "_useObjectSpaceNormalMap", void 0);
  66110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66112. ], StandardMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  66113. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66114. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallax")
  66115. ], StandardMaterial.prototype, "_useParallax", void 0);
  66116. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66117. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66118. ], StandardMaterial.prototype, "useParallax", void 0);
  66119. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66120. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallaxOcclusion")
  66121. ], StandardMaterial.prototype, "_useParallaxOcclusion", void 0);
  66122. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66123. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66124. ], StandardMaterial.prototype, "useParallaxOcclusion", void 0);
  66125. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66126. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66127. ], StandardMaterial.prototype, "parallaxScaleBias", void 0);
  66128. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66129. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("roughness")
  66130. ], StandardMaterial.prototype, "_roughness", void 0);
  66131. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66132. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66133. ], StandardMaterial.prototype, "roughness", void 0);
  66134. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66135. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66136. ], StandardMaterial.prototype, "indexOfRefraction", void 0);
  66137. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66138. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66139. ], StandardMaterial.prototype, "invertRefractionY", void 0);
  66140. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66141. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66142. ], StandardMaterial.prototype, "alphaCutOff", void 0);
  66143. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66144. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useLightmapAsShadowmap")
  66145. ], StandardMaterial.prototype, "_useLightmapAsShadowmap", void 0);
  66146. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66147. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66148. ], StandardMaterial.prototype, "useLightmapAsShadowmap", void 0);
  66149. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66150. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("diffuseFresnelParameters")
  66151. ], StandardMaterial.prototype, "_diffuseFresnelParameters", void 0);
  66152. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66153. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66154. ], StandardMaterial.prototype, "diffuseFresnelParameters", void 0);
  66155. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66156. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("opacityFresnelParameters")
  66157. ], StandardMaterial.prototype, "_opacityFresnelParameters", void 0);
  66158. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66159. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelAndMiscDirty")
  66160. ], StandardMaterial.prototype, "opacityFresnelParameters", void 0);
  66161. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66162. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("reflectionFresnelParameters")
  66163. ], StandardMaterial.prototype, "_reflectionFresnelParameters", void 0);
  66164. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66165. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66166. ], StandardMaterial.prototype, "reflectionFresnelParameters", void 0);
  66167. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66168. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("refractionFresnelParameters")
  66169. ], StandardMaterial.prototype, "_refractionFresnelParameters", void 0);
  66170. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66171. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66172. ], StandardMaterial.prototype, "refractionFresnelParameters", void 0);
  66173. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66174. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("emissiveFresnelParameters")
  66175. ], StandardMaterial.prototype, "_emissiveFresnelParameters", void 0);
  66176. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66177. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66178. ], StandardMaterial.prototype, "emissiveFresnelParameters", void 0);
  66179. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66180. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionFresnelFromSpecular")
  66181. ], StandardMaterial.prototype, "_useReflectionFresnelFromSpecular", void 0);
  66182. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66183. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66184. ], StandardMaterial.prototype, "useReflectionFresnelFromSpecular", void 0);
  66185. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66186. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useGlossinessFromSpecularMapAlpha")
  66187. ], StandardMaterial.prototype, "_useGlossinessFromSpecularMapAlpha", void 0);
  66188. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66189. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66190. ], StandardMaterial.prototype, "useGlossinessFromSpecularMapAlpha", void 0);
  66191. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66192. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
  66193. ], StandardMaterial.prototype, "_maxSimultaneousLights", void 0);
  66194. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66195. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  66196. ], StandardMaterial.prototype, "maxSimultaneousLights", void 0);
  66197. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66198. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapX")
  66199. ], StandardMaterial.prototype, "_invertNormalMapX", void 0);
  66200. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66201. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66202. ], StandardMaterial.prototype, "invertNormalMapX", void 0);
  66203. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66204. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapY")
  66205. ], StandardMaterial.prototype, "_invertNormalMapY", void 0);
  66206. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66207. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66208. ], StandardMaterial.prototype, "invertNormalMapY", void 0);
  66209. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66210. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("twoSidedLighting")
  66211. ], StandardMaterial.prototype, "_twoSidedLighting", void 0);
  66212. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66213. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66214. ], StandardMaterial.prototype, "twoSidedLighting", void 0);
  66215. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66216. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66217. ], StandardMaterial.prototype, "useLogarithmicDepth", null);
  66218. return StandardMaterial;
  66219. }(_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  66220. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardMaterial"] = StandardMaterial;
  66221. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].DefaultMaterialFactory = function (scene) {
  66222. return new StandardMaterial("default material", scene);
  66223. };
  66224. /***/ }),
  66225. /***/ "./Materials/uniformBuffer.ts":
  66226. /*!************************************!*\
  66227. !*** ./Materials/uniformBuffer.ts ***!
  66228. \************************************/
  66229. /*! exports provided: UniformBuffer */
  66230. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66231. "use strict";
  66232. __webpack_require__.r(__webpack_exports__);
  66233. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return UniformBuffer; });
  66234. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  66235. /**
  66236. * Uniform buffer objects.
  66237. *
  66238. * Handles blocks of uniform on the GPU.
  66239. *
  66240. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  66241. *
  66242. * For more information, please refer to :
  66243. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  66244. */
  66245. var UniformBuffer = /** @class */ (function () {
  66246. /**
  66247. * Instantiates a new Uniform buffer objects.
  66248. *
  66249. * Handles blocks of uniform on the GPU.
  66250. *
  66251. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  66252. *
  66253. * For more information, please refer to :
  66254. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  66255. * @param engine Define the engine the buffer is associated with
  66256. * @param data Define the data contained in the buffer
  66257. * @param dynamic Define if the buffer is updatable
  66258. */
  66259. function UniformBuffer(engine, data, dynamic) {
  66260. this._engine = engine;
  66261. this._noUBO = !engine.supportsUniformBuffers;
  66262. this._dynamic = dynamic;
  66263. this._data = data || [];
  66264. this._uniformLocations = {};
  66265. this._uniformSizes = {};
  66266. this._uniformLocationPointer = 0;
  66267. this._needSync = false;
  66268. if (this._noUBO) {
  66269. this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;
  66270. this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;
  66271. this.updateFloat = this._updateFloatForEffect;
  66272. this.updateFloat2 = this._updateFloat2ForEffect;
  66273. this.updateFloat3 = this._updateFloat3ForEffect;
  66274. this.updateFloat4 = this._updateFloat4ForEffect;
  66275. this.updateMatrix = this._updateMatrixForEffect;
  66276. this.updateVector3 = this._updateVector3ForEffect;
  66277. this.updateVector4 = this._updateVector4ForEffect;
  66278. this.updateColor3 = this._updateColor3ForEffect;
  66279. this.updateColor4 = this._updateColor4ForEffect;
  66280. }
  66281. else {
  66282. this._engine._uniformBuffers.push(this);
  66283. this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;
  66284. this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;
  66285. this.updateFloat = this._updateFloatForUniform;
  66286. this.updateFloat2 = this._updateFloat2ForUniform;
  66287. this.updateFloat3 = this._updateFloat3ForUniform;
  66288. this.updateFloat4 = this._updateFloat4ForUniform;
  66289. this.updateMatrix = this._updateMatrixForUniform;
  66290. this.updateVector3 = this._updateVector3ForUniform;
  66291. this.updateVector4 = this._updateVector4ForUniform;
  66292. this.updateColor3 = this._updateColor3ForUniform;
  66293. this.updateColor4 = this._updateColor4ForUniform;
  66294. }
  66295. }
  66296. Object.defineProperty(UniformBuffer.prototype, "useUbo", {
  66297. /**
  66298. * Indicates if the buffer is using the WebGL2 UBO implementation,
  66299. * or just falling back on setUniformXXX calls.
  66300. */
  66301. get: function () {
  66302. return !this._noUBO;
  66303. },
  66304. enumerable: true,
  66305. configurable: true
  66306. });
  66307. Object.defineProperty(UniformBuffer.prototype, "isSync", {
  66308. /**
  66309. * Indicates if the WebGL underlying uniform buffer is in sync
  66310. * with the javascript cache data.
  66311. */
  66312. get: function () {
  66313. return !this._needSync;
  66314. },
  66315. enumerable: true,
  66316. configurable: true
  66317. });
  66318. /**
  66319. * Indicates if the WebGL underlying uniform buffer is dynamic.
  66320. * Also, a dynamic UniformBuffer will disable cache verification and always
  66321. * update the underlying WebGL uniform buffer to the GPU.
  66322. * @returns if Dynamic, otherwise false
  66323. */
  66324. UniformBuffer.prototype.isDynamic = function () {
  66325. return this._dynamic !== undefined;
  66326. };
  66327. /**
  66328. * The data cache on JS side.
  66329. * @returns the underlying data as a float array
  66330. */
  66331. UniformBuffer.prototype.getData = function () {
  66332. return this._bufferData;
  66333. };
  66334. /**
  66335. * The underlying WebGL Uniform buffer.
  66336. * @returns the webgl buffer
  66337. */
  66338. UniformBuffer.prototype.getBuffer = function () {
  66339. return this._buffer;
  66340. };
  66341. /**
  66342. * std140 layout specifies how to align data within an UBO structure.
  66343. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  66344. * for specs.
  66345. */
  66346. UniformBuffer.prototype._fillAlignment = function (size) {
  66347. // This code has been simplified because we only use floats, vectors of 1, 2, 3, 4 components
  66348. // and 4x4 matrices
  66349. // TODO : change if other types are used
  66350. var alignment;
  66351. if (size <= 2) {
  66352. alignment = size;
  66353. }
  66354. else {
  66355. alignment = 4;
  66356. }
  66357. if ((this._uniformLocationPointer % alignment) !== 0) {
  66358. var oldPointer = this._uniformLocationPointer;
  66359. this._uniformLocationPointer += alignment - (this._uniformLocationPointer % alignment);
  66360. var diff = this._uniformLocationPointer - oldPointer;
  66361. for (var i = 0; i < diff; i++) {
  66362. this._data.push(0);
  66363. }
  66364. }
  66365. };
  66366. /**
  66367. * Adds an uniform in the buffer.
  66368. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  66369. * for the layout to be correct !
  66370. * @param name Name of the uniform, as used in the uniform block in the shader.
  66371. * @param size Data size, or data directly.
  66372. */
  66373. UniformBuffer.prototype.addUniform = function (name, size) {
  66374. if (this._noUBO) {
  66375. return;
  66376. }
  66377. if (this._uniformLocations[name] !== undefined) {
  66378. // Already existing uniform
  66379. return;
  66380. }
  66381. // This function must be called in the order of the shader layout !
  66382. // size can be the size of the uniform, or data directly
  66383. var data;
  66384. if (size instanceof Array) {
  66385. data = size;
  66386. size = data.length;
  66387. }
  66388. else {
  66389. size = size;
  66390. data = [];
  66391. // Fill with zeros
  66392. for (var i = 0; i < size; i++) {
  66393. data.push(0);
  66394. }
  66395. }
  66396. this._fillAlignment(size);
  66397. this._uniformSizes[name] = size;
  66398. this._uniformLocations[name] = this._uniformLocationPointer;
  66399. this._uniformLocationPointer += size;
  66400. for (var i = 0; i < size; i++) {
  66401. this._data.push(data[i]);
  66402. }
  66403. this._needSync = true;
  66404. };
  66405. /**
  66406. * Adds a Matrix 4x4 to the uniform buffer.
  66407. * @param name Name of the uniform, as used in the uniform block in the shader.
  66408. * @param mat A 4x4 matrix.
  66409. */
  66410. UniformBuffer.prototype.addMatrix = function (name, mat) {
  66411. this.addUniform(name, Array.prototype.slice.call(mat.toArray()));
  66412. };
  66413. /**
  66414. * Adds a vec2 to the uniform buffer.
  66415. * @param name Name of the uniform, as used in the uniform block in the shader.
  66416. * @param x Define the x component value of the vec2
  66417. * @param y Define the y component value of the vec2
  66418. */
  66419. UniformBuffer.prototype.addFloat2 = function (name, x, y) {
  66420. var temp = [x, y];
  66421. this.addUniform(name, temp);
  66422. };
  66423. /**
  66424. * Adds a vec3 to the uniform buffer.
  66425. * @param name Name of the uniform, as used in the uniform block in the shader.
  66426. * @param x Define the x component value of the vec3
  66427. * @param y Define the y component value of the vec3
  66428. * @param z Define the z component value of the vec3
  66429. */
  66430. UniformBuffer.prototype.addFloat3 = function (name, x, y, z) {
  66431. var temp = [x, y, z];
  66432. this.addUniform(name, temp);
  66433. };
  66434. /**
  66435. * Adds a vec3 to the uniform buffer.
  66436. * @param name Name of the uniform, as used in the uniform block in the shader.
  66437. * @param color Define the vec3 from a Color
  66438. */
  66439. UniformBuffer.prototype.addColor3 = function (name, color) {
  66440. var temp = new Array();
  66441. color.toArray(temp);
  66442. this.addUniform(name, temp);
  66443. };
  66444. /**
  66445. * Adds a vec4 to the uniform buffer.
  66446. * @param name Name of the uniform, as used in the uniform block in the shader.
  66447. * @param color Define the rgb components from a Color
  66448. * @param alpha Define the a component of the vec4
  66449. */
  66450. UniformBuffer.prototype.addColor4 = function (name, color, alpha) {
  66451. var temp = new Array();
  66452. color.toArray(temp);
  66453. temp.push(alpha);
  66454. this.addUniform(name, temp);
  66455. };
  66456. /**
  66457. * Adds a vec3 to the uniform buffer.
  66458. * @param name Name of the uniform, as used in the uniform block in the shader.
  66459. * @param vector Define the vec3 components from a Vector
  66460. */
  66461. UniformBuffer.prototype.addVector3 = function (name, vector) {
  66462. var temp = new Array();
  66463. vector.toArray(temp);
  66464. this.addUniform(name, temp);
  66465. };
  66466. /**
  66467. * Adds a Matrix 3x3 to the uniform buffer.
  66468. * @param name Name of the uniform, as used in the uniform block in the shader.
  66469. */
  66470. UniformBuffer.prototype.addMatrix3x3 = function (name) {
  66471. this.addUniform(name, 12);
  66472. };
  66473. /**
  66474. * Adds a Matrix 2x2 to the uniform buffer.
  66475. * @param name Name of the uniform, as used in the uniform block in the shader.
  66476. */
  66477. UniformBuffer.prototype.addMatrix2x2 = function (name) {
  66478. this.addUniform(name, 8);
  66479. };
  66480. /**
  66481. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  66482. */
  66483. UniformBuffer.prototype.create = function () {
  66484. if (this._noUBO) {
  66485. return;
  66486. }
  66487. if (this._buffer) {
  66488. return; // nothing to do
  66489. }
  66490. // See spec, alignment must be filled as a vec4
  66491. this._fillAlignment(4);
  66492. this._bufferData = new Float32Array(this._data);
  66493. this._rebuild();
  66494. this._needSync = true;
  66495. };
  66496. /** @hidden */
  66497. UniformBuffer.prototype._rebuild = function () {
  66498. if (this._noUBO) {
  66499. return;
  66500. }
  66501. if (this._dynamic) {
  66502. this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData);
  66503. }
  66504. else {
  66505. this._buffer = this._engine.createUniformBuffer(this._bufferData);
  66506. }
  66507. };
  66508. /**
  66509. * Updates the WebGL Uniform Buffer on the GPU.
  66510. * If the `dynamic` flag is set to true, no cache comparison is done.
  66511. * Otherwise, the buffer will be updated only if the cache differs.
  66512. */
  66513. UniformBuffer.prototype.update = function () {
  66514. if (!this._buffer) {
  66515. this.create();
  66516. return;
  66517. }
  66518. if (!this._dynamic && !this._needSync) {
  66519. return;
  66520. }
  66521. this._engine.updateUniformBuffer(this._buffer, this._bufferData);
  66522. this._needSync = false;
  66523. };
  66524. /**
  66525. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  66526. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  66527. * @param data Define the flattened data
  66528. * @param size Define the size of the data.
  66529. */
  66530. UniformBuffer.prototype.updateUniform = function (uniformName, data, size) {
  66531. var location = this._uniformLocations[uniformName];
  66532. if (location === undefined) {
  66533. if (this._buffer) {
  66534. // Cannot add an uniform if the buffer is already created
  66535. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add an uniform after UBO has been created.");
  66536. return;
  66537. }
  66538. this.addUniform(uniformName, size);
  66539. location = this._uniformLocations[uniformName];
  66540. }
  66541. if (!this._buffer) {
  66542. this.create();
  66543. }
  66544. if (!this._dynamic) {
  66545. // Cache for static uniform buffers
  66546. var changed = false;
  66547. for (var i = 0; i < size; i++) {
  66548. if (this._bufferData[location + i] !== data[i]) {
  66549. changed = true;
  66550. this._bufferData[location + i] = data[i];
  66551. }
  66552. }
  66553. this._needSync = this._needSync || changed;
  66554. }
  66555. else {
  66556. // No cache for dynamic
  66557. for (var i = 0; i < size; i++) {
  66558. this._bufferData[location + i] = data[i];
  66559. }
  66560. }
  66561. };
  66562. // Update methods
  66563. UniformBuffer.prototype._updateMatrix3x3ForUniform = function (name, matrix) {
  66564. // To match std140, matrix must be realigned
  66565. for (var i = 0; i < 3; i++) {
  66566. UniformBuffer._tempBuffer[i * 4] = matrix[i * 3];
  66567. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 3 + 1];
  66568. UniformBuffer._tempBuffer[i * 4 + 2] = matrix[i * 3 + 2];
  66569. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  66570. }
  66571. this.updateUniform(name, UniformBuffer._tempBuffer, 12);
  66572. };
  66573. UniformBuffer.prototype._updateMatrix3x3ForEffect = function (name, matrix) {
  66574. this._currentEffect.setMatrix3x3(name, matrix);
  66575. };
  66576. UniformBuffer.prototype._updateMatrix2x2ForEffect = function (name, matrix) {
  66577. this._currentEffect.setMatrix2x2(name, matrix);
  66578. };
  66579. UniformBuffer.prototype._updateMatrix2x2ForUniform = function (name, matrix) {
  66580. // To match std140, matrix must be realigned
  66581. for (var i = 0; i < 2; i++) {
  66582. UniformBuffer._tempBuffer[i * 4] = matrix[i * 2];
  66583. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 2 + 1];
  66584. UniformBuffer._tempBuffer[i * 4 + 2] = 0.0;
  66585. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  66586. }
  66587. this.updateUniform(name, UniformBuffer._tempBuffer, 8);
  66588. };
  66589. UniformBuffer.prototype._updateFloatForEffect = function (name, x) {
  66590. this._currentEffect.setFloat(name, x);
  66591. };
  66592. UniformBuffer.prototype._updateFloatForUniform = function (name, x) {
  66593. UniformBuffer._tempBuffer[0] = x;
  66594. this.updateUniform(name, UniformBuffer._tempBuffer, 1);
  66595. };
  66596. UniformBuffer.prototype._updateFloat2ForEffect = function (name, x, y, suffix) {
  66597. if (suffix === void 0) { suffix = ""; }
  66598. this._currentEffect.setFloat2(name + suffix, x, y);
  66599. };
  66600. UniformBuffer.prototype._updateFloat2ForUniform = function (name, x, y) {
  66601. UniformBuffer._tempBuffer[0] = x;
  66602. UniformBuffer._tempBuffer[1] = y;
  66603. this.updateUniform(name, UniformBuffer._tempBuffer, 2);
  66604. };
  66605. UniformBuffer.prototype._updateFloat3ForEffect = function (name, x, y, z, suffix) {
  66606. if (suffix === void 0) { suffix = ""; }
  66607. this._currentEffect.setFloat3(name + suffix, x, y, z);
  66608. };
  66609. UniformBuffer.prototype._updateFloat3ForUniform = function (name, x, y, z) {
  66610. UniformBuffer._tempBuffer[0] = x;
  66611. UniformBuffer._tempBuffer[1] = y;
  66612. UniformBuffer._tempBuffer[2] = z;
  66613. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  66614. };
  66615. UniformBuffer.prototype._updateFloat4ForEffect = function (name, x, y, z, w, suffix) {
  66616. if (suffix === void 0) { suffix = ""; }
  66617. this._currentEffect.setFloat4(name + suffix, x, y, z, w);
  66618. };
  66619. UniformBuffer.prototype._updateFloat4ForUniform = function (name, x, y, z, w) {
  66620. UniformBuffer._tempBuffer[0] = x;
  66621. UniformBuffer._tempBuffer[1] = y;
  66622. UniformBuffer._tempBuffer[2] = z;
  66623. UniformBuffer._tempBuffer[3] = w;
  66624. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  66625. };
  66626. UniformBuffer.prototype._updateMatrixForEffect = function (name, mat) {
  66627. this._currentEffect.setMatrix(name, mat);
  66628. };
  66629. UniformBuffer.prototype._updateMatrixForUniform = function (name, mat) {
  66630. this.updateUniform(name, mat.toArray(), 16);
  66631. };
  66632. UniformBuffer.prototype._updateVector3ForEffect = function (name, vector) {
  66633. this._currentEffect.setVector3(name, vector);
  66634. };
  66635. UniformBuffer.prototype._updateVector3ForUniform = function (name, vector) {
  66636. vector.toArray(UniformBuffer._tempBuffer);
  66637. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  66638. };
  66639. UniformBuffer.prototype._updateVector4ForEffect = function (name, vector) {
  66640. this._currentEffect.setVector4(name, vector);
  66641. };
  66642. UniformBuffer.prototype._updateVector4ForUniform = function (name, vector) {
  66643. vector.toArray(UniformBuffer._tempBuffer);
  66644. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  66645. };
  66646. UniformBuffer.prototype._updateColor3ForEffect = function (name, color, suffix) {
  66647. if (suffix === void 0) { suffix = ""; }
  66648. this._currentEffect.setColor3(name + suffix, color);
  66649. };
  66650. UniformBuffer.prototype._updateColor3ForUniform = function (name, color) {
  66651. color.toArray(UniformBuffer._tempBuffer);
  66652. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  66653. };
  66654. UniformBuffer.prototype._updateColor4ForEffect = function (name, color, alpha, suffix) {
  66655. if (suffix === void 0) { suffix = ""; }
  66656. this._currentEffect.setColor4(name + suffix, color, alpha);
  66657. };
  66658. UniformBuffer.prototype._updateColor4ForUniform = function (name, color, alpha) {
  66659. color.toArray(UniformBuffer._tempBuffer);
  66660. UniformBuffer._tempBuffer[3] = alpha;
  66661. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  66662. };
  66663. /**
  66664. * Sets a sampler uniform on the effect.
  66665. * @param name Define the name of the sampler.
  66666. * @param texture Define the texture to set in the sampler
  66667. */
  66668. UniformBuffer.prototype.setTexture = function (name, texture) {
  66669. this._currentEffect.setTexture(name, texture);
  66670. };
  66671. /**
  66672. * Directly updates the value of the uniform in the cache AND on the GPU.
  66673. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  66674. * @param data Define the flattened data
  66675. */
  66676. UniformBuffer.prototype.updateUniformDirectly = function (uniformName, data) {
  66677. this.updateUniform(uniformName, data, data.length);
  66678. this.update();
  66679. };
  66680. /**
  66681. * Binds this uniform buffer to an effect.
  66682. * @param effect Define the effect to bind the buffer to
  66683. * @param name Name of the uniform block in the shader.
  66684. */
  66685. UniformBuffer.prototype.bindToEffect = function (effect, name) {
  66686. this._currentEffect = effect;
  66687. if (this._noUBO || !this._buffer) {
  66688. return;
  66689. }
  66690. effect.bindUniformBuffer(this._buffer, name);
  66691. };
  66692. /**
  66693. * Disposes the uniform buffer.
  66694. */
  66695. UniformBuffer.prototype.dispose = function () {
  66696. if (this._noUBO) {
  66697. return;
  66698. }
  66699. var uniformBuffers = this._engine._uniformBuffers;
  66700. var index = uniformBuffers.indexOf(this);
  66701. if (index !== -1) {
  66702. uniformBuffers[index] = uniformBuffers[uniformBuffers.length - 1];
  66703. uniformBuffers.pop();
  66704. }
  66705. if (!this._buffer) {
  66706. return;
  66707. }
  66708. if (this._engine._releaseBuffer(this._buffer)) {
  66709. this._buffer = null;
  66710. }
  66711. };
  66712. // Pool for avoiding memory leaks
  66713. UniformBuffer._MAX_UNIFORM_SIZE = 256;
  66714. UniformBuffer._tempBuffer = new Float32Array(UniformBuffer._MAX_UNIFORM_SIZE);
  66715. return UniformBuffer;
  66716. }());
  66717. /***/ }),
  66718. /***/ "./Maths/index.ts":
  66719. /*!************************!*\
  66720. !*** ./Maths/index.ts ***!
  66721. \************************/
  66722. /*! 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 */
  66723. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66724. "use strict";
  66725. __webpack_require__.r(__webpack_exports__);
  66726. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  66727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  66728. /* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math */ "./Maths/math.ts");
  66729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]; });
  66730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]; });
  66731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"]; });
  66732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color3"]; });
  66733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color4"]; });
  66734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]; });
  66735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]; });
  66736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]; });
  66737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Size"]; });
  66738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]; });
  66739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]; });
  66740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Plane"]; });
  66741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Viewport"]; });
  66742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Frustum"]; });
  66743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Space"]; });
  66744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Axis"]; });
  66745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"]; });
  66746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Orientation"]; });
  66747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Angle"]; });
  66748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Arc2"]; });
  66749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path2"]; });
  66750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path3D"]; });
  66751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Curve3"]; });
  66752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalVertex"]; });
  66753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalTextureVertex"]; });
  66754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Tmp"]; });
  66755. /* harmony import */ var _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  66756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"]; });
  66757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]; });
  66758. /***/ }),
  66759. /***/ "./Maths/math.scalar.ts":
  66760. /*!******************************!*\
  66761. !*** ./Maths/math.scalar.ts ***!
  66762. \******************************/
  66763. /*! exports provided: Scalar */
  66764. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66765. "use strict";
  66766. __webpack_require__.r(__webpack_exports__);
  66767. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return Scalar; });
  66768. /**
  66769. * Scalar computation library
  66770. */
  66771. var Scalar = /** @class */ (function () {
  66772. function Scalar() {
  66773. }
  66774. /**
  66775. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66776. * @param a number
  66777. * @param b number
  66778. * @param epsilon (default = 1.401298E-45)
  66779. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66780. */
  66781. Scalar.WithinEpsilon = function (a, b, epsilon) {
  66782. if (epsilon === void 0) { epsilon = 1.401298E-45; }
  66783. var num = a - b;
  66784. return -epsilon <= num && num <= epsilon;
  66785. };
  66786. /**
  66787. * Returns a string : the upper case translation of the number i to hexadecimal.
  66788. * @param i number
  66789. * @returns the upper case translation of the number i to hexadecimal.
  66790. */
  66791. Scalar.ToHex = function (i) {
  66792. var str = i.toString(16);
  66793. if (i <= 15) {
  66794. return ("0" + str).toUpperCase();
  66795. }
  66796. return str.toUpperCase();
  66797. };
  66798. /**
  66799. * Returns -1 if value is negative and +1 is value is positive.
  66800. * @param value the value
  66801. * @returns the value itself if it's equal to zero.
  66802. */
  66803. Scalar.Sign = function (value) {
  66804. value = +value; // convert to a number
  66805. if (value === 0 || isNaN(value)) {
  66806. return value;
  66807. }
  66808. return value > 0 ? 1 : -1;
  66809. };
  66810. /**
  66811. * Returns the value itself if it's between min and max.
  66812. * Returns min if the value is lower than min.
  66813. * Returns max if the value is greater than max.
  66814. * @param value the value to clmap
  66815. * @param min the min value to clamp to (default: 0)
  66816. * @param max the max value to clamp to (default: 1)
  66817. * @returns the clamped value
  66818. */
  66819. Scalar.Clamp = function (value, min, max) {
  66820. if (min === void 0) { min = 0; }
  66821. if (max === void 0) { max = 1; }
  66822. return Math.min(max, Math.max(min, value));
  66823. };
  66824. /**
  66825. * the log2 of value.
  66826. * @param value the value to compute log2 of
  66827. * @returns the log2 of value.
  66828. */
  66829. Scalar.Log2 = function (value) {
  66830. return Math.log(value) * Math.LOG2E;
  66831. };
  66832. /**
  66833. * Loops the value, so that it is never larger than length and never smaller than 0.
  66834. *
  66835. * This is similar to the modulo operator but it works with floating point numbers.
  66836. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  66837. * With t = 5 and length = 2.5, the result would be 0.0.
  66838. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  66839. * @param value the value
  66840. * @param length the length
  66841. * @returns the looped value
  66842. */
  66843. Scalar.Repeat = function (value, length) {
  66844. return value - Math.floor(value / length) * length;
  66845. };
  66846. /**
  66847. * Normalize the value between 0.0 and 1.0 using min and max values
  66848. * @param value value to normalize
  66849. * @param min max to normalize between
  66850. * @param max min to normalize between
  66851. * @returns the normalized value
  66852. */
  66853. Scalar.Normalize = function (value, min, max) {
  66854. return (value - min) / (max - min);
  66855. };
  66856. /**
  66857. * Denormalize the value from 0.0 and 1.0 using min and max values
  66858. * @param normalized value to denormalize
  66859. * @param min max to denormalize between
  66860. * @param max min to denormalize between
  66861. * @returns the denormalized value
  66862. */
  66863. Scalar.Denormalize = function (normalized, min, max) {
  66864. return (normalized * (max - min) + min);
  66865. };
  66866. /**
  66867. * Calculates the shortest difference between two given angles given in degrees.
  66868. * @param current current angle in degrees
  66869. * @param target target angle in degrees
  66870. * @returns the delta
  66871. */
  66872. Scalar.DeltaAngle = function (current, target) {
  66873. var num = Scalar.Repeat(target - current, 360.0);
  66874. if (num > 180.0) {
  66875. num -= 360.0;
  66876. }
  66877. return num;
  66878. };
  66879. /**
  66880. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  66881. * @param tx value
  66882. * @param length length
  66883. * @returns The returned value will move back and forth between 0 and length
  66884. */
  66885. Scalar.PingPong = function (tx, length) {
  66886. var t = Scalar.Repeat(tx, length * 2.0);
  66887. return length - Math.abs(t - length);
  66888. };
  66889. /**
  66890. * Interpolates between min and max with smoothing at the limits.
  66891. *
  66892. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  66893. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  66894. * @param from from
  66895. * @param to to
  66896. * @param tx value
  66897. * @returns the smooth stepped value
  66898. */
  66899. Scalar.SmoothStep = function (from, to, tx) {
  66900. var t = Scalar.Clamp(tx);
  66901. t = -2.0 * t * t * t + 3.0 * t * t;
  66902. return to * t + from * (1.0 - t);
  66903. };
  66904. /**
  66905. * Moves a value current towards target.
  66906. *
  66907. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  66908. * Negative values of maxDelta pushes the value away from target.
  66909. * @param current current value
  66910. * @param target target value
  66911. * @param maxDelta max distance to move
  66912. * @returns resulting value
  66913. */
  66914. Scalar.MoveTowards = function (current, target, maxDelta) {
  66915. var result = 0;
  66916. if (Math.abs(target - current) <= maxDelta) {
  66917. result = target;
  66918. }
  66919. else {
  66920. result = current + Scalar.Sign(target - current) * maxDelta;
  66921. }
  66922. return result;
  66923. };
  66924. /**
  66925. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66926. *
  66927. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  66928. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  66929. * @param current current value
  66930. * @param target target value
  66931. * @param maxDelta max distance to move
  66932. * @returns resulting angle
  66933. */
  66934. Scalar.MoveTowardsAngle = function (current, target, maxDelta) {
  66935. var num = Scalar.DeltaAngle(current, target);
  66936. var result = 0;
  66937. if (-maxDelta < num && num < maxDelta) {
  66938. result = target;
  66939. }
  66940. else {
  66941. target = current + num;
  66942. result = Scalar.MoveTowards(current, target, maxDelta);
  66943. }
  66944. return result;
  66945. };
  66946. /**
  66947. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  66948. * @param start start value
  66949. * @param end target value
  66950. * @param amount amount to lerp between
  66951. * @returns the lerped value
  66952. */
  66953. Scalar.Lerp = function (start, end, amount) {
  66954. return start + ((end - start) * amount);
  66955. };
  66956. /**
  66957. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66958. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  66959. * @param start start value
  66960. * @param end target value
  66961. * @param amount amount to lerp between
  66962. * @returns the lerped value
  66963. */
  66964. Scalar.LerpAngle = function (start, end, amount) {
  66965. var num = Scalar.Repeat(end - start, 360.0);
  66966. if (num > 180.0) {
  66967. num -= 360.0;
  66968. }
  66969. return start + num * Scalar.Clamp(amount);
  66970. };
  66971. /**
  66972. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  66973. * @param a start value
  66974. * @param b target value
  66975. * @param value value between a and b
  66976. * @returns the inverseLerp value
  66977. */
  66978. Scalar.InverseLerp = function (a, b, value) {
  66979. var result = 0;
  66980. if (a != b) {
  66981. result = Scalar.Clamp((value - a) / (b - a));
  66982. }
  66983. else {
  66984. result = 0.0;
  66985. }
  66986. return result;
  66987. };
  66988. /**
  66989. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  66990. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  66991. * @param value1 spline value
  66992. * @param tangent1 spline value
  66993. * @param value2 spline value
  66994. * @param tangent2 spline value
  66995. * @param amount input value
  66996. * @returns hermite result
  66997. */
  66998. Scalar.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  66999. var squared = amount * amount;
  67000. var cubed = amount * squared;
  67001. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  67002. var part2 = (-2.0 * cubed) + (3.0 * squared);
  67003. var part3 = (cubed - (2.0 * squared)) + amount;
  67004. var part4 = cubed - squared;
  67005. return (((value1 * part1) + (value2 * part2)) + (tangent1 * part3)) + (tangent2 * part4);
  67006. };
  67007. /**
  67008. * Returns a random float number between and min and max values
  67009. * @param min min value of random
  67010. * @param max max value of random
  67011. * @returns random value
  67012. */
  67013. Scalar.RandomRange = function (min, max) {
  67014. if (min === max) {
  67015. return min;
  67016. }
  67017. return ((Math.random() * (max - min)) + min);
  67018. };
  67019. /**
  67020. * This function returns percentage of a number in a given range.
  67021. *
  67022. * RangeToPercent(40,20,60) will return 0.5 (50%)
  67023. * RangeToPercent(34,0,100) will return 0.34 (34%)
  67024. * @param number to convert to percentage
  67025. * @param min min range
  67026. * @param max max range
  67027. * @returns the percentage
  67028. */
  67029. Scalar.RangeToPercent = function (number, min, max) {
  67030. return ((number - min) / (max - min));
  67031. };
  67032. /**
  67033. * This function returns number that corresponds to the percentage in a given range.
  67034. *
  67035. * PercentToRange(0.34,0,100) will return 34.
  67036. * @param percent to convert to number
  67037. * @param min min range
  67038. * @param max max range
  67039. * @returns the number
  67040. */
  67041. Scalar.PercentToRange = function (percent, min, max) {
  67042. return ((max - min) * percent + min);
  67043. };
  67044. /**
  67045. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  67046. * @param angle The angle to normalize in radian.
  67047. * @return The converted angle.
  67048. */
  67049. Scalar.NormalizeRadians = function (angle) {
  67050. // More precise but slower version kept for reference.
  67051. // angle = angle % Tools.TwoPi;
  67052. // angle = (angle + Tools.TwoPi) % Tools.TwoPi;
  67053. //if (angle > Math.PI) {
  67054. // angle -= Tools.TwoPi;
  67055. //}
  67056. angle -= (Scalar.TwoPi * Math.floor((angle + Math.PI) / Scalar.TwoPi));
  67057. return angle;
  67058. };
  67059. /**
  67060. * Two pi constants convenient for computation.
  67061. */
  67062. Scalar.TwoPi = Math.PI * 2;
  67063. return Scalar;
  67064. }());
  67065. /***/ }),
  67066. /***/ "./Maths/math.ts":
  67067. /*!***********************!*\
  67068. !*** ./Maths/math.ts ***!
  67069. \***********************/
  67070. /*! 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 */
  67071. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67072. "use strict";
  67073. __webpack_require__.r(__webpack_exports__);
  67074. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return ToGammaSpace; });
  67075. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return ToLinearSpace; });
  67076. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return Epsilon; });
  67077. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return Color3; });
  67078. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return Color4; });
  67079. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return Vector2; });
  67080. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return Vector3; });
  67081. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return Vector4; });
  67082. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return Size; });
  67083. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return Quaternion; });
  67084. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return Matrix; });
  67085. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return Plane; });
  67086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return Viewport; });
  67087. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return Frustum; });
  67088. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return Space; });
  67089. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return Axis; });
  67090. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return BezierCurve; });
  67091. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return Orientation; });
  67092. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return Angle; });
  67093. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return Arc2; });
  67094. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return Path2; });
  67095. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return Path3D; });
  67096. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return Curve3; });
  67097. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return PositionNormalVertex; });
  67098. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return PositionNormalTextureVertex; });
  67099. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return Tmp; });
  67100. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  67101. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  67102. /**
  67103. * Constant used to convert a value to gamma space
  67104. * @ignorenaming
  67105. */
  67106. var ToGammaSpace = 1 / 2.2;
  67107. /**
  67108. * Constant used to convert a value to linear space
  67109. * @ignorenaming
  67110. */
  67111. var ToLinearSpace = 2.2;
  67112. /**
  67113. * Constant used to define the minimal number value in Babylon.js
  67114. * @ignorenaming
  67115. */
  67116. var Epsilon = 0.001;
  67117. /**
  67118. * Class used to hold a RBG color
  67119. */
  67120. var Color3 = /** @class */ (function () {
  67121. /**
  67122. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  67123. * @param r defines the red component (between 0 and 1, default is 0)
  67124. * @param g defines the green component (between 0 and 1, default is 0)
  67125. * @param b defines the blue component (between 0 and 1, default is 0)
  67126. */
  67127. function Color3(
  67128. /**
  67129. * Defines the red component (between 0 and 1, default is 0)
  67130. */
  67131. r,
  67132. /**
  67133. * Defines the green component (between 0 and 1, default is 0)
  67134. */
  67135. g,
  67136. /**
  67137. * Defines the blue component (between 0 and 1, default is 0)
  67138. */
  67139. b) {
  67140. if (r === void 0) { r = 0; }
  67141. if (g === void 0) { g = 0; }
  67142. if (b === void 0) { b = 0; }
  67143. this.r = r;
  67144. this.g = g;
  67145. this.b = b;
  67146. }
  67147. /**
  67148. * Creates a string with the Color3 current values
  67149. * @returns the string representation of the Color3 object
  67150. */
  67151. Color3.prototype.toString = function () {
  67152. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}";
  67153. };
  67154. /**
  67155. * Returns the string "Color3"
  67156. * @returns "Color3"
  67157. */
  67158. Color3.prototype.getClassName = function () {
  67159. return "Color3";
  67160. };
  67161. /**
  67162. * Compute the Color3 hash code
  67163. * @returns an unique number that can be used to hash Color3 objects
  67164. */
  67165. Color3.prototype.getHashCode = function () {
  67166. var hash = this.r || 0;
  67167. hash = (hash * 397) ^ (this.g || 0);
  67168. hash = (hash * 397) ^ (this.b || 0);
  67169. return hash;
  67170. };
  67171. // Operators
  67172. /**
  67173. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  67174. * @param array defines the array where to store the r,g,b components
  67175. * @param index defines an optional index in the target array to define where to start storing values
  67176. * @returns the current Color3 object
  67177. */
  67178. Color3.prototype.toArray = function (array, index) {
  67179. if (index === void 0) { index = 0; }
  67180. array[index] = this.r;
  67181. array[index + 1] = this.g;
  67182. array[index + 2] = this.b;
  67183. return this;
  67184. };
  67185. /**
  67186. * Returns a new Color4 object from the current Color3 and the given alpha
  67187. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  67188. * @returns a new Color4 object
  67189. */
  67190. Color3.prototype.toColor4 = function (alpha) {
  67191. if (alpha === void 0) { alpha = 1; }
  67192. return new Color4(this.r, this.g, this.b, alpha);
  67193. };
  67194. /**
  67195. * Returns a new array populated with 3 numeric elements : red, green and blue values
  67196. * @returns the new array
  67197. */
  67198. Color3.prototype.asArray = function () {
  67199. var result = new Array();
  67200. this.toArray(result, 0);
  67201. return result;
  67202. };
  67203. /**
  67204. * Returns the luminance value
  67205. * @returns a float value
  67206. */
  67207. Color3.prototype.toLuminance = function () {
  67208. return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
  67209. };
  67210. /**
  67211. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  67212. * @param otherColor defines the second operand
  67213. * @returns the new Color3 object
  67214. */
  67215. Color3.prototype.multiply = function (otherColor) {
  67216. return new Color3(this.r * otherColor.r, this.g * otherColor.g, this.b * otherColor.b);
  67217. };
  67218. /**
  67219. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  67220. * @param otherColor defines the second operand
  67221. * @param result defines the Color3 object where to store the result
  67222. * @returns the current Color3
  67223. */
  67224. Color3.prototype.multiplyToRef = function (otherColor, result) {
  67225. result.r = this.r * otherColor.r;
  67226. result.g = this.g * otherColor.g;
  67227. result.b = this.b * otherColor.b;
  67228. return this;
  67229. };
  67230. /**
  67231. * Determines equality between Color3 objects
  67232. * @param otherColor defines the second operand
  67233. * @returns true if the rgb values are equal to the given ones
  67234. */
  67235. Color3.prototype.equals = function (otherColor) {
  67236. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b;
  67237. };
  67238. /**
  67239. * Determines equality between the current Color3 object and a set of r,b,g values
  67240. * @param r defines the red component to check
  67241. * @param g defines the green component to check
  67242. * @param b defines the blue component to check
  67243. * @returns true if the rgb values are equal to the given ones
  67244. */
  67245. Color3.prototype.equalsFloats = function (r, g, b) {
  67246. return this.r === r && this.g === g && this.b === b;
  67247. };
  67248. /**
  67249. * Multiplies in place each rgb value by scale
  67250. * @param scale defines the scaling factor
  67251. * @returns the updated Color3
  67252. */
  67253. Color3.prototype.scale = function (scale) {
  67254. return new Color3(this.r * scale, this.g * scale, this.b * scale);
  67255. };
  67256. /**
  67257. * Multiplies the rgb values by scale and stores the result into "result"
  67258. * @param scale defines the scaling factor
  67259. * @param result defines the Color3 object where to store the result
  67260. * @returns the unmodified current Color3
  67261. */
  67262. Color3.prototype.scaleToRef = function (scale, result) {
  67263. result.r = this.r * scale;
  67264. result.g = this.g * scale;
  67265. result.b = this.b * scale;
  67266. return this;
  67267. };
  67268. /**
  67269. * Scale the current Color3 values by a factor and add the result to a given Color3
  67270. * @param scale defines the scale factor
  67271. * @param result defines color to store the result into
  67272. * @returns the unmodified current Color3
  67273. */
  67274. Color3.prototype.scaleAndAddToRef = function (scale, result) {
  67275. result.r += this.r * scale;
  67276. result.g += this.g * scale;
  67277. result.b += this.b * scale;
  67278. return this;
  67279. };
  67280. /**
  67281. * Clamps the rgb values by the min and max values and stores the result into "result"
  67282. * @param min defines minimum clamping value (default is 0)
  67283. * @param max defines maximum clamping value (default is 1)
  67284. * @param result defines color to store the result into
  67285. * @returns the original Color3
  67286. */
  67287. Color3.prototype.clampToRef = function (min, max, result) {
  67288. if (min === void 0) { min = 0; }
  67289. if (max === void 0) { max = 1; }
  67290. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  67291. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  67292. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  67293. return this;
  67294. };
  67295. /**
  67296. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  67297. * @param otherColor defines the second operand
  67298. * @returns the new Color3
  67299. */
  67300. Color3.prototype.add = function (otherColor) {
  67301. return new Color3(this.r + otherColor.r, this.g + otherColor.g, this.b + otherColor.b);
  67302. };
  67303. /**
  67304. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  67305. * @param otherColor defines the second operand
  67306. * @param result defines Color3 object to store the result into
  67307. * @returns the unmodified current Color3
  67308. */
  67309. Color3.prototype.addToRef = function (otherColor, result) {
  67310. result.r = this.r + otherColor.r;
  67311. result.g = this.g + otherColor.g;
  67312. result.b = this.b + otherColor.b;
  67313. return this;
  67314. };
  67315. /**
  67316. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  67317. * @param otherColor defines the second operand
  67318. * @returns the new Color3
  67319. */
  67320. Color3.prototype.subtract = function (otherColor) {
  67321. return new Color3(this.r - otherColor.r, this.g - otherColor.g, this.b - otherColor.b);
  67322. };
  67323. /**
  67324. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  67325. * @param otherColor defines the second operand
  67326. * @param result defines Color3 object to store the result into
  67327. * @returns the unmodified current Color3
  67328. */
  67329. Color3.prototype.subtractToRef = function (otherColor, result) {
  67330. result.r = this.r - otherColor.r;
  67331. result.g = this.g - otherColor.g;
  67332. result.b = this.b - otherColor.b;
  67333. return this;
  67334. };
  67335. /**
  67336. * Copy the current object
  67337. * @returns a new Color3 copied the current one
  67338. */
  67339. Color3.prototype.clone = function () {
  67340. return new Color3(this.r, this.g, this.b);
  67341. };
  67342. /**
  67343. * Copies the rgb values from the source in the current Color3
  67344. * @param source defines the source Color3 object
  67345. * @returns the updated Color3 object
  67346. */
  67347. Color3.prototype.copyFrom = function (source) {
  67348. this.r = source.r;
  67349. this.g = source.g;
  67350. this.b = source.b;
  67351. return this;
  67352. };
  67353. /**
  67354. * Updates the Color3 rgb values from the given floats
  67355. * @param r defines the red component to read from
  67356. * @param g defines the green component to read from
  67357. * @param b defines the blue component to read from
  67358. * @returns the current Color3 object
  67359. */
  67360. Color3.prototype.copyFromFloats = function (r, g, b) {
  67361. this.r = r;
  67362. this.g = g;
  67363. this.b = b;
  67364. return this;
  67365. };
  67366. /**
  67367. * Updates the Color3 rgb values from the given floats
  67368. * @param r defines the red component to read from
  67369. * @param g defines the green component to read from
  67370. * @param b defines the blue component to read from
  67371. * @returns the current Color3 object
  67372. */
  67373. Color3.prototype.set = function (r, g, b) {
  67374. return this.copyFromFloats(r, g, b);
  67375. };
  67376. /**
  67377. * Compute the Color3 hexadecimal code as a string
  67378. * @returns a string containing the hexadecimal representation of the Color3 object
  67379. */
  67380. Color3.prototype.toHexString = function () {
  67381. var intR = (this.r * 255) | 0;
  67382. var intG = (this.g * 255) | 0;
  67383. var intB = (this.b * 255) | 0;
  67384. 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);
  67385. };
  67386. /**
  67387. * Computes a new Color3 converted from the current one to linear space
  67388. * @returns a new Color3 object
  67389. */
  67390. Color3.prototype.toLinearSpace = function () {
  67391. var convertedColor = new Color3();
  67392. this.toLinearSpaceToRef(convertedColor);
  67393. return convertedColor;
  67394. };
  67395. /**
  67396. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  67397. * @param convertedColor defines the Color3 object where to store the linear space version
  67398. * @returns the unmodified Color3
  67399. */
  67400. Color3.prototype.toLinearSpaceToRef = function (convertedColor) {
  67401. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  67402. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  67403. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  67404. return this;
  67405. };
  67406. /**
  67407. * Computes a new Color3 converted from the current one to gamma space
  67408. * @returns a new Color3 object
  67409. */
  67410. Color3.prototype.toGammaSpace = function () {
  67411. var convertedColor = new Color3();
  67412. this.toGammaSpaceToRef(convertedColor);
  67413. return convertedColor;
  67414. };
  67415. /**
  67416. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  67417. * @param convertedColor defines the Color3 object where to store the gamma space version
  67418. * @returns the unmodified Color3
  67419. */
  67420. Color3.prototype.toGammaSpaceToRef = function (convertedColor) {
  67421. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  67422. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  67423. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  67424. return this;
  67425. };
  67426. /**
  67427. * Creates a new Color3 from the string containing valid hexadecimal values
  67428. * @param hex defines a string containing valid hexadecimal values
  67429. * @returns a new Color3 object
  67430. */
  67431. Color3.FromHexString = function (hex) {
  67432. if (hex.substring(0, 1) !== "#" || hex.length !== 7) {
  67433. return new Color3(0, 0, 0);
  67434. }
  67435. var r = parseInt(hex.substring(1, 3), 16);
  67436. var g = parseInt(hex.substring(3, 5), 16);
  67437. var b = parseInt(hex.substring(5, 7), 16);
  67438. return Color3.FromInts(r, g, b);
  67439. };
  67440. /**
  67441. * Creates a new Vector3 from the starting index of the given array
  67442. * @param array defines the source array
  67443. * @param offset defines an offset in the source array
  67444. * @returns a new Color3 object
  67445. */
  67446. Color3.FromArray = function (array, offset) {
  67447. if (offset === void 0) { offset = 0; }
  67448. return new Color3(array[offset], array[offset + 1], array[offset + 2]);
  67449. };
  67450. /**
  67451. * Creates a new Color3 from integer values (< 256)
  67452. * @param r defines the red component to read from (value between 0 and 255)
  67453. * @param g defines the green component to read from (value between 0 and 255)
  67454. * @param b defines the blue component to read from (value between 0 and 255)
  67455. * @returns a new Color3 object
  67456. */
  67457. Color3.FromInts = function (r, g, b) {
  67458. return new Color3(r / 255.0, g / 255.0, b / 255.0);
  67459. };
  67460. /**
  67461. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  67462. * @param start defines the start Color3 value
  67463. * @param end defines the end Color3 value
  67464. * @param amount defines the gradient value between start and end
  67465. * @returns a new Color3 object
  67466. */
  67467. Color3.Lerp = function (start, end, amount) {
  67468. var result = new Color3(0.0, 0.0, 0.0);
  67469. Color3.LerpToRef(start, end, amount, result);
  67470. return result;
  67471. };
  67472. /**
  67473. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  67474. * @param left defines the start value
  67475. * @param right defines the end value
  67476. * @param amount defines the gradient factor
  67477. * @param result defines the Color3 object where to store the result
  67478. */
  67479. Color3.LerpToRef = function (left, right, amount, result) {
  67480. result.r = left.r + ((right.r - left.r) * amount);
  67481. result.g = left.g + ((right.g - left.g) * amount);
  67482. result.b = left.b + ((right.b - left.b) * amount);
  67483. };
  67484. /**
  67485. * Returns a Color3 value containing a red color
  67486. * @returns a new Color3 object
  67487. */
  67488. Color3.Red = function () { return new Color3(1, 0, 0); };
  67489. /**
  67490. * Returns a Color3 value containing a green color
  67491. * @returns a new Color3 object
  67492. */
  67493. Color3.Green = function () { return new Color3(0, 1, 0); };
  67494. /**
  67495. * Returns a Color3 value containing a blue color
  67496. * @returns a new Color3 object
  67497. */
  67498. Color3.Blue = function () { return new Color3(0, 0, 1); };
  67499. /**
  67500. * Returns a Color3 value containing a black color
  67501. * @returns a new Color3 object
  67502. */
  67503. Color3.Black = function () { return new Color3(0, 0, 0); };
  67504. Object.defineProperty(Color3, "BlackReadOnly", {
  67505. /**
  67506. * Gets a Color3 value containing a black color that must not be updated
  67507. */
  67508. get: function () {
  67509. return Color3._BlackReadOnly;
  67510. },
  67511. enumerable: true,
  67512. configurable: true
  67513. });
  67514. /**
  67515. * Returns a Color3 value containing a white color
  67516. * @returns a new Color3 object
  67517. */
  67518. Color3.White = function () { return new Color3(1, 1, 1); };
  67519. /**
  67520. * Returns a Color3 value containing a purple color
  67521. * @returns a new Color3 object
  67522. */
  67523. Color3.Purple = function () { return new Color3(0.5, 0, 0.5); };
  67524. /**
  67525. * Returns a Color3 value containing a magenta color
  67526. * @returns a new Color3 object
  67527. */
  67528. Color3.Magenta = function () { return new Color3(1, 0, 1); };
  67529. /**
  67530. * Returns a Color3 value containing a yellow color
  67531. * @returns a new Color3 object
  67532. */
  67533. Color3.Yellow = function () { return new Color3(1, 1, 0); };
  67534. /**
  67535. * Returns a Color3 value containing a gray color
  67536. * @returns a new Color3 object
  67537. */
  67538. Color3.Gray = function () { return new Color3(0.5, 0.5, 0.5); };
  67539. /**
  67540. * Returns a Color3 value containing a teal color
  67541. * @returns a new Color3 object
  67542. */
  67543. Color3.Teal = function () { return new Color3(0, 1.0, 1.0); };
  67544. /**
  67545. * Returns a Color3 value containing a random color
  67546. * @returns a new Color3 object
  67547. */
  67548. Color3.Random = function () { return new Color3(Math.random(), Math.random(), Math.random()); };
  67549. // Statics
  67550. Color3._BlackReadOnly = Color3.Black();
  67551. return Color3;
  67552. }());
  67553. /**
  67554. * Class used to hold a RBGA color
  67555. */
  67556. var Color4 = /** @class */ (function () {
  67557. /**
  67558. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  67559. * @param r defines the red component (between 0 and 1, default is 0)
  67560. * @param g defines the green component (between 0 and 1, default is 0)
  67561. * @param b defines the blue component (between 0 and 1, default is 0)
  67562. * @param a defines the alpha component (between 0 and 1, default is 1)
  67563. */
  67564. function Color4(
  67565. /**
  67566. * Defines the red component (between 0 and 1, default is 0)
  67567. */
  67568. r,
  67569. /**
  67570. * Defines the green component (between 0 and 1, default is 0)
  67571. */
  67572. g,
  67573. /**
  67574. * Defines the blue component (between 0 and 1, default is 0)
  67575. */
  67576. b,
  67577. /**
  67578. * Defines the alpha component (between 0 and 1, default is 1)
  67579. */
  67580. a) {
  67581. if (r === void 0) { r = 0; }
  67582. if (g === void 0) { g = 0; }
  67583. if (b === void 0) { b = 0; }
  67584. if (a === void 0) { a = 1; }
  67585. this.r = r;
  67586. this.g = g;
  67587. this.b = b;
  67588. this.a = a;
  67589. }
  67590. // Operators
  67591. /**
  67592. * Adds in place the given Color4 values to the current Color4 object
  67593. * @param right defines the second operand
  67594. * @returns the current updated Color4 object
  67595. */
  67596. Color4.prototype.addInPlace = function (right) {
  67597. this.r += right.r;
  67598. this.g += right.g;
  67599. this.b += right.b;
  67600. this.a += right.a;
  67601. return this;
  67602. };
  67603. /**
  67604. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  67605. * @returns the new array
  67606. */
  67607. Color4.prototype.asArray = function () {
  67608. var result = new Array();
  67609. this.toArray(result, 0);
  67610. return result;
  67611. };
  67612. /**
  67613. * Stores from the starting index in the given array the Color4 successive values
  67614. * @param array defines the array where to store the r,g,b components
  67615. * @param index defines an optional index in the target array to define where to start storing values
  67616. * @returns the current Color4 object
  67617. */
  67618. Color4.prototype.toArray = function (array, index) {
  67619. if (index === void 0) { index = 0; }
  67620. array[index] = this.r;
  67621. array[index + 1] = this.g;
  67622. array[index + 2] = this.b;
  67623. array[index + 3] = this.a;
  67624. return this;
  67625. };
  67626. /**
  67627. * Determines equality between Color4 objects
  67628. * @param otherColor defines the second operand
  67629. * @returns true if the rgba values are equal to the given ones
  67630. */
  67631. Color4.prototype.equals = function (otherColor) {
  67632. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b && this.a === otherColor.a;
  67633. };
  67634. /**
  67635. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  67636. * @param right defines the second operand
  67637. * @returns a new Color4 object
  67638. */
  67639. Color4.prototype.add = function (right) {
  67640. return new Color4(this.r + right.r, this.g + right.g, this.b + right.b, this.a + right.a);
  67641. };
  67642. /**
  67643. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  67644. * @param right defines the second operand
  67645. * @returns a new Color4 object
  67646. */
  67647. Color4.prototype.subtract = function (right) {
  67648. return new Color4(this.r - right.r, this.g - right.g, this.b - right.b, this.a - right.a);
  67649. };
  67650. /**
  67651. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  67652. * @param right defines the second operand
  67653. * @param result defines the Color4 object where to store the result
  67654. * @returns the current Color4 object
  67655. */
  67656. Color4.prototype.subtractToRef = function (right, result) {
  67657. result.r = this.r - right.r;
  67658. result.g = this.g - right.g;
  67659. result.b = this.b - right.b;
  67660. result.a = this.a - right.a;
  67661. return this;
  67662. };
  67663. /**
  67664. * Creates a new Color4 with the current Color4 values multiplied by scale
  67665. * @param scale defines the scaling factor to apply
  67666. * @returns a new Color4 object
  67667. */
  67668. Color4.prototype.scale = function (scale) {
  67669. return new Color4(this.r * scale, this.g * scale, this.b * scale, this.a * scale);
  67670. };
  67671. /**
  67672. * Multiplies the current Color4 values by scale and stores the result in "result"
  67673. * @param scale defines the scaling factor to apply
  67674. * @param result defines the Color4 object where to store the result
  67675. * @returns the current unmodified Color4
  67676. */
  67677. Color4.prototype.scaleToRef = function (scale, result) {
  67678. result.r = this.r * scale;
  67679. result.g = this.g * scale;
  67680. result.b = this.b * scale;
  67681. result.a = this.a * scale;
  67682. return this;
  67683. };
  67684. /**
  67685. * Scale the current Color4 values by a factor and add the result to a given Color4
  67686. * @param scale defines the scale factor
  67687. * @param result defines the Color4 object where to store the result
  67688. * @returns the unmodified current Color4
  67689. */
  67690. Color4.prototype.scaleAndAddToRef = function (scale, result) {
  67691. result.r += this.r * scale;
  67692. result.g += this.g * scale;
  67693. result.b += this.b * scale;
  67694. result.a += this.a * scale;
  67695. return this;
  67696. };
  67697. /**
  67698. * Clamps the rgb values by the min and max values and stores the result into "result"
  67699. * @param min defines minimum clamping value (default is 0)
  67700. * @param max defines maximum clamping value (default is 1)
  67701. * @param result defines color to store the result into.
  67702. * @returns the cuurent Color4
  67703. */
  67704. Color4.prototype.clampToRef = function (min, max, result) {
  67705. if (min === void 0) { min = 0; }
  67706. if (max === void 0) { max = 1; }
  67707. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  67708. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  67709. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  67710. result.a = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.a, min, max);
  67711. return this;
  67712. };
  67713. /**
  67714. * Multipy an Color4 value by another and return a new Color4 object
  67715. * @param color defines the Color4 value to multiply by
  67716. * @returns a new Color4 object
  67717. */
  67718. Color4.prototype.multiply = function (color) {
  67719. return new Color4(this.r * color.r, this.g * color.g, this.b * color.b, this.a * color.a);
  67720. };
  67721. /**
  67722. * Multipy a Color4 value by another and push the result in a reference value
  67723. * @param color defines the Color4 value to multiply by
  67724. * @param result defines the Color4 to fill the result in
  67725. * @returns the result Color4
  67726. */
  67727. Color4.prototype.multiplyToRef = function (color, result) {
  67728. result.r = this.r * color.r;
  67729. result.g = this.g * color.g;
  67730. result.b = this.b * color.b;
  67731. result.a = this.a * color.a;
  67732. return result;
  67733. };
  67734. /**
  67735. * Creates a string with the Color4 current values
  67736. * @returns the string representation of the Color4 object
  67737. */
  67738. Color4.prototype.toString = function () {
  67739. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
  67740. };
  67741. /**
  67742. * Returns the string "Color4"
  67743. * @returns "Color4"
  67744. */
  67745. Color4.prototype.getClassName = function () {
  67746. return "Color4";
  67747. };
  67748. /**
  67749. * Compute the Color4 hash code
  67750. * @returns an unique number that can be used to hash Color4 objects
  67751. */
  67752. Color4.prototype.getHashCode = function () {
  67753. var hash = this.r || 0;
  67754. hash = (hash * 397) ^ (this.g || 0);
  67755. hash = (hash * 397) ^ (this.b || 0);
  67756. hash = (hash * 397) ^ (this.a || 0);
  67757. return hash;
  67758. };
  67759. /**
  67760. * Creates a new Color4 copied from the current one
  67761. * @returns a new Color4 object
  67762. */
  67763. Color4.prototype.clone = function () {
  67764. return new Color4(this.r, this.g, this.b, this.a);
  67765. };
  67766. /**
  67767. * Copies the given Color4 values into the current one
  67768. * @param source defines the source Color4 object
  67769. * @returns the current updated Color4 object
  67770. */
  67771. Color4.prototype.copyFrom = function (source) {
  67772. this.r = source.r;
  67773. this.g = source.g;
  67774. this.b = source.b;
  67775. this.a = source.a;
  67776. return this;
  67777. };
  67778. /**
  67779. * Copies the given float values into the current one
  67780. * @param r defines the red component to read from
  67781. * @param g defines the green component to read from
  67782. * @param b defines the blue component to read from
  67783. * @param a defines the alpha component to read from
  67784. * @returns the current updated Color4 object
  67785. */
  67786. Color4.prototype.copyFromFloats = function (r, g, b, a) {
  67787. this.r = r;
  67788. this.g = g;
  67789. this.b = b;
  67790. this.a = a;
  67791. return this;
  67792. };
  67793. /**
  67794. * Copies the given float values into the current one
  67795. * @param r defines the red component to read from
  67796. * @param g defines the green component to read from
  67797. * @param b defines the blue component to read from
  67798. * @param a defines the alpha component to read from
  67799. * @returns the current updated Color4 object
  67800. */
  67801. Color4.prototype.set = function (r, g, b, a) {
  67802. return this.copyFromFloats(r, g, b, a);
  67803. };
  67804. /**
  67805. * Compute the Color4 hexadecimal code as a string
  67806. * @returns a string containing the hexadecimal representation of the Color4 object
  67807. */
  67808. Color4.prototype.toHexString = function () {
  67809. var intR = (this.r * 255) | 0;
  67810. var intG = (this.g * 255) | 0;
  67811. var intB = (this.b * 255) | 0;
  67812. var intA = (this.a * 255) | 0;
  67813. 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);
  67814. };
  67815. /**
  67816. * Computes a new Color4 converted from the current one to linear space
  67817. * @returns a new Color4 object
  67818. */
  67819. Color4.prototype.toLinearSpace = function () {
  67820. var convertedColor = new Color4();
  67821. this.toLinearSpaceToRef(convertedColor);
  67822. return convertedColor;
  67823. };
  67824. /**
  67825. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  67826. * @param convertedColor defines the Color4 object where to store the linear space version
  67827. * @returns the unmodified Color4
  67828. */
  67829. Color4.prototype.toLinearSpaceToRef = function (convertedColor) {
  67830. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  67831. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  67832. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  67833. convertedColor.a = this.a;
  67834. return this;
  67835. };
  67836. /**
  67837. * Computes a new Color4 converted from the current one to gamma space
  67838. * @returns a new Color4 object
  67839. */
  67840. Color4.prototype.toGammaSpace = function () {
  67841. var convertedColor = new Color4();
  67842. this.toGammaSpaceToRef(convertedColor);
  67843. return convertedColor;
  67844. };
  67845. /**
  67846. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  67847. * @param convertedColor defines the Color4 object where to store the gamma space version
  67848. * @returns the unmodified Color4
  67849. */
  67850. Color4.prototype.toGammaSpaceToRef = function (convertedColor) {
  67851. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  67852. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  67853. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  67854. convertedColor.a = this.a;
  67855. return this;
  67856. };
  67857. // Statics
  67858. /**
  67859. * Creates a new Color4 from the string containing valid hexadecimal values
  67860. * @param hex defines a string containing valid hexadecimal values
  67861. * @returns a new Color4 object
  67862. */
  67863. Color4.FromHexString = function (hex) {
  67864. if (hex.substring(0, 1) !== "#" || hex.length !== 9) {
  67865. return new Color4(0.0, 0.0, 0.0, 0.0);
  67866. }
  67867. var r = parseInt(hex.substring(1, 3), 16);
  67868. var g = parseInt(hex.substring(3, 5), 16);
  67869. var b = parseInt(hex.substring(5, 7), 16);
  67870. var a = parseInt(hex.substring(7, 9), 16);
  67871. return Color4.FromInts(r, g, b, a);
  67872. };
  67873. /**
  67874. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  67875. * @param left defines the start value
  67876. * @param right defines the end value
  67877. * @param amount defines the gradient factor
  67878. * @returns a new Color4 object
  67879. */
  67880. Color4.Lerp = function (left, right, amount) {
  67881. var result = new Color4(0.0, 0.0, 0.0, 0.0);
  67882. Color4.LerpToRef(left, right, amount, result);
  67883. return result;
  67884. };
  67885. /**
  67886. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  67887. * @param left defines the start value
  67888. * @param right defines the end value
  67889. * @param amount defines the gradient factor
  67890. * @param result defines the Color4 object where to store data
  67891. */
  67892. Color4.LerpToRef = function (left, right, amount, result) {
  67893. result.r = left.r + (right.r - left.r) * amount;
  67894. result.g = left.g + (right.g - left.g) * amount;
  67895. result.b = left.b + (right.b - left.b) * amount;
  67896. result.a = left.a + (right.a - left.a) * amount;
  67897. };
  67898. /**
  67899. * Creates a new Color4 from a Color3 and an alpha value
  67900. * @param color3 defines the source Color3 to read from
  67901. * @param alpha defines the alpha component (1.0 by default)
  67902. * @returns a new Color4 object
  67903. */
  67904. Color4.FromColor3 = function (color3, alpha) {
  67905. if (alpha === void 0) { alpha = 1.0; }
  67906. return new Color4(color3.r, color3.g, color3.b, alpha);
  67907. };
  67908. /**
  67909. * Creates a new Color4 from the starting index element of the given array
  67910. * @param array defines the source array to read from
  67911. * @param offset defines the offset in the source array
  67912. * @returns a new Color4 object
  67913. */
  67914. Color4.FromArray = function (array, offset) {
  67915. if (offset === void 0) { offset = 0; }
  67916. return new Color4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  67917. };
  67918. /**
  67919. * Creates a new Color3 from integer values (< 256)
  67920. * @param r defines the red component to read from (value between 0 and 255)
  67921. * @param g defines the green component to read from (value between 0 and 255)
  67922. * @param b defines the blue component to read from (value between 0 and 255)
  67923. * @param a defines the alpha component to read from (value between 0 and 255)
  67924. * @returns a new Color3 object
  67925. */
  67926. Color4.FromInts = function (r, g, b, a) {
  67927. return new Color4(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
  67928. };
  67929. /**
  67930. * Check the content of a given array and convert it to an array containing RGBA data
  67931. * If the original array was already containing count * 4 values then it is returned directly
  67932. * @param colors defines the array to check
  67933. * @param count defines the number of RGBA data to expect
  67934. * @returns an array containing count * 4 values (RGBA)
  67935. */
  67936. Color4.CheckColors4 = function (colors, count) {
  67937. // Check if color3 was used
  67938. if (colors.length === count * 3) {
  67939. var colors4 = [];
  67940. for (var index = 0; index < colors.length; index += 3) {
  67941. var newIndex = (index / 3) * 4;
  67942. colors4[newIndex] = colors[index];
  67943. colors4[newIndex + 1] = colors[index + 1];
  67944. colors4[newIndex + 2] = colors[index + 2];
  67945. colors4[newIndex + 3] = 1.0;
  67946. }
  67947. return colors4;
  67948. }
  67949. return colors;
  67950. };
  67951. return Color4;
  67952. }());
  67953. /**
  67954. * Class representing a vector containing 2 coordinates
  67955. */
  67956. var Vector2 = /** @class */ (function () {
  67957. /**
  67958. * Creates a new Vector2 from the given x and y coordinates
  67959. * @param x defines the first coordinate
  67960. * @param y defines the second coordinate
  67961. */
  67962. function Vector2(
  67963. /** defines the first coordinate */
  67964. x,
  67965. /** defines the second coordinate */
  67966. y) {
  67967. if (x === void 0) { x = 0; }
  67968. if (y === void 0) { y = 0; }
  67969. this.x = x;
  67970. this.y = y;
  67971. }
  67972. /**
  67973. * Gets a string with the Vector2 coordinates
  67974. * @returns a string with the Vector2 coordinates
  67975. */
  67976. Vector2.prototype.toString = function () {
  67977. return "{X: " + this.x + " Y:" + this.y + "}";
  67978. };
  67979. /**
  67980. * Gets class name
  67981. * @returns the string "Vector2"
  67982. */
  67983. Vector2.prototype.getClassName = function () {
  67984. return "Vector2";
  67985. };
  67986. /**
  67987. * Gets current vector hash code
  67988. * @returns the Vector2 hash code as a number
  67989. */
  67990. Vector2.prototype.getHashCode = function () {
  67991. var hash = this.x || 0;
  67992. hash = (hash * 397) ^ (this.y || 0);
  67993. return hash;
  67994. };
  67995. // Operators
  67996. /**
  67997. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  67998. * @param array defines the source array
  67999. * @param index defines the offset in source array
  68000. * @returns the current Vector2
  68001. */
  68002. Vector2.prototype.toArray = function (array, index) {
  68003. if (index === void 0) { index = 0; }
  68004. array[index] = this.x;
  68005. array[index + 1] = this.y;
  68006. return this;
  68007. };
  68008. /**
  68009. * Copy the current vector to an array
  68010. * @returns a new array with 2 elements: the Vector2 coordinates.
  68011. */
  68012. Vector2.prototype.asArray = function () {
  68013. var result = new Array();
  68014. this.toArray(result, 0);
  68015. return result;
  68016. };
  68017. /**
  68018. * Sets the Vector2 coordinates with the given Vector2 coordinates
  68019. * @param source defines the source Vector2
  68020. * @returns the current updated Vector2
  68021. */
  68022. Vector2.prototype.copyFrom = function (source) {
  68023. this.x = source.x;
  68024. this.y = source.y;
  68025. return this;
  68026. };
  68027. /**
  68028. * Sets the Vector2 coordinates with the given floats
  68029. * @param x defines the first coordinate
  68030. * @param y defines the second coordinate
  68031. * @returns the current updated Vector2
  68032. */
  68033. Vector2.prototype.copyFromFloats = function (x, y) {
  68034. this.x = x;
  68035. this.y = y;
  68036. return this;
  68037. };
  68038. /**
  68039. * Sets the Vector2 coordinates with the given floats
  68040. * @param x defines the first coordinate
  68041. * @param y defines the second coordinate
  68042. * @returns the current updated Vector2
  68043. */
  68044. Vector2.prototype.set = function (x, y) {
  68045. return this.copyFromFloats(x, y);
  68046. };
  68047. /**
  68048. * Add another vector with the current one
  68049. * @param otherVector defines the other vector
  68050. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  68051. */
  68052. Vector2.prototype.add = function (otherVector) {
  68053. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  68054. };
  68055. /**
  68056. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  68057. * @param otherVector defines the other vector
  68058. * @param result defines the target vector
  68059. * @returns the unmodified current Vector2
  68060. */
  68061. Vector2.prototype.addToRef = function (otherVector, result) {
  68062. result.x = this.x + otherVector.x;
  68063. result.y = this.y + otherVector.y;
  68064. return this;
  68065. };
  68066. /**
  68067. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  68068. * @param otherVector defines the other vector
  68069. * @returns the current updated Vector2
  68070. */
  68071. Vector2.prototype.addInPlace = function (otherVector) {
  68072. this.x += otherVector.x;
  68073. this.y += otherVector.y;
  68074. return this;
  68075. };
  68076. /**
  68077. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  68078. * @param otherVector defines the other vector
  68079. * @returns a new Vector2
  68080. */
  68081. Vector2.prototype.addVector3 = function (otherVector) {
  68082. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  68083. };
  68084. /**
  68085. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  68086. * @param otherVector defines the other vector
  68087. * @returns a new Vector2
  68088. */
  68089. Vector2.prototype.subtract = function (otherVector) {
  68090. return new Vector2(this.x - otherVector.x, this.y - otherVector.y);
  68091. };
  68092. /**
  68093. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  68094. * @param otherVector defines the other vector
  68095. * @param result defines the target vector
  68096. * @returns the unmodified current Vector2
  68097. */
  68098. Vector2.prototype.subtractToRef = function (otherVector, result) {
  68099. result.x = this.x - otherVector.x;
  68100. result.y = this.y - otherVector.y;
  68101. return this;
  68102. };
  68103. /**
  68104. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  68105. * @param otherVector defines the other vector
  68106. * @returns the current updated Vector2
  68107. */
  68108. Vector2.prototype.subtractInPlace = function (otherVector) {
  68109. this.x -= otherVector.x;
  68110. this.y -= otherVector.y;
  68111. return this;
  68112. };
  68113. /**
  68114. * Multiplies in place the current Vector2 coordinates by the given ones
  68115. * @param otherVector defines the other vector
  68116. * @returns the current updated Vector2
  68117. */
  68118. Vector2.prototype.multiplyInPlace = function (otherVector) {
  68119. this.x *= otherVector.x;
  68120. this.y *= otherVector.y;
  68121. return this;
  68122. };
  68123. /**
  68124. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  68125. * @param otherVector defines the other vector
  68126. * @returns a new Vector2
  68127. */
  68128. Vector2.prototype.multiply = function (otherVector) {
  68129. return new Vector2(this.x * otherVector.x, this.y * otherVector.y);
  68130. };
  68131. /**
  68132. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  68133. * @param otherVector defines the other vector
  68134. * @param result defines the target vector
  68135. * @returns the unmodified current Vector2
  68136. */
  68137. Vector2.prototype.multiplyToRef = function (otherVector, result) {
  68138. result.x = this.x * otherVector.x;
  68139. result.y = this.y * otherVector.y;
  68140. return this;
  68141. };
  68142. /**
  68143. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  68144. * @param x defines the first coordinate
  68145. * @param y defines the second coordinate
  68146. * @returns a new Vector2
  68147. */
  68148. Vector2.prototype.multiplyByFloats = function (x, y) {
  68149. return new Vector2(this.x * x, this.y * y);
  68150. };
  68151. /**
  68152. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  68153. * @param otherVector defines the other vector
  68154. * @returns a new Vector2
  68155. */
  68156. Vector2.prototype.divide = function (otherVector) {
  68157. return new Vector2(this.x / otherVector.x, this.y / otherVector.y);
  68158. };
  68159. /**
  68160. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  68161. * @param otherVector defines the other vector
  68162. * @param result defines the target vector
  68163. * @returns the unmodified current Vector2
  68164. */
  68165. Vector2.prototype.divideToRef = function (otherVector, result) {
  68166. result.x = this.x / otherVector.x;
  68167. result.y = this.y / otherVector.y;
  68168. return this;
  68169. };
  68170. /**
  68171. * Divides the current Vector2 coordinates by the given ones
  68172. * @param otherVector defines the other vector
  68173. * @returns the current updated Vector2
  68174. */
  68175. Vector2.prototype.divideInPlace = function (otherVector) {
  68176. return this.divideToRef(otherVector, this);
  68177. };
  68178. /**
  68179. * Gets a new Vector2 with current Vector2 negated coordinates
  68180. * @returns a new Vector2
  68181. */
  68182. Vector2.prototype.negate = function () {
  68183. return new Vector2(-this.x, -this.y);
  68184. };
  68185. /**
  68186. * Multiply the Vector2 coordinates by scale
  68187. * @param scale defines the scaling factor
  68188. * @returns the current updated Vector2
  68189. */
  68190. Vector2.prototype.scaleInPlace = function (scale) {
  68191. this.x *= scale;
  68192. this.y *= scale;
  68193. return this;
  68194. };
  68195. /**
  68196. * Returns a new Vector2 scaled by "scale" from the current Vector2
  68197. * @param scale defines the scaling factor
  68198. * @returns a new Vector2
  68199. */
  68200. Vector2.prototype.scale = function (scale) {
  68201. var result = new Vector2(0, 0);
  68202. this.scaleToRef(scale, result);
  68203. return result;
  68204. };
  68205. /**
  68206. * Scale the current Vector2 values by a factor to a given Vector2
  68207. * @param scale defines the scale factor
  68208. * @param result defines the Vector2 object where to store the result
  68209. * @returns the unmodified current Vector2
  68210. */
  68211. Vector2.prototype.scaleToRef = function (scale, result) {
  68212. result.x = this.x * scale;
  68213. result.y = this.y * scale;
  68214. return this;
  68215. };
  68216. /**
  68217. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  68218. * @param scale defines the scale factor
  68219. * @param result defines the Vector2 object where to store the result
  68220. * @returns the unmodified current Vector2
  68221. */
  68222. Vector2.prototype.scaleAndAddToRef = function (scale, result) {
  68223. result.x += this.x * scale;
  68224. result.y += this.y * scale;
  68225. return this;
  68226. };
  68227. /**
  68228. * Gets a boolean if two vectors are equals
  68229. * @param otherVector defines the other vector
  68230. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  68231. */
  68232. Vector2.prototype.equals = function (otherVector) {
  68233. return otherVector && this.x === otherVector.x && this.y === otherVector.y;
  68234. };
  68235. /**
  68236. * Gets a boolean if two vectors are equals (using an epsilon value)
  68237. * @param otherVector defines the other vector
  68238. * @param epsilon defines the minimal distance to consider equality
  68239. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  68240. */
  68241. Vector2.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  68242. if (epsilon === void 0) { epsilon = Epsilon; }
  68243. 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);
  68244. };
  68245. /**
  68246. * Gets a new Vector2 from current Vector2 floored values
  68247. * @returns a new Vector2
  68248. */
  68249. Vector2.prototype.floor = function () {
  68250. return new Vector2(Math.floor(this.x), Math.floor(this.y));
  68251. };
  68252. /**
  68253. * Gets a new Vector2 from current Vector2 floored values
  68254. * @returns a new Vector2
  68255. */
  68256. Vector2.prototype.fract = function () {
  68257. return new Vector2(this.x - Math.floor(this.x), this.y - Math.floor(this.y));
  68258. };
  68259. // Properties
  68260. /**
  68261. * Gets the length of the vector
  68262. * @returns the vector length (float)
  68263. */
  68264. Vector2.prototype.length = function () {
  68265. return Math.sqrt(this.x * this.x + this.y * this.y);
  68266. };
  68267. /**
  68268. * Gets the vector squared length
  68269. * @returns the vector squared length (float)
  68270. */
  68271. Vector2.prototype.lengthSquared = function () {
  68272. return (this.x * this.x + this.y * this.y);
  68273. };
  68274. // Methods
  68275. /**
  68276. * Normalize the vector
  68277. * @returns the current updated Vector2
  68278. */
  68279. Vector2.prototype.normalize = function () {
  68280. var len = this.length();
  68281. if (len === 0) {
  68282. return this;
  68283. }
  68284. var num = 1.0 / len;
  68285. this.x *= num;
  68286. this.y *= num;
  68287. return this;
  68288. };
  68289. /**
  68290. * Gets a new Vector2 copied from the Vector2
  68291. * @returns a new Vector2
  68292. */
  68293. Vector2.prototype.clone = function () {
  68294. return new Vector2(this.x, this.y);
  68295. };
  68296. // Statics
  68297. /**
  68298. * Gets a new Vector2(0, 0)
  68299. * @returns a new Vector2
  68300. */
  68301. Vector2.Zero = function () {
  68302. return new Vector2(0, 0);
  68303. };
  68304. /**
  68305. * Gets a new Vector2(1, 1)
  68306. * @returns a new Vector2
  68307. */
  68308. Vector2.One = function () {
  68309. return new Vector2(1, 1);
  68310. };
  68311. /**
  68312. * Gets a new Vector2 set from the given index element of the given array
  68313. * @param array defines the data source
  68314. * @param offset defines the offset in the data source
  68315. * @returns a new Vector2
  68316. */
  68317. Vector2.FromArray = function (array, offset) {
  68318. if (offset === void 0) { offset = 0; }
  68319. return new Vector2(array[offset], array[offset + 1]);
  68320. };
  68321. /**
  68322. * Sets "result" from the given index element of the given array
  68323. * @param array defines the data source
  68324. * @param offset defines the offset in the data source
  68325. * @param result defines the target vector
  68326. */
  68327. Vector2.FromArrayToRef = function (array, offset, result) {
  68328. result.x = array[offset];
  68329. result.y = array[offset + 1];
  68330. };
  68331. /**
  68332. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  68333. * @param value1 defines 1st point of control
  68334. * @param value2 defines 2nd point of control
  68335. * @param value3 defines 3rd point of control
  68336. * @param value4 defines 4th point of control
  68337. * @param amount defines the interpolation factor
  68338. * @returns a new Vector2
  68339. */
  68340. Vector2.CatmullRom = function (value1, value2, value3, value4, amount) {
  68341. var squared = amount * amount;
  68342. var cubed = amount * squared;
  68343. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  68344. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  68345. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  68346. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  68347. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  68348. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  68349. return new Vector2(x, y);
  68350. };
  68351. /**
  68352. * 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".
  68353. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  68354. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  68355. * @param value defines the value to clamp
  68356. * @param min defines the lower limit
  68357. * @param max defines the upper limit
  68358. * @returns a new Vector2
  68359. */
  68360. Vector2.Clamp = function (value, min, max) {
  68361. var x = value.x;
  68362. x = (x > max.x) ? max.x : x;
  68363. x = (x < min.x) ? min.x : x;
  68364. var y = value.y;
  68365. y = (y > max.y) ? max.y : y;
  68366. y = (y < min.y) ? min.y : y;
  68367. return new Vector2(x, y);
  68368. };
  68369. /**
  68370. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  68371. * @param value1 defines the 1st control point
  68372. * @param tangent1 defines the outgoing tangent
  68373. * @param value2 defines the 2nd control point
  68374. * @param tangent2 defines the incoming tangent
  68375. * @param amount defines the interpolation factor
  68376. * @returns a new Vector2
  68377. */
  68378. Vector2.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  68379. var squared = amount * amount;
  68380. var cubed = amount * squared;
  68381. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  68382. var part2 = (-2.0 * cubed) + (3.0 * squared);
  68383. var part3 = (cubed - (2.0 * squared)) + amount;
  68384. var part4 = cubed - squared;
  68385. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  68386. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  68387. return new Vector2(x, y);
  68388. };
  68389. /**
  68390. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  68391. * @param start defines the start vector
  68392. * @param end defines the end vector
  68393. * @param amount defines the interpolation factor
  68394. * @returns a new Vector2
  68395. */
  68396. Vector2.Lerp = function (start, end, amount) {
  68397. var x = start.x + ((end.x - start.x) * amount);
  68398. var y = start.y + ((end.y - start.y) * amount);
  68399. return new Vector2(x, y);
  68400. };
  68401. /**
  68402. * Gets the dot product of the vector "left" and the vector "right"
  68403. * @param left defines first vector
  68404. * @param right defines second vector
  68405. * @returns the dot product (float)
  68406. */
  68407. Vector2.Dot = function (left, right) {
  68408. return left.x * right.x + left.y * right.y;
  68409. };
  68410. /**
  68411. * Returns a new Vector2 equal to the normalized given vector
  68412. * @param vector defines the vector to normalize
  68413. * @returns a new Vector2
  68414. */
  68415. Vector2.Normalize = function (vector) {
  68416. var newVector = vector.clone();
  68417. newVector.normalize();
  68418. return newVector;
  68419. };
  68420. /**
  68421. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  68422. * @param left defines 1st vector
  68423. * @param right defines 2nd vector
  68424. * @returns a new Vector2
  68425. */
  68426. Vector2.Minimize = function (left, right) {
  68427. var x = (left.x < right.x) ? left.x : right.x;
  68428. var y = (left.y < right.y) ? left.y : right.y;
  68429. return new Vector2(x, y);
  68430. };
  68431. /**
  68432. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  68433. * @param left defines 1st vector
  68434. * @param right defines 2nd vector
  68435. * @returns a new Vector2
  68436. */
  68437. Vector2.Maximize = function (left, right) {
  68438. var x = (left.x > right.x) ? left.x : right.x;
  68439. var y = (left.y > right.y) ? left.y : right.y;
  68440. return new Vector2(x, y);
  68441. };
  68442. /**
  68443. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  68444. * @param vector defines the vector to transform
  68445. * @param transformation defines the matrix to apply
  68446. * @returns a new Vector2
  68447. */
  68448. Vector2.Transform = function (vector, transformation) {
  68449. var r = Vector2.Zero();
  68450. Vector2.TransformToRef(vector, transformation, r);
  68451. return r;
  68452. };
  68453. /**
  68454. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  68455. * @param vector defines the vector to transform
  68456. * @param transformation defines the matrix to apply
  68457. * @param result defines the target vector
  68458. */
  68459. Vector2.TransformToRef = function (vector, transformation, result) {
  68460. var m = transformation.m;
  68461. var x = (vector.x * m[0]) + (vector.y * m[4]) + m[12];
  68462. var y = (vector.x * m[1]) + (vector.y * m[5]) + m[13];
  68463. result.x = x;
  68464. result.y = y;
  68465. };
  68466. /**
  68467. * Determines if a given vector is included in a triangle
  68468. * @param p defines the vector to test
  68469. * @param p0 defines 1st triangle point
  68470. * @param p1 defines 2nd triangle point
  68471. * @param p2 defines 3rd triangle point
  68472. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  68473. */
  68474. Vector2.PointInTriangle = function (p, p0, p1, p2) {
  68475. var a = 1 / 2 * (-p1.y * p2.x + p0.y * (-p1.x + p2.x) + p0.x * (p1.y - p2.y) + p1.x * p2.y);
  68476. var sign = a < 0 ? -1 : 1;
  68477. var s = (p0.y * p2.x - p0.x * p2.y + (p2.y - p0.y) * p.x + (p0.x - p2.x) * p.y) * sign;
  68478. var t = (p0.x * p1.y - p0.y * p1.x + (p0.y - p1.y) * p.x + (p1.x - p0.x) * p.y) * sign;
  68479. return s > 0 && t > 0 && (s + t) < 2 * a * sign;
  68480. };
  68481. /**
  68482. * Gets the distance between the vectors "value1" and "value2"
  68483. * @param value1 defines first vector
  68484. * @param value2 defines second vector
  68485. * @returns the distance between vectors
  68486. */
  68487. Vector2.Distance = function (value1, value2) {
  68488. return Math.sqrt(Vector2.DistanceSquared(value1, value2));
  68489. };
  68490. /**
  68491. * Returns the squared distance between the vectors "value1" and "value2"
  68492. * @param value1 defines first vector
  68493. * @param value2 defines second vector
  68494. * @returns the squared distance between vectors
  68495. */
  68496. Vector2.DistanceSquared = function (value1, value2) {
  68497. var x = value1.x - value2.x;
  68498. var y = value1.y - value2.y;
  68499. return (x * x) + (y * y);
  68500. };
  68501. /**
  68502. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  68503. * @param value1 defines first vector
  68504. * @param value2 defines second vector
  68505. * @returns a new Vector2
  68506. */
  68507. Vector2.Center = function (value1, value2) {
  68508. var center = value1.add(value2);
  68509. center.scaleInPlace(0.5);
  68510. return center;
  68511. };
  68512. /**
  68513. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  68514. * @param p defines the middle point
  68515. * @param segA defines one point of the segment
  68516. * @param segB defines the other point of the segment
  68517. * @returns the shortest distance
  68518. */
  68519. Vector2.DistanceOfPointFromSegment = function (p, segA, segB) {
  68520. var l2 = Vector2.DistanceSquared(segA, segB);
  68521. if (l2 === 0.0) {
  68522. return Vector2.Distance(p, segA);
  68523. }
  68524. var v = segB.subtract(segA);
  68525. var t = Math.max(0, Math.min(1, Vector2.Dot(p.subtract(segA), v) / l2));
  68526. var proj = segA.add(v.multiplyByFloats(t, t));
  68527. return Vector2.Distance(p, proj);
  68528. };
  68529. return Vector2;
  68530. }());
  68531. /**
  68532. * Classed used to store (x,y,z) vector representation
  68533. * A Vector3 is the main object used in 3D geometry
  68534. * It can represent etiher the coordinates of a point the space, either a direction
  68535. * Reminder: js uses a left handed forward facing system
  68536. */
  68537. var Vector3 = /** @class */ (function () {
  68538. /**
  68539. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  68540. * @param x defines the first coordinates (on X axis)
  68541. * @param y defines the second coordinates (on Y axis)
  68542. * @param z defines the third coordinates (on Z axis)
  68543. */
  68544. function Vector3(
  68545. /**
  68546. * Defines the first coordinates (on X axis)
  68547. */
  68548. x,
  68549. /**
  68550. * Defines the second coordinates (on Y axis)
  68551. */
  68552. y,
  68553. /**
  68554. * Defines the third coordinates (on Z axis)
  68555. */
  68556. z) {
  68557. if (x === void 0) { x = 0; }
  68558. if (y === void 0) { y = 0; }
  68559. if (z === void 0) { z = 0; }
  68560. this.x = x;
  68561. this.y = y;
  68562. this.z = z;
  68563. }
  68564. /**
  68565. * Creates a string representation of the Vector3
  68566. * @returns a string with the Vector3 coordinates.
  68567. */
  68568. Vector3.prototype.toString = function () {
  68569. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + "}";
  68570. };
  68571. /**
  68572. * Gets the class name
  68573. * @returns the string "Vector3"
  68574. */
  68575. Vector3.prototype.getClassName = function () {
  68576. return "Vector3";
  68577. };
  68578. /**
  68579. * Creates the Vector3 hash code
  68580. * @returns a number which tends to be unique between Vector3 instances
  68581. */
  68582. Vector3.prototype.getHashCode = function () {
  68583. var hash = this.x || 0;
  68584. hash = (hash * 397) ^ (this.y || 0);
  68585. hash = (hash * 397) ^ (this.z || 0);
  68586. return hash;
  68587. };
  68588. // Operators
  68589. /**
  68590. * Creates an array containing three elements : the coordinates of the Vector3
  68591. * @returns a new array of numbers
  68592. */
  68593. Vector3.prototype.asArray = function () {
  68594. var result = [];
  68595. this.toArray(result, 0);
  68596. return result;
  68597. };
  68598. /**
  68599. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  68600. * @param array defines the destination array
  68601. * @param index defines the offset in the destination array
  68602. * @returns the current Vector3
  68603. */
  68604. Vector3.prototype.toArray = function (array, index) {
  68605. if (index === void 0) { index = 0; }
  68606. array[index] = this.x;
  68607. array[index + 1] = this.y;
  68608. array[index + 2] = this.z;
  68609. return this;
  68610. };
  68611. /**
  68612. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  68613. * @returns a new Quaternion object, computed from the Vector3 coordinates
  68614. */
  68615. Vector3.prototype.toQuaternion = function () {
  68616. return Quaternion.RotationYawPitchRoll(this.y, this.x, this.z);
  68617. };
  68618. /**
  68619. * Adds the given vector to the current Vector3
  68620. * @param otherVector defines the second operand
  68621. * @returns the current updated Vector3
  68622. */
  68623. Vector3.prototype.addInPlace = function (otherVector) {
  68624. return this.addInPlaceFromFloats(otherVector.x, otherVector.y, otherVector.z);
  68625. };
  68626. /**
  68627. * Adds the given coordinates to the current Vector3
  68628. * @param x defines the x coordinate of the operand
  68629. * @param y defines the y coordinate of the operand
  68630. * @param z defines the z coordinate of the operand
  68631. * @returns the current updated Vector3
  68632. */
  68633. Vector3.prototype.addInPlaceFromFloats = function (x, y, z) {
  68634. this.x += x;
  68635. this.y += y;
  68636. this.z += z;
  68637. return this;
  68638. };
  68639. /**
  68640. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  68641. * @param otherVector defines the second operand
  68642. * @returns the resulting Vector3
  68643. */
  68644. Vector3.prototype.add = function (otherVector) {
  68645. return new Vector3(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  68646. };
  68647. /**
  68648. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  68649. * @param otherVector defines the second operand
  68650. * @param result defines the Vector3 object where to store the result
  68651. * @returns the current Vector3
  68652. */
  68653. Vector3.prototype.addToRef = function (otherVector, result) {
  68654. return result.copyFromFloats(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  68655. };
  68656. /**
  68657. * Subtract the given vector from the current Vector3
  68658. * @param otherVector defines the second operand
  68659. * @returns the current updated Vector3
  68660. */
  68661. Vector3.prototype.subtractInPlace = function (otherVector) {
  68662. this.x -= otherVector.x;
  68663. this.y -= otherVector.y;
  68664. this.z -= otherVector.z;
  68665. return this;
  68666. };
  68667. /**
  68668. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  68669. * @param otherVector defines the second operand
  68670. * @returns the resulting Vector3
  68671. */
  68672. Vector3.prototype.subtract = function (otherVector) {
  68673. return new Vector3(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z);
  68674. };
  68675. /**
  68676. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  68677. * @param otherVector defines the second operand
  68678. * @param result defines the Vector3 object where to store the result
  68679. * @returns the current Vector3
  68680. */
  68681. Vector3.prototype.subtractToRef = function (otherVector, result) {
  68682. return this.subtractFromFloatsToRef(otherVector.x, otherVector.y, otherVector.z, result);
  68683. };
  68684. /**
  68685. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  68686. * @param x defines the x coordinate of the operand
  68687. * @param y defines the y coordinate of the operand
  68688. * @param z defines the z coordinate of the operand
  68689. * @returns the resulting Vector3
  68690. */
  68691. Vector3.prototype.subtractFromFloats = function (x, y, z) {
  68692. return new Vector3(this.x - x, this.y - y, this.z - z);
  68693. };
  68694. /**
  68695. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  68696. * @param x defines the x coordinate of the operand
  68697. * @param y defines the y coordinate of the operand
  68698. * @param z defines the z coordinate of the operand
  68699. * @param result defines the Vector3 object where to store the result
  68700. * @returns the current Vector3
  68701. */
  68702. Vector3.prototype.subtractFromFloatsToRef = function (x, y, z, result) {
  68703. return result.copyFromFloats(this.x - x, this.y - y, this.z - z);
  68704. };
  68705. /**
  68706. * Gets a new Vector3 set with the current Vector3 negated coordinates
  68707. * @returns a new Vector3
  68708. */
  68709. Vector3.prototype.negate = function () {
  68710. return new Vector3(-this.x, -this.y, -this.z);
  68711. };
  68712. /**
  68713. * Multiplies the Vector3 coordinates by the float "scale"
  68714. * @param scale defines the multiplier factor
  68715. * @returns the current updated Vector3
  68716. */
  68717. Vector3.prototype.scaleInPlace = function (scale) {
  68718. this.x *= scale;
  68719. this.y *= scale;
  68720. this.z *= scale;
  68721. return this;
  68722. };
  68723. /**
  68724. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  68725. * @param scale defines the multiplier factor
  68726. * @returns a new Vector3
  68727. */
  68728. Vector3.prototype.scale = function (scale) {
  68729. return new Vector3(this.x * scale, this.y * scale, this.z * scale);
  68730. };
  68731. /**
  68732. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  68733. * @param scale defines the multiplier factor
  68734. * @param result defines the Vector3 object where to store the result
  68735. * @returns the current Vector3
  68736. */
  68737. Vector3.prototype.scaleToRef = function (scale, result) {
  68738. return result.copyFromFloats(this.x * scale, this.y * scale, this.z * scale);
  68739. };
  68740. /**
  68741. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  68742. * @param scale defines the scale factor
  68743. * @param result defines the Vector3 object where to store the result
  68744. * @returns the unmodified current Vector3
  68745. */
  68746. Vector3.prototype.scaleAndAddToRef = function (scale, result) {
  68747. return result.addInPlaceFromFloats(this.x * scale, this.y * scale, this.z * scale);
  68748. };
  68749. /**
  68750. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  68751. * @param otherVector defines the second operand
  68752. * @returns true if both vectors are equals
  68753. */
  68754. Vector3.prototype.equals = function (otherVector) {
  68755. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z;
  68756. };
  68757. /**
  68758. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  68759. * @param otherVector defines the second operand
  68760. * @param epsilon defines the minimal distance to define values as equals
  68761. * @returns true if both vectors are distant less than epsilon
  68762. */
  68763. Vector3.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  68764. if (epsilon === void 0) { epsilon = Epsilon; }
  68765. 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);
  68766. };
  68767. /**
  68768. * Returns true if the current Vector3 coordinates equals the given floats
  68769. * @param x defines the x coordinate of the operand
  68770. * @param y defines the y coordinate of the operand
  68771. * @param z defines the z coordinate of the operand
  68772. * @returns true if both vectors are equals
  68773. */
  68774. Vector3.prototype.equalsToFloats = function (x, y, z) {
  68775. return this.x === x && this.y === y && this.z === z;
  68776. };
  68777. /**
  68778. * Multiplies the current Vector3 coordinates by the given ones
  68779. * @param otherVector defines the second operand
  68780. * @returns the current updated Vector3
  68781. */
  68782. Vector3.prototype.multiplyInPlace = function (otherVector) {
  68783. this.x *= otherVector.x;
  68784. this.y *= otherVector.y;
  68785. this.z *= otherVector.z;
  68786. return this;
  68787. };
  68788. /**
  68789. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  68790. * @param otherVector defines the second operand
  68791. * @returns the new Vector3
  68792. */
  68793. Vector3.prototype.multiply = function (otherVector) {
  68794. return this.multiplyByFloats(otherVector.x, otherVector.y, otherVector.z);
  68795. };
  68796. /**
  68797. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  68798. * @param otherVector defines the second operand
  68799. * @param result defines the Vector3 object where to store the result
  68800. * @returns the current Vector3
  68801. */
  68802. Vector3.prototype.multiplyToRef = function (otherVector, result) {
  68803. return result.copyFromFloats(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z);
  68804. };
  68805. /**
  68806. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  68807. * @param x defines the x coordinate of the operand
  68808. * @param y defines the y coordinate of the operand
  68809. * @param z defines the z coordinate of the operand
  68810. * @returns the new Vector3
  68811. */
  68812. Vector3.prototype.multiplyByFloats = function (x, y, z) {
  68813. return new Vector3(this.x * x, this.y * y, this.z * z);
  68814. };
  68815. /**
  68816. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  68817. * @param otherVector defines the second operand
  68818. * @returns the new Vector3
  68819. */
  68820. Vector3.prototype.divide = function (otherVector) {
  68821. return new Vector3(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  68822. };
  68823. /**
  68824. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  68825. * @param otherVector defines the second operand
  68826. * @param result defines the Vector3 object where to store the result
  68827. * @returns the current Vector3
  68828. */
  68829. Vector3.prototype.divideToRef = function (otherVector, result) {
  68830. return result.copyFromFloats(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  68831. };
  68832. /**
  68833. * Divides the current Vector3 coordinates by the given ones.
  68834. * @param otherVector defines the second operand
  68835. * @returns the current updated Vector3
  68836. */
  68837. Vector3.prototype.divideInPlace = function (otherVector) {
  68838. return this.divideToRef(otherVector, this);
  68839. };
  68840. /**
  68841. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  68842. * @param other defines the second operand
  68843. * @returns the current updated Vector3
  68844. */
  68845. Vector3.prototype.minimizeInPlace = function (other) {
  68846. return this.minimizeInPlaceFromFloats(other.x, other.y, other.z);
  68847. };
  68848. /**
  68849. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  68850. * @param other defines the second operand
  68851. * @returns the current updated Vector3
  68852. */
  68853. Vector3.prototype.maximizeInPlace = function (other) {
  68854. return this.maximizeInPlaceFromFloats(other.x, other.y, other.z);
  68855. };
  68856. /**
  68857. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  68858. * @param x defines the x coordinate of the operand
  68859. * @param y defines the y coordinate of the operand
  68860. * @param z defines the z coordinate of the operand
  68861. * @returns the current updated Vector3
  68862. */
  68863. Vector3.prototype.minimizeInPlaceFromFloats = function (x, y, z) {
  68864. if (x < this.x) {
  68865. this.x = x;
  68866. }
  68867. if (y < this.y) {
  68868. this.y = y;
  68869. }
  68870. if (z < this.z) {
  68871. this.z = z;
  68872. }
  68873. return this;
  68874. };
  68875. /**
  68876. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  68877. * @param x defines the x coordinate of the operand
  68878. * @param y defines the y coordinate of the operand
  68879. * @param z defines the z coordinate of the operand
  68880. * @returns the current updated Vector3
  68881. */
  68882. Vector3.prototype.maximizeInPlaceFromFloats = function (x, y, z) {
  68883. if (x > this.x) {
  68884. this.x = x;
  68885. }
  68886. if (y > this.y) {
  68887. this.y = y;
  68888. }
  68889. if (z > this.z) {
  68890. this.z = z;
  68891. }
  68892. return this;
  68893. };
  68894. /**
  68895. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  68896. * Check if is non uniform within a certain amount of decimal places to account for this
  68897. * @param epsilon the amount the values can differ
  68898. * @returns if the the vector is non uniform to a certain number of decimal places
  68899. */
  68900. Vector3.prototype.isNonUniformWithinEpsilon = function (epsilon) {
  68901. var absX = Math.abs(this.x);
  68902. var absY = Math.abs(this.y);
  68903. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absY, epsilon)) {
  68904. return true;
  68905. }
  68906. var absZ = Math.abs(this.z);
  68907. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absZ, epsilon)) {
  68908. return true;
  68909. }
  68910. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absY, absZ, epsilon)) {
  68911. return true;
  68912. }
  68913. return false;
  68914. };
  68915. Object.defineProperty(Vector3.prototype, "isNonUniform", {
  68916. /**
  68917. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  68918. */
  68919. get: function () {
  68920. var absX = Math.abs(this.x);
  68921. var absY = Math.abs(this.y);
  68922. if (absX !== absY) {
  68923. return true;
  68924. }
  68925. var absZ = Math.abs(this.z);
  68926. if (absX !== absZ) {
  68927. return true;
  68928. }
  68929. if (absY !== absZ) {
  68930. return true;
  68931. }
  68932. return false;
  68933. },
  68934. enumerable: true,
  68935. configurable: true
  68936. });
  68937. /**
  68938. * Gets a new Vector3 from current Vector3 floored values
  68939. * @returns a new Vector3
  68940. */
  68941. Vector3.prototype.floor = function () {
  68942. return new Vector3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
  68943. };
  68944. /**
  68945. * Gets a new Vector3 from current Vector3 floored values
  68946. * @returns a new Vector3
  68947. */
  68948. Vector3.prototype.fract = function () {
  68949. return new Vector3(this.x - Math.floor(this.x), this.y - Math.floor(this.y), this.z - Math.floor(this.z));
  68950. };
  68951. // Properties
  68952. /**
  68953. * Gets the length of the Vector3
  68954. * @returns the length of the Vecto3
  68955. */
  68956. Vector3.prototype.length = function () {
  68957. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  68958. };
  68959. /**
  68960. * Gets the squared length of the Vector3
  68961. * @returns squared length of the Vector3
  68962. */
  68963. Vector3.prototype.lengthSquared = function () {
  68964. return (this.x * this.x + this.y * this.y + this.z * this.z);
  68965. };
  68966. /**
  68967. * Normalize the current Vector3.
  68968. * Please note that this is an in place operation.
  68969. * @returns the current updated Vector3
  68970. */
  68971. Vector3.prototype.normalize = function () {
  68972. return this.normalizeFromLength(this.length());
  68973. };
  68974. /**
  68975. * Reorders the x y z properties of the vector in place
  68976. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  68977. * @returns the current updated vector
  68978. */
  68979. Vector3.prototype.reorderInPlace = function (order) {
  68980. var _this = this;
  68981. order = order.toLowerCase();
  68982. if (order === "xyz") {
  68983. return this;
  68984. }
  68985. MathTmp.Vector3[0].copyFrom(this);
  68986. ["x", "y", "z"].forEach(function (val, i) {
  68987. _this[val] = MathTmp.Vector3[0][order[i]];
  68988. });
  68989. return this;
  68990. };
  68991. /**
  68992. * Rotates the vector around 0,0,0 by a quaternion
  68993. * @param quaternion the rotation quaternion
  68994. * @param result vector to store the result
  68995. * @returns the resulting vector
  68996. */
  68997. Vector3.prototype.rotateByQuaternionToRef = function (quaternion, result) {
  68998. quaternion.toRotationMatrix(MathTmp.Matrix[0]);
  68999. Vector3.TransformCoordinatesToRef(this, MathTmp.Matrix[0], result);
  69000. return result;
  69001. };
  69002. /**
  69003. * Rotates a vector around a given point
  69004. * @param quaternion the rotation quaternion
  69005. * @param point the point to rotate around
  69006. * @param result vector to store the result
  69007. * @returns the resulting vector
  69008. */
  69009. Vector3.prototype.rotateByQuaternionAroundPointToRef = function (quaternion, point, result) {
  69010. this.subtractToRef(point, MathTmp.Vector3[0]);
  69011. MathTmp.Vector3[0].rotateByQuaternionToRef(quaternion, MathTmp.Vector3[0]);
  69012. point.addToRef(MathTmp.Vector3[0], result);
  69013. return result;
  69014. };
  69015. /**
  69016. * Normalize the current Vector3 with the given input length.
  69017. * Please note that this is an in place operation.
  69018. * @param len the length of the vector
  69019. * @returns the current updated Vector3
  69020. */
  69021. Vector3.prototype.normalizeFromLength = function (len) {
  69022. if (len === 0 || len === 1.0) {
  69023. return this;
  69024. }
  69025. return this.scaleInPlace(1.0 / len);
  69026. };
  69027. /**
  69028. * Normalize the current Vector3 to a new vector
  69029. * @returns the new Vector3
  69030. */
  69031. Vector3.prototype.normalizeToNew = function () {
  69032. var normalized = new Vector3(0, 0, 0);
  69033. this.normalizeToRef(normalized);
  69034. return normalized;
  69035. };
  69036. /**
  69037. * Normalize the current Vector3 to the reference
  69038. * @param reference define the Vector3 to update
  69039. * @returns the updated Vector3
  69040. */
  69041. Vector3.prototype.normalizeToRef = function (reference) {
  69042. var len = this.length();
  69043. if (len === 0 || len === 1.0) {
  69044. return reference.copyFromFloats(this.x, this.y, this.z);
  69045. }
  69046. return this.scaleToRef(1.0 / len, reference);
  69047. };
  69048. /**
  69049. * Creates a new Vector3 copied from the current Vector3
  69050. * @returns the new Vector3
  69051. */
  69052. Vector3.prototype.clone = function () {
  69053. return new Vector3(this.x, this.y, this.z);
  69054. };
  69055. /**
  69056. * Copies the given vector coordinates to the current Vector3 ones
  69057. * @param source defines the source Vector3
  69058. * @returns the current updated Vector3
  69059. */
  69060. Vector3.prototype.copyFrom = function (source) {
  69061. return this.copyFromFloats(source.x, source.y, source.z);
  69062. };
  69063. /**
  69064. * Copies the given floats to the current Vector3 coordinates
  69065. * @param x defines the x coordinate of the operand
  69066. * @param y defines the y coordinate of the operand
  69067. * @param z defines the z coordinate of the operand
  69068. * @returns the current updated Vector3
  69069. */
  69070. Vector3.prototype.copyFromFloats = function (x, y, z) {
  69071. this.x = x;
  69072. this.y = y;
  69073. this.z = z;
  69074. return this;
  69075. };
  69076. /**
  69077. * Copies the given floats to the current Vector3 coordinates
  69078. * @param x defines the x coordinate of the operand
  69079. * @param y defines the y coordinate of the operand
  69080. * @param z defines the z coordinate of the operand
  69081. * @returns the current updated Vector3
  69082. */
  69083. Vector3.prototype.set = function (x, y, z) {
  69084. return this.copyFromFloats(x, y, z);
  69085. };
  69086. /**
  69087. * Copies the given float to the current Vector3 coordinates
  69088. * @param v defines the x, y and z coordinates of the operand
  69089. * @returns the current updated Vector3
  69090. */
  69091. Vector3.prototype.setAll = function (v) {
  69092. this.x = this.y = this.z = v;
  69093. return this;
  69094. };
  69095. // Statics
  69096. /**
  69097. * Get the clip factor between two vectors
  69098. * @param vector0 defines the first operand
  69099. * @param vector1 defines the second operand
  69100. * @param axis defines the axis to use
  69101. * @param size defines the size along the axis
  69102. * @returns the clip factor
  69103. */
  69104. Vector3.GetClipFactor = function (vector0, vector1, axis, size) {
  69105. var d0 = Vector3.Dot(vector0, axis) - size;
  69106. var d1 = Vector3.Dot(vector1, axis) - size;
  69107. var s = d0 / (d0 - d1);
  69108. return s;
  69109. };
  69110. /**
  69111. * Get angle between two vectors
  69112. * @param vector0 angle between vector0 and vector1
  69113. * @param vector1 angle between vector0 and vector1
  69114. * @param normal direction of the normal
  69115. * @return the angle between vector0 and vector1
  69116. */
  69117. Vector3.GetAngleBetweenVectors = function (vector0, vector1, normal) {
  69118. var v0 = vector0.normalizeToRef(MathTmp.Vector3[1]);
  69119. var v1 = vector1.normalizeToRef(MathTmp.Vector3[2]);
  69120. var dot = Vector3.Dot(v0, v1);
  69121. var n = MathTmp.Vector3[3];
  69122. Vector3.CrossToRef(v0, v1, n);
  69123. if (Vector3.Dot(n, normal) > 0) {
  69124. return Math.acos(dot);
  69125. }
  69126. return -Math.acos(dot);
  69127. };
  69128. /**
  69129. * Returns a new Vector3 set from the index "offset" of the given array
  69130. * @param array defines the source array
  69131. * @param offset defines the offset in the source array
  69132. * @returns the new Vector3
  69133. */
  69134. Vector3.FromArray = function (array, offset) {
  69135. if (offset === void 0) { offset = 0; }
  69136. return new Vector3(array[offset], array[offset + 1], array[offset + 2]);
  69137. };
  69138. /**
  69139. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  69140. * This function is deprecated. Use FromArray instead
  69141. * @param array defines the source array
  69142. * @param offset defines the offset in the source array
  69143. * @returns the new Vector3
  69144. */
  69145. Vector3.FromFloatArray = function (array, offset) {
  69146. return Vector3.FromArray(array, offset);
  69147. };
  69148. /**
  69149. * Sets the given vector "result" with the element values from the index "offset" of the given array
  69150. * @param array defines the source array
  69151. * @param offset defines the offset in the source array
  69152. * @param result defines the Vector3 where to store the result
  69153. */
  69154. Vector3.FromArrayToRef = function (array, offset, result) {
  69155. result.x = array[offset];
  69156. result.y = array[offset + 1];
  69157. result.z = array[offset + 2];
  69158. };
  69159. /**
  69160. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  69161. * This function is deprecated. Use FromArrayToRef instead.
  69162. * @param array defines the source array
  69163. * @param offset defines the offset in the source array
  69164. * @param result defines the Vector3 where to store the result
  69165. */
  69166. Vector3.FromFloatArrayToRef = function (array, offset, result) {
  69167. return Vector3.FromArrayToRef(array, offset, result);
  69168. };
  69169. /**
  69170. * Sets the given vector "result" with the given floats.
  69171. * @param x defines the x coordinate of the source
  69172. * @param y defines the y coordinate of the source
  69173. * @param z defines the z coordinate of the source
  69174. * @param result defines the Vector3 where to store the result
  69175. */
  69176. Vector3.FromFloatsToRef = function (x, y, z, result) {
  69177. result.copyFromFloats(x, y, z);
  69178. };
  69179. /**
  69180. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  69181. * @returns a new empty Vector3
  69182. */
  69183. Vector3.Zero = function () {
  69184. return new Vector3(0.0, 0.0, 0.0);
  69185. };
  69186. /**
  69187. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  69188. * @returns a new unit Vector3
  69189. */
  69190. Vector3.One = function () {
  69191. return new Vector3(1.0, 1.0, 1.0);
  69192. };
  69193. /**
  69194. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  69195. * @returns a new up Vector3
  69196. */
  69197. Vector3.Up = function () {
  69198. return new Vector3(0.0, 1.0, 0.0);
  69199. };
  69200. Object.defineProperty(Vector3, "UpReadOnly", {
  69201. /**
  69202. * Gets a up Vector3 that must not be updated
  69203. */
  69204. get: function () {
  69205. return Vector3._UpReadOnly;
  69206. },
  69207. enumerable: true,
  69208. configurable: true
  69209. });
  69210. /**
  69211. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  69212. * @returns a new down Vector3
  69213. */
  69214. Vector3.Down = function () {
  69215. return new Vector3(0.0, -1.0, 0.0);
  69216. };
  69217. /**
  69218. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  69219. * @returns a new forward Vector3
  69220. */
  69221. Vector3.Forward = function () {
  69222. return new Vector3(0.0, 0.0, 1.0);
  69223. };
  69224. /**
  69225. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  69226. * @returns a new forward Vector3
  69227. */
  69228. Vector3.Backward = function () {
  69229. return new Vector3(0.0, 0.0, -1.0);
  69230. };
  69231. /**
  69232. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  69233. * @returns a new right Vector3
  69234. */
  69235. Vector3.Right = function () {
  69236. return new Vector3(1.0, 0.0, 0.0);
  69237. };
  69238. /**
  69239. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  69240. * @returns a new left Vector3
  69241. */
  69242. Vector3.Left = function () {
  69243. return new Vector3(-1.0, 0.0, 0.0);
  69244. };
  69245. /**
  69246. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  69247. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69248. * @param vector defines the Vector3 to transform
  69249. * @param transformation defines the transformation matrix
  69250. * @returns the transformed Vector3
  69251. */
  69252. Vector3.TransformCoordinates = function (vector, transformation) {
  69253. var result = Vector3.Zero();
  69254. Vector3.TransformCoordinatesToRef(vector, transformation, result);
  69255. return result;
  69256. };
  69257. /**
  69258. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  69259. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69260. * @param vector defines the Vector3 to transform
  69261. * @param transformation defines the transformation matrix
  69262. * @param result defines the Vector3 where to store the result
  69263. */
  69264. Vector3.TransformCoordinatesToRef = function (vector, transformation, result) {
  69265. Vector3.TransformCoordinatesFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  69266. };
  69267. /**
  69268. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  69269. * This method computes tranformed coordinates only, not transformed direction vectors
  69270. * @param x define the x coordinate of the source vector
  69271. * @param y define the y coordinate of the source vector
  69272. * @param z define the z coordinate of the source vector
  69273. * @param transformation defines the transformation matrix
  69274. * @param result defines the Vector3 where to store the result
  69275. */
  69276. Vector3.TransformCoordinatesFromFloatsToRef = function (x, y, z, transformation, result) {
  69277. var m = transformation.m;
  69278. var rx = x * m[0] + y * m[4] + z * m[8] + m[12];
  69279. var ry = x * m[1] + y * m[5] + z * m[9] + m[13];
  69280. var rz = x * m[2] + y * m[6] + z * m[10] + m[14];
  69281. var rw = 1 / (x * m[3] + y * m[7] + z * m[11] + m[15]);
  69282. result.x = rx * rw;
  69283. result.y = ry * rw;
  69284. result.z = rz * rw;
  69285. };
  69286. /**
  69287. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  69288. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69289. * @param vector defines the Vector3 to transform
  69290. * @param transformation defines the transformation matrix
  69291. * @returns the new Vector3
  69292. */
  69293. Vector3.TransformNormal = function (vector, transformation) {
  69294. var result = Vector3.Zero();
  69295. Vector3.TransformNormalToRef(vector, transformation, result);
  69296. return result;
  69297. };
  69298. /**
  69299. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  69300. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69301. * @param vector defines the Vector3 to transform
  69302. * @param transformation defines the transformation matrix
  69303. * @param result defines the Vector3 where to store the result
  69304. */
  69305. Vector3.TransformNormalToRef = function (vector, transformation, result) {
  69306. this.TransformNormalFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  69307. };
  69308. /**
  69309. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  69310. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69311. * @param x define the x coordinate of the source vector
  69312. * @param y define the y coordinate of the source vector
  69313. * @param z define the z coordinate of the source vector
  69314. * @param transformation defines the transformation matrix
  69315. * @param result defines the Vector3 where to store the result
  69316. */
  69317. Vector3.TransformNormalFromFloatsToRef = function (x, y, z, transformation, result) {
  69318. var m = transformation.m;
  69319. result.x = x * m[0] + y * m[4] + z * m[8];
  69320. result.y = x * m[1] + y * m[5] + z * m[9];
  69321. result.z = x * m[2] + y * m[6] + z * m[10];
  69322. };
  69323. /**
  69324. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  69325. * @param value1 defines the first control point
  69326. * @param value2 defines the second control point
  69327. * @param value3 defines the third control point
  69328. * @param value4 defines the fourth control point
  69329. * @param amount defines the amount on the spline to use
  69330. * @returns the new Vector3
  69331. */
  69332. Vector3.CatmullRom = function (value1, value2, value3, value4, amount) {
  69333. var squared = amount * amount;
  69334. var cubed = amount * squared;
  69335. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  69336. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  69337. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  69338. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  69339. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  69340. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  69341. var z = 0.5 * ((((2.0 * value2.z) + ((-value1.z + value3.z) * amount)) +
  69342. (((((2.0 * value1.z) - (5.0 * value2.z)) + (4.0 * value3.z)) - value4.z) * squared)) +
  69343. ((((-value1.z + (3.0 * value2.z)) - (3.0 * value3.z)) + value4.z) * cubed));
  69344. return new Vector3(x, y, z);
  69345. };
  69346. /**
  69347. * 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"
  69348. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  69349. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  69350. * @param value defines the current value
  69351. * @param min defines the lower range value
  69352. * @param max defines the upper range value
  69353. * @returns the new Vector3
  69354. */
  69355. Vector3.Clamp = function (value, min, max) {
  69356. var v = new Vector3();
  69357. Vector3.ClampToRef(value, min, max, v);
  69358. return v;
  69359. };
  69360. /**
  69361. * 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"
  69362. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  69363. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  69364. * @param value defines the current value
  69365. * @param min defines the lower range value
  69366. * @param max defines the upper range value
  69367. * @param result defines the Vector3 where to store the result
  69368. */
  69369. Vector3.ClampToRef = function (value, min, max, result) {
  69370. var x = value.x;
  69371. x = (x > max.x) ? max.x : x;
  69372. x = (x < min.x) ? min.x : x;
  69373. var y = value.y;
  69374. y = (y > max.y) ? max.y : y;
  69375. y = (y < min.y) ? min.y : y;
  69376. var z = value.z;
  69377. z = (z > max.z) ? max.z : z;
  69378. z = (z < min.z) ? min.z : z;
  69379. result.copyFromFloats(x, y, z);
  69380. };
  69381. /**
  69382. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  69383. * @param value1 defines the first control point
  69384. * @param tangent1 defines the first tangent vector
  69385. * @param value2 defines the second control point
  69386. * @param tangent2 defines the second tangent vector
  69387. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  69388. * @returns the new Vector3
  69389. */
  69390. Vector3.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  69391. var squared = amount * amount;
  69392. var cubed = amount * squared;
  69393. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  69394. var part2 = (-2.0 * cubed) + (3.0 * squared);
  69395. var part3 = (cubed - (2.0 * squared)) + amount;
  69396. var part4 = cubed - squared;
  69397. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  69398. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  69399. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  69400. return new Vector3(x, y, z);
  69401. };
  69402. /**
  69403. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  69404. * @param start defines the start value
  69405. * @param end defines the end value
  69406. * @param amount max defines amount between both (between 0 and 1)
  69407. * @returns the new Vector3
  69408. */
  69409. Vector3.Lerp = function (start, end, amount) {
  69410. var result = new Vector3(0, 0, 0);
  69411. Vector3.LerpToRef(start, end, amount, result);
  69412. return result;
  69413. };
  69414. /**
  69415. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  69416. * @param start defines the start value
  69417. * @param end defines the end value
  69418. * @param amount max defines amount between both (between 0 and 1)
  69419. * @param result defines the Vector3 where to store the result
  69420. */
  69421. Vector3.LerpToRef = function (start, end, amount, result) {
  69422. result.x = start.x + ((end.x - start.x) * amount);
  69423. result.y = start.y + ((end.y - start.y) * amount);
  69424. result.z = start.z + ((end.z - start.z) * amount);
  69425. };
  69426. /**
  69427. * Returns the dot product (float) between the vectors "left" and "right"
  69428. * @param left defines the left operand
  69429. * @param right defines the right operand
  69430. * @returns the dot product
  69431. */
  69432. Vector3.Dot = function (left, right) {
  69433. return (left.x * right.x + left.y * right.y + left.z * right.z);
  69434. };
  69435. /**
  69436. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  69437. * The cross product is then orthogonal to both "left" and "right"
  69438. * @param left defines the left operand
  69439. * @param right defines the right operand
  69440. * @returns the cross product
  69441. */
  69442. Vector3.Cross = function (left, right) {
  69443. var result = Vector3.Zero();
  69444. Vector3.CrossToRef(left, right, result);
  69445. return result;
  69446. };
  69447. /**
  69448. * Sets the given vector "result" with the cross product of "left" and "right"
  69449. * The cross product is then orthogonal to both "left" and "right"
  69450. * @param left defines the left operand
  69451. * @param right defines the right operand
  69452. * @param result defines the Vector3 where to store the result
  69453. */
  69454. Vector3.CrossToRef = function (left, right, result) {
  69455. var x = left.y * right.z - left.z * right.y;
  69456. var y = left.z * right.x - left.x * right.z;
  69457. var z = left.x * right.y - left.y * right.x;
  69458. result.copyFromFloats(x, y, z);
  69459. };
  69460. /**
  69461. * Returns a new Vector3 as the normalization of the given vector
  69462. * @param vector defines the Vector3 to normalize
  69463. * @returns the new Vector3
  69464. */
  69465. Vector3.Normalize = function (vector) {
  69466. var result = Vector3.Zero();
  69467. Vector3.NormalizeToRef(vector, result);
  69468. return result;
  69469. };
  69470. /**
  69471. * Sets the given vector "result" with the normalization of the given first vector
  69472. * @param vector defines the Vector3 to normalize
  69473. * @param result defines the Vector3 where to store the result
  69474. */
  69475. Vector3.NormalizeToRef = function (vector, result) {
  69476. vector.normalizeToRef(result);
  69477. };
  69478. /**
  69479. * Project a Vector3 onto screen space
  69480. * @param vector defines the Vector3 to project
  69481. * @param world defines the world matrix to use
  69482. * @param transform defines the transform (view x projection) matrix to use
  69483. * @param viewport defines the screen viewport to use
  69484. * @returns the new Vector3
  69485. */
  69486. Vector3.Project = function (vector, world, transform, viewport) {
  69487. var cw = viewport.width;
  69488. var ch = viewport.height;
  69489. var cx = viewport.x;
  69490. var cy = viewport.y;
  69491. var viewportMatrix = MathTmp.Matrix[1];
  69492. 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);
  69493. var matrix = MathTmp.Matrix[0];
  69494. world.multiplyToRef(transform, matrix);
  69495. matrix.multiplyToRef(viewportMatrix, matrix);
  69496. return Vector3.TransformCoordinates(vector, matrix);
  69497. };
  69498. /** @hidden */
  69499. Vector3._UnprojectFromInvertedMatrixToRef = function (source, matrix, result) {
  69500. Vector3.TransformCoordinatesToRef(source, matrix, result);
  69501. var m = matrix.m;
  69502. var num = source.x * m[3] + source.y * m[7] + source.z * m[11] + m[15];
  69503. if (_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(num, 1.0)) {
  69504. result.scaleInPlace(1.0 / num);
  69505. }
  69506. };
  69507. /**
  69508. * Unproject from screen space to object space
  69509. * @param source defines the screen space Vector3 to use
  69510. * @param viewportWidth defines the current width of the viewport
  69511. * @param viewportHeight defines the current height of the viewport
  69512. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69513. * @param transform defines the transform (view x projection) matrix to use
  69514. * @returns the new Vector3
  69515. */
  69516. Vector3.UnprojectFromTransform = function (source, viewportWidth, viewportHeight, world, transform) {
  69517. var matrix = MathTmp.Matrix[0];
  69518. world.multiplyToRef(transform, matrix);
  69519. matrix.invert();
  69520. source.x = source.x / viewportWidth * 2 - 1;
  69521. source.y = -(source.y / viewportHeight * 2 - 1);
  69522. var vector = new Vector3();
  69523. Vector3._UnprojectFromInvertedMatrixToRef(source, matrix, vector);
  69524. return vector;
  69525. };
  69526. /**
  69527. * Unproject from screen space to object space
  69528. * @param source defines the screen space Vector3 to use
  69529. * @param viewportWidth defines the current width of the viewport
  69530. * @param viewportHeight defines the current height of the viewport
  69531. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69532. * @param view defines the view matrix to use
  69533. * @param projection defines the projection matrix to use
  69534. * @returns the new Vector3
  69535. */
  69536. Vector3.Unproject = function (source, viewportWidth, viewportHeight, world, view, projection) {
  69537. var result = Vector3.Zero();
  69538. Vector3.UnprojectToRef(source, viewportWidth, viewportHeight, world, view, projection, result);
  69539. return result;
  69540. };
  69541. /**
  69542. * Unproject from screen space to object space
  69543. * @param source defines the screen space Vector3 to use
  69544. * @param viewportWidth defines the current width of the viewport
  69545. * @param viewportHeight defines the current height of the viewport
  69546. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69547. * @param view defines the view matrix to use
  69548. * @param projection defines the projection matrix to use
  69549. * @param result defines the Vector3 where to store the result
  69550. */
  69551. Vector3.UnprojectToRef = function (source, viewportWidth, viewportHeight, world, view, projection, result) {
  69552. Vector3.UnprojectFloatsToRef(source.x, source.y, source.z, viewportWidth, viewportHeight, world, view, projection, result);
  69553. };
  69554. /**
  69555. * Unproject from screen space to object space
  69556. * @param sourceX defines the screen space x coordinate to use
  69557. * @param sourceY defines the screen space y coordinate to use
  69558. * @param sourceZ defines the screen space z coordinate to use
  69559. * @param viewportWidth defines the current width of the viewport
  69560. * @param viewportHeight defines the current height of the viewport
  69561. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69562. * @param view defines the view matrix to use
  69563. * @param projection defines the projection matrix to use
  69564. * @param result defines the Vector3 where to store the result
  69565. */
  69566. Vector3.UnprojectFloatsToRef = function (sourceX, sourceY, sourceZ, viewportWidth, viewportHeight, world, view, projection, result) {
  69567. var matrix = MathTmp.Matrix[0];
  69568. world.multiplyToRef(view, matrix);
  69569. matrix.multiplyToRef(projection, matrix);
  69570. matrix.invert();
  69571. var screenSource = MathTmp.Vector3[0];
  69572. screenSource.x = sourceX / viewportWidth * 2 - 1;
  69573. screenSource.y = -(sourceY / viewportHeight * 2 - 1);
  69574. screenSource.z = 2 * sourceZ - 1.0;
  69575. Vector3._UnprojectFromInvertedMatrixToRef(screenSource, matrix, result);
  69576. };
  69577. /**
  69578. * Gets the minimal coordinate values between two Vector3
  69579. * @param left defines the first operand
  69580. * @param right defines the second operand
  69581. * @returns the new Vector3
  69582. */
  69583. Vector3.Minimize = function (left, right) {
  69584. var min = left.clone();
  69585. min.minimizeInPlace(right);
  69586. return min;
  69587. };
  69588. /**
  69589. * Gets the maximal coordinate values between two Vector3
  69590. * @param left defines the first operand
  69591. * @param right defines the second operand
  69592. * @returns the new Vector3
  69593. */
  69594. Vector3.Maximize = function (left, right) {
  69595. var max = left.clone();
  69596. max.maximizeInPlace(right);
  69597. return max;
  69598. };
  69599. /**
  69600. * Returns the distance between the vectors "value1" and "value2"
  69601. * @param value1 defines the first operand
  69602. * @param value2 defines the second operand
  69603. * @returns the distance
  69604. */
  69605. Vector3.Distance = function (value1, value2) {
  69606. return Math.sqrt(Vector3.DistanceSquared(value1, value2));
  69607. };
  69608. /**
  69609. * Returns the squared distance between the vectors "value1" and "value2"
  69610. * @param value1 defines the first operand
  69611. * @param value2 defines the second operand
  69612. * @returns the squared distance
  69613. */
  69614. Vector3.DistanceSquared = function (value1, value2) {
  69615. var x = value1.x - value2.x;
  69616. var y = value1.y - value2.y;
  69617. var z = value1.z - value2.z;
  69618. return (x * x) + (y * y) + (z * z);
  69619. };
  69620. /**
  69621. * Returns a new Vector3 located at the center between "value1" and "value2"
  69622. * @param value1 defines the first operand
  69623. * @param value2 defines the second operand
  69624. * @returns the new Vector3
  69625. */
  69626. Vector3.Center = function (value1, value2) {
  69627. var center = value1.add(value2);
  69628. center.scaleInPlace(0.5);
  69629. return center;
  69630. };
  69631. /**
  69632. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  69633. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  69634. * to something in order to rotate it from its local system to the given target system
  69635. * Note: axis1, axis2 and axis3 are normalized during this operation
  69636. * @param axis1 defines the first axis
  69637. * @param axis2 defines the second axis
  69638. * @param axis3 defines the third axis
  69639. * @returns a new Vector3
  69640. */
  69641. Vector3.RotationFromAxis = function (axis1, axis2, axis3) {
  69642. var rotation = Vector3.Zero();
  69643. Vector3.RotationFromAxisToRef(axis1, axis2, axis3, rotation);
  69644. return rotation;
  69645. };
  69646. /**
  69647. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  69648. * @param axis1 defines the first axis
  69649. * @param axis2 defines the second axis
  69650. * @param axis3 defines the third axis
  69651. * @param ref defines the Vector3 where to store the result
  69652. */
  69653. Vector3.RotationFromAxisToRef = function (axis1, axis2, axis3, ref) {
  69654. var quat = MathTmp.Quaternion[0];
  69655. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  69656. quat.toEulerAnglesToRef(ref);
  69657. };
  69658. Vector3._UpReadOnly = Vector3.Up();
  69659. return Vector3;
  69660. }());
  69661. /**
  69662. * Vector4 class created for EulerAngle class conversion to Quaternion
  69663. */
  69664. var Vector4 = /** @class */ (function () {
  69665. /**
  69666. * Creates a Vector4 object from the given floats.
  69667. * @param x x value of the vector
  69668. * @param y y value of the vector
  69669. * @param z z value of the vector
  69670. * @param w w value of the vector
  69671. */
  69672. function Vector4(
  69673. /** x value of the vector */
  69674. x,
  69675. /** y value of the vector */
  69676. y,
  69677. /** z value of the vector */
  69678. z,
  69679. /** w value of the vector */
  69680. w) {
  69681. this.x = x;
  69682. this.y = y;
  69683. this.z = z;
  69684. this.w = w;
  69685. }
  69686. /**
  69687. * Returns the string with the Vector4 coordinates.
  69688. * @returns a string containing all the vector values
  69689. */
  69690. Vector4.prototype.toString = function () {
  69691. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  69692. };
  69693. /**
  69694. * Returns the string "Vector4".
  69695. * @returns "Vector4"
  69696. */
  69697. Vector4.prototype.getClassName = function () {
  69698. return "Vector4";
  69699. };
  69700. /**
  69701. * Returns the Vector4 hash code.
  69702. * @returns a unique hash code
  69703. */
  69704. Vector4.prototype.getHashCode = function () {
  69705. var hash = this.x || 0;
  69706. hash = (hash * 397) ^ (this.y || 0);
  69707. hash = (hash * 397) ^ (this.z || 0);
  69708. hash = (hash * 397) ^ (this.w || 0);
  69709. return hash;
  69710. };
  69711. // Operators
  69712. /**
  69713. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  69714. * @returns the resulting array
  69715. */
  69716. Vector4.prototype.asArray = function () {
  69717. var result = new Array();
  69718. this.toArray(result, 0);
  69719. return result;
  69720. };
  69721. /**
  69722. * Populates the given array from the given index with the Vector4 coordinates.
  69723. * @param array array to populate
  69724. * @param index index of the array to start at (default: 0)
  69725. * @returns the Vector4.
  69726. */
  69727. Vector4.prototype.toArray = function (array, index) {
  69728. if (index === undefined) {
  69729. index = 0;
  69730. }
  69731. array[index] = this.x;
  69732. array[index + 1] = this.y;
  69733. array[index + 2] = this.z;
  69734. array[index + 3] = this.w;
  69735. return this;
  69736. };
  69737. /**
  69738. * Adds the given vector to the current Vector4.
  69739. * @param otherVector the vector to add
  69740. * @returns the updated Vector4.
  69741. */
  69742. Vector4.prototype.addInPlace = function (otherVector) {
  69743. this.x += otherVector.x;
  69744. this.y += otherVector.y;
  69745. this.z += otherVector.z;
  69746. this.w += otherVector.w;
  69747. return this;
  69748. };
  69749. /**
  69750. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  69751. * @param otherVector the vector to add
  69752. * @returns the resulting vector
  69753. */
  69754. Vector4.prototype.add = function (otherVector) {
  69755. return new Vector4(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z, this.w + otherVector.w);
  69756. };
  69757. /**
  69758. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  69759. * @param otherVector the vector to add
  69760. * @param result the vector to store the result
  69761. * @returns the current Vector4.
  69762. */
  69763. Vector4.prototype.addToRef = function (otherVector, result) {
  69764. result.x = this.x + otherVector.x;
  69765. result.y = this.y + otherVector.y;
  69766. result.z = this.z + otherVector.z;
  69767. result.w = this.w + otherVector.w;
  69768. return this;
  69769. };
  69770. /**
  69771. * Subtract in place the given vector from the current Vector4.
  69772. * @param otherVector the vector to subtract
  69773. * @returns the updated Vector4.
  69774. */
  69775. Vector4.prototype.subtractInPlace = function (otherVector) {
  69776. this.x -= otherVector.x;
  69777. this.y -= otherVector.y;
  69778. this.z -= otherVector.z;
  69779. this.w -= otherVector.w;
  69780. return this;
  69781. };
  69782. /**
  69783. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  69784. * @param otherVector the vector to add
  69785. * @returns the new vector with the result
  69786. */
  69787. Vector4.prototype.subtract = function (otherVector) {
  69788. return new Vector4(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z, this.w - otherVector.w);
  69789. };
  69790. /**
  69791. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  69792. * @param otherVector the vector to subtract
  69793. * @param result the vector to store the result
  69794. * @returns the current Vector4.
  69795. */
  69796. Vector4.prototype.subtractToRef = function (otherVector, result) {
  69797. result.x = this.x - otherVector.x;
  69798. result.y = this.y - otherVector.y;
  69799. result.z = this.z - otherVector.z;
  69800. result.w = this.w - otherVector.w;
  69801. return this;
  69802. };
  69803. /**
  69804. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69805. */
  69806. /**
  69807. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69808. * @param x value to subtract
  69809. * @param y value to subtract
  69810. * @param z value to subtract
  69811. * @param w value to subtract
  69812. * @returns new vector containing the result
  69813. */
  69814. Vector4.prototype.subtractFromFloats = function (x, y, z, w) {
  69815. return new Vector4(this.x - x, this.y - y, this.z - z, this.w - w);
  69816. };
  69817. /**
  69818. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69819. * @param x value to subtract
  69820. * @param y value to subtract
  69821. * @param z value to subtract
  69822. * @param w value to subtract
  69823. * @param result the vector to store the result in
  69824. * @returns the current Vector4.
  69825. */
  69826. Vector4.prototype.subtractFromFloatsToRef = function (x, y, z, w, result) {
  69827. result.x = this.x - x;
  69828. result.y = this.y - y;
  69829. result.z = this.z - z;
  69830. result.w = this.w - w;
  69831. return this;
  69832. };
  69833. /**
  69834. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  69835. * @returns a new vector with the negated values
  69836. */
  69837. Vector4.prototype.negate = function () {
  69838. return new Vector4(-this.x, -this.y, -this.z, -this.w);
  69839. };
  69840. /**
  69841. * Multiplies the current Vector4 coordinates by scale (float).
  69842. * @param scale the number to scale with
  69843. * @returns the updated Vector4.
  69844. */
  69845. Vector4.prototype.scaleInPlace = function (scale) {
  69846. this.x *= scale;
  69847. this.y *= scale;
  69848. this.z *= scale;
  69849. this.w *= scale;
  69850. return this;
  69851. };
  69852. /**
  69853. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  69854. * @param scale the number to scale with
  69855. * @returns a new vector with the result
  69856. */
  69857. Vector4.prototype.scale = function (scale) {
  69858. return new Vector4(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
  69859. };
  69860. /**
  69861. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  69862. * @param scale the number to scale with
  69863. * @param result a vector to store the result in
  69864. * @returns the current Vector4.
  69865. */
  69866. Vector4.prototype.scaleToRef = function (scale, result) {
  69867. result.x = this.x * scale;
  69868. result.y = this.y * scale;
  69869. result.z = this.z * scale;
  69870. result.w = this.w * scale;
  69871. return this;
  69872. };
  69873. /**
  69874. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  69875. * @param scale defines the scale factor
  69876. * @param result defines the Vector4 object where to store the result
  69877. * @returns the unmodified current Vector4
  69878. */
  69879. Vector4.prototype.scaleAndAddToRef = function (scale, result) {
  69880. result.x += this.x * scale;
  69881. result.y += this.y * scale;
  69882. result.z += this.z * scale;
  69883. result.w += this.w * scale;
  69884. return this;
  69885. };
  69886. /**
  69887. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  69888. * @param otherVector the vector to compare against
  69889. * @returns true if they are equal
  69890. */
  69891. Vector4.prototype.equals = function (otherVector) {
  69892. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z && this.w === otherVector.w;
  69893. };
  69894. /**
  69895. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  69896. * @param otherVector vector to compare against
  69897. * @param epsilon (Default: very small number)
  69898. * @returns true if they are equal
  69899. */
  69900. Vector4.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  69901. if (epsilon === void 0) { epsilon = Epsilon; }
  69902. return otherVector
  69903. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon)
  69904. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon)
  69905. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.z, otherVector.z, epsilon)
  69906. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.w, otherVector.w, epsilon);
  69907. };
  69908. /**
  69909. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  69910. * @param x x value to compare against
  69911. * @param y y value to compare against
  69912. * @param z z value to compare against
  69913. * @param w w value to compare against
  69914. * @returns true if equal
  69915. */
  69916. Vector4.prototype.equalsToFloats = function (x, y, z, w) {
  69917. return this.x === x && this.y === y && this.z === z && this.w === w;
  69918. };
  69919. /**
  69920. * Multiplies in place the current Vector4 by the given one.
  69921. * @param otherVector vector to multiple with
  69922. * @returns the updated Vector4.
  69923. */
  69924. Vector4.prototype.multiplyInPlace = function (otherVector) {
  69925. this.x *= otherVector.x;
  69926. this.y *= otherVector.y;
  69927. this.z *= otherVector.z;
  69928. this.w *= otherVector.w;
  69929. return this;
  69930. };
  69931. /**
  69932. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  69933. * @param otherVector vector to multiple with
  69934. * @returns resulting new vector
  69935. */
  69936. Vector4.prototype.multiply = function (otherVector) {
  69937. return new Vector4(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z, this.w * otherVector.w);
  69938. };
  69939. /**
  69940. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  69941. * @param otherVector vector to multiple with
  69942. * @param result vector to store the result
  69943. * @returns the current Vector4.
  69944. */
  69945. Vector4.prototype.multiplyToRef = function (otherVector, result) {
  69946. result.x = this.x * otherVector.x;
  69947. result.y = this.y * otherVector.y;
  69948. result.z = this.z * otherVector.z;
  69949. result.w = this.w * otherVector.w;
  69950. return this;
  69951. };
  69952. /**
  69953. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  69954. * @param x x value multiply with
  69955. * @param y y value multiply with
  69956. * @param z z value multiply with
  69957. * @param w w value multiply with
  69958. * @returns resulting new vector
  69959. */
  69960. Vector4.prototype.multiplyByFloats = function (x, y, z, w) {
  69961. return new Vector4(this.x * x, this.y * y, this.z * z, this.w * w);
  69962. };
  69963. /**
  69964. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  69965. * @param otherVector vector to devide with
  69966. * @returns resulting new vector
  69967. */
  69968. Vector4.prototype.divide = function (otherVector) {
  69969. return new Vector4(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z, this.w / otherVector.w);
  69970. };
  69971. /**
  69972. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  69973. * @param otherVector vector to devide with
  69974. * @param result vector to store the result
  69975. * @returns the current Vector4.
  69976. */
  69977. Vector4.prototype.divideToRef = function (otherVector, result) {
  69978. result.x = this.x / otherVector.x;
  69979. result.y = this.y / otherVector.y;
  69980. result.z = this.z / otherVector.z;
  69981. result.w = this.w / otherVector.w;
  69982. return this;
  69983. };
  69984. /**
  69985. * Divides the current Vector3 coordinates by the given ones.
  69986. * @param otherVector vector to devide with
  69987. * @returns the updated Vector3.
  69988. */
  69989. Vector4.prototype.divideInPlace = function (otherVector) {
  69990. return this.divideToRef(otherVector, this);
  69991. };
  69992. /**
  69993. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  69994. * @param other defines the second operand
  69995. * @returns the current updated Vector4
  69996. */
  69997. Vector4.prototype.minimizeInPlace = function (other) {
  69998. if (other.x < this.x) {
  69999. this.x = other.x;
  70000. }
  70001. if (other.y < this.y) {
  70002. this.y = other.y;
  70003. }
  70004. if (other.z < this.z) {
  70005. this.z = other.z;
  70006. }
  70007. if (other.w < this.w) {
  70008. this.w = other.w;
  70009. }
  70010. return this;
  70011. };
  70012. /**
  70013. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  70014. * @param other defines the second operand
  70015. * @returns the current updated Vector4
  70016. */
  70017. Vector4.prototype.maximizeInPlace = function (other) {
  70018. if (other.x > this.x) {
  70019. this.x = other.x;
  70020. }
  70021. if (other.y > this.y) {
  70022. this.y = other.y;
  70023. }
  70024. if (other.z > this.z) {
  70025. this.z = other.z;
  70026. }
  70027. if (other.w > this.w) {
  70028. this.w = other.w;
  70029. }
  70030. return this;
  70031. };
  70032. /**
  70033. * Gets a new Vector4 from current Vector4 floored values
  70034. * @returns a new Vector4
  70035. */
  70036. Vector4.prototype.floor = function () {
  70037. return new Vector4(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z), Math.floor(this.w));
  70038. };
  70039. /**
  70040. * Gets a new Vector4 from current Vector3 floored values
  70041. * @returns a new Vector4
  70042. */
  70043. Vector4.prototype.fract = function () {
  70044. 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));
  70045. };
  70046. // Properties
  70047. /**
  70048. * Returns the Vector4 length (float).
  70049. * @returns the length
  70050. */
  70051. Vector4.prototype.length = function () {
  70052. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  70053. };
  70054. /**
  70055. * Returns the Vector4 squared length (float).
  70056. * @returns the length squared
  70057. */
  70058. Vector4.prototype.lengthSquared = function () {
  70059. return (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  70060. };
  70061. // Methods
  70062. /**
  70063. * Normalizes in place the Vector4.
  70064. * @returns the updated Vector4.
  70065. */
  70066. Vector4.prototype.normalize = function () {
  70067. var len = this.length();
  70068. if (len === 0) {
  70069. return this;
  70070. }
  70071. return this.scaleInPlace(1.0 / len);
  70072. };
  70073. /**
  70074. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  70075. * @returns this converted to a new vector3
  70076. */
  70077. Vector4.prototype.toVector3 = function () {
  70078. return new Vector3(this.x, this.y, this.z);
  70079. };
  70080. /**
  70081. * Returns a new Vector4 copied from the current one.
  70082. * @returns the new cloned vector
  70083. */
  70084. Vector4.prototype.clone = function () {
  70085. return new Vector4(this.x, this.y, this.z, this.w);
  70086. };
  70087. /**
  70088. * Updates the current Vector4 with the given one coordinates.
  70089. * @param source the source vector to copy from
  70090. * @returns the updated Vector4.
  70091. */
  70092. Vector4.prototype.copyFrom = function (source) {
  70093. this.x = source.x;
  70094. this.y = source.y;
  70095. this.z = source.z;
  70096. this.w = source.w;
  70097. return this;
  70098. };
  70099. /**
  70100. * Updates the current Vector4 coordinates with the given floats.
  70101. * @param x float to copy from
  70102. * @param y float to copy from
  70103. * @param z float to copy from
  70104. * @param w float to copy from
  70105. * @returns the updated Vector4.
  70106. */
  70107. Vector4.prototype.copyFromFloats = function (x, y, z, w) {
  70108. this.x = x;
  70109. this.y = y;
  70110. this.z = z;
  70111. this.w = w;
  70112. return this;
  70113. };
  70114. /**
  70115. * Updates the current Vector4 coordinates with the given floats.
  70116. * @param x float to set from
  70117. * @param y float to set from
  70118. * @param z float to set from
  70119. * @param w float to set from
  70120. * @returns the updated Vector4.
  70121. */
  70122. Vector4.prototype.set = function (x, y, z, w) {
  70123. return this.copyFromFloats(x, y, z, w);
  70124. };
  70125. /**
  70126. * Copies the given float to the current Vector3 coordinates
  70127. * @param v defines the x, y, z and w coordinates of the operand
  70128. * @returns the current updated Vector3
  70129. */
  70130. Vector4.prototype.setAll = function (v) {
  70131. this.x = this.y = this.z = this.w = v;
  70132. return this;
  70133. };
  70134. // Statics
  70135. /**
  70136. * Returns a new Vector4 set from the starting index of the given array.
  70137. * @param array the array to pull values from
  70138. * @param offset the offset into the array to start at
  70139. * @returns the new vector
  70140. */
  70141. Vector4.FromArray = function (array, offset) {
  70142. if (!offset) {
  70143. offset = 0;
  70144. }
  70145. return new Vector4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  70146. };
  70147. /**
  70148. * Updates the given vector "result" from the starting index of the given array.
  70149. * @param array the array to pull values from
  70150. * @param offset the offset into the array to start at
  70151. * @param result the vector to store the result in
  70152. */
  70153. Vector4.FromArrayToRef = function (array, offset, result) {
  70154. result.x = array[offset];
  70155. result.y = array[offset + 1];
  70156. result.z = array[offset + 2];
  70157. result.w = array[offset + 3];
  70158. };
  70159. /**
  70160. * Updates the given vector "result" from the starting index of the given Float32Array.
  70161. * @param array the array to pull values from
  70162. * @param offset the offset into the array to start at
  70163. * @param result the vector to store the result in
  70164. */
  70165. Vector4.FromFloatArrayToRef = function (array, offset, result) {
  70166. Vector4.FromArrayToRef(array, offset, result);
  70167. };
  70168. /**
  70169. * Updates the given vector "result" coordinates from the given floats.
  70170. * @param x float to set from
  70171. * @param y float to set from
  70172. * @param z float to set from
  70173. * @param w float to set from
  70174. * @param result the vector to the floats in
  70175. */
  70176. Vector4.FromFloatsToRef = function (x, y, z, w, result) {
  70177. result.x = x;
  70178. result.y = y;
  70179. result.z = z;
  70180. result.w = w;
  70181. };
  70182. /**
  70183. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  70184. * @returns the new vector
  70185. */
  70186. Vector4.Zero = function () {
  70187. return new Vector4(0.0, 0.0, 0.0, 0.0);
  70188. };
  70189. /**
  70190. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  70191. * @returns the new vector
  70192. */
  70193. Vector4.One = function () {
  70194. return new Vector4(1.0, 1.0, 1.0, 1.0);
  70195. };
  70196. /**
  70197. * Returns a new normalized Vector4 from the given one.
  70198. * @param vector the vector to normalize
  70199. * @returns the vector
  70200. */
  70201. Vector4.Normalize = function (vector) {
  70202. var result = Vector4.Zero();
  70203. Vector4.NormalizeToRef(vector, result);
  70204. return result;
  70205. };
  70206. /**
  70207. * Updates the given vector "result" from the normalization of the given one.
  70208. * @param vector the vector to normalize
  70209. * @param result the vector to store the result in
  70210. */
  70211. Vector4.NormalizeToRef = function (vector, result) {
  70212. result.copyFrom(vector);
  70213. result.normalize();
  70214. };
  70215. /**
  70216. * Returns a vector with the minimum values from the left and right vectors
  70217. * @param left left vector to minimize
  70218. * @param right right vector to minimize
  70219. * @returns a new vector with the minimum of the left and right vector values
  70220. */
  70221. Vector4.Minimize = function (left, right) {
  70222. var min = left.clone();
  70223. min.minimizeInPlace(right);
  70224. return min;
  70225. };
  70226. /**
  70227. * Returns a vector with the maximum values from the left and right vectors
  70228. * @param left left vector to maximize
  70229. * @param right right vector to maximize
  70230. * @returns a new vector with the maximum of the left and right vector values
  70231. */
  70232. Vector4.Maximize = function (left, right) {
  70233. var max = left.clone();
  70234. max.maximizeInPlace(right);
  70235. return max;
  70236. };
  70237. /**
  70238. * Returns the distance (float) between the vectors "value1" and "value2".
  70239. * @param value1 value to calulate the distance between
  70240. * @param value2 value to calulate the distance between
  70241. * @return the distance between the two vectors
  70242. */
  70243. Vector4.Distance = function (value1, value2) {
  70244. return Math.sqrt(Vector4.DistanceSquared(value1, value2));
  70245. };
  70246. /**
  70247. * Returns the squared distance (float) between the vectors "value1" and "value2".
  70248. * @param value1 value to calulate the distance between
  70249. * @param value2 value to calulate the distance between
  70250. * @return the distance between the two vectors squared
  70251. */
  70252. Vector4.DistanceSquared = function (value1, value2) {
  70253. var x = value1.x - value2.x;
  70254. var y = value1.y - value2.y;
  70255. var z = value1.z - value2.z;
  70256. var w = value1.w - value2.w;
  70257. return (x * x) + (y * y) + (z * z) + (w * w);
  70258. };
  70259. /**
  70260. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  70261. * @param value1 value to calulate the center between
  70262. * @param value2 value to calulate the center between
  70263. * @return the center between the two vectors
  70264. */
  70265. Vector4.Center = function (value1, value2) {
  70266. var center = value1.add(value2);
  70267. center.scaleInPlace(0.5);
  70268. return center;
  70269. };
  70270. /**
  70271. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  70272. * This methods computes transformed normalized direction vectors only.
  70273. * @param vector the vector to transform
  70274. * @param transformation the transformation matrix to apply
  70275. * @returns the new vector
  70276. */
  70277. Vector4.TransformNormal = function (vector, transformation) {
  70278. var result = Vector4.Zero();
  70279. Vector4.TransformNormalToRef(vector, transformation, result);
  70280. return result;
  70281. };
  70282. /**
  70283. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  70284. * This methods computes transformed normalized direction vectors only.
  70285. * @param vector the vector to transform
  70286. * @param transformation the transformation matrix to apply
  70287. * @param result the vector to store the result in
  70288. */
  70289. Vector4.TransformNormalToRef = function (vector, transformation, result) {
  70290. var m = transformation.m;
  70291. var x = (vector.x * m[0]) + (vector.y * m[4]) + (vector.z * m[8]);
  70292. var y = (vector.x * m[1]) + (vector.y * m[5]) + (vector.z * m[9]);
  70293. var z = (vector.x * m[2]) + (vector.y * m[6]) + (vector.z * m[10]);
  70294. result.x = x;
  70295. result.y = y;
  70296. result.z = z;
  70297. result.w = vector.w;
  70298. };
  70299. /**
  70300. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  70301. * This methods computes transformed normalized direction vectors only.
  70302. * @param x value to transform
  70303. * @param y value to transform
  70304. * @param z value to transform
  70305. * @param w value to transform
  70306. * @param transformation the transformation matrix to apply
  70307. * @param result the vector to store the results in
  70308. */
  70309. Vector4.TransformNormalFromFloatsToRef = function (x, y, z, w, transformation, result) {
  70310. var m = transformation.m;
  70311. result.x = (x * m[0]) + (y * m[4]) + (z * m[8]);
  70312. result.y = (x * m[1]) + (y * m[5]) + (z * m[9]);
  70313. result.z = (x * m[2]) + (y * m[6]) + (z * m[10]);
  70314. result.w = w;
  70315. };
  70316. /**
  70317. * Creates a new Vector4 from a Vector3
  70318. * @param source defines the source data
  70319. * @param w defines the 4th component (default is 0)
  70320. * @returns a new Vector4
  70321. */
  70322. Vector4.FromVector3 = function (source, w) {
  70323. if (w === void 0) { w = 0; }
  70324. return new Vector4(source.x, source.y, source.z, w);
  70325. };
  70326. return Vector4;
  70327. }());
  70328. /**
  70329. * Size containing widht and height
  70330. */
  70331. var Size = /** @class */ (function () {
  70332. /**
  70333. * Creates a Size object from the given width and height (floats).
  70334. * @param width width of the new size
  70335. * @param height height of the new size
  70336. */
  70337. function Size(width, height) {
  70338. this.width = width;
  70339. this.height = height;
  70340. }
  70341. /**
  70342. * Returns a string with the Size width and height
  70343. * @returns a string with the Size width and height
  70344. */
  70345. Size.prototype.toString = function () {
  70346. return "{W: " + this.width + ", H: " + this.height + "}";
  70347. };
  70348. /**
  70349. * "Size"
  70350. * @returns the string "Size"
  70351. */
  70352. Size.prototype.getClassName = function () {
  70353. return "Size";
  70354. };
  70355. /**
  70356. * Returns the Size hash code.
  70357. * @returns a hash code for a unique width and height
  70358. */
  70359. Size.prototype.getHashCode = function () {
  70360. var hash = this.width || 0;
  70361. hash = (hash * 397) ^ (this.height || 0);
  70362. return hash;
  70363. };
  70364. /**
  70365. * Updates the current size from the given one.
  70366. * @param src the given size
  70367. */
  70368. Size.prototype.copyFrom = function (src) {
  70369. this.width = src.width;
  70370. this.height = src.height;
  70371. };
  70372. /**
  70373. * Updates in place the current Size from the given floats.
  70374. * @param width width of the new size
  70375. * @param height height of the new size
  70376. * @returns the updated Size.
  70377. */
  70378. Size.prototype.copyFromFloats = function (width, height) {
  70379. this.width = width;
  70380. this.height = height;
  70381. return this;
  70382. };
  70383. /**
  70384. * Updates in place the current Size from the given floats.
  70385. * @param width width to set
  70386. * @param height height to set
  70387. * @returns the updated Size.
  70388. */
  70389. Size.prototype.set = function (width, height) {
  70390. return this.copyFromFloats(width, height);
  70391. };
  70392. /**
  70393. * Multiplies the width and height by numbers
  70394. * @param w factor to multiple the width by
  70395. * @param h factor to multiple the height by
  70396. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  70397. */
  70398. Size.prototype.multiplyByFloats = function (w, h) {
  70399. return new Size(this.width * w, this.height * h);
  70400. };
  70401. /**
  70402. * Clones the size
  70403. * @returns a new Size copied from the given one.
  70404. */
  70405. Size.prototype.clone = function () {
  70406. return new Size(this.width, this.height);
  70407. };
  70408. /**
  70409. * True if the current Size and the given one width and height are strictly equal.
  70410. * @param other the other size to compare against
  70411. * @returns True if the current Size and the given one width and height are strictly equal.
  70412. */
  70413. Size.prototype.equals = function (other) {
  70414. if (!other) {
  70415. return false;
  70416. }
  70417. return (this.width === other.width) && (this.height === other.height);
  70418. };
  70419. Object.defineProperty(Size.prototype, "surface", {
  70420. /**
  70421. * The surface of the Size : width * height (float).
  70422. */
  70423. get: function () {
  70424. return this.width * this.height;
  70425. },
  70426. enumerable: true,
  70427. configurable: true
  70428. });
  70429. /**
  70430. * Create a new size of zero
  70431. * @returns a new Size set to (0.0, 0.0)
  70432. */
  70433. Size.Zero = function () {
  70434. return new Size(0.0, 0.0);
  70435. };
  70436. /**
  70437. * Sums the width and height of two sizes
  70438. * @param otherSize size to add to this size
  70439. * @returns a new Size set as the addition result of the current Size and the given one.
  70440. */
  70441. Size.prototype.add = function (otherSize) {
  70442. var r = new Size(this.width + otherSize.width, this.height + otherSize.height);
  70443. return r;
  70444. };
  70445. /**
  70446. * Subtracts the width and height of two
  70447. * @param otherSize size to subtract to this size
  70448. * @returns a new Size set as the subtraction result of the given one from the current Size.
  70449. */
  70450. Size.prototype.subtract = function (otherSize) {
  70451. var r = new Size(this.width - otherSize.width, this.height - otherSize.height);
  70452. return r;
  70453. };
  70454. /**
  70455. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  70456. * @param start starting size to lerp between
  70457. * @param end end size to lerp between
  70458. * @param amount amount to lerp between the start and end values
  70459. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  70460. */
  70461. Size.Lerp = function (start, end, amount) {
  70462. var w = start.width + ((end.width - start.width) * amount);
  70463. var h = start.height + ((end.height - start.height) * amount);
  70464. return new Size(w, h);
  70465. };
  70466. return Size;
  70467. }());
  70468. /**
  70469. * Class used to store quaternion data
  70470. * @see https://en.wikipedia.org/wiki/Quaternion
  70471. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  70472. */
  70473. var Quaternion = /** @class */ (function () {
  70474. /**
  70475. * Creates a new Quaternion from the given floats
  70476. * @param x defines the first component (0 by default)
  70477. * @param y defines the second component (0 by default)
  70478. * @param z defines the third component (0 by default)
  70479. * @param w defines the fourth component (1.0 by default)
  70480. */
  70481. function Quaternion(
  70482. /** defines the first component (0 by default) */
  70483. x,
  70484. /** defines the second component (0 by default) */
  70485. y,
  70486. /** defines the third component (0 by default) */
  70487. z,
  70488. /** defines the fourth component (1.0 by default) */
  70489. w) {
  70490. if (x === void 0) { x = 0.0; }
  70491. if (y === void 0) { y = 0.0; }
  70492. if (z === void 0) { z = 0.0; }
  70493. if (w === void 0) { w = 1.0; }
  70494. this.x = x;
  70495. this.y = y;
  70496. this.z = z;
  70497. this.w = w;
  70498. }
  70499. /**
  70500. * Gets a string representation for the current quaternion
  70501. * @returns a string with the Quaternion coordinates
  70502. */
  70503. Quaternion.prototype.toString = function () {
  70504. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  70505. };
  70506. /**
  70507. * Gets the class name of the quaternion
  70508. * @returns the string "Quaternion"
  70509. */
  70510. Quaternion.prototype.getClassName = function () {
  70511. return "Quaternion";
  70512. };
  70513. /**
  70514. * Gets a hash code for this quaternion
  70515. * @returns the quaternion hash code
  70516. */
  70517. Quaternion.prototype.getHashCode = function () {
  70518. var hash = this.x || 0;
  70519. hash = (hash * 397) ^ (this.y || 0);
  70520. hash = (hash * 397) ^ (this.z || 0);
  70521. hash = (hash * 397) ^ (this.w || 0);
  70522. return hash;
  70523. };
  70524. /**
  70525. * Copy the quaternion to an array
  70526. * @returns a new array populated with 4 elements from the quaternion coordinates
  70527. */
  70528. Quaternion.prototype.asArray = function () {
  70529. return [this.x, this.y, this.z, this.w];
  70530. };
  70531. /**
  70532. * Check if two quaternions are equals
  70533. * @param otherQuaternion defines the second operand
  70534. * @return true if the current quaternion and the given one coordinates are strictly equals
  70535. */
  70536. Quaternion.prototype.equals = function (otherQuaternion) {
  70537. return otherQuaternion && this.x === otherQuaternion.x && this.y === otherQuaternion.y && this.z === otherQuaternion.z && this.w === otherQuaternion.w;
  70538. };
  70539. /**
  70540. * Clone the current quaternion
  70541. * @returns a new quaternion copied from the current one
  70542. */
  70543. Quaternion.prototype.clone = function () {
  70544. return new Quaternion(this.x, this.y, this.z, this.w);
  70545. };
  70546. /**
  70547. * Copy a quaternion to the current one
  70548. * @param other defines the other quaternion
  70549. * @returns the updated current quaternion
  70550. */
  70551. Quaternion.prototype.copyFrom = function (other) {
  70552. this.x = other.x;
  70553. this.y = other.y;
  70554. this.z = other.z;
  70555. this.w = other.w;
  70556. return this;
  70557. };
  70558. /**
  70559. * Updates the current quaternion with the given float coordinates
  70560. * @param x defines the x coordinate
  70561. * @param y defines the y coordinate
  70562. * @param z defines the z coordinate
  70563. * @param w defines the w coordinate
  70564. * @returns the updated current quaternion
  70565. */
  70566. Quaternion.prototype.copyFromFloats = function (x, y, z, w) {
  70567. this.x = x;
  70568. this.y = y;
  70569. this.z = z;
  70570. this.w = w;
  70571. return this;
  70572. };
  70573. /**
  70574. * Updates the current quaternion from the given float coordinates
  70575. * @param x defines the x coordinate
  70576. * @param y defines the y coordinate
  70577. * @param z defines the z coordinate
  70578. * @param w defines the w coordinate
  70579. * @returns the updated current quaternion
  70580. */
  70581. Quaternion.prototype.set = function (x, y, z, w) {
  70582. return this.copyFromFloats(x, y, z, w);
  70583. };
  70584. /**
  70585. * Adds two quaternions
  70586. * @param other defines the second operand
  70587. * @returns a new quaternion as the addition result of the given one and the current quaternion
  70588. */
  70589. Quaternion.prototype.add = function (other) {
  70590. return new Quaternion(this.x + other.x, this.y + other.y, this.z + other.z, this.w + other.w);
  70591. };
  70592. /**
  70593. * Add a quaternion to the current one
  70594. * @param other defines the quaternion to add
  70595. * @returns the current quaternion
  70596. */
  70597. Quaternion.prototype.addInPlace = function (other) {
  70598. this.x += other.x;
  70599. this.y += other.y;
  70600. this.z += other.z;
  70601. this.w += other.w;
  70602. return this;
  70603. };
  70604. /**
  70605. * Subtract two quaternions
  70606. * @param other defines the second operand
  70607. * @returns a new quaternion as the subtraction result of the given one from the current one
  70608. */
  70609. Quaternion.prototype.subtract = function (other) {
  70610. return new Quaternion(this.x - other.x, this.y - other.y, this.z - other.z, this.w - other.w);
  70611. };
  70612. /**
  70613. * Multiplies the current quaternion by a scale factor
  70614. * @param value defines the scale factor
  70615. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  70616. */
  70617. Quaternion.prototype.scale = function (value) {
  70618. return new Quaternion(this.x * value, this.y * value, this.z * value, this.w * value);
  70619. };
  70620. /**
  70621. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  70622. * @param scale defines the scale factor
  70623. * @param result defines the Quaternion object where to store the result
  70624. * @returns the unmodified current quaternion
  70625. */
  70626. Quaternion.prototype.scaleToRef = function (scale, result) {
  70627. result.x = this.x * scale;
  70628. result.y = this.y * scale;
  70629. result.z = this.z * scale;
  70630. result.w = this.w * scale;
  70631. return this;
  70632. };
  70633. /**
  70634. * Multiplies in place the current quaternion by a scale factor
  70635. * @param value defines the scale factor
  70636. * @returns the current modified quaternion
  70637. */
  70638. Quaternion.prototype.scaleInPlace = function (value) {
  70639. this.x *= value;
  70640. this.y *= value;
  70641. this.z *= value;
  70642. this.w *= value;
  70643. return this;
  70644. };
  70645. /**
  70646. * Scale the current quaternion values by a factor and add the result to a given quaternion
  70647. * @param scale defines the scale factor
  70648. * @param result defines the Quaternion object where to store the result
  70649. * @returns the unmodified current quaternion
  70650. */
  70651. Quaternion.prototype.scaleAndAddToRef = function (scale, result) {
  70652. result.x += this.x * scale;
  70653. result.y += this.y * scale;
  70654. result.z += this.z * scale;
  70655. result.w += this.w * scale;
  70656. return this;
  70657. };
  70658. /**
  70659. * Multiplies two quaternions
  70660. * @param q1 defines the second operand
  70661. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  70662. */
  70663. Quaternion.prototype.multiply = function (q1) {
  70664. var result = new Quaternion(0, 0, 0, 1.0);
  70665. this.multiplyToRef(q1, result);
  70666. return result;
  70667. };
  70668. /**
  70669. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  70670. * @param q1 defines the second operand
  70671. * @param result defines the target quaternion
  70672. * @returns the current quaternion
  70673. */
  70674. Quaternion.prototype.multiplyToRef = function (q1, result) {
  70675. var x = this.x * q1.w + this.y * q1.z - this.z * q1.y + this.w * q1.x;
  70676. var y = -this.x * q1.z + this.y * q1.w + this.z * q1.x + this.w * q1.y;
  70677. var z = this.x * q1.y - this.y * q1.x + this.z * q1.w + this.w * q1.z;
  70678. var w = -this.x * q1.x - this.y * q1.y - this.z * q1.z + this.w * q1.w;
  70679. result.copyFromFloats(x, y, z, w);
  70680. return this;
  70681. };
  70682. /**
  70683. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  70684. * @param q1 defines the second operand
  70685. * @returns the currentupdated quaternion
  70686. */
  70687. Quaternion.prototype.multiplyInPlace = function (q1) {
  70688. this.multiplyToRef(q1, this);
  70689. return this;
  70690. };
  70691. /**
  70692. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  70693. * @param ref defines the target quaternion
  70694. * @returns the current quaternion
  70695. */
  70696. Quaternion.prototype.conjugateToRef = function (ref) {
  70697. ref.copyFromFloats(-this.x, -this.y, -this.z, this.w);
  70698. return this;
  70699. };
  70700. /**
  70701. * Conjugates in place (1-q) the current quaternion
  70702. * @returns the current updated quaternion
  70703. */
  70704. Quaternion.prototype.conjugateInPlace = function () {
  70705. this.x *= -1;
  70706. this.y *= -1;
  70707. this.z *= -1;
  70708. return this;
  70709. };
  70710. /**
  70711. * Conjugates in place (1-q) the current quaternion
  70712. * @returns a new quaternion
  70713. */
  70714. Quaternion.prototype.conjugate = function () {
  70715. var result = new Quaternion(-this.x, -this.y, -this.z, this.w);
  70716. return result;
  70717. };
  70718. /**
  70719. * Gets length of current quaternion
  70720. * @returns the quaternion length (float)
  70721. */
  70722. Quaternion.prototype.length = function () {
  70723. return Math.sqrt((this.x * this.x) + (this.y * this.y) + (this.z * this.z) + (this.w * this.w));
  70724. };
  70725. /**
  70726. * Normalize in place the current quaternion
  70727. * @returns the current updated quaternion
  70728. */
  70729. Quaternion.prototype.normalize = function () {
  70730. var length = 1.0 / this.length();
  70731. this.x *= length;
  70732. this.y *= length;
  70733. this.z *= length;
  70734. this.w *= length;
  70735. return this;
  70736. };
  70737. /**
  70738. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  70739. * @param order is a reserved parameter and is ignore for now
  70740. * @returns a new Vector3 containing the Euler angles
  70741. */
  70742. Quaternion.prototype.toEulerAngles = function (order) {
  70743. if (order === void 0) { order = "YZX"; }
  70744. var result = Vector3.Zero();
  70745. this.toEulerAnglesToRef(result);
  70746. return result;
  70747. };
  70748. /**
  70749. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  70750. * @param result defines the vector which will be filled with the Euler angles
  70751. * @param order is a reserved parameter and is ignore for now
  70752. * @returns the current unchanged quaternion
  70753. */
  70754. Quaternion.prototype.toEulerAnglesToRef = function (result) {
  70755. var qz = this.z;
  70756. var qx = this.x;
  70757. var qy = this.y;
  70758. var qw = this.w;
  70759. var sqw = qw * qw;
  70760. var sqz = qz * qz;
  70761. var sqx = qx * qx;
  70762. var sqy = qy * qy;
  70763. var zAxisY = qy * qz - qx * qw;
  70764. var limit = .4999999;
  70765. if (zAxisY < -limit) {
  70766. result.y = 2 * Math.atan2(qy, qw);
  70767. result.x = Math.PI / 2;
  70768. result.z = 0;
  70769. }
  70770. else if (zAxisY > limit) {
  70771. result.y = 2 * Math.atan2(qy, qw);
  70772. result.x = -Math.PI / 2;
  70773. result.z = 0;
  70774. }
  70775. else {
  70776. result.z = Math.atan2(2.0 * (qx * qy + qz * qw), (-sqz - sqx + sqy + sqw));
  70777. result.x = Math.asin(-2.0 * (qz * qy - qx * qw));
  70778. result.y = Math.atan2(2.0 * (qz * qx + qy * qw), (sqz - sqx - sqy + sqw));
  70779. }
  70780. return this;
  70781. };
  70782. /**
  70783. * Updates the given rotation matrix with the current quaternion values
  70784. * @param result defines the target matrix
  70785. * @returns the current unchanged quaternion
  70786. */
  70787. Quaternion.prototype.toRotationMatrix = function (result) {
  70788. Matrix.FromQuaternionToRef(this, result);
  70789. return this;
  70790. };
  70791. /**
  70792. * Updates the current quaternion from the given rotation matrix values
  70793. * @param matrix defines the source matrix
  70794. * @returns the current updated quaternion
  70795. */
  70796. Quaternion.prototype.fromRotationMatrix = function (matrix) {
  70797. Quaternion.FromRotationMatrixToRef(matrix, this);
  70798. return this;
  70799. };
  70800. // Statics
  70801. /**
  70802. * Creates a new quaternion from a rotation matrix
  70803. * @param matrix defines the source matrix
  70804. * @returns a new quaternion created from the given rotation matrix values
  70805. */
  70806. Quaternion.FromRotationMatrix = function (matrix) {
  70807. var result = new Quaternion();
  70808. Quaternion.FromRotationMatrixToRef(matrix, result);
  70809. return result;
  70810. };
  70811. /**
  70812. * Updates the given quaternion with the given rotation matrix values
  70813. * @param matrix defines the source matrix
  70814. * @param result defines the target quaternion
  70815. */
  70816. Quaternion.FromRotationMatrixToRef = function (matrix, result) {
  70817. var data = matrix.m;
  70818. var m11 = data[0], m12 = data[4], m13 = data[8];
  70819. var m21 = data[1], m22 = data[5], m23 = data[9];
  70820. var m31 = data[2], m32 = data[6], m33 = data[10];
  70821. var trace = m11 + m22 + m33;
  70822. var s;
  70823. if (trace > 0) {
  70824. s = 0.5 / Math.sqrt(trace + 1.0);
  70825. result.w = 0.25 / s;
  70826. result.x = (m32 - m23) * s;
  70827. result.y = (m13 - m31) * s;
  70828. result.z = (m21 - m12) * s;
  70829. }
  70830. else if (m11 > m22 && m11 > m33) {
  70831. s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
  70832. result.w = (m32 - m23) / s;
  70833. result.x = 0.25 * s;
  70834. result.y = (m12 + m21) / s;
  70835. result.z = (m13 + m31) / s;
  70836. }
  70837. else if (m22 > m33) {
  70838. s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
  70839. result.w = (m13 - m31) / s;
  70840. result.x = (m12 + m21) / s;
  70841. result.y = 0.25 * s;
  70842. result.z = (m23 + m32) / s;
  70843. }
  70844. else {
  70845. s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
  70846. result.w = (m21 - m12) / s;
  70847. result.x = (m13 + m31) / s;
  70848. result.y = (m23 + m32) / s;
  70849. result.z = 0.25 * s;
  70850. }
  70851. };
  70852. /**
  70853. * Returns the dot product (float) between the quaternions "left" and "right"
  70854. * @param left defines the left operand
  70855. * @param right defines the right operand
  70856. * @returns the dot product
  70857. */
  70858. Quaternion.Dot = function (left, right) {
  70859. return (left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w);
  70860. };
  70861. /**
  70862. * Checks if the two quaternions are close to each other
  70863. * @param quat0 defines the first quaternion to check
  70864. * @param quat1 defines the second quaternion to check
  70865. * @returns true if the two quaternions are close to each other
  70866. */
  70867. Quaternion.AreClose = function (quat0, quat1) {
  70868. var dot = Quaternion.Dot(quat0, quat1);
  70869. return dot >= 0;
  70870. };
  70871. /**
  70872. * Creates an empty quaternion
  70873. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  70874. */
  70875. Quaternion.Zero = function () {
  70876. return new Quaternion(0.0, 0.0, 0.0, 0.0);
  70877. };
  70878. /**
  70879. * Inverse a given quaternion
  70880. * @param q defines the source quaternion
  70881. * @returns a new quaternion as the inverted current quaternion
  70882. */
  70883. Quaternion.Inverse = function (q) {
  70884. return new Quaternion(-q.x, -q.y, -q.z, q.w);
  70885. };
  70886. /**
  70887. * Inverse a given quaternion
  70888. * @param q defines the source quaternion
  70889. * @param result the quaternion the result will be stored in
  70890. * @returns the result quaternion
  70891. */
  70892. Quaternion.InverseToRef = function (q, result) {
  70893. result.set(-q.x, -q.y, -q.z, q.w);
  70894. return result;
  70895. };
  70896. /**
  70897. * Creates an identity quaternion
  70898. * @returns the identity quaternion
  70899. */
  70900. Quaternion.Identity = function () {
  70901. return new Quaternion(0.0, 0.0, 0.0, 1.0);
  70902. };
  70903. /**
  70904. * Gets a boolean indicating if the given quaternion is identity
  70905. * @param quaternion defines the quaternion to check
  70906. * @returns true if the quaternion is identity
  70907. */
  70908. Quaternion.IsIdentity = function (quaternion) {
  70909. return quaternion && quaternion.x === 0 && quaternion.y === 0 && quaternion.z === 0 && quaternion.w === 1;
  70910. };
  70911. /**
  70912. * Creates a quaternion from a rotation around an axis
  70913. * @param axis defines the axis to use
  70914. * @param angle defines the angle to use
  70915. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  70916. */
  70917. Quaternion.RotationAxis = function (axis, angle) {
  70918. return Quaternion.RotationAxisToRef(axis, angle, new Quaternion());
  70919. };
  70920. /**
  70921. * Creates a rotation around an axis and stores it into the given quaternion
  70922. * @param axis defines the axis to use
  70923. * @param angle defines the angle to use
  70924. * @param result defines the target quaternion
  70925. * @returns the target quaternion
  70926. */
  70927. Quaternion.RotationAxisToRef = function (axis, angle, result) {
  70928. var sin = Math.sin(angle / 2);
  70929. axis.normalize();
  70930. result.w = Math.cos(angle / 2);
  70931. result.x = axis.x * sin;
  70932. result.y = axis.y * sin;
  70933. result.z = axis.z * sin;
  70934. return result;
  70935. };
  70936. /**
  70937. * Creates a new quaternion from data stored into an array
  70938. * @param array defines the data source
  70939. * @param offset defines the offset in the source array where the data starts
  70940. * @returns a new quaternion
  70941. */
  70942. Quaternion.FromArray = function (array, offset) {
  70943. if (!offset) {
  70944. offset = 0;
  70945. }
  70946. return new Quaternion(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  70947. };
  70948. /**
  70949. * Create a quaternion from Euler rotation angles
  70950. * @param x Pitch
  70951. * @param y Yaw
  70952. * @param z Roll
  70953. * @returns the new Quaternion
  70954. */
  70955. Quaternion.FromEulerAngles = function (x, y, z) {
  70956. var q = new Quaternion();
  70957. Quaternion.RotationYawPitchRollToRef(y, x, z, q);
  70958. return q;
  70959. };
  70960. /**
  70961. * Updates a quaternion from Euler rotation angles
  70962. * @param x Pitch
  70963. * @param y Yaw
  70964. * @param z Roll
  70965. * @param result the quaternion to store the result
  70966. * @returns the updated quaternion
  70967. */
  70968. Quaternion.FromEulerAnglesToRef = function (x, y, z, result) {
  70969. Quaternion.RotationYawPitchRollToRef(y, x, z, result);
  70970. return result;
  70971. };
  70972. /**
  70973. * Create a quaternion from Euler rotation vector
  70974. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  70975. * @returns the new Quaternion
  70976. */
  70977. Quaternion.FromEulerVector = function (vec) {
  70978. var q = new Quaternion();
  70979. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, q);
  70980. return q;
  70981. };
  70982. /**
  70983. * Updates a quaternion from Euler rotation vector
  70984. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  70985. * @param result the quaternion to store the result
  70986. * @returns the updated quaternion
  70987. */
  70988. Quaternion.FromEulerVectorToRef = function (vec, result) {
  70989. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, result);
  70990. return result;
  70991. };
  70992. /**
  70993. * Creates a new quaternion from the given Euler float angles (y, x, z)
  70994. * @param yaw defines the rotation around Y axis
  70995. * @param pitch defines the rotation around X axis
  70996. * @param roll defines the rotation around Z axis
  70997. * @returns the new quaternion
  70998. */
  70999. Quaternion.RotationYawPitchRoll = function (yaw, pitch, roll) {
  71000. var q = new Quaternion();
  71001. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, q);
  71002. return q;
  71003. };
  71004. /**
  71005. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  71006. * @param yaw defines the rotation around Y axis
  71007. * @param pitch defines the rotation around X axis
  71008. * @param roll defines the rotation around Z axis
  71009. * @param result defines the target quaternion
  71010. */
  71011. Quaternion.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  71012. // Produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
  71013. var halfRoll = roll * 0.5;
  71014. var halfPitch = pitch * 0.5;
  71015. var halfYaw = yaw * 0.5;
  71016. var sinRoll = Math.sin(halfRoll);
  71017. var cosRoll = Math.cos(halfRoll);
  71018. var sinPitch = Math.sin(halfPitch);
  71019. var cosPitch = Math.cos(halfPitch);
  71020. var sinYaw = Math.sin(halfYaw);
  71021. var cosYaw = Math.cos(halfYaw);
  71022. result.x = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);
  71023. result.y = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);
  71024. result.z = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);
  71025. result.w = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);
  71026. };
  71027. /**
  71028. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  71029. * @param alpha defines the rotation around first axis
  71030. * @param beta defines the rotation around second axis
  71031. * @param gamma defines the rotation around third axis
  71032. * @returns the new quaternion
  71033. */
  71034. Quaternion.RotationAlphaBetaGamma = function (alpha, beta, gamma) {
  71035. var result = new Quaternion();
  71036. Quaternion.RotationAlphaBetaGammaToRef(alpha, beta, gamma, result);
  71037. return result;
  71038. };
  71039. /**
  71040. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  71041. * @param alpha defines the rotation around first axis
  71042. * @param beta defines the rotation around second axis
  71043. * @param gamma defines the rotation around third axis
  71044. * @param result defines the target quaternion
  71045. */
  71046. Quaternion.RotationAlphaBetaGammaToRef = function (alpha, beta, gamma, result) {
  71047. // Produces a quaternion from Euler angles in the z-x-z orientation
  71048. var halfGammaPlusAlpha = (gamma + alpha) * 0.5;
  71049. var halfGammaMinusAlpha = (gamma - alpha) * 0.5;
  71050. var halfBeta = beta * 0.5;
  71051. result.x = Math.cos(halfGammaMinusAlpha) * Math.sin(halfBeta);
  71052. result.y = Math.sin(halfGammaMinusAlpha) * Math.sin(halfBeta);
  71053. result.z = Math.sin(halfGammaPlusAlpha) * Math.cos(halfBeta);
  71054. result.w = Math.cos(halfGammaPlusAlpha) * Math.cos(halfBeta);
  71055. };
  71056. /**
  71057. * 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)
  71058. * @param axis1 defines the first axis
  71059. * @param axis2 defines the second axis
  71060. * @param axis3 defines the third axis
  71061. * @returns the new quaternion
  71062. */
  71063. Quaternion.RotationQuaternionFromAxis = function (axis1, axis2, axis3) {
  71064. var quat = new Quaternion(0.0, 0.0, 0.0, 0.0);
  71065. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  71066. return quat;
  71067. };
  71068. /**
  71069. * 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
  71070. * @param axis1 defines the first axis
  71071. * @param axis2 defines the second axis
  71072. * @param axis3 defines the third axis
  71073. * @param ref defines the target quaternion
  71074. */
  71075. Quaternion.RotationQuaternionFromAxisToRef = function (axis1, axis2, axis3, ref) {
  71076. var rotMat = MathTmp.Matrix[0];
  71077. Matrix.FromXYZAxesToRef(axis1.normalize(), axis2.normalize(), axis3.normalize(), rotMat);
  71078. Quaternion.FromRotationMatrixToRef(rotMat, ref);
  71079. };
  71080. /**
  71081. * Interpolates between two quaternions
  71082. * @param left defines first quaternion
  71083. * @param right defines second quaternion
  71084. * @param amount defines the gradient to use
  71085. * @returns the new interpolated quaternion
  71086. */
  71087. Quaternion.Slerp = function (left, right, amount) {
  71088. var result = Quaternion.Identity();
  71089. Quaternion.SlerpToRef(left, right, amount, result);
  71090. return result;
  71091. };
  71092. /**
  71093. * Interpolates between two quaternions and stores it into a target quaternion
  71094. * @param left defines first quaternion
  71095. * @param right defines second quaternion
  71096. * @param amount defines the gradient to use
  71097. * @param result defines the target quaternion
  71098. */
  71099. Quaternion.SlerpToRef = function (left, right, amount, result) {
  71100. var num2;
  71101. var num3;
  71102. var num4 = (((left.x * right.x) + (left.y * right.y)) + (left.z * right.z)) + (left.w * right.w);
  71103. var flag = false;
  71104. if (num4 < 0) {
  71105. flag = true;
  71106. num4 = -num4;
  71107. }
  71108. if (num4 > 0.999999) {
  71109. num3 = 1 - amount;
  71110. num2 = flag ? -amount : amount;
  71111. }
  71112. else {
  71113. var num5 = Math.acos(num4);
  71114. var num6 = (1.0 / Math.sin(num5));
  71115. num3 = (Math.sin((1.0 - amount) * num5)) * num6;
  71116. num2 = flag ? ((-Math.sin(amount * num5)) * num6) : ((Math.sin(amount * num5)) * num6);
  71117. }
  71118. result.x = (num3 * left.x) + (num2 * right.x);
  71119. result.y = (num3 * left.y) + (num2 * right.y);
  71120. result.z = (num3 * left.z) + (num2 * right.z);
  71121. result.w = (num3 * left.w) + (num2 * right.w);
  71122. };
  71123. /**
  71124. * Interpolate between two quaternions using Hermite interpolation
  71125. * @param value1 defines first quaternion
  71126. * @param tangent1 defines the incoming tangent
  71127. * @param value2 defines second quaternion
  71128. * @param tangent2 defines the outgoing tangent
  71129. * @param amount defines the target quaternion
  71130. * @returns the new interpolated quaternion
  71131. */
  71132. Quaternion.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  71133. var squared = amount * amount;
  71134. var cubed = amount * squared;
  71135. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  71136. var part2 = (-2.0 * cubed) + (3.0 * squared);
  71137. var part3 = (cubed - (2.0 * squared)) + amount;
  71138. var part4 = cubed - squared;
  71139. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  71140. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  71141. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  71142. var w = (((value1.w * part1) + (value2.w * part2)) + (tangent1.w * part3)) + (tangent2.w * part4);
  71143. return new Quaternion(x, y, z, w);
  71144. };
  71145. return Quaternion;
  71146. }());
  71147. /**
  71148. * Class used to store matrix data (4x4)
  71149. */
  71150. var Matrix = /** @class */ (function () {
  71151. /**
  71152. * Creates an empty matrix (filled with zeros)
  71153. */
  71154. function Matrix() {
  71155. this._isIdentity = false;
  71156. this._isIdentityDirty = true;
  71157. this._isIdentity3x2 = true;
  71158. this._isIdentity3x2Dirty = true;
  71159. this._m = new Float32Array(16);
  71160. this._updateIdentityStatus(false);
  71161. }
  71162. Object.defineProperty(Matrix.prototype, "m", {
  71163. /**
  71164. * Gets the internal data of the matrix
  71165. */
  71166. get: function () { return this._m; },
  71167. enumerable: true,
  71168. configurable: true
  71169. });
  71170. /** @hidden */
  71171. Matrix.prototype._markAsUpdated = function () {
  71172. this.updateFlag = Matrix._updateFlagSeed++;
  71173. this._isIdentity = false;
  71174. this._isIdentity3x2 = false;
  71175. this._isIdentityDirty = true;
  71176. this._isIdentity3x2Dirty = true;
  71177. };
  71178. /** @hidden */
  71179. Matrix.prototype._updateIdentityStatus = function (isIdentity, isIdentityDirty, isIdentity3x2, isIdentity3x2Dirty) {
  71180. if (isIdentityDirty === void 0) { isIdentityDirty = false; }
  71181. if (isIdentity3x2 === void 0) { isIdentity3x2 = false; }
  71182. if (isIdentity3x2Dirty === void 0) { isIdentity3x2Dirty = true; }
  71183. this.updateFlag = Matrix._updateFlagSeed++;
  71184. this._isIdentity = isIdentity;
  71185. this._isIdentity3x2 = isIdentity || isIdentity3x2;
  71186. this._isIdentityDirty = this._isIdentity ? false : isIdentityDirty;
  71187. this._isIdentity3x2Dirty = this._isIdentity3x2 ? false : isIdentity3x2Dirty;
  71188. };
  71189. // Properties
  71190. /**
  71191. * Check if the current matrix is identity
  71192. * @returns true is the matrix is the identity matrix
  71193. */
  71194. Matrix.prototype.isIdentity = function () {
  71195. if (this._isIdentityDirty) {
  71196. this._isIdentityDirty = false;
  71197. var m = this._m;
  71198. this._isIdentity = (m[0] === 1.0 && m[1] === 0.0 && m[2] === 0.0 && m[3] === 0.0 &&
  71199. m[4] === 0.0 && m[5] === 1.0 && m[6] === 0.0 && m[7] === 0.0 &&
  71200. m[8] === 0.0 && m[9] === 0.0 && m[10] === 1.0 && m[11] === 0.0 &&
  71201. m[12] === 0.0 && m[13] === 0.0 && m[14] === 0.0 && m[15] === 1.0);
  71202. }
  71203. return this._isIdentity;
  71204. };
  71205. /**
  71206. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  71207. * @returns true is the matrix is the identity matrix
  71208. */
  71209. Matrix.prototype.isIdentityAs3x2 = function () {
  71210. if (this._isIdentity3x2Dirty) {
  71211. this._isIdentity3x2Dirty = false;
  71212. if (this._m[0] !== 1.0 || this._m[5] !== 1.0 || this._m[15] !== 1.0) {
  71213. this._isIdentity3x2 = false;
  71214. }
  71215. else if (this._m[1] !== 0.0 || this._m[2] !== 0.0 || this._m[3] !== 0.0 ||
  71216. this._m[4] !== 0.0 || this._m[6] !== 0.0 || this._m[7] !== 0.0 ||
  71217. this._m[8] !== 0.0 || this._m[9] !== 0.0 || this._m[10] !== 0.0 || this._m[11] !== 0.0 ||
  71218. this._m[12] !== 0.0 || this._m[13] !== 0.0 || this._m[14] !== 0.0) {
  71219. this._isIdentity3x2 = false;
  71220. }
  71221. else {
  71222. this._isIdentity3x2 = true;
  71223. }
  71224. }
  71225. return this._isIdentity3x2;
  71226. };
  71227. /**
  71228. * Gets the determinant of the matrix
  71229. * @returns the matrix determinant
  71230. */
  71231. Matrix.prototype.determinant = function () {
  71232. if (this._isIdentity === true) {
  71233. return 1;
  71234. }
  71235. var m = this._m;
  71236. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  71237. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  71238. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  71239. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  71240. // https://en.wikipedia.org/wiki/Laplace_expansion
  71241. // to compute the deterrminant of a 4x4 Matrix we compute the cofactors of any row or column,
  71242. // then we multiply each Cofactor by its corresponding matrix value and sum them all to get the determinant
  71243. // Cofactor(i, j) = sign(i,j) * det(Minor(i, j))
  71244. // where
  71245. // - sign(i,j) = (i+j) % 2 === 0 ? 1 : -1
  71246. // - Minor(i, j) is the 3x3 matrix we get by removing row i and column j from current Matrix
  71247. //
  71248. // Here we do that for the 1st row.
  71249. var det_22_33 = m22 * m33 - m32 * m23;
  71250. var det_21_33 = m21 * m33 - m31 * m23;
  71251. var det_21_32 = m21 * m32 - m31 * m22;
  71252. var det_20_33 = m20 * m33 - m30 * m23;
  71253. var det_20_32 = m20 * m32 - m22 * m30;
  71254. var det_20_31 = m20 * m31 - m30 * m21;
  71255. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  71256. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  71257. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  71258. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  71259. return m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  71260. };
  71261. // Methods
  71262. /**
  71263. * Returns the matrix as a Float32Array
  71264. * @returns the matrix underlying array
  71265. */
  71266. Matrix.prototype.toArray = function () {
  71267. return this._m;
  71268. };
  71269. /**
  71270. * Returns the matrix as a Float32Array
  71271. * @returns the matrix underlying array.
  71272. */
  71273. Matrix.prototype.asArray = function () {
  71274. return this._m;
  71275. };
  71276. /**
  71277. * Inverts the current matrix in place
  71278. * @returns the current inverted matrix
  71279. */
  71280. Matrix.prototype.invert = function () {
  71281. this.invertToRef(this);
  71282. return this;
  71283. };
  71284. /**
  71285. * Sets all the matrix elements to zero
  71286. * @returns the current matrix
  71287. */
  71288. Matrix.prototype.reset = function () {
  71289. 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);
  71290. this._updateIdentityStatus(false);
  71291. return this;
  71292. };
  71293. /**
  71294. * Adds the current matrix with a second one
  71295. * @param other defines the matrix to add
  71296. * @returns a new matrix as the addition of the current matrix and the given one
  71297. */
  71298. Matrix.prototype.add = function (other) {
  71299. var result = new Matrix();
  71300. this.addToRef(other, result);
  71301. return result;
  71302. };
  71303. /**
  71304. * Sets the given matrix "result" to the addition of the current matrix and the given one
  71305. * @param other defines the matrix to add
  71306. * @param result defines the target matrix
  71307. * @returns the current matrix
  71308. */
  71309. Matrix.prototype.addToRef = function (other, result) {
  71310. var m = this._m;
  71311. var resultM = result._m;
  71312. var otherM = other.m;
  71313. for (var index = 0; index < 16; index++) {
  71314. resultM[index] = m[index] + otherM[index];
  71315. }
  71316. result._markAsUpdated();
  71317. return this;
  71318. };
  71319. /**
  71320. * Adds in place the given matrix to the current matrix
  71321. * @param other defines the second operand
  71322. * @returns the current updated matrix
  71323. */
  71324. Matrix.prototype.addToSelf = function (other) {
  71325. var m = this._m;
  71326. var otherM = other.m;
  71327. for (var index = 0; index < 16; index++) {
  71328. m[index] += otherM[index];
  71329. }
  71330. this._markAsUpdated();
  71331. return this;
  71332. };
  71333. /**
  71334. * Sets the given matrix to the current inverted Matrix
  71335. * @param other defines the target matrix
  71336. * @returns the unmodified current matrix
  71337. */
  71338. Matrix.prototype.invertToRef = function (other) {
  71339. if (this._isIdentity === true) {
  71340. Matrix.IdentityToRef(other);
  71341. return this;
  71342. }
  71343. // the inverse of a Matrix is the transpose of cofactor matrix divided by the determinant
  71344. var m = this._m;
  71345. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  71346. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  71347. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  71348. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  71349. var det_22_33 = m22 * m33 - m32 * m23;
  71350. var det_21_33 = m21 * m33 - m31 * m23;
  71351. var det_21_32 = m21 * m32 - m31 * m22;
  71352. var det_20_33 = m20 * m33 - m30 * m23;
  71353. var det_20_32 = m20 * m32 - m22 * m30;
  71354. var det_20_31 = m20 * m31 - m30 * m21;
  71355. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  71356. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  71357. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  71358. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  71359. var det = m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  71360. if (det === 0) {
  71361. // not invertible
  71362. other.copyFrom(this);
  71363. return this;
  71364. }
  71365. var detInv = 1 / det;
  71366. var det_12_33 = m12 * m33 - m32 * m13;
  71367. var det_11_33 = m11 * m33 - m31 * m13;
  71368. var det_11_32 = m11 * m32 - m31 * m12;
  71369. var det_10_33 = m10 * m33 - m30 * m13;
  71370. var det_10_32 = m10 * m32 - m30 * m12;
  71371. var det_10_31 = m10 * m31 - m30 * m11;
  71372. var det_12_23 = m12 * m23 - m22 * m13;
  71373. var det_11_23 = m11 * m23 - m21 * m13;
  71374. var det_11_22 = m11 * m22 - m21 * m12;
  71375. var det_10_23 = m10 * m23 - m20 * m13;
  71376. var det_10_22 = m10 * m22 - m20 * m12;
  71377. var det_10_21 = m10 * m21 - m20 * m11;
  71378. var cofact_10 = -(m01 * det_22_33 - m02 * det_21_33 + m03 * det_21_32);
  71379. var cofact_11 = +(m00 * det_22_33 - m02 * det_20_33 + m03 * det_20_32);
  71380. var cofact_12 = -(m00 * det_21_33 - m01 * det_20_33 + m03 * det_20_31);
  71381. var cofact_13 = +(m00 * det_21_32 - m01 * det_20_32 + m02 * det_20_31);
  71382. var cofact_20 = +(m01 * det_12_33 - m02 * det_11_33 + m03 * det_11_32);
  71383. var cofact_21 = -(m00 * det_12_33 - m02 * det_10_33 + m03 * det_10_32);
  71384. var cofact_22 = +(m00 * det_11_33 - m01 * det_10_33 + m03 * det_10_31);
  71385. var cofact_23 = -(m00 * det_11_32 - m01 * det_10_32 + m02 * det_10_31);
  71386. var cofact_30 = -(m01 * det_12_23 - m02 * det_11_23 + m03 * det_11_22);
  71387. var cofact_31 = +(m00 * det_12_23 - m02 * det_10_23 + m03 * det_10_22);
  71388. var cofact_32 = -(m00 * det_11_23 - m01 * det_10_23 + m03 * det_10_21);
  71389. var cofact_33 = +(m00 * det_11_22 - m01 * det_10_22 + m02 * det_10_21);
  71390. 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);
  71391. return this;
  71392. };
  71393. /**
  71394. * add a value at the specified position in the current Matrix
  71395. * @param index the index of the value within the matrix. between 0 and 15.
  71396. * @param value the value to be added
  71397. * @returns the current updated matrix
  71398. */
  71399. Matrix.prototype.addAtIndex = function (index, value) {
  71400. this._m[index] += value;
  71401. this._markAsUpdated();
  71402. return this;
  71403. };
  71404. /**
  71405. * mutiply the specified position in the current Matrix by a value
  71406. * @param index the index of the value within the matrix. between 0 and 15.
  71407. * @param value the value to be added
  71408. * @returns the current updated matrix
  71409. */
  71410. Matrix.prototype.multiplyAtIndex = function (index, value) {
  71411. this._m[index] *= value;
  71412. this._markAsUpdated();
  71413. return this;
  71414. };
  71415. /**
  71416. * Inserts the translation vector (using 3 floats) in the current matrix
  71417. * @param x defines the 1st component of the translation
  71418. * @param y defines the 2nd component of the translation
  71419. * @param z defines the 3rd component of the translation
  71420. * @returns the current updated matrix
  71421. */
  71422. Matrix.prototype.setTranslationFromFloats = function (x, y, z) {
  71423. this._m[12] = x;
  71424. this._m[13] = y;
  71425. this._m[14] = z;
  71426. this._markAsUpdated();
  71427. return this;
  71428. };
  71429. /**
  71430. * Inserts the translation vector in the current matrix
  71431. * @param vector3 defines the translation to insert
  71432. * @returns the current updated matrix
  71433. */
  71434. Matrix.prototype.setTranslation = function (vector3) {
  71435. return this.setTranslationFromFloats(vector3.x, vector3.y, vector3.z);
  71436. };
  71437. /**
  71438. * Gets the translation value of the current matrix
  71439. * @returns a new Vector3 as the extracted translation from the matrix
  71440. */
  71441. Matrix.prototype.getTranslation = function () {
  71442. return new Vector3(this._m[12], this._m[13], this._m[14]);
  71443. };
  71444. /**
  71445. * Fill a Vector3 with the extracted translation from the matrix
  71446. * @param result defines the Vector3 where to store the translation
  71447. * @returns the current matrix
  71448. */
  71449. Matrix.prototype.getTranslationToRef = function (result) {
  71450. result.x = this._m[12];
  71451. result.y = this._m[13];
  71452. result.z = this._m[14];
  71453. return this;
  71454. };
  71455. /**
  71456. * Remove rotation and scaling part from the matrix
  71457. * @returns the updated matrix
  71458. */
  71459. Matrix.prototype.removeRotationAndScaling = function () {
  71460. var m = this.m;
  71461. 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);
  71462. this._updateIdentityStatus(m[12] === 0 && m[13] === 0 && m[14] === 0 && m[15] === 1);
  71463. return this;
  71464. };
  71465. /**
  71466. * Multiply two matrices
  71467. * @param other defines the second operand
  71468. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  71469. */
  71470. Matrix.prototype.multiply = function (other) {
  71471. var result = new Matrix();
  71472. this.multiplyToRef(other, result);
  71473. return result;
  71474. };
  71475. /**
  71476. * Copy the current matrix from the given one
  71477. * @param other defines the source matrix
  71478. * @returns the current updated matrix
  71479. */
  71480. Matrix.prototype.copyFrom = function (other) {
  71481. other.copyToArray(this._m);
  71482. var o = other;
  71483. this._updateIdentityStatus(o._isIdentity, o._isIdentityDirty, o._isIdentity3x2, o._isIdentity3x2Dirty);
  71484. return this;
  71485. };
  71486. /**
  71487. * Populates the given array from the starting index with the current matrix values
  71488. * @param array defines the target array
  71489. * @param offset defines the offset in the target array where to start storing values
  71490. * @returns the current matrix
  71491. */
  71492. Matrix.prototype.copyToArray = function (array, offset) {
  71493. if (offset === void 0) { offset = 0; }
  71494. for (var index = 0; index < 16; index++) {
  71495. array[offset + index] = this._m[index];
  71496. }
  71497. return this;
  71498. };
  71499. /**
  71500. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  71501. * @param other defines the second operand
  71502. * @param result defines the matrix where to store the multiplication
  71503. * @returns the current matrix
  71504. */
  71505. Matrix.prototype.multiplyToRef = function (other, result) {
  71506. if (this._isIdentity) {
  71507. result.copyFrom(other);
  71508. return this;
  71509. }
  71510. if (other._isIdentity) {
  71511. result.copyFrom(this);
  71512. return this;
  71513. }
  71514. this.multiplyToArray(other, result._m, 0);
  71515. result._markAsUpdated();
  71516. return this;
  71517. };
  71518. /**
  71519. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  71520. * @param other defines the second operand
  71521. * @param result defines the array where to store the multiplication
  71522. * @param offset defines the offset in the target array where to start storing values
  71523. * @returns the current matrix
  71524. */
  71525. Matrix.prototype.multiplyToArray = function (other, result, offset) {
  71526. var m = this._m;
  71527. var otherM = other.m;
  71528. var tm0 = m[0], tm1 = m[1], tm2 = m[2], tm3 = m[3];
  71529. var tm4 = m[4], tm5 = m[5], tm6 = m[6], tm7 = m[7];
  71530. var tm8 = m[8], tm9 = m[9], tm10 = m[10], tm11 = m[11];
  71531. var tm12 = m[12], tm13 = m[13], tm14 = m[14], tm15 = m[15];
  71532. var om0 = otherM[0], om1 = otherM[1], om2 = otherM[2], om3 = otherM[3];
  71533. var om4 = otherM[4], om5 = otherM[5], om6 = otherM[6], om7 = otherM[7];
  71534. var om8 = otherM[8], om9 = otherM[9], om10 = otherM[10], om11 = otherM[11];
  71535. var om12 = otherM[12], om13 = otherM[13], om14 = otherM[14], om15 = otherM[15];
  71536. result[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;
  71537. result[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;
  71538. result[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;
  71539. result[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;
  71540. result[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;
  71541. result[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;
  71542. result[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;
  71543. result[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;
  71544. result[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;
  71545. result[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;
  71546. result[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;
  71547. result[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;
  71548. result[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;
  71549. result[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;
  71550. result[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;
  71551. result[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;
  71552. return this;
  71553. };
  71554. /**
  71555. * Check equality between this matrix and a second one
  71556. * @param value defines the second matrix to compare
  71557. * @returns true is the current matrix and the given one values are strictly equal
  71558. */
  71559. Matrix.prototype.equals = function (value) {
  71560. var other = value;
  71561. if (!other) {
  71562. return false;
  71563. }
  71564. if (this._isIdentity || other._isIdentity) {
  71565. if (!this._isIdentityDirty && !other._isIdentityDirty) {
  71566. return this._isIdentity && other._isIdentity;
  71567. }
  71568. }
  71569. var m = this.m;
  71570. var om = other.m;
  71571. return (m[0] === om[0] && m[1] === om[1] && m[2] === om[2] && m[3] === om[3] &&
  71572. m[4] === om[4] && m[5] === om[5] && m[6] === om[6] && m[7] === om[7] &&
  71573. m[8] === om[8] && m[9] === om[9] && m[10] === om[10] && m[11] === om[11] &&
  71574. m[12] === om[12] && m[13] === om[13] && m[14] === om[14] && m[15] === om[15]);
  71575. };
  71576. /**
  71577. * Clone the current matrix
  71578. * @returns a new matrix from the current matrix
  71579. */
  71580. Matrix.prototype.clone = function () {
  71581. var matrix = new Matrix();
  71582. matrix.copyFrom(this);
  71583. return matrix;
  71584. };
  71585. /**
  71586. * Returns the name of the current matrix class
  71587. * @returns the string "Matrix"
  71588. */
  71589. Matrix.prototype.getClassName = function () {
  71590. return "Matrix";
  71591. };
  71592. /**
  71593. * Gets the hash code of the current matrix
  71594. * @returns the hash code
  71595. */
  71596. Matrix.prototype.getHashCode = function () {
  71597. var hash = this._m[0] || 0;
  71598. for (var i = 1; i < 16; i++) {
  71599. hash = (hash * 397) ^ (this._m[i] || 0);
  71600. }
  71601. return hash;
  71602. };
  71603. /**
  71604. * Decomposes the current Matrix into a translation, rotation and scaling components
  71605. * @param scale defines the scale vector3 given as a reference to update
  71606. * @param rotation defines the rotation quaternion given as a reference to update
  71607. * @param translation defines the translation vector3 given as a reference to update
  71608. * @returns true if operation was successful
  71609. */
  71610. Matrix.prototype.decompose = function (scale, rotation, translation) {
  71611. if (this._isIdentity) {
  71612. if (translation) {
  71613. translation.setAll(0);
  71614. }
  71615. if (scale) {
  71616. scale.setAll(1);
  71617. }
  71618. if (rotation) {
  71619. rotation.copyFromFloats(0, 0, 0, 1);
  71620. }
  71621. return true;
  71622. }
  71623. var m = this._m;
  71624. if (translation) {
  71625. translation.copyFromFloats(m[12], m[13], m[14]);
  71626. }
  71627. scale = scale || MathTmp.Vector3[0];
  71628. scale.x = Math.sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
  71629. scale.y = Math.sqrt(m[4] * m[4] + m[5] * m[5] + m[6] * m[6]);
  71630. scale.z = Math.sqrt(m[8] * m[8] + m[9] * m[9] + m[10] * m[10]);
  71631. if (this.determinant() <= 0) {
  71632. scale.y *= -1;
  71633. }
  71634. if (scale.x === 0 || scale.y === 0 || scale.z === 0) {
  71635. if (rotation) {
  71636. rotation.copyFromFloats(0.0, 0.0, 0.0, 1.0);
  71637. }
  71638. return false;
  71639. }
  71640. if (rotation) {
  71641. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  71642. 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]);
  71643. Quaternion.FromRotationMatrixToRef(MathTmp.Matrix[0], rotation);
  71644. }
  71645. return true;
  71646. };
  71647. /**
  71648. * Gets specific row of the matrix
  71649. * @param index defines the number of the row to get
  71650. * @returns the index-th row of the current matrix as a new Vector4
  71651. */
  71652. Matrix.prototype.getRow = function (index) {
  71653. if (index < 0 || index > 3) {
  71654. return null;
  71655. }
  71656. var i = index * 4;
  71657. return new Vector4(this._m[i + 0], this._m[i + 1], this._m[i + 2], this._m[i + 3]);
  71658. };
  71659. /**
  71660. * Sets the index-th row of the current matrix to the vector4 values
  71661. * @param index defines the number of the row to set
  71662. * @param row defines the target vector4
  71663. * @returns the updated current matrix
  71664. */
  71665. Matrix.prototype.setRow = function (index, row) {
  71666. return this.setRowFromFloats(index, row.x, row.y, row.z, row.w);
  71667. };
  71668. /**
  71669. * Compute the transpose of the matrix
  71670. * @returns the new transposed matrix
  71671. */
  71672. Matrix.prototype.transpose = function () {
  71673. return Matrix.Transpose(this);
  71674. };
  71675. /**
  71676. * Compute the transpose of the matrix and store it in a given matrix
  71677. * @param result defines the target matrix
  71678. * @returns the current matrix
  71679. */
  71680. Matrix.prototype.transposeToRef = function (result) {
  71681. Matrix.TransposeToRef(this, result);
  71682. return this;
  71683. };
  71684. /**
  71685. * Sets the index-th row of the current matrix with the given 4 x float values
  71686. * @param index defines the row index
  71687. * @param x defines the x component to set
  71688. * @param y defines the y component to set
  71689. * @param z defines the z component to set
  71690. * @param w defines the w component to set
  71691. * @returns the updated current matrix
  71692. */
  71693. Matrix.prototype.setRowFromFloats = function (index, x, y, z, w) {
  71694. if (index < 0 || index > 3) {
  71695. return this;
  71696. }
  71697. var i = index * 4;
  71698. this._m[i + 0] = x;
  71699. this._m[i + 1] = y;
  71700. this._m[i + 2] = z;
  71701. this._m[i + 3] = w;
  71702. this._markAsUpdated();
  71703. return this;
  71704. };
  71705. /**
  71706. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  71707. * @param scale defines the scale factor
  71708. * @returns a new matrix
  71709. */
  71710. Matrix.prototype.scale = function (scale) {
  71711. var result = new Matrix();
  71712. this.scaleToRef(scale, result);
  71713. return result;
  71714. };
  71715. /**
  71716. * Scale the current matrix values by a factor to a given result matrix
  71717. * @param scale defines the scale factor
  71718. * @param result defines the matrix to store the result
  71719. * @returns the current matrix
  71720. */
  71721. Matrix.prototype.scaleToRef = function (scale, result) {
  71722. for (var index = 0; index < 16; index++) {
  71723. result._m[index] = this._m[index] * scale;
  71724. }
  71725. result._markAsUpdated();
  71726. return this;
  71727. };
  71728. /**
  71729. * Scale the current matrix values by a factor and add the result to a given matrix
  71730. * @param scale defines the scale factor
  71731. * @param result defines the Matrix to store the result
  71732. * @returns the current matrix
  71733. */
  71734. Matrix.prototype.scaleAndAddToRef = function (scale, result) {
  71735. for (var index = 0; index < 16; index++) {
  71736. result._m[index] += this._m[index] * scale;
  71737. }
  71738. result._markAsUpdated();
  71739. return this;
  71740. };
  71741. /**
  71742. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  71743. * @param ref matrix to store the result
  71744. */
  71745. Matrix.prototype.toNormalMatrix = function (ref) {
  71746. var tmp = MathTmp.Matrix[0];
  71747. this.invertToRef(tmp);
  71748. tmp.transposeToRef(ref);
  71749. var m = ref._m;
  71750. 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);
  71751. };
  71752. /**
  71753. * Gets only rotation part of the current matrix
  71754. * @returns a new matrix sets to the extracted rotation matrix from the current one
  71755. */
  71756. Matrix.prototype.getRotationMatrix = function () {
  71757. var result = new Matrix();
  71758. this.getRotationMatrixToRef(result);
  71759. return result;
  71760. };
  71761. /**
  71762. * Extracts the rotation matrix from the current one and sets it as the given "result"
  71763. * @param result defines the target matrix to store data to
  71764. * @returns the current matrix
  71765. */
  71766. Matrix.prototype.getRotationMatrixToRef = function (result) {
  71767. var scale = MathTmp.Vector3[0];
  71768. if (!this.decompose(scale)) {
  71769. Matrix.IdentityToRef(result);
  71770. return this;
  71771. }
  71772. var m = this._m;
  71773. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  71774. 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);
  71775. return this;
  71776. };
  71777. /**
  71778. * Toggles model matrix from being right handed to left handed in place and vice versa
  71779. */
  71780. Matrix.prototype.toggleModelMatrixHandInPlace = function () {
  71781. var m = this._m;
  71782. m[2] *= -1;
  71783. m[6] *= -1;
  71784. m[8] *= -1;
  71785. m[9] *= -1;
  71786. m[14] *= -1;
  71787. this._markAsUpdated();
  71788. };
  71789. /**
  71790. * Toggles projection matrix from being right handed to left handed in place and vice versa
  71791. */
  71792. Matrix.prototype.toggleProjectionMatrixHandInPlace = function () {
  71793. var m = this._m;
  71794. m[8] *= -1;
  71795. m[9] *= -1;
  71796. m[10] *= -1;
  71797. m[11] *= -1;
  71798. this._markAsUpdated();
  71799. };
  71800. // Statics
  71801. /**
  71802. * Creates a matrix from an array
  71803. * @param array defines the source array
  71804. * @param offset defines an offset in the source array
  71805. * @returns a new Matrix set from the starting index of the given array
  71806. */
  71807. Matrix.FromArray = function (array, offset) {
  71808. if (offset === void 0) { offset = 0; }
  71809. var result = new Matrix();
  71810. Matrix.FromArrayToRef(array, offset, result);
  71811. return result;
  71812. };
  71813. /**
  71814. * Copy the content of an array into a given matrix
  71815. * @param array defines the source array
  71816. * @param offset defines an offset in the source array
  71817. * @param result defines the target matrix
  71818. */
  71819. Matrix.FromArrayToRef = function (array, offset, result) {
  71820. for (var index = 0; index < 16; index++) {
  71821. result._m[index] = array[index + offset];
  71822. }
  71823. result._markAsUpdated();
  71824. };
  71825. /**
  71826. * Stores an array into a matrix after having multiplied each component by a given factor
  71827. * @param array defines the source array
  71828. * @param offset defines the offset in the source array
  71829. * @param scale defines the scaling factor
  71830. * @param result defines the target matrix
  71831. */
  71832. Matrix.FromFloat32ArrayToRefScaled = function (array, offset, scale, result) {
  71833. for (var index = 0; index < 16; index++) {
  71834. result._m[index] = array[index + offset] * scale;
  71835. }
  71836. result._markAsUpdated();
  71837. };
  71838. Object.defineProperty(Matrix, "IdentityReadOnly", {
  71839. /**
  71840. * Gets an identity matrix that must not be updated
  71841. */
  71842. get: function () {
  71843. return Matrix._identityReadOnly;
  71844. },
  71845. enumerable: true,
  71846. configurable: true
  71847. });
  71848. /**
  71849. * Stores a list of values (16) inside a given matrix
  71850. * @param initialM11 defines 1st value of 1st row
  71851. * @param initialM12 defines 2nd value of 1st row
  71852. * @param initialM13 defines 3rd value of 1st row
  71853. * @param initialM14 defines 4th value of 1st row
  71854. * @param initialM21 defines 1st value of 2nd row
  71855. * @param initialM22 defines 2nd value of 2nd row
  71856. * @param initialM23 defines 3rd value of 2nd row
  71857. * @param initialM24 defines 4th value of 2nd row
  71858. * @param initialM31 defines 1st value of 3rd row
  71859. * @param initialM32 defines 2nd value of 3rd row
  71860. * @param initialM33 defines 3rd value of 3rd row
  71861. * @param initialM34 defines 4th value of 3rd row
  71862. * @param initialM41 defines 1st value of 4th row
  71863. * @param initialM42 defines 2nd value of 4th row
  71864. * @param initialM43 defines 3rd value of 4th row
  71865. * @param initialM44 defines 4th value of 4th row
  71866. * @param result defines the target matrix
  71867. */
  71868. Matrix.FromValuesToRef = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44, result) {
  71869. var m = result._m;
  71870. m[0] = initialM11;
  71871. m[1] = initialM12;
  71872. m[2] = initialM13;
  71873. m[3] = initialM14;
  71874. m[4] = initialM21;
  71875. m[5] = initialM22;
  71876. m[6] = initialM23;
  71877. m[7] = initialM24;
  71878. m[8] = initialM31;
  71879. m[9] = initialM32;
  71880. m[10] = initialM33;
  71881. m[11] = initialM34;
  71882. m[12] = initialM41;
  71883. m[13] = initialM42;
  71884. m[14] = initialM43;
  71885. m[15] = initialM44;
  71886. result._markAsUpdated();
  71887. };
  71888. /**
  71889. * Creates new matrix from a list of values (16)
  71890. * @param initialM11 defines 1st value of 1st row
  71891. * @param initialM12 defines 2nd value of 1st row
  71892. * @param initialM13 defines 3rd value of 1st row
  71893. * @param initialM14 defines 4th value of 1st row
  71894. * @param initialM21 defines 1st value of 2nd row
  71895. * @param initialM22 defines 2nd value of 2nd row
  71896. * @param initialM23 defines 3rd value of 2nd row
  71897. * @param initialM24 defines 4th value of 2nd row
  71898. * @param initialM31 defines 1st value of 3rd row
  71899. * @param initialM32 defines 2nd value of 3rd row
  71900. * @param initialM33 defines 3rd value of 3rd row
  71901. * @param initialM34 defines 4th value of 3rd row
  71902. * @param initialM41 defines 1st value of 4th row
  71903. * @param initialM42 defines 2nd value of 4th row
  71904. * @param initialM43 defines 3rd value of 4th row
  71905. * @param initialM44 defines 4th value of 4th row
  71906. * @returns the new matrix
  71907. */
  71908. Matrix.FromValues = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44) {
  71909. var result = new Matrix();
  71910. var m = result._m;
  71911. m[0] = initialM11;
  71912. m[1] = initialM12;
  71913. m[2] = initialM13;
  71914. m[3] = initialM14;
  71915. m[4] = initialM21;
  71916. m[5] = initialM22;
  71917. m[6] = initialM23;
  71918. m[7] = initialM24;
  71919. m[8] = initialM31;
  71920. m[9] = initialM32;
  71921. m[10] = initialM33;
  71922. m[11] = initialM34;
  71923. m[12] = initialM41;
  71924. m[13] = initialM42;
  71925. m[14] = initialM43;
  71926. m[15] = initialM44;
  71927. result._markAsUpdated();
  71928. return result;
  71929. };
  71930. /**
  71931. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71932. * @param scale defines the scale vector3
  71933. * @param rotation defines the rotation quaternion
  71934. * @param translation defines the translation vector3
  71935. * @returns a new matrix
  71936. */
  71937. Matrix.Compose = function (scale, rotation, translation) {
  71938. var result = new Matrix();
  71939. Matrix.ComposeToRef(scale, rotation, translation, result);
  71940. return result;
  71941. };
  71942. /**
  71943. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71944. * @param scale defines the scale vector3
  71945. * @param rotation defines the rotation quaternion
  71946. * @param translation defines the translation vector3
  71947. * @param result defines the target matrix
  71948. */
  71949. Matrix.ComposeToRef = function (scale, rotation, translation, result) {
  71950. Matrix.ScalingToRef(scale.x, scale.y, scale.z, MathTmp.Matrix[1]);
  71951. rotation.toRotationMatrix(MathTmp.Matrix[0]);
  71952. MathTmp.Matrix[1].multiplyToRef(MathTmp.Matrix[0], result);
  71953. result.setTranslation(translation);
  71954. };
  71955. /**
  71956. * Creates a new identity matrix
  71957. * @returns a new identity matrix
  71958. */
  71959. Matrix.Identity = function () {
  71960. 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);
  71961. identity._updateIdentityStatus(true);
  71962. return identity;
  71963. };
  71964. /**
  71965. * Creates a new identity matrix and stores the result in a given matrix
  71966. * @param result defines the target matrix
  71967. */
  71968. Matrix.IdentityToRef = function (result) {
  71969. 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);
  71970. result._updateIdentityStatus(true);
  71971. };
  71972. /**
  71973. * Creates a new zero matrix
  71974. * @returns a new zero matrix
  71975. */
  71976. Matrix.Zero = function () {
  71977. 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);
  71978. zero._updateIdentityStatus(false);
  71979. return zero;
  71980. };
  71981. /**
  71982. * Creates a new rotation matrix for "angle" radians around the X axis
  71983. * @param angle defines the angle (in radians) to use
  71984. * @return the new matrix
  71985. */
  71986. Matrix.RotationX = function (angle) {
  71987. var result = new Matrix();
  71988. Matrix.RotationXToRef(angle, result);
  71989. return result;
  71990. };
  71991. /**
  71992. * Creates a new matrix as the invert of a given matrix
  71993. * @param source defines the source matrix
  71994. * @returns the new matrix
  71995. */
  71996. Matrix.Invert = function (source) {
  71997. var result = new Matrix();
  71998. source.invertToRef(result);
  71999. return result;
  72000. };
  72001. /**
  72002. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  72003. * @param angle defines the angle (in radians) to use
  72004. * @param result defines the target matrix
  72005. */
  72006. Matrix.RotationXToRef = function (angle, result) {
  72007. var s = Math.sin(angle);
  72008. var c = Math.cos(angle);
  72009. 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);
  72010. result._updateIdentityStatus(c === 1 && s === 0);
  72011. };
  72012. /**
  72013. * Creates a new rotation matrix for "angle" radians around the Y axis
  72014. * @param angle defines the angle (in radians) to use
  72015. * @return the new matrix
  72016. */
  72017. Matrix.RotationY = function (angle) {
  72018. var result = new Matrix();
  72019. Matrix.RotationYToRef(angle, result);
  72020. return result;
  72021. };
  72022. /**
  72023. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  72024. * @param angle defines the angle (in radians) to use
  72025. * @param result defines the target matrix
  72026. */
  72027. Matrix.RotationYToRef = function (angle, result) {
  72028. var s = Math.sin(angle);
  72029. var c = Math.cos(angle);
  72030. 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);
  72031. result._updateIdentityStatus(c === 1 && s === 0);
  72032. };
  72033. /**
  72034. * Creates a new rotation matrix for "angle" radians around the Z axis
  72035. * @param angle defines the angle (in radians) to use
  72036. * @return the new matrix
  72037. */
  72038. Matrix.RotationZ = function (angle) {
  72039. var result = new Matrix();
  72040. Matrix.RotationZToRef(angle, result);
  72041. return result;
  72042. };
  72043. /**
  72044. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  72045. * @param angle defines the angle (in radians) to use
  72046. * @param result defines the target matrix
  72047. */
  72048. Matrix.RotationZToRef = function (angle, result) {
  72049. var s = Math.sin(angle);
  72050. var c = Math.cos(angle);
  72051. 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);
  72052. result._updateIdentityStatus(c === 1 && s === 0);
  72053. };
  72054. /**
  72055. * Creates a new rotation matrix for "angle" radians around the given axis
  72056. * @param axis defines the axis to use
  72057. * @param angle defines the angle (in radians) to use
  72058. * @return the new matrix
  72059. */
  72060. Matrix.RotationAxis = function (axis, angle) {
  72061. var result = new Matrix();
  72062. Matrix.RotationAxisToRef(axis, angle, result);
  72063. return result;
  72064. };
  72065. /**
  72066. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  72067. * @param axis defines the axis to use
  72068. * @param angle defines the angle (in radians) to use
  72069. * @param result defines the target matrix
  72070. */
  72071. Matrix.RotationAxisToRef = function (axis, angle, result) {
  72072. var s = Math.sin(-angle);
  72073. var c = Math.cos(-angle);
  72074. var c1 = 1 - c;
  72075. axis.normalize();
  72076. var m = result._m;
  72077. m[0] = (axis.x * axis.x) * c1 + c;
  72078. m[1] = (axis.x * axis.y) * c1 - (axis.z * s);
  72079. m[2] = (axis.x * axis.z) * c1 + (axis.y * s);
  72080. m[3] = 0.0;
  72081. m[4] = (axis.y * axis.x) * c1 + (axis.z * s);
  72082. m[5] = (axis.y * axis.y) * c1 + c;
  72083. m[6] = (axis.y * axis.z) * c1 - (axis.x * s);
  72084. m[7] = 0.0;
  72085. m[8] = (axis.z * axis.x) * c1 - (axis.y * s);
  72086. m[9] = (axis.z * axis.y) * c1 + (axis.x * s);
  72087. m[10] = (axis.z * axis.z) * c1 + c;
  72088. m[11] = 0.0;
  72089. m[12] = 0.0;
  72090. m[13] = 0.0;
  72091. m[14] = 0.0;
  72092. m[15] = 1.0;
  72093. result._markAsUpdated();
  72094. };
  72095. /**
  72096. * Creates a rotation matrix
  72097. * @param yaw defines the yaw angle in radians (Y axis)
  72098. * @param pitch defines the pitch angle in radians (X axis)
  72099. * @param roll defines the roll angle in radians (X axis)
  72100. * @returns the new rotation matrix
  72101. */
  72102. Matrix.RotationYawPitchRoll = function (yaw, pitch, roll) {
  72103. var result = new Matrix();
  72104. Matrix.RotationYawPitchRollToRef(yaw, pitch, roll, result);
  72105. return result;
  72106. };
  72107. /**
  72108. * Creates a rotation matrix and stores it in a given matrix
  72109. * @param yaw defines the yaw angle in radians (Y axis)
  72110. * @param pitch defines the pitch angle in radians (X axis)
  72111. * @param roll defines the roll angle in radians (X axis)
  72112. * @param result defines the target matrix
  72113. */
  72114. Matrix.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  72115. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, MathTmp.Quaternion[0]);
  72116. MathTmp.Quaternion[0].toRotationMatrix(result);
  72117. };
  72118. /**
  72119. * Creates a scaling matrix
  72120. * @param x defines the scale factor on X axis
  72121. * @param y defines the scale factor on Y axis
  72122. * @param z defines the scale factor on Z axis
  72123. * @returns the new matrix
  72124. */
  72125. Matrix.Scaling = function (x, y, z) {
  72126. var result = new Matrix();
  72127. Matrix.ScalingToRef(x, y, z, result);
  72128. return result;
  72129. };
  72130. /**
  72131. * Creates a scaling matrix and stores it in a given matrix
  72132. * @param x defines the scale factor on X axis
  72133. * @param y defines the scale factor on Y axis
  72134. * @param z defines the scale factor on Z axis
  72135. * @param result defines the target matrix
  72136. */
  72137. Matrix.ScalingToRef = function (x, y, z, result) {
  72138. 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);
  72139. result._updateIdentityStatus(x === 1 && y === 1 && z === 1);
  72140. };
  72141. /**
  72142. * Creates a translation matrix
  72143. * @param x defines the translation on X axis
  72144. * @param y defines the translation on Y axis
  72145. * @param z defines the translationon Z axis
  72146. * @returns the new matrix
  72147. */
  72148. Matrix.Translation = function (x, y, z) {
  72149. var result = new Matrix();
  72150. Matrix.TranslationToRef(x, y, z, result);
  72151. return result;
  72152. };
  72153. /**
  72154. * Creates a translation matrix and stores it in a given matrix
  72155. * @param x defines the translation on X axis
  72156. * @param y defines the translation on Y axis
  72157. * @param z defines the translationon Z axis
  72158. * @param result defines the target matrix
  72159. */
  72160. Matrix.TranslationToRef = function (x, y, z, result) {
  72161. 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);
  72162. result._updateIdentityStatus(x === 0 && y === 0 && z === 0);
  72163. };
  72164. /**
  72165. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72166. * @param startValue defines the start value
  72167. * @param endValue defines the end value
  72168. * @param gradient defines the gradient factor
  72169. * @returns the new matrix
  72170. */
  72171. Matrix.Lerp = function (startValue, endValue, gradient) {
  72172. var result = new Matrix();
  72173. Matrix.LerpToRef(startValue, endValue, gradient, result);
  72174. return result;
  72175. };
  72176. /**
  72177. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72178. * @param startValue defines the start value
  72179. * @param endValue defines the end value
  72180. * @param gradient defines the gradient factor
  72181. * @param result defines the Matrix object where to store data
  72182. */
  72183. Matrix.LerpToRef = function (startValue, endValue, gradient, result) {
  72184. var resultM = result._m;
  72185. var startM = startValue.m;
  72186. var endM = endValue.m;
  72187. for (var index = 0; index < 16; index++) {
  72188. resultM[index] = startM[index] * (1.0 - gradient) + endM[index] * gradient;
  72189. }
  72190. result._markAsUpdated();
  72191. };
  72192. /**
  72193. * Builds a new matrix whose values are computed by:
  72194. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72195. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72196. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72197. * @param startValue defines the first matrix
  72198. * @param endValue defines the second matrix
  72199. * @param gradient defines the gradient between the two matrices
  72200. * @returns the new matrix
  72201. */
  72202. Matrix.DecomposeLerp = function (startValue, endValue, gradient) {
  72203. var result = new Matrix();
  72204. Matrix.DecomposeLerpToRef(startValue, endValue, gradient, result);
  72205. return result;
  72206. };
  72207. /**
  72208. * Update a matrix to values which are computed by:
  72209. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72210. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72211. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72212. * @param startValue defines the first matrix
  72213. * @param endValue defines the second matrix
  72214. * @param gradient defines the gradient between the two matrices
  72215. * @param result defines the target matrix
  72216. */
  72217. Matrix.DecomposeLerpToRef = function (startValue, endValue, gradient, result) {
  72218. var startScale = MathTmp.Vector3[0];
  72219. var startRotation = MathTmp.Quaternion[0];
  72220. var startTranslation = MathTmp.Vector3[1];
  72221. startValue.decompose(startScale, startRotation, startTranslation);
  72222. var endScale = MathTmp.Vector3[2];
  72223. var endRotation = MathTmp.Quaternion[1];
  72224. var endTranslation = MathTmp.Vector3[3];
  72225. endValue.decompose(endScale, endRotation, endTranslation);
  72226. var resultScale = MathTmp.Vector3[4];
  72227. Vector3.LerpToRef(startScale, endScale, gradient, resultScale);
  72228. var resultRotation = MathTmp.Quaternion[2];
  72229. Quaternion.SlerpToRef(startRotation, endRotation, gradient, resultRotation);
  72230. var resultTranslation = MathTmp.Vector3[5];
  72231. Vector3.LerpToRef(startTranslation, endTranslation, gradient, resultTranslation);
  72232. Matrix.ComposeToRef(resultScale, resultRotation, resultTranslation, result);
  72233. };
  72234. /**
  72235. * 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"
  72236. * This function works in left handed mode
  72237. * @param eye defines the final position of the entity
  72238. * @param target defines where the entity should look at
  72239. * @param up defines the up vector for the entity
  72240. * @returns the new matrix
  72241. */
  72242. Matrix.LookAtLH = function (eye, target, up) {
  72243. var result = new Matrix();
  72244. Matrix.LookAtLHToRef(eye, target, up, result);
  72245. return result;
  72246. };
  72247. /**
  72248. * 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".
  72249. * This function works in left handed mode
  72250. * @param eye defines the final position of the entity
  72251. * @param target defines where the entity should look at
  72252. * @param up defines the up vector for the entity
  72253. * @param result defines the target matrix
  72254. */
  72255. Matrix.LookAtLHToRef = function (eye, target, up, result) {
  72256. var xAxis = MathTmp.Vector3[0];
  72257. var yAxis = MathTmp.Vector3[1];
  72258. var zAxis = MathTmp.Vector3[2];
  72259. // Z axis
  72260. target.subtractToRef(eye, zAxis);
  72261. zAxis.normalize();
  72262. // X axis
  72263. Vector3.CrossToRef(up, zAxis, xAxis);
  72264. var xSquareLength = xAxis.lengthSquared();
  72265. if (xSquareLength === 0) {
  72266. xAxis.x = 1.0;
  72267. }
  72268. else {
  72269. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  72270. }
  72271. // Y axis
  72272. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  72273. yAxis.normalize();
  72274. // Eye angles
  72275. var ex = -Vector3.Dot(xAxis, eye);
  72276. var ey = -Vector3.Dot(yAxis, eye);
  72277. var ez = -Vector3.Dot(zAxis, eye);
  72278. 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);
  72279. };
  72280. /**
  72281. * 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"
  72282. * This function works in right handed mode
  72283. * @param eye defines the final position of the entity
  72284. * @param target defines where the entity should look at
  72285. * @param up defines the up vector for the entity
  72286. * @returns the new matrix
  72287. */
  72288. Matrix.LookAtRH = function (eye, target, up) {
  72289. var result = new Matrix();
  72290. Matrix.LookAtRHToRef(eye, target, up, result);
  72291. return result;
  72292. };
  72293. /**
  72294. * 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".
  72295. * This function works in right handed mode
  72296. * @param eye defines the final position of the entity
  72297. * @param target defines where the entity should look at
  72298. * @param up defines the up vector for the entity
  72299. * @param result defines the target matrix
  72300. */
  72301. Matrix.LookAtRHToRef = function (eye, target, up, result) {
  72302. var xAxis = MathTmp.Vector3[0];
  72303. var yAxis = MathTmp.Vector3[1];
  72304. var zAxis = MathTmp.Vector3[2];
  72305. // Z axis
  72306. eye.subtractToRef(target, zAxis);
  72307. zAxis.normalize();
  72308. // X axis
  72309. Vector3.CrossToRef(up, zAxis, xAxis);
  72310. var xSquareLength = xAxis.lengthSquared();
  72311. if (xSquareLength === 0) {
  72312. xAxis.x = 1.0;
  72313. }
  72314. else {
  72315. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  72316. }
  72317. // Y axis
  72318. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  72319. yAxis.normalize();
  72320. // Eye angles
  72321. var ex = -Vector3.Dot(xAxis, eye);
  72322. var ey = -Vector3.Dot(yAxis, eye);
  72323. var ez = -Vector3.Dot(zAxis, eye);
  72324. 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);
  72325. };
  72326. /**
  72327. * Create a left-handed orthographic projection matrix
  72328. * @param width defines the viewport width
  72329. * @param height defines the viewport height
  72330. * @param znear defines the near clip plane
  72331. * @param zfar defines the far clip plane
  72332. * @returns a new matrix as a left-handed orthographic projection matrix
  72333. */
  72334. Matrix.OrthoLH = function (width, height, znear, zfar) {
  72335. var matrix = new Matrix();
  72336. Matrix.OrthoLHToRef(width, height, znear, zfar, matrix);
  72337. return matrix;
  72338. };
  72339. /**
  72340. * Store a left-handed orthographic projection to a given matrix
  72341. * @param width defines the viewport width
  72342. * @param height defines the viewport height
  72343. * @param znear defines the near clip plane
  72344. * @param zfar defines the far clip plane
  72345. * @param result defines the target matrix
  72346. */
  72347. Matrix.OrthoLHToRef = function (width, height, znear, zfar, result) {
  72348. var n = znear;
  72349. var f = zfar;
  72350. var a = 2.0 / width;
  72351. var b = 2.0 / height;
  72352. var c = 2.0 / (f - n);
  72353. var d = -(f + n) / (f - n);
  72354. 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);
  72355. result._updateIdentityStatus(a === 1 && b === 1 && c === 1 && d === 0);
  72356. };
  72357. /**
  72358. * Create a left-handed orthographic projection matrix
  72359. * @param left defines the viewport left coordinate
  72360. * @param right defines the viewport right coordinate
  72361. * @param bottom defines the viewport bottom coordinate
  72362. * @param top defines the viewport top coordinate
  72363. * @param znear defines the near clip plane
  72364. * @param zfar defines the far clip plane
  72365. * @returns a new matrix as a left-handed orthographic projection matrix
  72366. */
  72367. Matrix.OrthoOffCenterLH = function (left, right, bottom, top, znear, zfar) {
  72368. var matrix = new Matrix();
  72369. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, matrix);
  72370. return matrix;
  72371. };
  72372. /**
  72373. * Stores a left-handed orthographic projection into a given matrix
  72374. * @param left defines the viewport left coordinate
  72375. * @param right defines the viewport right coordinate
  72376. * @param bottom defines the viewport bottom coordinate
  72377. * @param top defines the viewport top coordinate
  72378. * @param znear defines the near clip plane
  72379. * @param zfar defines the far clip plane
  72380. * @param result defines the target matrix
  72381. */
  72382. Matrix.OrthoOffCenterLHToRef = function (left, right, bottom, top, znear, zfar, result) {
  72383. var n = znear;
  72384. var f = zfar;
  72385. var a = 2.0 / (right - left);
  72386. var b = 2.0 / (top - bottom);
  72387. var c = 2.0 / (f - n);
  72388. var d = -(f + n) / (f - n);
  72389. var i0 = (left + right) / (left - right);
  72390. var i1 = (top + bottom) / (bottom - top);
  72391. 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);
  72392. result._markAsUpdated();
  72393. };
  72394. /**
  72395. * Creates a right-handed orthographic projection matrix
  72396. * @param left defines the viewport left coordinate
  72397. * @param right defines the viewport right coordinate
  72398. * @param bottom defines the viewport bottom coordinate
  72399. * @param top defines the viewport top coordinate
  72400. * @param znear defines the near clip plane
  72401. * @param zfar defines the far clip plane
  72402. * @returns a new matrix as a right-handed orthographic projection matrix
  72403. */
  72404. Matrix.OrthoOffCenterRH = function (left, right, bottom, top, znear, zfar) {
  72405. var matrix = new Matrix();
  72406. Matrix.OrthoOffCenterRHToRef(left, right, bottom, top, znear, zfar, matrix);
  72407. return matrix;
  72408. };
  72409. /**
  72410. * Stores a right-handed orthographic projection into a given matrix
  72411. * @param left defines the viewport left coordinate
  72412. * @param right defines the viewport right coordinate
  72413. * @param bottom defines the viewport bottom coordinate
  72414. * @param top defines the viewport top coordinate
  72415. * @param znear defines the near clip plane
  72416. * @param zfar defines the far clip plane
  72417. * @param result defines the target matrix
  72418. */
  72419. Matrix.OrthoOffCenterRHToRef = function (left, right, bottom, top, znear, zfar, result) {
  72420. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, result);
  72421. result._m[10] *= -1; // No need to call _markAsUpdated as previous function already called it and let _isIdentityDirty to true
  72422. };
  72423. /**
  72424. * Creates a left-handed perspective projection matrix
  72425. * @param width defines the viewport width
  72426. * @param height defines the viewport height
  72427. * @param znear defines the near clip plane
  72428. * @param zfar defines the far clip plane
  72429. * @returns a new matrix as a left-handed perspective projection matrix
  72430. */
  72431. Matrix.PerspectiveLH = function (width, height, znear, zfar) {
  72432. var matrix = new Matrix();
  72433. var n = znear;
  72434. var f = zfar;
  72435. var a = 2.0 * n / width;
  72436. var b = 2.0 * n / height;
  72437. var c = (f + n) / (f - n);
  72438. var d = -2.0 * f * n / (f - n);
  72439. 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);
  72440. matrix._updateIdentityStatus(false);
  72441. return matrix;
  72442. };
  72443. /**
  72444. * Creates a left-handed perspective projection matrix
  72445. * @param fov defines the horizontal field of view
  72446. * @param aspect defines the aspect ratio
  72447. * @param znear defines the near clip plane
  72448. * @param zfar defines the far clip plane
  72449. * @returns a new matrix as a left-handed perspective projection matrix
  72450. */
  72451. Matrix.PerspectiveFovLH = function (fov, aspect, znear, zfar) {
  72452. var matrix = new Matrix();
  72453. Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
  72454. return matrix;
  72455. };
  72456. /**
  72457. * Stores a left-handed perspective projection into a given matrix
  72458. * @param fov defines the horizontal field of view
  72459. * @param aspect defines the aspect ratio
  72460. * @param znear defines the near clip plane
  72461. * @param zfar defines the far clip plane
  72462. * @param result defines the target matrix
  72463. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72464. */
  72465. Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  72466. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  72467. var n = znear;
  72468. var f = zfar;
  72469. var t = 1.0 / (Math.tan(fov * 0.5));
  72470. var a = isVerticalFovFixed ? (t / aspect) : t;
  72471. var b = isVerticalFovFixed ? t : (t * aspect);
  72472. var c = (f + n) / (f - n);
  72473. var d = -2.0 * f * n / (f - n);
  72474. 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);
  72475. result._updateIdentityStatus(false);
  72476. };
  72477. /**
  72478. * Creates a right-handed perspective projection matrix
  72479. * @param fov defines the horizontal field of view
  72480. * @param aspect defines the aspect ratio
  72481. * @param znear defines the near clip plane
  72482. * @param zfar defines the far clip plane
  72483. * @returns a new matrix as a right-handed perspective projection matrix
  72484. */
  72485. Matrix.PerspectiveFovRH = function (fov, aspect, znear, zfar) {
  72486. var matrix = new Matrix();
  72487. Matrix.PerspectiveFovRHToRef(fov, aspect, znear, zfar, matrix);
  72488. return matrix;
  72489. };
  72490. /**
  72491. * Stores a right-handed perspective projection into a given matrix
  72492. * @param fov defines the horizontal field of view
  72493. * @param aspect defines the aspect ratio
  72494. * @param znear defines the near clip plane
  72495. * @param zfar defines the far clip plane
  72496. * @param result defines the target matrix
  72497. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72498. */
  72499. Matrix.PerspectiveFovRHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  72500. //alternatively this could be expressed as:
  72501. // m = PerspectiveFovLHToRef
  72502. // m[10] *= -1.0;
  72503. // m[11] *= -1.0;
  72504. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  72505. var n = znear;
  72506. var f = zfar;
  72507. var t = 1.0 / (Math.tan(fov * 0.5));
  72508. var a = isVerticalFovFixed ? (t / aspect) : t;
  72509. var b = isVerticalFovFixed ? t : (t * aspect);
  72510. var c = -(f + n) / (f - n);
  72511. var d = -2 * f * n / (f - n);
  72512. 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);
  72513. result._updateIdentityStatus(false);
  72514. };
  72515. /**
  72516. * Stores a perspective projection for WebVR info a given matrix
  72517. * @param fov defines the field of view
  72518. * @param znear defines the near clip plane
  72519. * @param zfar defines the far clip plane
  72520. * @param result defines the target matrix
  72521. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  72522. */
  72523. Matrix.PerspectiveFovWebVRToRef = function (fov, znear, zfar, result, rightHanded) {
  72524. if (rightHanded === void 0) { rightHanded = false; }
  72525. var rightHandedFactor = rightHanded ? -1 : 1;
  72526. var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
  72527. var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);
  72528. var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);
  72529. var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
  72530. var xScale = 2.0 / (leftTan + rightTan);
  72531. var yScale = 2.0 / (upTan + downTan);
  72532. var m = result._m;
  72533. m[0] = xScale;
  72534. m[1] = m[2] = m[3] = m[4] = 0.0;
  72535. m[5] = yScale;
  72536. m[6] = m[7] = 0.0;
  72537. m[8] = ((leftTan - rightTan) * xScale * 0.5);
  72538. m[9] = -((upTan - downTan) * yScale * 0.5);
  72539. m[10] = -zfar / (znear - zfar);
  72540. m[11] = 1.0 * rightHandedFactor;
  72541. m[12] = m[13] = m[15] = 0.0;
  72542. m[14] = -(2.0 * zfar * znear) / (zfar - znear);
  72543. result._markAsUpdated();
  72544. };
  72545. /**
  72546. * Computes a complete transformation matrix
  72547. * @param viewport defines the viewport to use
  72548. * @param world defines the world matrix
  72549. * @param view defines the view matrix
  72550. * @param projection defines the projection matrix
  72551. * @param zmin defines the near clip plane
  72552. * @param zmax defines the far clip plane
  72553. * @returns the transformation matrix
  72554. */
  72555. Matrix.GetFinalMatrix = function (viewport, world, view, projection, zmin, zmax) {
  72556. var cw = viewport.width;
  72557. var ch = viewport.height;
  72558. var cx = viewport.x;
  72559. var cy = viewport.y;
  72560. 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);
  72561. var matrix = MathTmp.Matrix[0];
  72562. world.multiplyToRef(view, matrix);
  72563. matrix.multiplyToRef(projection, matrix);
  72564. return matrix.multiply(viewportMatrix);
  72565. };
  72566. /**
  72567. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  72568. * @param matrix defines the matrix to use
  72569. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  72570. */
  72571. Matrix.GetAsMatrix2x2 = function (matrix) {
  72572. var m = matrix.m;
  72573. return new Float32Array([m[0], m[1], m[4], m[5]]);
  72574. };
  72575. /**
  72576. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  72577. * @param matrix defines the matrix to use
  72578. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  72579. */
  72580. Matrix.GetAsMatrix3x3 = function (matrix) {
  72581. var m = matrix.m;
  72582. return new Float32Array([
  72583. m[0], m[1], m[2],
  72584. m[4], m[5], m[6],
  72585. m[8], m[9], m[10]
  72586. ]);
  72587. };
  72588. /**
  72589. * Compute the transpose of a given matrix
  72590. * @param matrix defines the matrix to transpose
  72591. * @returns the new matrix
  72592. */
  72593. Matrix.Transpose = function (matrix) {
  72594. var result = new Matrix();
  72595. Matrix.TransposeToRef(matrix, result);
  72596. return result;
  72597. };
  72598. /**
  72599. * Compute the transpose of a matrix and store it in a target matrix
  72600. * @param matrix defines the matrix to transpose
  72601. * @param result defines the target matrix
  72602. */
  72603. Matrix.TransposeToRef = function (matrix, result) {
  72604. var rm = result._m;
  72605. var mm = matrix.m;
  72606. rm[0] = mm[0];
  72607. rm[1] = mm[4];
  72608. rm[2] = mm[8];
  72609. rm[3] = mm[12];
  72610. rm[4] = mm[1];
  72611. rm[5] = mm[5];
  72612. rm[6] = mm[9];
  72613. rm[7] = mm[13];
  72614. rm[8] = mm[2];
  72615. rm[9] = mm[6];
  72616. rm[10] = mm[10];
  72617. rm[11] = mm[14];
  72618. rm[12] = mm[3];
  72619. rm[13] = mm[7];
  72620. rm[14] = mm[11];
  72621. rm[15] = mm[15];
  72622. // identity-ness does not change when transposing
  72623. result._updateIdentityStatus(matrix._isIdentity, matrix._isIdentityDirty);
  72624. };
  72625. /**
  72626. * Computes a reflection matrix from a plane
  72627. * @param plane defines the reflection plane
  72628. * @returns a new matrix
  72629. */
  72630. Matrix.Reflection = function (plane) {
  72631. var matrix = new Matrix();
  72632. Matrix.ReflectionToRef(plane, matrix);
  72633. return matrix;
  72634. };
  72635. /**
  72636. * Computes a reflection matrix from a plane
  72637. * @param plane defines the reflection plane
  72638. * @param result defines the target matrix
  72639. */
  72640. Matrix.ReflectionToRef = function (plane, result) {
  72641. plane.normalize();
  72642. var x = plane.normal.x;
  72643. var y = plane.normal.y;
  72644. var z = plane.normal.z;
  72645. var temp = -2 * x;
  72646. var temp2 = -2 * y;
  72647. var temp3 = -2 * z;
  72648. 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);
  72649. };
  72650. /**
  72651. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  72652. * @param xaxis defines the value of the 1st axis
  72653. * @param yaxis defines the value of the 2nd axis
  72654. * @param zaxis defines the value of the 3rd axis
  72655. * @param result defines the target matrix
  72656. */
  72657. Matrix.FromXYZAxesToRef = function (xaxis, yaxis, zaxis, result) {
  72658. 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);
  72659. };
  72660. /**
  72661. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  72662. * @param quat defines the quaternion to use
  72663. * @param result defines the target matrix
  72664. */
  72665. Matrix.FromQuaternionToRef = function (quat, result) {
  72666. var xx = quat.x * quat.x;
  72667. var yy = quat.y * quat.y;
  72668. var zz = quat.z * quat.z;
  72669. var xy = quat.x * quat.y;
  72670. var zw = quat.z * quat.w;
  72671. var zx = quat.z * quat.x;
  72672. var yw = quat.y * quat.w;
  72673. var yz = quat.y * quat.z;
  72674. var xw = quat.x * quat.w;
  72675. result._m[0] = 1.0 - (2.0 * (yy + zz));
  72676. result._m[1] = 2.0 * (xy + zw);
  72677. result._m[2] = 2.0 * (zx - yw);
  72678. result._m[3] = 0.0;
  72679. result._m[4] = 2.0 * (xy - zw);
  72680. result._m[5] = 1.0 - (2.0 * (zz + xx));
  72681. result._m[6] = 2.0 * (yz + xw);
  72682. result._m[7] = 0.0;
  72683. result._m[8] = 2.0 * (zx + yw);
  72684. result._m[9] = 2.0 * (yz - xw);
  72685. result._m[10] = 1.0 - (2.0 * (yy + xx));
  72686. result._m[11] = 0.0;
  72687. result._m[12] = 0.0;
  72688. result._m[13] = 0.0;
  72689. result._m[14] = 0.0;
  72690. result._m[15] = 1.0;
  72691. result._markAsUpdated();
  72692. };
  72693. Matrix._updateFlagSeed = 0;
  72694. Matrix._identityReadOnly = Matrix.Identity();
  72695. return Matrix;
  72696. }());
  72697. /**
  72698. * Represens a plane by the equation ax + by + cz + d = 0
  72699. */
  72700. var Plane = /** @class */ (function () {
  72701. /**
  72702. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  72703. * @param a a component of the plane
  72704. * @param b b component of the plane
  72705. * @param c c component of the plane
  72706. * @param d d component of the plane
  72707. */
  72708. function Plane(a, b, c, d) {
  72709. this.normal = new Vector3(a, b, c);
  72710. this.d = d;
  72711. }
  72712. /**
  72713. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  72714. */
  72715. Plane.prototype.asArray = function () {
  72716. return [this.normal.x, this.normal.y, this.normal.z, this.d];
  72717. };
  72718. // Methods
  72719. /**
  72720. * @returns a new plane copied from the current Plane.
  72721. */
  72722. Plane.prototype.clone = function () {
  72723. return new Plane(this.normal.x, this.normal.y, this.normal.z, this.d);
  72724. };
  72725. /**
  72726. * @returns the string "Plane".
  72727. */
  72728. Plane.prototype.getClassName = function () {
  72729. return "Plane";
  72730. };
  72731. /**
  72732. * @returns the Plane hash code.
  72733. */
  72734. Plane.prototype.getHashCode = function () {
  72735. var hash = this.normal.getHashCode();
  72736. hash = (hash * 397) ^ (this.d || 0);
  72737. return hash;
  72738. };
  72739. /**
  72740. * Normalize the current Plane in place.
  72741. * @returns the updated Plane.
  72742. */
  72743. Plane.prototype.normalize = function () {
  72744. var norm = (Math.sqrt((this.normal.x * this.normal.x) + (this.normal.y * this.normal.y) + (this.normal.z * this.normal.z)));
  72745. var magnitude = 0.0;
  72746. if (norm !== 0) {
  72747. magnitude = 1.0 / norm;
  72748. }
  72749. this.normal.x *= magnitude;
  72750. this.normal.y *= magnitude;
  72751. this.normal.z *= magnitude;
  72752. this.d *= magnitude;
  72753. return this;
  72754. };
  72755. /**
  72756. * Applies a transformation the plane and returns the result
  72757. * @param transformation the transformation matrix to be applied to the plane
  72758. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  72759. */
  72760. Plane.prototype.transform = function (transformation) {
  72761. var transposedMatrix = MathTmp.Matrix[0];
  72762. Matrix.TransposeToRef(transformation, transposedMatrix);
  72763. var m = transposedMatrix.m;
  72764. var x = this.normal.x;
  72765. var y = this.normal.y;
  72766. var z = this.normal.z;
  72767. var d = this.d;
  72768. var normalX = x * m[0] + y * m[1] + z * m[2] + d * m[3];
  72769. var normalY = x * m[4] + y * m[5] + z * m[6] + d * m[7];
  72770. var normalZ = x * m[8] + y * m[9] + z * m[10] + d * m[11];
  72771. var finalD = x * m[12] + y * m[13] + z * m[14] + d * m[15];
  72772. return new Plane(normalX, normalY, normalZ, finalD);
  72773. };
  72774. /**
  72775. * Calcualtte the dot product between the point and the plane normal
  72776. * @param point point to calculate the dot product with
  72777. * @returns the dot product (float) of the point coordinates and the plane normal.
  72778. */
  72779. Plane.prototype.dotCoordinate = function (point) {
  72780. return ((((this.normal.x * point.x) + (this.normal.y * point.y)) + (this.normal.z * point.z)) + this.d);
  72781. };
  72782. /**
  72783. * Updates the current Plane from the plane defined by the three given points.
  72784. * @param point1 one of the points used to contruct the plane
  72785. * @param point2 one of the points used to contruct the plane
  72786. * @param point3 one of the points used to contruct the plane
  72787. * @returns the updated Plane.
  72788. */
  72789. Plane.prototype.copyFromPoints = function (point1, point2, point3) {
  72790. var x1 = point2.x - point1.x;
  72791. var y1 = point2.y - point1.y;
  72792. var z1 = point2.z - point1.z;
  72793. var x2 = point3.x - point1.x;
  72794. var y2 = point3.y - point1.y;
  72795. var z2 = point3.z - point1.z;
  72796. var yz = (y1 * z2) - (z1 * y2);
  72797. var xz = (z1 * x2) - (x1 * z2);
  72798. var xy = (x1 * y2) - (y1 * x2);
  72799. var pyth = (Math.sqrt((yz * yz) + (xz * xz) + (xy * xy)));
  72800. var invPyth;
  72801. if (pyth !== 0) {
  72802. invPyth = 1.0 / pyth;
  72803. }
  72804. else {
  72805. invPyth = 0.0;
  72806. }
  72807. this.normal.x = yz * invPyth;
  72808. this.normal.y = xz * invPyth;
  72809. this.normal.z = xy * invPyth;
  72810. this.d = -((this.normal.x * point1.x) + (this.normal.y * point1.y) + (this.normal.z * point1.z));
  72811. return this;
  72812. };
  72813. /**
  72814. * Checks if the plane is facing a given direction
  72815. * @param direction the direction to check if the plane is facing
  72816. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  72817. * @returns True is the vector "direction" is the same side than the plane normal.
  72818. */
  72819. Plane.prototype.isFrontFacingTo = function (direction, epsilon) {
  72820. var dot = Vector3.Dot(this.normal, direction);
  72821. return (dot <= epsilon);
  72822. };
  72823. /**
  72824. * Calculates the distance to a point
  72825. * @param point point to calculate distance to
  72826. * @returns the signed distance (float) from the given point to the Plane.
  72827. */
  72828. Plane.prototype.signedDistanceTo = function (point) {
  72829. return Vector3.Dot(point, this.normal) + this.d;
  72830. };
  72831. // Statics
  72832. /**
  72833. * Creates a plane from an array
  72834. * @param array the array to create a plane from
  72835. * @returns a new Plane from the given array.
  72836. */
  72837. Plane.FromArray = function (array) {
  72838. return new Plane(array[0], array[1], array[2], array[3]);
  72839. };
  72840. /**
  72841. * Creates a plane from three points
  72842. * @param point1 point used to create the plane
  72843. * @param point2 point used to create the plane
  72844. * @param point3 point used to create the plane
  72845. * @returns a new Plane defined by the three given points.
  72846. */
  72847. Plane.FromPoints = function (point1, point2, point3) {
  72848. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  72849. result.copyFromPoints(point1, point2, point3);
  72850. return result;
  72851. };
  72852. /**
  72853. * Creates a plane from an origin point and a normal
  72854. * @param origin origin of the plane to be constructed
  72855. * @param normal normal of the plane to be constructed
  72856. * @returns a new Plane the normal vector to this plane at the given origin point.
  72857. * Note : the vector "normal" is updated because normalized.
  72858. */
  72859. Plane.FromPositionAndNormal = function (origin, normal) {
  72860. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  72861. normal.normalize();
  72862. result.normal = normal;
  72863. result.d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  72864. return result;
  72865. };
  72866. /**
  72867. * Calculates the distance from a plane and a point
  72868. * @param origin origin of the plane to be constructed
  72869. * @param normal normal of the plane to be constructed
  72870. * @param point point to calculate distance to
  72871. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  72872. */
  72873. Plane.SignedDistanceToPlaneFromPositionAndNormal = function (origin, normal, point) {
  72874. var d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  72875. return Vector3.Dot(point, normal) + d;
  72876. };
  72877. return Plane;
  72878. }());
  72879. /**
  72880. * Class used to represent a viewport on screen
  72881. */
  72882. var Viewport = /** @class */ (function () {
  72883. /**
  72884. * Creates a Viewport object located at (x, y) and sized (width, height)
  72885. * @param x defines viewport left coordinate
  72886. * @param y defines viewport top coordinate
  72887. * @param width defines the viewport width
  72888. * @param height defines the viewport height
  72889. */
  72890. function Viewport(
  72891. /** viewport left coordinate */
  72892. x,
  72893. /** viewport top coordinate */
  72894. y,
  72895. /**viewport width */
  72896. width,
  72897. /** viewport height */
  72898. height) {
  72899. this.x = x;
  72900. this.y = y;
  72901. this.width = width;
  72902. this.height = height;
  72903. }
  72904. /**
  72905. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  72906. * @param renderWidth defines the rendering width
  72907. * @param renderHeight defines the rendering height
  72908. * @returns a new Viewport
  72909. */
  72910. Viewport.prototype.toGlobal = function (renderWidth, renderHeight) {
  72911. return new Viewport(this.x * renderWidth, this.y * renderHeight, this.width * renderWidth, this.height * renderHeight);
  72912. };
  72913. /**
  72914. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  72915. * @param renderWidth defines the rendering width
  72916. * @param renderHeight defines the rendering height
  72917. * @param ref defines the target viewport
  72918. * @returns the current viewport
  72919. */
  72920. Viewport.prototype.toGlobalToRef = function (renderWidth, renderHeight, ref) {
  72921. ref.x = this.x * renderWidth;
  72922. ref.y = this.y * renderHeight;
  72923. ref.width = this.width * renderWidth;
  72924. ref.height = this.height * renderHeight;
  72925. return this;
  72926. };
  72927. /**
  72928. * Returns a new Viewport copied from the current one
  72929. * @returns a new Viewport
  72930. */
  72931. Viewport.prototype.clone = function () {
  72932. return new Viewport(this.x, this.y, this.width, this.height);
  72933. };
  72934. return Viewport;
  72935. }());
  72936. /**
  72937. * Reprasents a camera frustum
  72938. */
  72939. var Frustum = /** @class */ (function () {
  72940. function Frustum() {
  72941. }
  72942. /**
  72943. * Gets the planes representing the frustum
  72944. * @param transform matrix to be applied to the returned planes
  72945. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  72946. */
  72947. Frustum.GetPlanes = function (transform) {
  72948. var frustumPlanes = [];
  72949. for (var index = 0; index < 6; index++) {
  72950. frustumPlanes.push(new Plane(0.0, 0.0, 0.0, 0.0));
  72951. }
  72952. Frustum.GetPlanesToRef(transform, frustumPlanes);
  72953. return frustumPlanes;
  72954. };
  72955. /**
  72956. * Gets the near frustum plane transformed by the transform matrix
  72957. * @param transform transformation matrix to be applied to the resulting frustum plane
  72958. * @param frustumPlane the resuling frustum plane
  72959. */
  72960. Frustum.GetNearPlaneToRef = function (transform, frustumPlane) {
  72961. var m = transform.m;
  72962. frustumPlane.normal.x = m[3] + m[2];
  72963. frustumPlane.normal.y = m[7] + m[6];
  72964. frustumPlane.normal.z = m[11] + m[10];
  72965. frustumPlane.d = m[15] + m[14];
  72966. frustumPlane.normalize();
  72967. };
  72968. /**
  72969. * Gets the far frustum plane transformed by the transform matrix
  72970. * @param transform transformation matrix to be applied to the resulting frustum plane
  72971. * @param frustumPlane the resuling frustum plane
  72972. */
  72973. Frustum.GetFarPlaneToRef = function (transform, frustumPlane) {
  72974. var m = transform.m;
  72975. frustumPlane.normal.x = m[3] - m[2];
  72976. frustumPlane.normal.y = m[7] - m[6];
  72977. frustumPlane.normal.z = m[11] - m[10];
  72978. frustumPlane.d = m[15] - m[14];
  72979. frustumPlane.normalize();
  72980. };
  72981. /**
  72982. * Gets the left frustum plane transformed by the transform matrix
  72983. * @param transform transformation matrix to be applied to the resulting frustum plane
  72984. * @param frustumPlane the resuling frustum plane
  72985. */
  72986. Frustum.GetLeftPlaneToRef = function (transform, frustumPlane) {
  72987. var m = transform.m;
  72988. frustumPlane.normal.x = m[3] + m[0];
  72989. frustumPlane.normal.y = m[7] + m[4];
  72990. frustumPlane.normal.z = m[11] + m[8];
  72991. frustumPlane.d = m[15] + m[12];
  72992. frustumPlane.normalize();
  72993. };
  72994. /**
  72995. * Gets the right frustum plane transformed by the transform matrix
  72996. * @param transform transformation matrix to be applied to the resulting frustum plane
  72997. * @param frustumPlane the resuling frustum plane
  72998. */
  72999. Frustum.GetRightPlaneToRef = function (transform, frustumPlane) {
  73000. var m = transform.m;
  73001. frustumPlane.normal.x = m[3] - m[0];
  73002. frustumPlane.normal.y = m[7] - m[4];
  73003. frustumPlane.normal.z = m[11] - m[8];
  73004. frustumPlane.d = m[15] - m[12];
  73005. frustumPlane.normalize();
  73006. };
  73007. /**
  73008. * Gets the top frustum plane transformed by the transform matrix
  73009. * @param transform transformation matrix to be applied to the resulting frustum plane
  73010. * @param frustumPlane the resuling frustum plane
  73011. */
  73012. Frustum.GetTopPlaneToRef = function (transform, frustumPlane) {
  73013. var m = transform.m;
  73014. frustumPlane.normal.x = m[3] - m[1];
  73015. frustumPlane.normal.y = m[7] - m[5];
  73016. frustumPlane.normal.z = m[11] - m[9];
  73017. frustumPlane.d = m[15] - m[13];
  73018. frustumPlane.normalize();
  73019. };
  73020. /**
  73021. * Gets the bottom frustum plane transformed by the transform matrix
  73022. * @param transform transformation matrix to be applied to the resulting frustum plane
  73023. * @param frustumPlane the resuling frustum plane
  73024. */
  73025. Frustum.GetBottomPlaneToRef = function (transform, frustumPlane) {
  73026. var m = transform.m;
  73027. frustumPlane.normal.x = m[3] + m[1];
  73028. frustumPlane.normal.y = m[7] + m[5];
  73029. frustumPlane.normal.z = m[11] + m[9];
  73030. frustumPlane.d = m[15] + m[13];
  73031. frustumPlane.normalize();
  73032. };
  73033. /**
  73034. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  73035. * @param transform transformation matrix to be applied to the resulting frustum planes
  73036. * @param frustumPlanes the resuling frustum planes
  73037. */
  73038. Frustum.GetPlanesToRef = function (transform, frustumPlanes) {
  73039. // Near
  73040. Frustum.GetNearPlaneToRef(transform, frustumPlanes[0]);
  73041. // Far
  73042. Frustum.GetFarPlaneToRef(transform, frustumPlanes[1]);
  73043. // Left
  73044. Frustum.GetLeftPlaneToRef(transform, frustumPlanes[2]);
  73045. // Right
  73046. Frustum.GetRightPlaneToRef(transform, frustumPlanes[3]);
  73047. // Top
  73048. Frustum.GetTopPlaneToRef(transform, frustumPlanes[4]);
  73049. // Bottom
  73050. Frustum.GetBottomPlaneToRef(transform, frustumPlanes[5]);
  73051. };
  73052. return Frustum;
  73053. }());
  73054. /** Defines supported spaces */
  73055. var Space;
  73056. (function (Space) {
  73057. /** Local (object) space */
  73058. Space[Space["LOCAL"] = 0] = "LOCAL";
  73059. /** World space */
  73060. Space[Space["WORLD"] = 1] = "WORLD";
  73061. /** Bone space */
  73062. Space[Space["BONE"] = 2] = "BONE";
  73063. })(Space || (Space = {}));
  73064. /** Defines the 3 main axes */
  73065. var Axis = /** @class */ (function () {
  73066. function Axis() {
  73067. }
  73068. /** X axis */
  73069. Axis.X = new Vector3(1.0, 0.0, 0.0);
  73070. /** Y axis */
  73071. Axis.Y = new Vector3(0.0, 1.0, 0.0);
  73072. /** Z axis */
  73073. Axis.Z = new Vector3(0.0, 0.0, 1.0);
  73074. return Axis;
  73075. }());
  73076. /** Class used to represent a Bezier curve */
  73077. var BezierCurve = /** @class */ (function () {
  73078. function BezierCurve() {
  73079. }
  73080. /**
  73081. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  73082. * @param t defines the time
  73083. * @param x1 defines the left coordinate on X axis
  73084. * @param y1 defines the left coordinate on Y axis
  73085. * @param x2 defines the right coordinate on X axis
  73086. * @param y2 defines the right coordinate on Y axis
  73087. * @returns the interpolated value
  73088. */
  73089. BezierCurve.Interpolate = function (t, x1, y1, x2, y2) {
  73090. // Extract X (which is equal to time here)
  73091. var f0 = 1 - 3 * x2 + 3 * x1;
  73092. var f1 = 3 * x2 - 6 * x1;
  73093. var f2 = 3 * x1;
  73094. var refinedT = t;
  73095. for (var i = 0; i < 5; i++) {
  73096. var refinedT2 = refinedT * refinedT;
  73097. var refinedT3 = refinedT2 * refinedT;
  73098. var x = f0 * refinedT3 + f1 * refinedT2 + f2 * refinedT;
  73099. var slope = 1.0 / (3.0 * f0 * refinedT2 + 2.0 * f1 * refinedT + f2);
  73100. refinedT -= (x - t) * slope;
  73101. refinedT = Math.min(1, Math.max(0, refinedT));
  73102. }
  73103. // Resolve cubic bezier for the given x
  73104. return 3 * Math.pow(1 - refinedT, 2) * refinedT * y1 +
  73105. 3 * (1 - refinedT) * Math.pow(refinedT, 2) * y2 +
  73106. Math.pow(refinedT, 3);
  73107. };
  73108. return BezierCurve;
  73109. }());
  73110. /**
  73111. * Defines potential orientation for back face culling
  73112. */
  73113. var Orientation;
  73114. (function (Orientation) {
  73115. /**
  73116. * Clockwise
  73117. */
  73118. Orientation[Orientation["CW"] = 0] = "CW";
  73119. /** Counter clockwise */
  73120. Orientation[Orientation["CCW"] = 1] = "CCW";
  73121. })(Orientation || (Orientation = {}));
  73122. /**
  73123. * Defines angle representation
  73124. */
  73125. var Angle = /** @class */ (function () {
  73126. /**
  73127. * Creates an Angle object of "radians" radians (float).
  73128. */
  73129. function Angle(radians) {
  73130. this._radians = radians;
  73131. if (this._radians < 0.0) {
  73132. this._radians += (2.0 * Math.PI);
  73133. }
  73134. }
  73135. /**
  73136. * Get value in degrees
  73137. * @returns the Angle value in degrees (float)
  73138. */
  73139. Angle.prototype.degrees = function () {
  73140. return this._radians * 180.0 / Math.PI;
  73141. };
  73142. /**
  73143. * Get value in radians
  73144. * @returns the Angle value in radians (float)
  73145. */
  73146. Angle.prototype.radians = function () {
  73147. return this._radians;
  73148. };
  73149. /**
  73150. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  73151. * @param a defines first vector
  73152. * @param b defines second vector
  73153. * @returns a new Angle
  73154. */
  73155. Angle.BetweenTwoPoints = function (a, b) {
  73156. var delta = b.subtract(a);
  73157. var theta = Math.atan2(delta.y, delta.x);
  73158. return new Angle(theta);
  73159. };
  73160. /**
  73161. * Gets a new Angle object from the given float in radians
  73162. * @param radians defines the angle value in radians
  73163. * @returns a new Angle
  73164. */
  73165. Angle.FromRadians = function (radians) {
  73166. return new Angle(radians);
  73167. };
  73168. /**
  73169. * Gets a new Angle object from the given float in degrees
  73170. * @param degrees defines the angle value in degrees
  73171. * @returns a new Angle
  73172. */
  73173. Angle.FromDegrees = function (degrees) {
  73174. return new Angle(degrees * Math.PI / 180.0);
  73175. };
  73176. return Angle;
  73177. }());
  73178. /**
  73179. * This represents an arc in a 2d space.
  73180. */
  73181. var Arc2 = /** @class */ (function () {
  73182. /**
  73183. * Creates an Arc object from the three given points : start, middle and end.
  73184. * @param startPoint Defines the start point of the arc
  73185. * @param midPoint Defines the midlle point of the arc
  73186. * @param endPoint Defines the end point of the arc
  73187. */
  73188. function Arc2(
  73189. /** Defines the start point of the arc */
  73190. startPoint,
  73191. /** Defines the mid point of the arc */
  73192. midPoint,
  73193. /** Defines the end point of the arc */
  73194. endPoint) {
  73195. this.startPoint = startPoint;
  73196. this.midPoint = midPoint;
  73197. this.endPoint = endPoint;
  73198. var temp = Math.pow(midPoint.x, 2) + Math.pow(midPoint.y, 2);
  73199. var startToMid = (Math.pow(startPoint.x, 2) + Math.pow(startPoint.y, 2) - temp) / 2.;
  73200. var midToEnd = (temp - Math.pow(endPoint.x, 2) - Math.pow(endPoint.y, 2)) / 2.;
  73201. var det = (startPoint.x - midPoint.x) * (midPoint.y - endPoint.y) - (midPoint.x - endPoint.x) * (startPoint.y - midPoint.y);
  73202. 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);
  73203. this.radius = this.centerPoint.subtract(this.startPoint).length();
  73204. this.startAngle = Angle.BetweenTwoPoints(this.centerPoint, this.startPoint);
  73205. var a1 = this.startAngle.degrees();
  73206. var a2 = Angle.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees();
  73207. var a3 = Angle.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
  73208. // angles correction
  73209. if (a2 - a1 > +180.0) {
  73210. a2 -= 360.0;
  73211. }
  73212. if (a2 - a1 < -180.0) {
  73213. a2 += 360.0;
  73214. }
  73215. if (a3 - a2 > +180.0) {
  73216. a3 -= 360.0;
  73217. }
  73218. if (a3 - a2 < -180.0) {
  73219. a3 += 360.0;
  73220. }
  73221. this.orientation = (a2 - a1) < 0 ? Orientation.CW : Orientation.CCW;
  73222. this.angle = Angle.FromDegrees(this.orientation === Orientation.CW ? a1 - a3 : a3 - a1);
  73223. }
  73224. return Arc2;
  73225. }());
  73226. /**
  73227. * Represents a 2D path made up of multiple 2D points
  73228. */
  73229. var Path2 = /** @class */ (function () {
  73230. /**
  73231. * Creates a Path2 object from the starting 2D coordinates x and y.
  73232. * @param x the starting points x value
  73233. * @param y the starting points y value
  73234. */
  73235. function Path2(x, y) {
  73236. this._points = new Array();
  73237. this._length = 0.0;
  73238. /**
  73239. * If the path start and end point are the same
  73240. */
  73241. this.closed = false;
  73242. this._points.push(new Vector2(x, y));
  73243. }
  73244. /**
  73245. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  73246. * @param x the added points x value
  73247. * @param y the added points y value
  73248. * @returns the updated Path2.
  73249. */
  73250. Path2.prototype.addLineTo = function (x, y) {
  73251. if (this.closed) {
  73252. return this;
  73253. }
  73254. var newPoint = new Vector2(x, y);
  73255. var previousPoint = this._points[this._points.length - 1];
  73256. this._points.push(newPoint);
  73257. this._length += newPoint.subtract(previousPoint).length();
  73258. return this;
  73259. };
  73260. /**
  73261. * 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.
  73262. * @param midX middle point x value
  73263. * @param midY middle point y value
  73264. * @param endX end point x value
  73265. * @param endY end point y value
  73266. * @param numberOfSegments (default: 36)
  73267. * @returns the updated Path2.
  73268. */
  73269. Path2.prototype.addArcTo = function (midX, midY, endX, endY, numberOfSegments) {
  73270. if (numberOfSegments === void 0) { numberOfSegments = 36; }
  73271. if (this.closed) {
  73272. return this;
  73273. }
  73274. var startPoint = this._points[this._points.length - 1];
  73275. var midPoint = new Vector2(midX, midY);
  73276. var endPoint = new Vector2(endX, endY);
  73277. var arc = new Arc2(startPoint, midPoint, endPoint);
  73278. var increment = arc.angle.radians() / numberOfSegments;
  73279. if (arc.orientation === Orientation.CW) {
  73280. increment *= -1;
  73281. }
  73282. var currentAngle = arc.startAngle.radians() + increment;
  73283. for (var i = 0; i < numberOfSegments; i++) {
  73284. var x = Math.cos(currentAngle) * arc.radius + arc.centerPoint.x;
  73285. var y = Math.sin(currentAngle) * arc.radius + arc.centerPoint.y;
  73286. this.addLineTo(x, y);
  73287. currentAngle += increment;
  73288. }
  73289. return this;
  73290. };
  73291. /**
  73292. * Closes the Path2.
  73293. * @returns the Path2.
  73294. */
  73295. Path2.prototype.close = function () {
  73296. this.closed = true;
  73297. return this;
  73298. };
  73299. /**
  73300. * Gets the sum of the distance between each sequential point in the path
  73301. * @returns the Path2 total length (float).
  73302. */
  73303. Path2.prototype.length = function () {
  73304. var result = this._length;
  73305. if (!this.closed) {
  73306. var lastPoint = this._points[this._points.length - 1];
  73307. var firstPoint = this._points[0];
  73308. result += (firstPoint.subtract(lastPoint).length());
  73309. }
  73310. return result;
  73311. };
  73312. /**
  73313. * Gets the points which construct the path
  73314. * @returns the Path2 internal array of points.
  73315. */
  73316. Path2.prototype.getPoints = function () {
  73317. return this._points;
  73318. };
  73319. /**
  73320. * Retreives the point at the distance aways from the starting point
  73321. * @param normalizedLengthPosition the length along the path to retreive the point from
  73322. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  73323. */
  73324. Path2.prototype.getPointAtLengthPosition = function (normalizedLengthPosition) {
  73325. if (normalizedLengthPosition < 0 || normalizedLengthPosition > 1) {
  73326. return Vector2.Zero();
  73327. }
  73328. var lengthPosition = normalizedLengthPosition * this.length();
  73329. var previousOffset = 0;
  73330. for (var i = 0; i < this._points.length; i++) {
  73331. var j = (i + 1) % this._points.length;
  73332. var a = this._points[i];
  73333. var b = this._points[j];
  73334. var bToA = b.subtract(a);
  73335. var nextOffset = (bToA.length() + previousOffset);
  73336. if (lengthPosition >= previousOffset && lengthPosition <= nextOffset) {
  73337. var dir = bToA.normalize();
  73338. var localOffset = lengthPosition - previousOffset;
  73339. return new Vector2(a.x + (dir.x * localOffset), a.y + (dir.y * localOffset));
  73340. }
  73341. previousOffset = nextOffset;
  73342. }
  73343. return Vector2.Zero();
  73344. };
  73345. /**
  73346. * Creates a new path starting from an x and y position
  73347. * @param x starting x value
  73348. * @param y starting y value
  73349. * @returns a new Path2 starting at the coordinates (x, y).
  73350. */
  73351. Path2.StartingAt = function (x, y) {
  73352. return new Path2(x, y);
  73353. };
  73354. return Path2;
  73355. }());
  73356. /**
  73357. * Represents a 3D path made up of multiple 3D points
  73358. */
  73359. var Path3D = /** @class */ (function () {
  73360. /**
  73361. * new Path3D(path, normal, raw)
  73362. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  73363. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  73364. * @param path an array of Vector3, the curve axis of the Path3D
  73365. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  73366. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  73367. */
  73368. function Path3D(
  73369. /**
  73370. * an array of Vector3, the curve axis of the Path3D
  73371. */
  73372. path, firstNormal, raw) {
  73373. if (firstNormal === void 0) { firstNormal = null; }
  73374. this.path = path;
  73375. this._curve = new Array();
  73376. this._distances = new Array();
  73377. this._tangents = new Array();
  73378. this._normals = new Array();
  73379. this._binormals = new Array();
  73380. for (var p = 0; p < path.length; p++) {
  73381. this._curve[p] = path[p].clone(); // hard copy
  73382. }
  73383. this._raw = raw || false;
  73384. this._compute(firstNormal);
  73385. }
  73386. /**
  73387. * Returns the Path3D array of successive Vector3 designing its curve.
  73388. * @returns the Path3D array of successive Vector3 designing its curve.
  73389. */
  73390. Path3D.prototype.getCurve = function () {
  73391. return this._curve;
  73392. };
  73393. /**
  73394. * Returns an array populated with tangent vectors on each Path3D curve point.
  73395. * @returns an array populated with tangent vectors on each Path3D curve point.
  73396. */
  73397. Path3D.prototype.getTangents = function () {
  73398. return this._tangents;
  73399. };
  73400. /**
  73401. * Returns an array populated with normal vectors on each Path3D curve point.
  73402. * @returns an array populated with normal vectors on each Path3D curve point.
  73403. */
  73404. Path3D.prototype.getNormals = function () {
  73405. return this._normals;
  73406. };
  73407. /**
  73408. * Returns an array populated with binormal vectors on each Path3D curve point.
  73409. * @returns an array populated with binormal vectors on each Path3D curve point.
  73410. */
  73411. Path3D.prototype.getBinormals = function () {
  73412. return this._binormals;
  73413. };
  73414. /**
  73415. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  73416. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  73417. */
  73418. Path3D.prototype.getDistances = function () {
  73419. return this._distances;
  73420. };
  73421. /**
  73422. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  73423. * @param path path which all values are copied into the curves points
  73424. * @param firstNormal which should be projected onto the curve
  73425. * @returns the same object updated.
  73426. */
  73427. Path3D.prototype.update = function (path, firstNormal) {
  73428. if (firstNormal === void 0) { firstNormal = null; }
  73429. for (var p = 0; p < path.length; p++) {
  73430. this._curve[p].x = path[p].x;
  73431. this._curve[p].y = path[p].y;
  73432. this._curve[p].z = path[p].z;
  73433. }
  73434. this._compute(firstNormal);
  73435. return this;
  73436. };
  73437. // private function compute() : computes tangents, normals and binormals
  73438. Path3D.prototype._compute = function (firstNormal) {
  73439. var l = this._curve.length;
  73440. // first and last tangents
  73441. this._tangents[0] = this._getFirstNonNullVector(0);
  73442. if (!this._raw) {
  73443. this._tangents[0].normalize();
  73444. }
  73445. this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
  73446. if (!this._raw) {
  73447. this._tangents[l - 1].normalize();
  73448. }
  73449. // normals and binormals at first point : arbitrary vector with _normalVector()
  73450. var tg0 = this._tangents[0];
  73451. var pp0 = this._normalVector(tg0, firstNormal);
  73452. this._normals[0] = pp0;
  73453. if (!this._raw) {
  73454. this._normals[0].normalize();
  73455. }
  73456. this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
  73457. if (!this._raw) {
  73458. this._binormals[0].normalize();
  73459. }
  73460. this._distances[0] = 0.0;
  73461. // normals and binormals : next points
  73462. var prev; // previous vector (segment)
  73463. var cur; // current vector (segment)
  73464. var curTang; // current tangent
  73465. // previous normal
  73466. var prevBinor; // previous binormal
  73467. for (var i = 1; i < l; i++) {
  73468. // tangents
  73469. prev = this._getLastNonNullVector(i);
  73470. if (i < l - 1) {
  73471. cur = this._getFirstNonNullVector(i);
  73472. this._tangents[i] = prev.add(cur);
  73473. this._tangents[i].normalize();
  73474. }
  73475. this._distances[i] = this._distances[i - 1] + prev.length();
  73476. // normals and binormals
  73477. // http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
  73478. curTang = this._tangents[i];
  73479. prevBinor = this._binormals[i - 1];
  73480. this._normals[i] = Vector3.Cross(prevBinor, curTang);
  73481. if (!this._raw) {
  73482. this._normals[i].normalize();
  73483. }
  73484. this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
  73485. if (!this._raw) {
  73486. this._binormals[i].normalize();
  73487. }
  73488. }
  73489. };
  73490. // private function getFirstNonNullVector(index)
  73491. // returns the first non null vector from index : curve[index + N].subtract(curve[index])
  73492. Path3D.prototype._getFirstNonNullVector = function (index) {
  73493. var i = 1;
  73494. var nNVector = this._curve[index + i].subtract(this._curve[index]);
  73495. while (nNVector.length() === 0 && index + i + 1 < this._curve.length) {
  73496. i++;
  73497. nNVector = this._curve[index + i].subtract(this._curve[index]);
  73498. }
  73499. return nNVector;
  73500. };
  73501. // private function getLastNonNullVector(index)
  73502. // returns the last non null vector from index : curve[index].subtract(curve[index - N])
  73503. Path3D.prototype._getLastNonNullVector = function (index) {
  73504. var i = 1;
  73505. var nLVector = this._curve[index].subtract(this._curve[index - i]);
  73506. while (nLVector.length() === 0 && index > i + 1) {
  73507. i++;
  73508. nLVector = this._curve[index].subtract(this._curve[index - i]);
  73509. }
  73510. return nLVector;
  73511. };
  73512. // private function normalVector(v0, vt, va) :
  73513. // returns an arbitrary point in the plane defined by the point v0 and the vector vt orthogonal to this plane
  73514. // if va is passed, it returns the va projection on the plane orthogonal to vt at the point v0
  73515. Path3D.prototype._normalVector = function (vt, va) {
  73516. var normal0;
  73517. var tgl = vt.length();
  73518. if (tgl === 0.0) {
  73519. tgl = 1.0;
  73520. }
  73521. if (va === undefined || va === null) {
  73522. var point;
  73523. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.y) / tgl, 1.0, Epsilon)) { // search for a point in the plane
  73524. point = new Vector3(0.0, -1.0, 0.0);
  73525. }
  73526. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.x) / tgl, 1.0, Epsilon)) {
  73527. point = new Vector3(1.0, 0.0, 0.0);
  73528. }
  73529. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.z) / tgl, 1.0, Epsilon)) {
  73530. point = new Vector3(0.0, 0.0, 1.0);
  73531. }
  73532. else {
  73533. point = Vector3.Zero();
  73534. }
  73535. normal0 = Vector3.Cross(vt, point);
  73536. }
  73537. else {
  73538. normal0 = Vector3.Cross(vt, va);
  73539. Vector3.CrossToRef(normal0, vt, normal0);
  73540. }
  73541. normal0.normalize();
  73542. return normal0;
  73543. };
  73544. return Path3D;
  73545. }());
  73546. /**
  73547. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73548. * A Curve3 is designed from a series of successive Vector3.
  73549. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  73550. */
  73551. var Curve3 = /** @class */ (function () {
  73552. /**
  73553. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73554. * A Curve3 is designed from a series of successive Vector3.
  73555. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  73556. * @param points points which make up the curve
  73557. */
  73558. function Curve3(points) {
  73559. this._length = 0.0;
  73560. this._points = points;
  73561. this._length = this._computeLength(points);
  73562. }
  73563. /**
  73564. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  73565. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  73566. * @param v1 (Vector3) the control point
  73567. * @param v2 (Vector3) the end point of the Quadratic Bezier
  73568. * @param nbPoints (integer) the wanted number of points in the curve
  73569. * @returns the created Curve3
  73570. */
  73571. Curve3.CreateQuadraticBezier = function (v0, v1, v2, nbPoints) {
  73572. nbPoints = nbPoints > 2 ? nbPoints : 3;
  73573. var bez = new Array();
  73574. var equation = function (t, val0, val1, val2) {
  73575. var res = (1.0 - t) * (1.0 - t) * val0 + 2.0 * t * (1.0 - t) * val1 + t * t * val2;
  73576. return res;
  73577. };
  73578. for (var i = 0; i <= nbPoints; i++) {
  73579. 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)));
  73580. }
  73581. return new Curve3(bez);
  73582. };
  73583. /**
  73584. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  73585. * @param v0 (Vector3) the origin point of the Cubic Bezier
  73586. * @param v1 (Vector3) the first control point
  73587. * @param v2 (Vector3) the second control point
  73588. * @param v3 (Vector3) the end point of the Cubic Bezier
  73589. * @param nbPoints (integer) the wanted number of points in the curve
  73590. * @returns the created Curve3
  73591. */
  73592. Curve3.CreateCubicBezier = function (v0, v1, v2, v3, nbPoints) {
  73593. nbPoints = nbPoints > 3 ? nbPoints : 4;
  73594. var bez = new Array();
  73595. var equation = function (t, val0, val1, val2, val3) {
  73596. 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;
  73597. return res;
  73598. };
  73599. for (var i = 0; i <= nbPoints; i++) {
  73600. 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)));
  73601. }
  73602. return new Curve3(bez);
  73603. };
  73604. /**
  73605. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  73606. * @param p1 (Vector3) the origin point of the Hermite Spline
  73607. * @param t1 (Vector3) the tangent vector at the origin point
  73608. * @param p2 (Vector3) the end point of the Hermite Spline
  73609. * @param t2 (Vector3) the tangent vector at the end point
  73610. * @param nbPoints (integer) the wanted number of points in the curve
  73611. * @returns the created Curve3
  73612. */
  73613. Curve3.CreateHermiteSpline = function (p1, t1, p2, t2, nbPoints) {
  73614. var hermite = new Array();
  73615. var step = 1.0 / nbPoints;
  73616. for (var i = 0; i <= nbPoints; i++) {
  73617. hermite.push(Vector3.Hermite(p1, t1, p2, t2, i * step));
  73618. }
  73619. return new Curve3(hermite);
  73620. };
  73621. /**
  73622. * Returns a Curve3 object along a CatmullRom Spline curve :
  73623. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  73624. * @param nbPoints (integer) the wanted number of points between each curve control points
  73625. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  73626. * @returns the created Curve3
  73627. */
  73628. Curve3.CreateCatmullRomSpline = function (points, nbPoints, closed) {
  73629. var catmullRom = new Array();
  73630. var step = 1.0 / nbPoints;
  73631. var amount = 0.0;
  73632. if (closed) {
  73633. var pointsCount = points.length;
  73634. for (var i = 0; i < pointsCount; i++) {
  73635. amount = 0;
  73636. for (var c = 0; c < nbPoints; c++) {
  73637. catmullRom.push(Vector3.CatmullRom(points[i % pointsCount], points[(i + 1) % pointsCount], points[(i + 2) % pointsCount], points[(i + 3) % pointsCount], amount));
  73638. amount += step;
  73639. }
  73640. }
  73641. catmullRom.push(catmullRom[0]);
  73642. }
  73643. else {
  73644. var totalPoints = new Array();
  73645. totalPoints.push(points[0].clone());
  73646. Array.prototype.push.apply(totalPoints, points);
  73647. totalPoints.push(points[points.length - 1].clone());
  73648. for (var i = 0; i < totalPoints.length - 3; i++) {
  73649. amount = 0;
  73650. for (var c = 0; c < nbPoints; c++) {
  73651. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  73652. amount += step;
  73653. }
  73654. }
  73655. i--;
  73656. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  73657. }
  73658. return new Curve3(catmullRom);
  73659. };
  73660. /**
  73661. * @returns the Curve3 stored array of successive Vector3
  73662. */
  73663. Curve3.prototype.getPoints = function () {
  73664. return this._points;
  73665. };
  73666. /**
  73667. * @returns the computed length (float) of the curve.
  73668. */
  73669. Curve3.prototype.length = function () {
  73670. return this._length;
  73671. };
  73672. /**
  73673. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  73674. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  73675. * curveA and curveB keep unchanged.
  73676. * @param curve the curve to continue from this curve
  73677. * @returns the newly constructed curve
  73678. */
  73679. Curve3.prototype.continue = function (curve) {
  73680. var lastPoint = this._points[this._points.length - 1];
  73681. var continuedPoints = this._points.slice();
  73682. var curvePoints = curve.getPoints();
  73683. for (var i = 1; i < curvePoints.length; i++) {
  73684. continuedPoints.push(curvePoints[i].subtract(curvePoints[0]).add(lastPoint));
  73685. }
  73686. var continuedCurve = new Curve3(continuedPoints);
  73687. return continuedCurve;
  73688. };
  73689. Curve3.prototype._computeLength = function (path) {
  73690. var l = 0;
  73691. for (var i = 1; i < path.length; i++) {
  73692. l += (path[i].subtract(path[i - 1])).length();
  73693. }
  73694. return l;
  73695. };
  73696. return Curve3;
  73697. }());
  73698. // Vertex formats
  73699. /**
  73700. * Contains position and normal vectors for a vertex
  73701. */
  73702. var PositionNormalVertex = /** @class */ (function () {
  73703. /**
  73704. * Creates a PositionNormalVertex
  73705. * @param position the position of the vertex (defaut: 0,0,0)
  73706. * @param normal the normal of the vertex (defaut: 0,1,0)
  73707. */
  73708. function PositionNormalVertex(
  73709. /** the position of the vertex (defaut: 0,0,0) */
  73710. position,
  73711. /** the normal of the vertex (defaut: 0,1,0) */
  73712. normal) {
  73713. if (position === void 0) { position = Vector3.Zero(); }
  73714. if (normal === void 0) { normal = Vector3.Up(); }
  73715. this.position = position;
  73716. this.normal = normal;
  73717. }
  73718. /**
  73719. * Clones the PositionNormalVertex
  73720. * @returns the cloned PositionNormalVertex
  73721. */
  73722. PositionNormalVertex.prototype.clone = function () {
  73723. return new PositionNormalVertex(this.position.clone(), this.normal.clone());
  73724. };
  73725. return PositionNormalVertex;
  73726. }());
  73727. /**
  73728. * Contains position, normal and uv vectors for a vertex
  73729. */
  73730. var PositionNormalTextureVertex = /** @class */ (function () {
  73731. /**
  73732. * Creates a PositionNormalTextureVertex
  73733. * @param position the position of the vertex (defaut: 0,0,0)
  73734. * @param normal the normal of the vertex (defaut: 0,1,0)
  73735. * @param uv the uv of the vertex (default: 0,0)
  73736. */
  73737. function PositionNormalTextureVertex(
  73738. /** the position of the vertex (defaut: 0,0,0) */
  73739. position,
  73740. /** the normal of the vertex (defaut: 0,1,0) */
  73741. normal,
  73742. /** the uv of the vertex (default: 0,0) */
  73743. uv) {
  73744. if (position === void 0) { position = Vector3.Zero(); }
  73745. if (normal === void 0) { normal = Vector3.Up(); }
  73746. if (uv === void 0) { uv = Vector2.Zero(); }
  73747. this.position = position;
  73748. this.normal = normal;
  73749. this.uv = uv;
  73750. }
  73751. /**
  73752. * Clones the PositionNormalTextureVertex
  73753. * @returns the cloned PositionNormalTextureVertex
  73754. */
  73755. PositionNormalTextureVertex.prototype.clone = function () {
  73756. return new PositionNormalTextureVertex(this.position.clone(), this.normal.clone(), this.uv.clone());
  73757. };
  73758. return PositionNormalTextureVertex;
  73759. }());
  73760. // Temporary pre-allocated objects for engine internal use
  73761. // usage in any internal function :
  73762. // var tmp = Tmp.Vector3[0]; <= gets access to the first pre-created Vector3
  73763. // There's a Tmp array per object type : int, float, Vector2, Vector3, Vector4, Quaternion, Matrix
  73764. /**
  73765. * @hidden
  73766. */
  73767. var Tmp = /** @class */ (function () {
  73768. function Tmp() {
  73769. }
  73770. Tmp.Color3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Color3.Black);
  73771. Tmp.Color4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, function () { return new Color4(0, 0, 0, 0); });
  73772. Tmp.Vector2 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector2.Zero); // 3 temp Vector2 at once should be enough
  73773. Tmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(13, Vector3.Zero); // 13 temp Vector3 at once should be enough
  73774. Tmp.Vector4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector4.Zero); // 3 temp Vector4 at once should be enough
  73775. Tmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Quaternion.Zero); // 2 temp Quaternion at once should be enough
  73776. Tmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, Matrix.Identity); // 8 temp Matrices at once should be enough
  73777. return Tmp;
  73778. }());
  73779. /**
  73780. * @hidden
  73781. * Same as Tmp but not exported to keep it only for math functions to avoid conflicts
  73782. */
  73783. var MathTmp = /** @class */ (function () {
  73784. function MathTmp() {
  73785. }
  73786. MathTmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, Vector3.Zero);
  73787. MathTmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Matrix.Identity);
  73788. MathTmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Quaternion.Zero);
  73789. return MathTmp;
  73790. }());
  73791. /***/ }),
  73792. /***/ "./Maths/sphericalPolynomial.ts":
  73793. /*!**************************************!*\
  73794. !*** ./Maths/sphericalPolynomial.ts ***!
  73795. \**************************************/
  73796. /*! exports provided: SphericalPolynomial, SphericalHarmonics */
  73797. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  73798. "use strict";
  73799. __webpack_require__.r(__webpack_exports__);
  73800. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return SphericalPolynomial; });
  73801. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return SphericalHarmonics; });
  73802. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  73803. /**
  73804. * Class representing spherical polynomial coefficients to the 3rd degree
  73805. */
  73806. var SphericalPolynomial = /** @class */ (function () {
  73807. function SphericalPolynomial() {
  73808. /**
  73809. * The x coefficients of the spherical polynomial
  73810. */
  73811. this.x = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73812. /**
  73813. * The y coefficients of the spherical polynomial
  73814. */
  73815. this.y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73816. /**
  73817. * The z coefficients of the spherical polynomial
  73818. */
  73819. this.z = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73820. /**
  73821. * The xx coefficients of the spherical polynomial
  73822. */
  73823. this.xx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73824. /**
  73825. * The yy coefficients of the spherical polynomial
  73826. */
  73827. this.yy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73828. /**
  73829. * The zz coefficients of the spherical polynomial
  73830. */
  73831. this.zz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73832. /**
  73833. * The xy coefficients of the spherical polynomial
  73834. */
  73835. this.xy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73836. /**
  73837. * The yz coefficients of the spherical polynomial
  73838. */
  73839. this.yz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73840. /**
  73841. * The zx coefficients of the spherical polynomial
  73842. */
  73843. this.zx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73844. }
  73845. /**
  73846. * Adds an ambient color to the spherical polynomial
  73847. * @param color the color to add
  73848. */
  73849. SphericalPolynomial.prototype.addAmbient = function (color) {
  73850. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  73851. this.xx = this.xx.add(colorVector);
  73852. this.yy = this.yy.add(colorVector);
  73853. this.zz = this.zz.add(colorVector);
  73854. };
  73855. /**
  73856. * Scales the spherical polynomial by the given amount
  73857. * @param scale the amount to scale
  73858. */
  73859. SphericalPolynomial.prototype.scale = function (scale) {
  73860. this.x = this.x.scale(scale);
  73861. this.y = this.y.scale(scale);
  73862. this.z = this.z.scale(scale);
  73863. this.xx = this.xx.scale(scale);
  73864. this.yy = this.yy.scale(scale);
  73865. this.zz = this.zz.scale(scale);
  73866. this.yz = this.yz.scale(scale);
  73867. this.zx = this.zx.scale(scale);
  73868. this.xy = this.xy.scale(scale);
  73869. };
  73870. /**
  73871. * Gets the spherical polynomial from harmonics
  73872. * @param harmonics the spherical harmonics
  73873. * @returns the spherical polynomial
  73874. */
  73875. SphericalPolynomial.FromHarmonics = function (harmonics) {
  73876. var result = new SphericalPolynomial();
  73877. result.x = harmonics.l11.scale(1.02333);
  73878. result.y = harmonics.l1_1.scale(1.02333);
  73879. result.z = harmonics.l10.scale(1.02333);
  73880. result.xx = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).add(harmonics.lL22.scale(0.429043));
  73881. result.yy = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).subtract(harmonics.lL22.scale(0.429043));
  73882. result.zz = harmonics.l00.scale(0.886277).add(harmonics.l20.scale(0.495417));
  73883. result.yz = harmonics.l2_1.scale(0.858086);
  73884. result.zx = harmonics.l21.scale(0.858086);
  73885. result.xy = harmonics.l2_2.scale(0.858086);
  73886. result.scale(1.0 / Math.PI);
  73887. return result;
  73888. };
  73889. /**
  73890. * Constructs a spherical polynomial from an array.
  73891. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  73892. * @returns the spherical polynomial
  73893. */
  73894. SphericalPolynomial.FromArray = function (data) {
  73895. var sp = new SphericalPolynomial();
  73896. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sp.x);
  73897. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sp.y);
  73898. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sp.z);
  73899. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sp.xx);
  73900. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sp.yy);
  73901. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sp.zz);
  73902. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sp.yz);
  73903. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sp.zx);
  73904. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sp.xy);
  73905. return sp;
  73906. };
  73907. return SphericalPolynomial;
  73908. }());
  73909. /**
  73910. * Class representing spherical harmonics coefficients to the 3rd degree
  73911. */
  73912. var SphericalHarmonics = /** @class */ (function () {
  73913. function SphericalHarmonics() {
  73914. /**
  73915. * The l0,0 coefficients of the spherical harmonics
  73916. */
  73917. this.l00 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73918. /**
  73919. * The l1,-1 coefficients of the spherical harmonics
  73920. */
  73921. this.l1_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73922. /**
  73923. * The l1,0 coefficients of the spherical harmonics
  73924. */
  73925. this.l10 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73926. /**
  73927. * The l1,1 coefficients of the spherical harmonics
  73928. */
  73929. this.l11 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73930. /**
  73931. * The l2,-2 coefficients of the spherical harmonics
  73932. */
  73933. this.l2_2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73934. /**
  73935. * The l2,-1 coefficients of the spherical harmonics
  73936. */
  73937. this.l2_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73938. /**
  73939. * The l2,0 coefficients of the spherical harmonics
  73940. */
  73941. this.l20 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73942. /**
  73943. * The l2,1 coefficients of the spherical harmonics
  73944. */
  73945. this.l21 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73946. /**
  73947. * The l2,2 coefficients of the spherical harmonics
  73948. */
  73949. this.lL22 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73950. }
  73951. /**
  73952. * Adds a light to the spherical harmonics
  73953. * @param direction the direction of the light
  73954. * @param color the color of the light
  73955. * @param deltaSolidAngle the delta solid angle of the light
  73956. */
  73957. SphericalHarmonics.prototype.addLight = function (direction, color, deltaSolidAngle) {
  73958. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  73959. var c = colorVector.scale(deltaSolidAngle);
  73960. this.l00 = this.l00.add(c.scale(0.282095));
  73961. this.l1_1 = this.l1_1.add(c.scale(0.488603 * direction.y));
  73962. this.l10 = this.l10.add(c.scale(0.488603 * direction.z));
  73963. this.l11 = this.l11.add(c.scale(0.488603 * direction.x));
  73964. this.l2_2 = this.l2_2.add(c.scale(1.092548 * direction.x * direction.y));
  73965. this.l2_1 = this.l2_1.add(c.scale(1.092548 * direction.y * direction.z));
  73966. this.l21 = this.l21.add(c.scale(1.092548 * direction.x * direction.z));
  73967. this.l20 = this.l20.add(c.scale(0.315392 * (3.0 * direction.z * direction.z - 1.0)));
  73968. this.lL22 = this.lL22.add(c.scale(0.546274 * (direction.x * direction.x - direction.y * direction.y)));
  73969. };
  73970. /**
  73971. * Scales the spherical harmonics by the given amount
  73972. * @param scale the amount to scale
  73973. */
  73974. SphericalHarmonics.prototype.scale = function (scale) {
  73975. this.l00 = this.l00.scale(scale);
  73976. this.l1_1 = this.l1_1.scale(scale);
  73977. this.l10 = this.l10.scale(scale);
  73978. this.l11 = this.l11.scale(scale);
  73979. this.l2_2 = this.l2_2.scale(scale);
  73980. this.l2_1 = this.l2_1.scale(scale);
  73981. this.l20 = this.l20.scale(scale);
  73982. this.l21 = this.l21.scale(scale);
  73983. this.lL22 = this.lL22.scale(scale);
  73984. };
  73985. /**
  73986. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  73987. *
  73988. * ```
  73989. * E_lm = A_l * L_lm
  73990. * ```
  73991. *
  73992. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  73993. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  73994. * the scaling factors are given in equation 9.
  73995. */
  73996. SphericalHarmonics.prototype.convertIncidentRadianceToIrradiance = function () {
  73997. // Constant (Band 0)
  73998. this.l00 = this.l00.scale(3.141593);
  73999. // Linear (Band 1)
  74000. this.l1_1 = this.l1_1.scale(2.094395);
  74001. this.l10 = this.l10.scale(2.094395);
  74002. this.l11 = this.l11.scale(2.094395);
  74003. // Quadratic (Band 2)
  74004. this.l2_2 = this.l2_2.scale(0.785398);
  74005. this.l2_1 = this.l2_1.scale(0.785398);
  74006. this.l20 = this.l20.scale(0.785398);
  74007. this.l21 = this.l21.scale(0.785398);
  74008. this.lL22 = this.lL22.scale(0.785398);
  74009. };
  74010. /**
  74011. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  74012. *
  74013. * ```
  74014. * L = (1/pi) * E * rho
  74015. * ```
  74016. *
  74017. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  74018. */
  74019. SphericalHarmonics.prototype.convertIrradianceToLambertianRadiance = function () {
  74020. this.scale(1.0 / Math.PI);
  74021. // The resultant SH now represents outgoing radiance, so includes the Lambert 1/pi normalisation factor but without albedo (rho) applied
  74022. // (The pixel shader must apply albedo after texture fetches, etc).
  74023. };
  74024. /**
  74025. * Gets the spherical harmonics from polynomial
  74026. * @param polynomial the spherical polynomial
  74027. * @returns the spherical harmonics
  74028. */
  74029. SphericalHarmonics.FromPolynomial = function (polynomial) {
  74030. var result = new SphericalHarmonics();
  74031. result.l00 = polynomial.xx.scale(0.376127).add(polynomial.yy.scale(0.376127)).add(polynomial.zz.scale(0.376126));
  74032. result.l1_1 = polynomial.y.scale(0.977204);
  74033. result.l10 = polynomial.z.scale(0.977204);
  74034. result.l11 = polynomial.x.scale(0.977204);
  74035. result.l2_2 = polynomial.xy.scale(1.16538);
  74036. result.l2_1 = polynomial.yz.scale(1.16538);
  74037. result.l20 = polynomial.zz.scale(1.34567).subtract(polynomial.xx.scale(0.672834)).subtract(polynomial.yy.scale(0.672834));
  74038. result.l21 = polynomial.zx.scale(1.16538);
  74039. result.lL22 = polynomial.xx.scale(1.16538).subtract(polynomial.yy.scale(1.16538));
  74040. result.scale(Math.PI);
  74041. return result;
  74042. };
  74043. /**
  74044. * Constructs a spherical harmonics from an array.
  74045. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  74046. * @returns the spherical harmonics
  74047. */
  74048. SphericalHarmonics.FromArray = function (data) {
  74049. var sh = new SphericalHarmonics();
  74050. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sh.l00);
  74051. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sh.l1_1);
  74052. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sh.l10);
  74053. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sh.l11);
  74054. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sh.l2_2);
  74055. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sh.l2_1);
  74056. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sh.l20);
  74057. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sh.l21);
  74058. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sh.lL22);
  74059. return sh;
  74060. };
  74061. return SphericalHarmonics;
  74062. }());
  74063. /***/ }),
  74064. /***/ "./Meshes/Compression/dracoCompression.ts":
  74065. /*!************************************************!*\
  74066. !*** ./Meshes/Compression/dracoCompression.ts ***!
  74067. \************************************************/
  74068. /*! exports provided: DracoCompression */
  74069. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74070. "use strict";
  74071. __webpack_require__.r(__webpack_exports__);
  74072. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return DracoCompression; });
  74073. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  74074. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  74075. /**
  74076. * Draco compression (https://google.github.io/draco/)
  74077. *
  74078. * This class wraps the Draco module.
  74079. *
  74080. * **Encoder**
  74081. *
  74082. * The encoder is not currently implemented.
  74083. *
  74084. * **Decoder**
  74085. *
  74086. * 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.
  74087. *
  74088. * To update the configuration, use the following code:
  74089. * ```javascript
  74090. * DracoCompression.Configuration = {
  74091. * decoder: {
  74092. * wasmUrl: "<url to the WebAssembly library>",
  74093. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  74094. * fallbackUrl: "<url to the fallback JavaScript library>",
  74095. * }
  74096. * };
  74097. * ```
  74098. *
  74099. * 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.
  74100. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  74101. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  74102. *
  74103. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  74104. * ```javascript
  74105. * var dracoCompression = new DracoCompression();
  74106. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  74107. * [VertexBuffer.PositionKind]: 0
  74108. * });
  74109. * ```
  74110. *
  74111. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  74112. */
  74113. var DracoCompression = /** @class */ (function () {
  74114. /**
  74115. * Constructor
  74116. */
  74117. function DracoCompression() {
  74118. }
  74119. Object.defineProperty(DracoCompression, "DecoderAvailable", {
  74120. /**
  74121. * Returns true if the decoder is available.
  74122. */
  74123. get: function () {
  74124. if (typeof DracoDecoderModule !== "undefined") {
  74125. return true;
  74126. }
  74127. var decoder = DracoCompression.Configuration.decoder;
  74128. if (decoder) {
  74129. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  74130. return true;
  74131. }
  74132. if (decoder.fallbackUrl) {
  74133. return true;
  74134. }
  74135. }
  74136. return false;
  74137. },
  74138. enumerable: true,
  74139. configurable: true
  74140. });
  74141. /**
  74142. * Stop all async operations and release resources.
  74143. */
  74144. DracoCompression.prototype.dispose = function () {
  74145. };
  74146. /**
  74147. * Decode Draco compressed mesh data to vertex data.
  74148. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  74149. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  74150. * @returns A promise that resolves with the decoded vertex data
  74151. */
  74152. DracoCompression.prototype.decodeMeshAsync = function (data, attributes) {
  74153. var dataView = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
  74154. return DracoCompression._GetDecoderModule().then(function (wrappedModule) {
  74155. var module = wrappedModule.module;
  74156. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  74157. var buffer = new module.DecoderBuffer();
  74158. buffer.Init(dataView, dataView.byteLength);
  74159. var decoder = new module.Decoder();
  74160. var geometry;
  74161. var status;
  74162. try {
  74163. var type = decoder.GetEncodedGeometryType(buffer);
  74164. switch (type) {
  74165. case module.TRIANGULAR_MESH:
  74166. geometry = new module.Mesh();
  74167. status = decoder.DecodeBufferToMesh(buffer, geometry);
  74168. break;
  74169. case module.POINT_CLOUD:
  74170. geometry = new module.PointCloud();
  74171. status = decoder.DecodeBufferToPointCloud(buffer, geometry);
  74172. break;
  74173. default:
  74174. throw new Error("Invalid geometry type " + type);
  74175. }
  74176. if (!status.ok() || !geometry.ptr) {
  74177. throw new Error(status.error_msg());
  74178. }
  74179. var numPoints = geometry.num_points();
  74180. if (type === module.TRIANGULAR_MESH) {
  74181. var numFaces = geometry.num_faces();
  74182. var faceIndices = new module.DracoInt32Array();
  74183. try {
  74184. var indices = new Uint32Array(numFaces * 3);
  74185. for (var i = 0; i < numFaces; i++) {
  74186. decoder.GetFaceFromMesh(geometry, i, faceIndices);
  74187. var offset = i * 3;
  74188. indices[offset + 0] = faceIndices.GetValue(0);
  74189. indices[offset + 1] = faceIndices.GetValue(1);
  74190. indices[offset + 2] = faceIndices.GetValue(2);
  74191. }
  74192. vertexData.indices = indices;
  74193. }
  74194. finally {
  74195. module.destroy(faceIndices);
  74196. }
  74197. }
  74198. for (var kind in attributes) {
  74199. var uniqueId = attributes[kind];
  74200. var attribute = decoder.GetAttributeByUniqueId(geometry, uniqueId);
  74201. var dracoData = new module.DracoFloat32Array();
  74202. try {
  74203. decoder.GetAttributeFloatForAllPoints(geometry, attribute, dracoData);
  74204. var babylonData = new Float32Array(numPoints * attribute.num_components());
  74205. for (var i = 0; i < babylonData.length; i++) {
  74206. babylonData[i] = dracoData.GetValue(i);
  74207. }
  74208. vertexData.set(babylonData, kind);
  74209. }
  74210. finally {
  74211. module.destroy(dracoData);
  74212. }
  74213. }
  74214. }
  74215. finally {
  74216. if (geometry) {
  74217. module.destroy(geometry);
  74218. }
  74219. module.destroy(decoder);
  74220. module.destroy(buffer);
  74221. }
  74222. return vertexData;
  74223. });
  74224. };
  74225. DracoCompression._GetDecoderModule = function () {
  74226. if (!DracoCompression._DecoderModulePromise) {
  74227. var promise = null;
  74228. var config_1 = {};
  74229. if (typeof DracoDecoderModule !== "undefined") {
  74230. promise = Promise.resolve();
  74231. }
  74232. else {
  74233. var decoder = DracoCompression.Configuration.decoder;
  74234. if (decoder) {
  74235. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  74236. promise = Promise.all([
  74237. DracoCompression._LoadScriptAsync(decoder.wasmUrl),
  74238. DracoCompression._LoadFileAsync(decoder.wasmBinaryUrl).then(function (data) {
  74239. config_1.wasmBinary = data;
  74240. })
  74241. ]);
  74242. }
  74243. else if (decoder.fallbackUrl) {
  74244. promise = DracoCompression._LoadScriptAsync(decoder.fallbackUrl);
  74245. }
  74246. }
  74247. }
  74248. if (!promise) {
  74249. throw new Error("Draco decoder module is not available");
  74250. }
  74251. DracoCompression._DecoderModulePromise = promise.then(function () {
  74252. return new Promise(function (resolve) {
  74253. config_1.onModuleLoaded = function (decoderModule) {
  74254. // decoderModule is Promise-like. Wrap before resolving to avoid loop.
  74255. resolve({ module: decoderModule });
  74256. };
  74257. DracoDecoderModule(config_1);
  74258. });
  74259. });
  74260. }
  74261. return DracoCompression._DecoderModulePromise;
  74262. };
  74263. DracoCompression._LoadScriptAsync = function (url) {
  74264. return new Promise(function (resolve, reject) {
  74265. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadScript(url, function () {
  74266. resolve();
  74267. }, function (message) {
  74268. reject(new Error(message));
  74269. });
  74270. });
  74271. };
  74272. DracoCompression._LoadFileAsync = function (url) {
  74273. return new Promise(function (resolve, reject) {
  74274. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(url, function (data) {
  74275. resolve(data);
  74276. }, undefined, undefined, true, function (request, exception) {
  74277. reject(exception);
  74278. });
  74279. });
  74280. };
  74281. /**
  74282. * The configuration. Defaults to the following urls:
  74283. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  74284. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  74285. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  74286. */
  74287. DracoCompression.Configuration = {
  74288. decoder: {
  74289. wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",
  74290. wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm",
  74291. fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  74292. }
  74293. };
  74294. return DracoCompression;
  74295. }());
  74296. /***/ }),
  74297. /***/ "./Meshes/Compression/index.ts":
  74298. /*!*************************************!*\
  74299. !*** ./Meshes/Compression/index.ts ***!
  74300. \*************************************/
  74301. /*! exports provided: DracoCompression */
  74302. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74303. "use strict";
  74304. __webpack_require__.r(__webpack_exports__);
  74305. /* harmony import */ var _dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dracoCompression */ "./Meshes/Compression/dracoCompression.ts");
  74306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _dracoCompression__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  74307. /***/ }),
  74308. /***/ "./Meshes/abstractMesh.ts":
  74309. /*!********************************!*\
  74310. !*** ./Meshes/abstractMesh.ts ***!
  74311. \********************************/
  74312. /*! exports provided: AbstractMesh */
  74313. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74314. "use strict";
  74315. __webpack_require__.r(__webpack_exports__);
  74316. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return AbstractMesh; });
  74317. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  74318. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  74319. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  74320. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  74321. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  74322. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  74323. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  74324. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  74325. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  74326. /* harmony import */ var _Collisions_collider__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Collisions/collider */ "./Collisions/collider.ts");
  74327. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  74328. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  74329. /** @hidden */
  74330. var _FacetDataStorage = /** @class */ (function () {
  74331. function _FacetDataStorage() {
  74332. this.facetNb = 0; // facet number
  74333. this.partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space
  74334. this.partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
  74335. this.facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
  74336. this.facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
  74337. this.bbSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(); // bbox size approximated for facet data
  74338. this.subDiv = {
  74339. max: 1,
  74340. X: 1,
  74341. Y: 1,
  74342. Z: 1
  74343. };
  74344. this.facetDepthSort = false; // is the facet depth sort to be computed
  74345. this.facetDepthSortEnabled = false; // is the facet depth sort initialized
  74346. }
  74347. return _FacetDataStorage;
  74348. }());
  74349. /**
  74350. * Class used to store all common mesh properties
  74351. */
  74352. var AbstractMesh = /** @class */ (function (_super) {
  74353. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractMesh, _super);
  74354. // Constructor
  74355. /**
  74356. * Creates a new AbstractMesh
  74357. * @param name defines the name of the mesh
  74358. * @param scene defines the hosting scene
  74359. */
  74360. function AbstractMesh(name, scene) {
  74361. if (scene === void 0) { scene = null; }
  74362. var _this = _super.call(this, name, scene, false) || this;
  74363. _this._facetData = new _FacetDataStorage();
  74364. /**
  74365. * The culling strategy to use to check whether the mesh must be rendered or not.
  74366. * This value can be changed at any time and will be used on the next render mesh selection.
  74367. * The possible values are :
  74368. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  74369. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  74370. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  74371. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  74372. * Please read each static variable documentation to get details about the culling process.
  74373. * */
  74374. _this.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
  74375. // Events
  74376. /**
  74377. * An event triggered when this mesh collides with another one
  74378. */
  74379. _this.onCollideObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  74380. /**
  74381. * An event triggered when the collision's position changes
  74382. */
  74383. _this.onCollisionPositionChangeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  74384. /**
  74385. * An event triggered when material is changed
  74386. */
  74387. _this.onMaterialChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  74388. // Properties
  74389. /**
  74390. * Gets or sets the orientation for POV movement & rotation
  74391. */
  74392. _this.definedFacingForward = true;
  74393. _this._visibility = 1.0;
  74394. /** Gets or sets the alpha index used to sort transparent meshes
  74395. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  74396. */
  74397. _this.alphaIndex = Number.MAX_VALUE;
  74398. /**
  74399. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  74400. */
  74401. _this.isVisible = true;
  74402. /**
  74403. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  74404. */
  74405. _this.isPickable = true;
  74406. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  74407. _this.showSubMeshesBoundingBox = false;
  74408. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  74409. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  74410. */
  74411. _this.isBlocker = false;
  74412. /**
  74413. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  74414. */
  74415. _this.enablePointerMoveEvents = false;
  74416. /**
  74417. * Specifies the rendering group id for this mesh (0 by default)
  74418. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  74419. */
  74420. _this.renderingGroupId = 0;
  74421. _this._receiveShadows = false;
  74422. /** Defines color to use when rendering outline */
  74423. _this.outlineColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  74424. /** Define width to use when rendering outline */
  74425. _this.outlineWidth = 0.02;
  74426. /** Defines color to use when rendering overlay */
  74427. _this.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  74428. /** Defines alpha to use when rendering overlay */
  74429. _this.overlayAlpha = 0.5;
  74430. _this._hasVertexAlpha = false;
  74431. _this._useVertexColors = true;
  74432. _this._computeBonesUsingShaders = true;
  74433. _this._numBoneInfluencers = 4;
  74434. _this._applyFog = true;
  74435. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  74436. _this.useOctreeForRenderingSelection = true;
  74437. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  74438. _this.useOctreeForPicking = true;
  74439. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  74440. _this.useOctreeForCollisions = true;
  74441. _this._layerMask = 0x0FFFFFFF;
  74442. /**
  74443. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  74444. */
  74445. _this.alwaysSelectAsActiveMesh = false;
  74446. /**
  74447. * Gets or sets the current action manager
  74448. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74449. */
  74450. _this.actionManager = null;
  74451. // Collisions
  74452. _this._checkCollisions = false;
  74453. _this._collisionMask = -1;
  74454. _this._collisionGroup = -1;
  74455. /**
  74456. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  74457. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  74458. */
  74459. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 1, 0.5);
  74460. /**
  74461. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  74462. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  74463. */
  74464. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  74465. _this._oldPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  74466. _this._diffPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  74467. // Edges
  74468. /**
  74469. * Defines edge width used when edgesRenderer is enabled
  74470. * @see https://www.babylonjs-playground.com/#10OJSG#13
  74471. */
  74472. _this.edgesWidth = 1;
  74473. /**
  74474. * Defines edge color used when edgesRenderer is enabled
  74475. * @see https://www.babylonjs-playground.com/#10OJSG#13
  74476. */
  74477. _this.edgesColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](1, 0, 0, 1);
  74478. /** @hidden */
  74479. _this._renderId = 0;
  74480. /** @hidden */
  74481. _this._intersectionsInProgress = new Array();
  74482. /** @hidden */
  74483. _this._unIndexed = false;
  74484. /** @hidden */
  74485. _this._lightSources = new Array();
  74486. /**
  74487. * An event triggered when the mesh is rebuilt.
  74488. */
  74489. _this.onRebuildObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  74490. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  74491. if (collidedMesh === void 0) { collidedMesh = null; }
  74492. newPosition.subtractToRef(_this._oldPositionForCollisions, _this._diffPositionForCollisions);
  74493. if (_this._diffPositionForCollisions.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].CollisionsEpsilon) {
  74494. _this.position.addInPlace(_this._diffPositionForCollisions);
  74495. }
  74496. if (collidedMesh) {
  74497. _this.onCollideObservable.notifyObservers(collidedMesh);
  74498. }
  74499. _this.onCollisionPositionChangeObservable.notifyObservers(_this.position);
  74500. };
  74501. _this.getScene().addMesh(_this);
  74502. _this._resyncLightSources();
  74503. return _this;
  74504. }
  74505. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_NONE", {
  74506. /**
  74507. * No billboard
  74508. */
  74509. get: function () {
  74510. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE;
  74511. },
  74512. enumerable: true,
  74513. configurable: true
  74514. });
  74515. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_X", {
  74516. /** Billboard on X axis */
  74517. get: function () {
  74518. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_X;
  74519. },
  74520. enumerable: true,
  74521. configurable: true
  74522. });
  74523. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Y", {
  74524. /** Billboard on Y axis */
  74525. get: function () {
  74526. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Y;
  74527. },
  74528. enumerable: true,
  74529. configurable: true
  74530. });
  74531. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Z", {
  74532. /** Billboard on Z axis */
  74533. get: function () {
  74534. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Z;
  74535. },
  74536. enumerable: true,
  74537. configurable: true
  74538. });
  74539. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_ALL", {
  74540. /** Billboard on all axes */
  74541. get: function () {
  74542. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_ALL;
  74543. },
  74544. enumerable: true,
  74545. configurable: true
  74546. });
  74547. Object.defineProperty(AbstractMesh.prototype, "facetNb", {
  74548. /**
  74549. * Gets the number of facets in the mesh
  74550. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  74551. */
  74552. get: function () {
  74553. return this._facetData.facetNb;
  74554. },
  74555. enumerable: true,
  74556. configurable: true
  74557. });
  74558. Object.defineProperty(AbstractMesh.prototype, "partitioningSubdivisions", {
  74559. /**
  74560. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  74561. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  74562. */
  74563. get: function () {
  74564. return this._facetData.partitioningSubdivisions;
  74565. },
  74566. set: function (nb) {
  74567. this._facetData.partitioningSubdivisions = nb;
  74568. },
  74569. enumerable: true,
  74570. configurable: true
  74571. });
  74572. Object.defineProperty(AbstractMesh.prototype, "partitioningBBoxRatio", {
  74573. /**
  74574. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  74575. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  74576. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  74577. */
  74578. get: function () {
  74579. return this._facetData.partitioningBBoxRatio;
  74580. },
  74581. set: function (ratio) {
  74582. this._facetData.partitioningBBoxRatio = ratio;
  74583. },
  74584. enumerable: true,
  74585. configurable: true
  74586. });
  74587. Object.defineProperty(AbstractMesh.prototype, "mustDepthSortFacets", {
  74588. /**
  74589. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  74590. * Works only for updatable meshes.
  74591. * Doesn't work with multi-materials
  74592. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  74593. */
  74594. get: function () {
  74595. return this._facetData.facetDepthSort;
  74596. },
  74597. set: function (sort) {
  74598. this._facetData.facetDepthSort = sort;
  74599. },
  74600. enumerable: true,
  74601. configurable: true
  74602. });
  74603. Object.defineProperty(AbstractMesh.prototype, "facetDepthSortFrom", {
  74604. /**
  74605. * The location (Vector3) where the facet depth sort must be computed from.
  74606. * By default, the active camera position.
  74607. * Used only when facet depth sort is enabled
  74608. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  74609. */
  74610. get: function () {
  74611. return this._facetData.facetDepthSortFrom;
  74612. },
  74613. set: function (location) {
  74614. this._facetData.facetDepthSortFrom = location;
  74615. },
  74616. enumerable: true,
  74617. configurable: true
  74618. });
  74619. Object.defineProperty(AbstractMesh.prototype, "isFacetDataEnabled", {
  74620. /**
  74621. * gets a boolean indicating if facetData is enabled
  74622. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  74623. */
  74624. get: function () {
  74625. return this._facetData.facetDataEnabled;
  74626. },
  74627. enumerable: true,
  74628. configurable: true
  74629. });
  74630. /** @hidden */
  74631. AbstractMesh.prototype._updateNonUniformScalingState = function (value) {
  74632. if (!_super.prototype._updateNonUniformScalingState.call(this, value)) {
  74633. return false;
  74634. }
  74635. this._markSubMeshesAsMiscDirty();
  74636. return true;
  74637. };
  74638. Object.defineProperty(AbstractMesh.prototype, "onCollide", {
  74639. /** Set a function to call when this mesh collides with another one */
  74640. set: function (callback) {
  74641. if (this._onCollideObserver) {
  74642. this.onCollideObservable.remove(this._onCollideObserver);
  74643. }
  74644. this._onCollideObserver = this.onCollideObservable.add(callback);
  74645. },
  74646. enumerable: true,
  74647. configurable: true
  74648. });
  74649. Object.defineProperty(AbstractMesh.prototype, "onCollisionPositionChange", {
  74650. /** Set a function to call when the collision's position changes */
  74651. set: function (callback) {
  74652. if (this._onCollisionPositionChangeObserver) {
  74653. this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver);
  74654. }
  74655. this._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(callback);
  74656. },
  74657. enumerable: true,
  74658. configurable: true
  74659. });
  74660. Object.defineProperty(AbstractMesh.prototype, "visibility", {
  74661. /**
  74662. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  74663. */
  74664. get: function () {
  74665. return this._visibility;
  74666. },
  74667. /**
  74668. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  74669. */
  74670. set: function (value) {
  74671. if (this._visibility === value) {
  74672. return;
  74673. }
  74674. this._visibility = value;
  74675. this._markSubMeshesAsMiscDirty();
  74676. },
  74677. enumerable: true,
  74678. configurable: true
  74679. });
  74680. Object.defineProperty(AbstractMesh.prototype, "material", {
  74681. /** Gets or sets current material */
  74682. get: function () {
  74683. return this._material;
  74684. },
  74685. set: function (value) {
  74686. if (this._material === value) {
  74687. return;
  74688. }
  74689. // remove from material mesh map id needed
  74690. if (this._material && this._material.meshMap) {
  74691. this._material.meshMap[this.uniqueId] = undefined;
  74692. }
  74693. this._material = value;
  74694. if (value && value.meshMap) {
  74695. value.meshMap[this.uniqueId] = this;
  74696. }
  74697. if (this.onMaterialChangedObservable.hasObservers) {
  74698. this.onMaterialChangedObservable.notifyObservers(this);
  74699. }
  74700. if (!this.subMeshes) {
  74701. return;
  74702. }
  74703. this._unBindEffect();
  74704. },
  74705. enumerable: true,
  74706. configurable: true
  74707. });
  74708. Object.defineProperty(AbstractMesh.prototype, "receiveShadows", {
  74709. /**
  74710. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  74711. * @see http://doc.babylonjs.com/babylon101/shadows
  74712. */
  74713. get: function () {
  74714. return this._receiveShadows;
  74715. },
  74716. set: function (value) {
  74717. if (this._receiveShadows === value) {
  74718. return;
  74719. }
  74720. this._receiveShadows = value;
  74721. this._markSubMeshesAsLightDirty();
  74722. },
  74723. enumerable: true,
  74724. configurable: true
  74725. });
  74726. Object.defineProperty(AbstractMesh.prototype, "hasVertexAlpha", {
  74727. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  74728. get: function () {
  74729. return this._hasVertexAlpha;
  74730. },
  74731. set: function (value) {
  74732. if (this._hasVertexAlpha === value) {
  74733. return;
  74734. }
  74735. this._hasVertexAlpha = value;
  74736. this._markSubMeshesAsAttributesDirty();
  74737. this._markSubMeshesAsMiscDirty();
  74738. },
  74739. enumerable: true,
  74740. configurable: true
  74741. });
  74742. Object.defineProperty(AbstractMesh.prototype, "useVertexColors", {
  74743. /** 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) */
  74744. get: function () {
  74745. return this._useVertexColors;
  74746. },
  74747. set: function (value) {
  74748. if (this._useVertexColors === value) {
  74749. return;
  74750. }
  74751. this._useVertexColors = value;
  74752. this._markSubMeshesAsAttributesDirty();
  74753. },
  74754. enumerable: true,
  74755. configurable: true
  74756. });
  74757. Object.defineProperty(AbstractMesh.prototype, "computeBonesUsingShaders", {
  74758. /**
  74759. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  74760. */
  74761. get: function () {
  74762. return this._computeBonesUsingShaders;
  74763. },
  74764. set: function (value) {
  74765. if (this._computeBonesUsingShaders === value) {
  74766. return;
  74767. }
  74768. this._computeBonesUsingShaders = value;
  74769. this._markSubMeshesAsAttributesDirty();
  74770. },
  74771. enumerable: true,
  74772. configurable: true
  74773. });
  74774. Object.defineProperty(AbstractMesh.prototype, "numBoneInfluencers", {
  74775. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  74776. get: function () {
  74777. return this._numBoneInfluencers;
  74778. },
  74779. set: function (value) {
  74780. if (this._numBoneInfluencers === value) {
  74781. return;
  74782. }
  74783. this._numBoneInfluencers = value;
  74784. this._markSubMeshesAsAttributesDirty();
  74785. },
  74786. enumerable: true,
  74787. configurable: true
  74788. });
  74789. Object.defineProperty(AbstractMesh.prototype, "applyFog", {
  74790. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  74791. get: function () {
  74792. return this._applyFog;
  74793. },
  74794. set: function (value) {
  74795. if (this._applyFog === value) {
  74796. return;
  74797. }
  74798. this._applyFog = value;
  74799. this._markSubMeshesAsMiscDirty();
  74800. },
  74801. enumerable: true,
  74802. configurable: true
  74803. });
  74804. Object.defineProperty(AbstractMesh.prototype, "layerMask", {
  74805. /**
  74806. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  74807. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  74808. */
  74809. get: function () {
  74810. return this._layerMask;
  74811. },
  74812. set: function (value) {
  74813. if (value === this._layerMask) {
  74814. return;
  74815. }
  74816. this._layerMask = value;
  74817. this._resyncLightSources();
  74818. },
  74819. enumerable: true,
  74820. configurable: true
  74821. });
  74822. Object.defineProperty(AbstractMesh.prototype, "collisionMask", {
  74823. /**
  74824. * Gets or sets a collision mask used to mask collisions (default is -1).
  74825. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  74826. */
  74827. get: function () {
  74828. return this._collisionMask;
  74829. },
  74830. set: function (mask) {
  74831. this._collisionMask = !isNaN(mask) ? mask : -1;
  74832. },
  74833. enumerable: true,
  74834. configurable: true
  74835. });
  74836. Object.defineProperty(AbstractMesh.prototype, "collisionGroup", {
  74837. /**
  74838. * Gets or sets the current collision group mask (-1 by default).
  74839. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  74840. */
  74841. get: function () {
  74842. return this._collisionGroup;
  74843. },
  74844. set: function (mask) {
  74845. this._collisionGroup = !isNaN(mask) ? mask : -1;
  74846. },
  74847. enumerable: true,
  74848. configurable: true
  74849. });
  74850. Object.defineProperty(AbstractMesh.prototype, "_positions", {
  74851. /** @hidden */
  74852. get: function () {
  74853. return null;
  74854. },
  74855. enumerable: true,
  74856. configurable: true
  74857. });
  74858. Object.defineProperty(AbstractMesh.prototype, "skeleton", {
  74859. get: function () {
  74860. return this._skeleton;
  74861. },
  74862. /**
  74863. * Gets or sets a skeleton to apply skining transformations
  74864. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  74865. */
  74866. set: function (value) {
  74867. if (this._skeleton && this._skeleton.needInitialSkinMatrix) {
  74868. this._skeleton._unregisterMeshWithPoseMatrix(this);
  74869. }
  74870. if (value && value.needInitialSkinMatrix) {
  74871. value._registerMeshWithPoseMatrix(this);
  74872. }
  74873. this._skeleton = value;
  74874. if (!this._skeleton) {
  74875. this._bonesTransformMatrices = null;
  74876. }
  74877. this._markSubMeshesAsAttributesDirty();
  74878. },
  74879. enumerable: true,
  74880. configurable: true
  74881. });
  74882. /**
  74883. * Returns the string "AbstractMesh"
  74884. * @returns "AbstractMesh"
  74885. */
  74886. AbstractMesh.prototype.getClassName = function () {
  74887. return "AbstractMesh";
  74888. };
  74889. /**
  74890. * Gets a string representation of the current mesh
  74891. * @param fullDetails defines a boolean indicating if full details must be included
  74892. * @returns a string representation of the current mesh
  74893. */
  74894. AbstractMesh.prototype.toString = function (fullDetails) {
  74895. var ret = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
  74896. ret += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
  74897. if (this._skeleton) {
  74898. ret += ", skeleton: " + this._skeleton.name;
  74899. }
  74900. if (fullDetails) {
  74901. ret += ", billboard mode: " + (["NONE", "X", "Y", null, "Z", null, null, "ALL"])[this.billboardMode];
  74902. ret += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingFreezeWorldMatrix ? "YES" : "NO");
  74903. }
  74904. return ret;
  74905. };
  74906. /** @hidden */
  74907. AbstractMesh.prototype._rebuild = function () {
  74908. this.onRebuildObservable.notifyObservers(this);
  74909. if (this._occlusionQuery) {
  74910. this._occlusionQuery = null;
  74911. }
  74912. if (!this.subMeshes) {
  74913. return;
  74914. }
  74915. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  74916. var subMesh = _a[_i];
  74917. subMesh._rebuild();
  74918. }
  74919. };
  74920. /** @hidden */
  74921. AbstractMesh.prototype._resyncLightSources = function () {
  74922. this._lightSources.length = 0;
  74923. for (var _i = 0, _a = this.getScene().lights; _i < _a.length; _i++) {
  74924. var light = _a[_i];
  74925. if (!light.isEnabled()) {
  74926. continue;
  74927. }
  74928. if (light.canAffectMesh(this)) {
  74929. this._lightSources.push(light);
  74930. }
  74931. }
  74932. this._markSubMeshesAsLightDirty();
  74933. };
  74934. /** @hidden */
  74935. AbstractMesh.prototype._resyncLighSource = function (light) {
  74936. var isIn = light.isEnabled() && light.canAffectMesh(this);
  74937. var index = this._lightSources.indexOf(light);
  74938. if (index === -1) {
  74939. if (!isIn) {
  74940. return;
  74941. }
  74942. this._lightSources.push(light);
  74943. }
  74944. else {
  74945. if (isIn) {
  74946. return;
  74947. }
  74948. this._lightSources.splice(index, 1);
  74949. }
  74950. this._markSubMeshesAsLightDirty();
  74951. };
  74952. /** @hidden */
  74953. AbstractMesh.prototype._unBindEffect = function () {
  74954. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  74955. var subMesh = _a[_i];
  74956. subMesh.setEffect(null);
  74957. }
  74958. };
  74959. /** @hidden */
  74960. AbstractMesh.prototype._removeLightSource = function (light) {
  74961. var index = this._lightSources.indexOf(light);
  74962. if (index === -1) {
  74963. return;
  74964. }
  74965. this._lightSources.splice(index, 1);
  74966. this._markSubMeshesAsLightDirty();
  74967. };
  74968. AbstractMesh.prototype._markSubMeshesAsDirty = function (func) {
  74969. if (!this.subMeshes) {
  74970. return;
  74971. }
  74972. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  74973. var subMesh = _a[_i];
  74974. if (subMesh._materialDefines) {
  74975. func(subMesh._materialDefines);
  74976. }
  74977. }
  74978. };
  74979. /** @hidden */
  74980. AbstractMesh.prototype._markSubMeshesAsLightDirty = function () {
  74981. this._markSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
  74982. };
  74983. /** @hidden */
  74984. AbstractMesh.prototype._markSubMeshesAsAttributesDirty = function () {
  74985. this._markSubMeshesAsDirty(function (defines) { return defines.markAsAttributesDirty(); });
  74986. };
  74987. /** @hidden */
  74988. AbstractMesh.prototype._markSubMeshesAsMiscDirty = function () {
  74989. if (!this.subMeshes) {
  74990. return;
  74991. }
  74992. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  74993. var subMesh = _a[_i];
  74994. var material = subMesh.getMaterial();
  74995. if (material) {
  74996. material.markAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].MATERIAL_MiscDirtyFlag);
  74997. }
  74998. }
  74999. };
  75000. Object.defineProperty(AbstractMesh.prototype, "scaling", {
  75001. /**
  75002. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  75003. */
  75004. get: function () {
  75005. return this._scaling;
  75006. },
  75007. set: function (newScaling) {
  75008. this._scaling = newScaling;
  75009. if (this.physicsImpostor) {
  75010. this.physicsImpostor.forceUpdate();
  75011. }
  75012. },
  75013. enumerable: true,
  75014. configurable: true
  75015. });
  75016. Object.defineProperty(AbstractMesh.prototype, "isBlocked", {
  75017. // Methods
  75018. /**
  75019. * Returns true if the mesh is blocked. Implemented by child classes
  75020. */
  75021. get: function () {
  75022. return false;
  75023. },
  75024. enumerable: true,
  75025. configurable: true
  75026. });
  75027. /**
  75028. * Returns the mesh itself by default. Implemented by child classes
  75029. * @param camera defines the camera to use to pick the right LOD level
  75030. * @returns the currentAbstractMesh
  75031. */
  75032. AbstractMesh.prototype.getLOD = function (camera) {
  75033. return this;
  75034. };
  75035. /**
  75036. * Returns 0 by default. Implemented by child classes
  75037. * @returns an integer
  75038. */
  75039. AbstractMesh.prototype.getTotalVertices = function () {
  75040. return 0;
  75041. };
  75042. /**
  75043. * Returns a positive integer : the total number of indices in this mesh geometry.
  75044. * @returns the numner of indices or zero if the mesh has no geometry.
  75045. */
  75046. AbstractMesh.prototype.getTotalIndices = function () {
  75047. return 0;
  75048. };
  75049. /**
  75050. * Returns null by default. Implemented by child classes
  75051. * @returns null
  75052. */
  75053. AbstractMesh.prototype.getIndices = function () {
  75054. return null;
  75055. };
  75056. /**
  75057. * Returns the array of the requested vertex data kind. Implemented by child classes
  75058. * @param kind defines the vertex data kind to use
  75059. * @returns null
  75060. */
  75061. AbstractMesh.prototype.getVerticesData = function (kind) {
  75062. return null;
  75063. };
  75064. /**
  75065. * Sets the vertex data of the mesh geometry for the requested `kind`.
  75066. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  75067. * Note that a new underlying VertexBuffer object is created each call.
  75068. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  75069. * @param kind defines vertex data kind:
  75070. * * VertexBuffer.PositionKind
  75071. * * VertexBuffer.UVKind
  75072. * * VertexBuffer.UV2Kind
  75073. * * VertexBuffer.UV3Kind
  75074. * * VertexBuffer.UV4Kind
  75075. * * VertexBuffer.UV5Kind
  75076. * * VertexBuffer.UV6Kind
  75077. * * VertexBuffer.ColorKind
  75078. * * VertexBuffer.MatricesIndicesKind
  75079. * * VertexBuffer.MatricesIndicesExtraKind
  75080. * * VertexBuffer.MatricesWeightsKind
  75081. * * VertexBuffer.MatricesWeightsExtraKind
  75082. * @param data defines the data source
  75083. * @param updatable defines if the data must be flagged as updatable (or static)
  75084. * @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
  75085. * @returns the current mesh
  75086. */
  75087. AbstractMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  75088. return this;
  75089. };
  75090. /**
  75091. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  75092. * If the mesh has no geometry, it is simply returned as it is.
  75093. * @param kind defines vertex data kind:
  75094. * * VertexBuffer.PositionKind
  75095. * * VertexBuffer.UVKind
  75096. * * VertexBuffer.UV2Kind
  75097. * * VertexBuffer.UV3Kind
  75098. * * VertexBuffer.UV4Kind
  75099. * * VertexBuffer.UV5Kind
  75100. * * VertexBuffer.UV6Kind
  75101. * * VertexBuffer.ColorKind
  75102. * * VertexBuffer.MatricesIndicesKind
  75103. * * VertexBuffer.MatricesIndicesExtraKind
  75104. * * VertexBuffer.MatricesWeightsKind
  75105. * * VertexBuffer.MatricesWeightsExtraKind
  75106. * @param data defines the data source
  75107. * @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
  75108. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  75109. * @returns the current mesh
  75110. */
  75111. AbstractMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  75112. return this;
  75113. };
  75114. /**
  75115. * Sets the mesh indices,
  75116. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  75117. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  75118. * @param totalVertices Defines the total number of vertices
  75119. * @returns the current mesh
  75120. */
  75121. AbstractMesh.prototype.setIndices = function (indices, totalVertices) {
  75122. return this;
  75123. };
  75124. /**
  75125. * Gets a boolean indicating if specific vertex data is present
  75126. * @param kind defines the vertex data kind to use
  75127. * @returns true is data kind is present
  75128. */
  75129. AbstractMesh.prototype.isVerticesDataPresent = function (kind) {
  75130. return false;
  75131. };
  75132. /**
  75133. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  75134. * @returns a BoundingInfo
  75135. */
  75136. AbstractMesh.prototype.getBoundingInfo = function () {
  75137. if (this._masterMesh) {
  75138. return this._masterMesh.getBoundingInfo();
  75139. }
  75140. if (!this._boundingInfo) {
  75141. // this._boundingInfo is being created here
  75142. this._updateBoundingInfo();
  75143. }
  75144. // cannot be null.
  75145. return this._boundingInfo;
  75146. };
  75147. /**
  75148. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  75149. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  75150. * @returns the current mesh
  75151. */
  75152. AbstractMesh.prototype.normalizeToUnitCube = function (includeDescendants) {
  75153. if (includeDescendants === void 0) { includeDescendants = true; }
  75154. var boundingVectors = this.getHierarchyBoundingVectors(includeDescendants);
  75155. var sizeVec = boundingVectors.max.subtract(boundingVectors.min);
  75156. var maxDimension = Math.max(sizeVec.x, sizeVec.y, sizeVec.z);
  75157. if (maxDimension === 0) {
  75158. return this;
  75159. }
  75160. var scale = 1 / maxDimension;
  75161. this.scaling.scaleInPlace(scale);
  75162. return this;
  75163. };
  75164. /**
  75165. * Overwrite the current bounding info
  75166. * @param boundingInfo defines the new bounding info
  75167. * @returns the current mesh
  75168. */
  75169. AbstractMesh.prototype.setBoundingInfo = function (boundingInfo) {
  75170. this._boundingInfo = boundingInfo;
  75171. return this;
  75172. };
  75173. Object.defineProperty(AbstractMesh.prototype, "useBones", {
  75174. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  75175. get: function () {
  75176. 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));
  75177. },
  75178. enumerable: true,
  75179. configurable: true
  75180. });
  75181. /** @hidden */
  75182. AbstractMesh.prototype._preActivate = function () {
  75183. };
  75184. /** @hidden */
  75185. AbstractMesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  75186. };
  75187. /** @hidden */
  75188. AbstractMesh.prototype._activate = function (renderId) {
  75189. this._renderId = renderId;
  75190. };
  75191. /**
  75192. * Gets the current world matrix
  75193. * @returns a Matrix
  75194. */
  75195. AbstractMesh.prototype.getWorldMatrix = function () {
  75196. if (this._masterMesh) {
  75197. return this._masterMesh.getWorldMatrix();
  75198. }
  75199. return _super.prototype.getWorldMatrix.call(this);
  75200. };
  75201. /** @hidden */
  75202. AbstractMesh.prototype._getWorldMatrixDeterminant = function () {
  75203. if (this._masterMesh) {
  75204. return this._masterMesh._getWorldMatrixDeterminant();
  75205. }
  75206. return _super.prototype._getWorldMatrixDeterminant.call(this);
  75207. };
  75208. // ================================== Point of View Movement =================================
  75209. /**
  75210. * Perform relative position change from the point of view of behind the front of the mesh.
  75211. * This is performed taking into account the meshes current rotation, so you do not have to care.
  75212. * Supports definition of mesh facing forward or backward
  75213. * @param amountRight defines the distance on the right axis
  75214. * @param amountUp defines the distance on the up axis
  75215. * @param amountForward defines the distance on the forward axis
  75216. * @returns the current mesh
  75217. */
  75218. AbstractMesh.prototype.movePOV = function (amountRight, amountUp, amountForward) {
  75219. this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));
  75220. return this;
  75221. };
  75222. /**
  75223. * Calculate relative position change from the point of view of behind the front of the mesh.
  75224. * This is performed taking into account the meshes current rotation, so you do not have to care.
  75225. * Supports definition of mesh facing forward or backward
  75226. * @param amountRight defines the distance on the right axis
  75227. * @param amountUp defines the distance on the up axis
  75228. * @param amountForward defines the distance on the forward axis
  75229. * @returns the new displacement vector
  75230. */
  75231. AbstractMesh.prototype.calcMovePOV = function (amountRight, amountUp, amountForward) {
  75232. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  75233. var rotQuaternion = (this.rotationQuaternion) ? this.rotationQuaternion : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  75234. rotQuaternion.toRotationMatrix(rotMatrix);
  75235. var translationDelta = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  75236. var defForwardMult = this.definedFacingForward ? -1 : 1;
  75237. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(amountRight * defForwardMult, amountUp, amountForward * defForwardMult, rotMatrix, translationDelta);
  75238. return translationDelta;
  75239. };
  75240. // ================================== Point of View Rotation =================================
  75241. /**
  75242. * Perform relative rotation change from the point of view of behind the front of the mesh.
  75243. * Supports definition of mesh facing forward or backward
  75244. * @param flipBack defines the flip
  75245. * @param twirlClockwise defines the twirl
  75246. * @param tiltRight defines the tilt
  75247. * @returns the current mesh
  75248. */
  75249. AbstractMesh.prototype.rotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  75250. this.rotation.addInPlace(this.calcRotatePOV(flipBack, twirlClockwise, tiltRight));
  75251. return this;
  75252. };
  75253. /**
  75254. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  75255. * Supports definition of mesh facing forward or backward.
  75256. * @param flipBack defines the flip
  75257. * @param twirlClockwise defines the twirl
  75258. * @param tiltRight defines the tilt
  75259. * @returns the new rotation vector
  75260. */
  75261. AbstractMesh.prototype.calcRotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  75262. var defForwardMult = this.definedFacingForward ? 1 : -1;
  75263. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
  75264. };
  75265. /**
  75266. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  75267. * @param includeDescendants Include bounding info from descendants as well (true by default)
  75268. * @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
  75269. * @returns the new bounding vectors
  75270. */
  75271. AbstractMesh.prototype.getHierarchyBoundingVectors = function (includeDescendants, predicate) {
  75272. if (includeDescendants === void 0) { includeDescendants = true; }
  75273. if (predicate === void 0) { predicate = null; }
  75274. // Ensures that all world matrix will be recomputed.
  75275. this.getScene().incrementRenderId();
  75276. this.computeWorldMatrix(true);
  75277. var min;
  75278. var max;
  75279. var boundingInfo = this.getBoundingInfo();
  75280. if (!this.subMeshes) {
  75281. min = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  75282. max = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  75283. }
  75284. else {
  75285. min = boundingInfo.boundingBox.minimumWorld;
  75286. max = boundingInfo.boundingBox.maximumWorld;
  75287. }
  75288. if (includeDescendants) {
  75289. var descendants = this.getDescendants(false);
  75290. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  75291. var descendant = descendants_1[_i];
  75292. var childMesh = descendant;
  75293. childMesh.computeWorldMatrix(true);
  75294. // Filters meshes based on custom predicate function.
  75295. if (predicate && !predicate(childMesh)) {
  75296. continue;
  75297. }
  75298. //make sure we have the needed params to get mix and max
  75299. if (!childMesh.getBoundingInfo || childMesh.getTotalVertices() === 0) {
  75300. continue;
  75301. }
  75302. var childBoundingInfo = childMesh.getBoundingInfo();
  75303. var boundingBox = childBoundingInfo.boundingBox;
  75304. var minBox = boundingBox.minimumWorld;
  75305. var maxBox = boundingBox.maximumWorld;
  75306. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  75307. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  75308. }
  75309. }
  75310. return {
  75311. min: min,
  75312. max: max
  75313. };
  75314. };
  75315. /**
  75316. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75317. * This means the mesh underlying bounding box and sphere are recomputed.
  75318. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75319. * @returns the current mesh
  75320. */
  75321. AbstractMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  75322. if (applySkeleton === void 0) { applySkeleton = false; }
  75323. if (this._boundingInfo && this._boundingInfo.isLocked) {
  75324. return this;
  75325. }
  75326. this._refreshBoundingInfo(this._getPositionData(applySkeleton), null);
  75327. return this;
  75328. };
  75329. /** @hidden */
  75330. AbstractMesh.prototype._refreshBoundingInfo = function (data, bias) {
  75331. if (data) {
  75332. var extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMax(data, 0, this.getTotalVertices(), bias);
  75333. if (this._boundingInfo) {
  75334. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  75335. }
  75336. else {
  75337. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_10__["BoundingInfo"](extend.minimum, extend.maximum);
  75338. }
  75339. }
  75340. if (this.subMeshes) {
  75341. for (var index = 0; index < this.subMeshes.length; index++) {
  75342. this.subMeshes[index].refreshBoundingInfo();
  75343. }
  75344. }
  75345. this._updateBoundingInfo();
  75346. };
  75347. /** @hidden */
  75348. AbstractMesh.prototype._getPositionData = function (applySkeleton) {
  75349. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  75350. if (data && applySkeleton && this.skeleton) {
  75351. data = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Slice(data);
  75352. var matricesIndicesData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesKind);
  75353. var matricesWeightsData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsKind);
  75354. if (matricesWeightsData && matricesIndicesData) {
  75355. var needExtras = this.numBoneInfluencers > 4;
  75356. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  75357. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  75358. var skeletonMatrices = this.skeleton.getTransformMatrices(this);
  75359. var tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  75360. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  75361. var tempMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  75362. var matWeightIdx = 0;
  75363. for (var index = 0; index < data.length; index += 3, matWeightIdx += 4) {
  75364. finalMatrix.reset();
  75365. var inf;
  75366. var weight;
  75367. for (inf = 0; inf < 4; inf++) {
  75368. weight = matricesWeightsData[matWeightIdx + inf];
  75369. if (weight > 0) {
  75370. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  75371. finalMatrix.addToSelf(tempMatrix);
  75372. }
  75373. }
  75374. if (needExtras) {
  75375. for (inf = 0; inf < 4; inf++) {
  75376. weight = matricesWeightsExtraData[matWeightIdx + inf];
  75377. if (weight > 0) {
  75378. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  75379. finalMatrix.addToSelf(tempMatrix);
  75380. }
  75381. }
  75382. }
  75383. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
  75384. tempVector.toArray(data, index);
  75385. }
  75386. }
  75387. }
  75388. return data;
  75389. };
  75390. /** @hidden */
  75391. AbstractMesh.prototype._updateBoundingInfo = function () {
  75392. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  75393. if (this._boundingInfo) {
  75394. this._boundingInfo.update(effectiveMesh.worldMatrixFromCache);
  75395. }
  75396. else {
  75397. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_10__["BoundingInfo"](this.absolutePosition, this.absolutePosition, effectiveMesh.worldMatrixFromCache);
  75398. }
  75399. this._updateSubMeshesBoundingInfo(effectiveMesh.worldMatrixFromCache);
  75400. return this;
  75401. };
  75402. /** @hidden */
  75403. AbstractMesh.prototype._updateSubMeshesBoundingInfo = function (matrix) {
  75404. if (!this.subMeshes) {
  75405. return this;
  75406. }
  75407. var count = this.subMeshes.length;
  75408. for (var subIndex = 0; subIndex < count; subIndex++) {
  75409. var subMesh = this.subMeshes[subIndex];
  75410. if (count > 1 || !subMesh.IsGlobal) {
  75411. subMesh.updateBoundingInfo(matrix);
  75412. }
  75413. }
  75414. return this;
  75415. };
  75416. /** @hidden */
  75417. AbstractMesh.prototype._afterComputeWorldMatrix = function () {
  75418. // Bounding info
  75419. this._updateBoundingInfo();
  75420. };
  75421. /**
  75422. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  75423. * A mesh is in the frustum if its bounding box intersects the frustum
  75424. * @param frustumPlanes defines the frustum to test
  75425. * @returns true if the mesh is in the frustum planes
  75426. */
  75427. AbstractMesh.prototype.isInFrustum = function (frustumPlanes) {
  75428. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  75429. };
  75430. /**
  75431. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  75432. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  75433. * @param frustumPlanes defines the frustum to test
  75434. * @returns true if the mesh is completely in the frustum planes
  75435. */
  75436. AbstractMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  75437. return this._boundingInfo !== null && this._boundingInfo.isCompletelyInFrustum(frustumPlanes);
  75438. };
  75439. /**
  75440. * True if the mesh intersects another mesh or a SolidParticle object
  75441. * @param mesh defines a target mesh or SolidParticle to test
  75442. * @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)
  75443. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  75444. * @returns true if there is an intersection
  75445. */
  75446. AbstractMesh.prototype.intersectsMesh = function (mesh, precise, includeDescendants) {
  75447. if (precise === void 0) { precise = false; }
  75448. if (!this._boundingInfo || !mesh._boundingInfo) {
  75449. return false;
  75450. }
  75451. if (this._boundingInfo.intersects(mesh._boundingInfo, precise)) {
  75452. return true;
  75453. }
  75454. if (includeDescendants) {
  75455. for (var _i = 0, _a = this.getChildMeshes(); _i < _a.length; _i++) {
  75456. var child = _a[_i];
  75457. if (child.intersectsMesh(mesh, precise, true)) {
  75458. return true;
  75459. }
  75460. }
  75461. }
  75462. return false;
  75463. };
  75464. /**
  75465. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  75466. * @param point defines the point to test
  75467. * @returns true if there is an intersection
  75468. */
  75469. AbstractMesh.prototype.intersectsPoint = function (point) {
  75470. if (!this._boundingInfo) {
  75471. return false;
  75472. }
  75473. return this._boundingInfo.intersectsPoint(point);
  75474. };
  75475. Object.defineProperty(AbstractMesh.prototype, "checkCollisions", {
  75476. // Collisions
  75477. /**
  75478. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  75479. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  75480. */
  75481. get: function () {
  75482. return this._checkCollisions;
  75483. },
  75484. set: function (collisionEnabled) {
  75485. this._checkCollisions = collisionEnabled;
  75486. },
  75487. enumerable: true,
  75488. configurable: true
  75489. });
  75490. Object.defineProperty(AbstractMesh.prototype, "collider", {
  75491. /**
  75492. * Gets Collider object used to compute collisions (not physics)
  75493. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  75494. */
  75495. get: function () {
  75496. return this._collider;
  75497. },
  75498. enumerable: true,
  75499. configurable: true
  75500. });
  75501. /**
  75502. * Move the mesh using collision engine
  75503. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  75504. * @param displacement defines the requested displacement vector
  75505. * @returns the current mesh
  75506. */
  75507. AbstractMesh.prototype.moveWithCollisions = function (displacement) {
  75508. var globalPosition = this.getAbsolutePosition();
  75509. globalPosition.addToRef(this.ellipsoidOffset, this._oldPositionForCollisions);
  75510. if (!this._collider) {
  75511. this._collider = new _Collisions_collider__WEBPACK_IMPORTED_MODULE_9__["Collider"]();
  75512. }
  75513. this._collider._radius = this.ellipsoid;
  75514. this.getScene().collisionCoordinator.getNewPosition(this._oldPositionForCollisions, displacement, this._collider, 3, this, this._onCollisionPositionChange, this.uniqueId);
  75515. return this;
  75516. };
  75517. // Collisions
  75518. /** @hidden */
  75519. AbstractMesh.prototype._collideForSubMesh = function (subMesh, transformMatrix, collider) {
  75520. this._generatePointsArray();
  75521. if (!this._positions) {
  75522. return this;
  75523. }
  75524. // Transformation
  75525. if (!subMesh._lastColliderWorldVertices || !subMesh._lastColliderTransformMatrix.equals(transformMatrix)) {
  75526. subMesh._lastColliderTransformMatrix = transformMatrix.clone();
  75527. subMesh._lastColliderWorldVertices = [];
  75528. subMesh._trianglePlanes = [];
  75529. var start = subMesh.verticesStart;
  75530. var end = (subMesh.verticesStart + subMesh.verticesCount);
  75531. for (var i = start; i < end; i++) {
  75532. subMesh._lastColliderWorldVertices.push(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this._positions[i], transformMatrix));
  75533. }
  75534. }
  75535. // Collide
  75536. collider._collide(subMesh._trianglePlanes, subMesh._lastColliderWorldVertices, this.getIndices(), subMesh.indexStart, subMesh.indexStart + subMesh.indexCount, subMesh.verticesStart, !!subMesh.getMaterial());
  75537. if (collider.collisionFound) {
  75538. collider.collidedMesh = this;
  75539. }
  75540. return this;
  75541. };
  75542. /** @hidden */
  75543. AbstractMesh.prototype._processCollisionsForSubMeshes = function (collider, transformMatrix) {
  75544. var subMeshes = this._scene.getCollidingSubMeshCandidates(this, collider);
  75545. var len = subMeshes.length;
  75546. for (var index = 0; index < len; index++) {
  75547. var subMesh = subMeshes.data[index];
  75548. // Bounding test
  75549. if (len > 1 && !subMesh._checkCollision(collider)) {
  75550. continue;
  75551. }
  75552. this._collideForSubMesh(subMesh, transformMatrix, collider);
  75553. }
  75554. return this;
  75555. };
  75556. /** @hidden */
  75557. AbstractMesh.prototype._checkCollision = function (collider) {
  75558. // Bounding box test
  75559. if (!this._boundingInfo || !this._boundingInfo._checkCollision(collider)) {
  75560. return this;
  75561. }
  75562. // Transformation matrix
  75563. var collisionsScalingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  75564. var collisionsTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  75565. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
  75566. this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
  75567. this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
  75568. return this;
  75569. };
  75570. // Picking
  75571. /** @hidden */
  75572. AbstractMesh.prototype._generatePointsArray = function () {
  75573. return false;
  75574. };
  75575. /**
  75576. * Checks if the passed Ray intersects with the mesh
  75577. * @param ray defines the ray to use
  75578. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  75579. * @returns the picking info
  75580. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75581. */
  75582. AbstractMesh.prototype.intersects = function (ray, fastCheck) {
  75583. var pickingInfo = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]();
  75584. var intersectionThreshold = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0;
  75585. var boundingInfo = this._boundingInfo;
  75586. if (!this.subMeshes || !boundingInfo || !ray.intersectsSphere(boundingInfo.boundingSphere, intersectionThreshold) || !ray.intersectsBox(boundingInfo.boundingBox, intersectionThreshold)) {
  75587. return pickingInfo;
  75588. }
  75589. if (!this._generatePointsArray()) {
  75590. return pickingInfo;
  75591. }
  75592. var intersectInfo = null;
  75593. var subMeshes = this._scene.getIntersectingSubMeshCandidates(this, ray);
  75594. var len = subMeshes.length;
  75595. for (var index = 0; index < len; index++) {
  75596. var subMesh = subMeshes.data[index];
  75597. // Bounding test
  75598. if (len > 1 && !subMesh.canIntersects(ray)) {
  75599. continue;
  75600. }
  75601. var currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck);
  75602. if (currentIntersectInfo) {
  75603. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  75604. intersectInfo = currentIntersectInfo;
  75605. intersectInfo.subMeshId = index;
  75606. if (fastCheck) {
  75607. break;
  75608. }
  75609. }
  75610. }
  75611. }
  75612. if (intersectInfo) {
  75613. // Get picked point
  75614. var world = this.getWorldMatrix();
  75615. var worldOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  75616. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  75617. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(ray.origin, world, worldOrigin);
  75618. ray.direction.scaleToRef(intersectInfo.distance, direction);
  75619. var worldDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(direction, world);
  75620. var pickedPoint = worldDirection.addInPlace(worldOrigin);
  75621. // Return result
  75622. pickingInfo.hit = true;
  75623. pickingInfo.distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(worldOrigin, pickedPoint);
  75624. pickingInfo.pickedPoint = pickedPoint;
  75625. pickingInfo.pickedMesh = this;
  75626. pickingInfo.bu = intersectInfo.bu || 0;
  75627. pickingInfo.bv = intersectInfo.bv || 0;
  75628. pickingInfo.faceId = intersectInfo.faceId;
  75629. pickingInfo.subMeshId = intersectInfo.subMeshId;
  75630. return pickingInfo;
  75631. }
  75632. return pickingInfo;
  75633. };
  75634. /**
  75635. * Clones the current mesh
  75636. * @param name defines the mesh name
  75637. * @param newParent defines the new mesh parent
  75638. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  75639. * @returns the new mesh
  75640. */
  75641. AbstractMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  75642. return null;
  75643. };
  75644. /**
  75645. * Disposes all the submeshes of the current meshnp
  75646. * @returns the current mesh
  75647. */
  75648. AbstractMesh.prototype.releaseSubMeshes = function () {
  75649. if (this.subMeshes) {
  75650. while (this.subMeshes.length) {
  75651. this.subMeshes[0].dispose();
  75652. }
  75653. }
  75654. else {
  75655. this.subMeshes = new Array();
  75656. }
  75657. return this;
  75658. };
  75659. /**
  75660. * Releases resources associated with this abstract mesh.
  75661. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  75662. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  75663. */
  75664. AbstractMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  75665. var _this = this;
  75666. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  75667. var index;
  75668. // Smart Array Retainers.
  75669. this.getScene().freeActiveMeshes();
  75670. this.getScene().freeRenderingGroups();
  75671. // Action manager
  75672. if (this.actionManager !== undefined && this.actionManager !== null) {
  75673. this.actionManager.dispose();
  75674. this.actionManager = null;
  75675. }
  75676. // Skeleton
  75677. this._skeleton = null;
  75678. // Intersections in progress
  75679. for (index = 0; index < this._intersectionsInProgress.length; index++) {
  75680. var other = this._intersectionsInProgress[index];
  75681. var pos = other._intersectionsInProgress.indexOf(this);
  75682. other._intersectionsInProgress.splice(pos, 1);
  75683. }
  75684. this._intersectionsInProgress = [];
  75685. // Lights
  75686. var lights = this.getScene().lights;
  75687. lights.forEach(function (light) {
  75688. var meshIndex = light.includedOnlyMeshes.indexOf(_this);
  75689. if (meshIndex !== -1) {
  75690. light.includedOnlyMeshes.splice(meshIndex, 1);
  75691. }
  75692. meshIndex = light.excludedMeshes.indexOf(_this);
  75693. if (meshIndex !== -1) {
  75694. light.excludedMeshes.splice(meshIndex, 1);
  75695. }
  75696. // Shadow generators
  75697. var generator = light.getShadowGenerator();
  75698. if (generator) {
  75699. var shadowMap = generator.getShadowMap();
  75700. if (shadowMap && shadowMap.renderList) {
  75701. meshIndex = shadowMap.renderList.indexOf(_this);
  75702. if (meshIndex !== -1) {
  75703. shadowMap.renderList.splice(meshIndex, 1);
  75704. }
  75705. }
  75706. }
  75707. });
  75708. // SubMeshes
  75709. if (this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") {
  75710. this.releaseSubMeshes();
  75711. }
  75712. // Query
  75713. var engine = this.getScene().getEngine();
  75714. if (this._occlusionQuery) {
  75715. this.isOcclusionQueryInProgress = false;
  75716. engine.deleteQuery(this._occlusionQuery);
  75717. this._occlusionQuery = null;
  75718. }
  75719. // Engine
  75720. engine.wipeCaches();
  75721. // Remove from scene
  75722. this.getScene().removeMesh(this);
  75723. if (disposeMaterialAndTextures) {
  75724. if (this.material) {
  75725. this.material.dispose(false, true);
  75726. }
  75727. }
  75728. if (!doNotRecurse) {
  75729. // Particles
  75730. for (index = 0; index < this.getScene().particleSystems.length; index++) {
  75731. if (this.getScene().particleSystems[index].emitter === this) {
  75732. this.getScene().particleSystems[index].dispose();
  75733. index--;
  75734. }
  75735. }
  75736. }
  75737. // facet data
  75738. if (this._facetData.facetDataEnabled) {
  75739. this.disableFacetData();
  75740. }
  75741. this.onAfterWorldMatrixUpdateObservable.clear();
  75742. this.onCollideObservable.clear();
  75743. this.onCollisionPositionChangeObservable.clear();
  75744. this.onRebuildObservable.clear();
  75745. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  75746. };
  75747. /**
  75748. * Adds the passed mesh as a child to the current mesh
  75749. * @param mesh defines the child mesh
  75750. * @returns the current mesh
  75751. */
  75752. AbstractMesh.prototype.addChild = function (mesh) {
  75753. mesh.setParent(this);
  75754. return this;
  75755. };
  75756. /**
  75757. * Removes the passed mesh from the current mesh children list
  75758. * @param mesh defines the child mesh
  75759. * @returns the current mesh
  75760. */
  75761. AbstractMesh.prototype.removeChild = function (mesh) {
  75762. mesh.setParent(null);
  75763. return this;
  75764. };
  75765. // Facet data
  75766. /** @hidden */
  75767. AbstractMesh.prototype._initFacetData = function () {
  75768. var data = this._facetData;
  75769. if (!data.facetNormals) {
  75770. data.facetNormals = new Array();
  75771. }
  75772. if (!data.facetPositions) {
  75773. data.facetPositions = new Array();
  75774. }
  75775. if (!data.facetPartitioning) {
  75776. data.facetPartitioning = new Array();
  75777. }
  75778. data.facetNb = (this.getIndices().length / 3) | 0;
  75779. data.partitioningSubdivisions = (data.partitioningSubdivisions) ? data.partitioningSubdivisions : 10; // default nb of partitioning subdivisions = 10
  75780. data.partitioningBBoxRatio = (data.partitioningBBoxRatio) ? data.partitioningBBoxRatio : 1.01; // default ratio 1.01 = the partitioning is 1% bigger than the bounding box
  75781. for (var f = 0; f < data.facetNb; f++) {
  75782. data.facetNormals[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  75783. data.facetPositions[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  75784. }
  75785. data.facetDataEnabled = true;
  75786. return this;
  75787. };
  75788. /**
  75789. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  75790. * This method can be called within the render loop.
  75791. * 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
  75792. * @returns the current mesh
  75793. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75794. */
  75795. AbstractMesh.prototype.updateFacetData = function () {
  75796. var data = this._facetData;
  75797. if (!data.facetDataEnabled) {
  75798. this._initFacetData();
  75799. }
  75800. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  75801. var indices = this.getIndices();
  75802. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  75803. var bInfo = this.getBoundingInfo();
  75804. if (data.facetDepthSort && !data.facetDepthSortEnabled) {
  75805. // init arrays, matrix and sort function on first call
  75806. data.facetDepthSortEnabled = true;
  75807. if (indices instanceof Uint16Array) {
  75808. data.depthSortedIndices = new Uint16Array(indices);
  75809. }
  75810. else if (indices instanceof Uint32Array) {
  75811. data.depthSortedIndices = new Uint32Array(indices);
  75812. }
  75813. else {
  75814. var needs32bits = false;
  75815. for (var i = 0; i < indices.length; i++) {
  75816. if (indices[i] > 65535) {
  75817. needs32bits = true;
  75818. break;
  75819. }
  75820. }
  75821. if (needs32bits) {
  75822. data.depthSortedIndices = new Uint32Array(indices);
  75823. }
  75824. else {
  75825. data.depthSortedIndices = new Uint16Array(indices);
  75826. }
  75827. }
  75828. data.facetDepthSortFunction = function (f1, f2) {
  75829. return (f2.sqDistance - f1.sqDistance);
  75830. };
  75831. if (!data.facetDepthSortFrom) {
  75832. var camera = this.getScene().activeCamera;
  75833. data.facetDepthSortFrom = (camera) ? camera.position : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  75834. }
  75835. data.depthSortedFacets = [];
  75836. for (var f = 0; f < data.facetNb; f++) {
  75837. var depthSortedFacet = { ind: f * 3, sqDistance: 0.0 };
  75838. data.depthSortedFacets.push(depthSortedFacet);
  75839. }
  75840. data.invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  75841. data.facetDepthSortOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  75842. }
  75843. 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"];
  75844. 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"];
  75845. 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"];
  75846. var bbSizeMax = (data.bbSize.x > data.bbSize.y) ? data.bbSize.x : data.bbSize.y;
  75847. bbSizeMax = (bbSizeMax > data.bbSize.z) ? bbSizeMax : data.bbSize.z;
  75848. data.subDiv.max = data.partitioningSubdivisions;
  75849. data.subDiv.X = Math.floor(data.subDiv.max * data.bbSize.x / bbSizeMax); // adjust the number of subdivisions per axis
  75850. data.subDiv.Y = Math.floor(data.subDiv.max * data.bbSize.y / bbSizeMax); // according to each bbox size per axis
  75851. data.subDiv.Z = Math.floor(data.subDiv.max * data.bbSize.z / bbSizeMax);
  75852. data.subDiv.X = data.subDiv.X < 1 ? 1 : data.subDiv.X; // at least one subdivision
  75853. data.subDiv.Y = data.subDiv.Y < 1 ? 1 : data.subDiv.Y;
  75854. data.subDiv.Z = data.subDiv.Z < 1 ? 1 : data.subDiv.Z;
  75855. // set the parameters for ComputeNormals()
  75856. data.facetParameters.facetNormals = this.getFacetLocalNormals();
  75857. data.facetParameters.facetPositions = this.getFacetLocalPositions();
  75858. data.facetParameters.facetPartitioning = this.getFacetLocalPartitioning();
  75859. data.facetParameters.bInfo = bInfo;
  75860. data.facetParameters.bbSize = data.bbSize;
  75861. data.facetParameters.subDiv = data.subDiv;
  75862. data.facetParameters.ratio = this.partitioningBBoxRatio;
  75863. data.facetParameters.depthSort = data.facetDepthSort;
  75864. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  75865. this.computeWorldMatrix(true);
  75866. this._worldMatrix.invertToRef(data.invertedMatrix);
  75867. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
  75868. data.facetParameters.distanceTo = data.facetDepthSortOrigin;
  75869. }
  75870. data.facetParameters.depthSortedFacets = data.depthSortedFacets;
  75871. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, data.facetParameters);
  75872. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  75873. data.depthSortedFacets.sort(data.facetDepthSortFunction);
  75874. var l = (data.depthSortedIndices.length / 3) | 0;
  75875. for (var f = 0; f < l; f++) {
  75876. var sind = data.depthSortedFacets[f].ind;
  75877. data.depthSortedIndices[f * 3] = indices[sind];
  75878. data.depthSortedIndices[f * 3 + 1] = indices[sind + 1];
  75879. data.depthSortedIndices[f * 3 + 2] = indices[sind + 2];
  75880. }
  75881. this.updateIndices(data.depthSortedIndices);
  75882. }
  75883. return this;
  75884. };
  75885. /**
  75886. * Returns the facetLocalNormals array.
  75887. * The normals are expressed in the mesh local spac
  75888. * @returns an array of Vector3
  75889. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75890. */
  75891. AbstractMesh.prototype.getFacetLocalNormals = function () {
  75892. if (!this._facetData.facetNormals) {
  75893. this.updateFacetData();
  75894. }
  75895. return this._facetData.facetNormals;
  75896. };
  75897. /**
  75898. * Returns the facetLocalPositions array.
  75899. * The facet positions are expressed in the mesh local space
  75900. * @returns an array of Vector3
  75901. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75902. */
  75903. AbstractMesh.prototype.getFacetLocalPositions = function () {
  75904. if (!this._facetData.facetPositions) {
  75905. this.updateFacetData();
  75906. }
  75907. return this._facetData.facetPositions;
  75908. };
  75909. /**
  75910. * Returns the facetLocalPartioning array
  75911. * @returns an array of array of numbers
  75912. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75913. */
  75914. AbstractMesh.prototype.getFacetLocalPartitioning = function () {
  75915. if (!this._facetData.facetPartitioning) {
  75916. this.updateFacetData();
  75917. }
  75918. return this._facetData.facetPartitioning;
  75919. };
  75920. /**
  75921. * Returns the i-th facet position in the world system.
  75922. * This method allocates a new Vector3 per call
  75923. * @param i defines the facet index
  75924. * @returns a new Vector3
  75925. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75926. */
  75927. AbstractMesh.prototype.getFacetPosition = function (i) {
  75928. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  75929. this.getFacetPositionToRef(i, pos);
  75930. return pos;
  75931. };
  75932. /**
  75933. * Sets the reference Vector3 with the i-th facet position in the world system
  75934. * @param i defines the facet index
  75935. * @param ref defines the target vector
  75936. * @returns the current mesh
  75937. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75938. */
  75939. AbstractMesh.prototype.getFacetPositionToRef = function (i, ref) {
  75940. var localPos = (this.getFacetLocalPositions())[i];
  75941. var world = this.getWorldMatrix();
  75942. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(localPos, world, ref);
  75943. return this;
  75944. };
  75945. /**
  75946. * Returns the i-th facet normal in the world system.
  75947. * This method allocates a new Vector3 per call
  75948. * @param i defines the facet index
  75949. * @returns a new Vector3
  75950. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75951. */
  75952. AbstractMesh.prototype.getFacetNormal = function (i) {
  75953. var norm = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  75954. this.getFacetNormalToRef(i, norm);
  75955. return norm;
  75956. };
  75957. /**
  75958. * Sets the reference Vector3 with the i-th facet normal in the world system
  75959. * @param i defines the facet index
  75960. * @param ref defines the target vector
  75961. * @returns the current mesh
  75962. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75963. */
  75964. AbstractMesh.prototype.getFacetNormalToRef = function (i, ref) {
  75965. var localNorm = (this.getFacetLocalNormals())[i];
  75966. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localNorm, this.getWorldMatrix(), ref);
  75967. return this;
  75968. };
  75969. /**
  75970. * 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)
  75971. * @param x defines x coordinate
  75972. * @param y defines y coordinate
  75973. * @param z defines z coordinate
  75974. * @returns the array of facet indexes
  75975. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75976. */
  75977. AbstractMesh.prototype.getFacetsAtLocalCoordinates = function (x, y, z) {
  75978. var bInfo = this.getBoundingInfo();
  75979. var data = this._facetData;
  75980. var ox = Math.floor((x - bInfo.minimum.x * data.partitioningBBoxRatio) * data.subDiv.X * data.partitioningBBoxRatio / data.bbSize.x);
  75981. var oy = Math.floor((y - bInfo.minimum.y * data.partitioningBBoxRatio) * data.subDiv.Y * data.partitioningBBoxRatio / data.bbSize.y);
  75982. var oz = Math.floor((z - bInfo.minimum.z * data.partitioningBBoxRatio) * data.subDiv.Z * data.partitioningBBoxRatio / data.bbSize.z);
  75983. if (ox < 0 || ox > data.subDiv.max || oy < 0 || oy > data.subDiv.max || oz < 0 || oz > data.subDiv.max) {
  75984. return null;
  75985. }
  75986. return data.facetPartitioning[ox + data.subDiv.max * oy + data.subDiv.max * data.subDiv.max * oz];
  75987. };
  75988. /**
  75989. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  75990. * @param projected sets as the (x,y,z) world projection on the facet
  75991. * @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
  75992. * @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
  75993. * @param x defines x coordinate
  75994. * @param y defines y coordinate
  75995. * @param z defines z coordinate
  75996. * @returns the face index if found (or null instead)
  75997. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75998. */
  75999. AbstractMesh.prototype.getClosestFacetAtCoordinates = function (x, y, z, projected, checkFace, facing) {
  76000. if (checkFace === void 0) { checkFace = false; }
  76001. if (facing === void 0) { facing = true; }
  76002. var world = this.getWorldMatrix();
  76003. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5];
  76004. world.invertToRef(invMat);
  76005. var invVect = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[8];
  76006. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, invMat, invVect); // transform (x,y,z) to coordinates in the mesh local space
  76007. var closest = this.getClosestFacetAtLocalCoordinates(invVect.x, invVect.y, invVect.z, projected, checkFace, facing);
  76008. if (projected) {
  76009. // tranform the local computed projected vector to world coordinates
  76010. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(projected.x, projected.y, projected.z, world, projected);
  76011. }
  76012. return closest;
  76013. };
  76014. /**
  76015. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  76016. * @param projected sets as the (x,y,z) local projection on the facet
  76017. * @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
  76018. * @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
  76019. * @param x defines x coordinate
  76020. * @param y defines y coordinate
  76021. * @param z defines z coordinate
  76022. * @returns the face index if found (or null instead)
  76023. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  76024. */
  76025. AbstractMesh.prototype.getClosestFacetAtLocalCoordinates = function (x, y, z, projected, checkFace, facing) {
  76026. if (checkFace === void 0) { checkFace = false; }
  76027. if (facing === void 0) { facing = true; }
  76028. var closest = null;
  76029. var tmpx = 0.0;
  76030. var tmpy = 0.0;
  76031. var tmpz = 0.0;
  76032. var d = 0.0; // tmp dot facet normal * facet position
  76033. var t0 = 0.0;
  76034. var projx = 0.0;
  76035. var projy = 0.0;
  76036. var projz = 0.0;
  76037. // Get all the facets in the same partitioning block than (x, y, z)
  76038. var facetPositions = this.getFacetLocalPositions();
  76039. var facetNormals = this.getFacetLocalNormals();
  76040. var facetsInBlock = this.getFacetsAtLocalCoordinates(x, y, z);
  76041. if (!facetsInBlock) {
  76042. return null;
  76043. }
  76044. // Get the closest facet to (x, y, z)
  76045. var shortest = Number.MAX_VALUE; // init distance vars
  76046. var tmpDistance = shortest;
  76047. var fib; // current facet in the block
  76048. var norm; // current facet normal
  76049. var p0; // current facet barycenter position
  76050. // loop on all the facets in the current partitioning block
  76051. for (var idx = 0; idx < facetsInBlock.length; idx++) {
  76052. fib = facetsInBlock[idx];
  76053. norm = facetNormals[fib];
  76054. p0 = facetPositions[fib];
  76055. d = (x - p0.x) * norm.x + (y - p0.y) * norm.y + (z - p0.z) * norm.z;
  76056. if (!checkFace || (checkFace && facing && d >= 0.0) || (checkFace && !facing && d <= 0.0)) {
  76057. // compute (x,y,z) projection on the facet = (projx, projy, projz)
  76058. d = norm.x * p0.x + norm.y * p0.y + norm.z * p0.z;
  76059. t0 = -(norm.x * x + norm.y * y + norm.z * z - d) / (norm.x * norm.x + norm.y * norm.y + norm.z * norm.z);
  76060. projx = x + norm.x * t0;
  76061. projy = y + norm.y * t0;
  76062. projz = z + norm.z * t0;
  76063. tmpx = projx - x;
  76064. tmpy = projy - y;
  76065. tmpz = projz - z;
  76066. tmpDistance = tmpx * tmpx + tmpy * tmpy + tmpz * tmpz; // compute length between (x, y, z) and its projection on the facet
  76067. if (tmpDistance < shortest) { // just keep the closest facet to (x, y, z)
  76068. shortest = tmpDistance;
  76069. closest = fib;
  76070. if (projected) {
  76071. projected.x = projx;
  76072. projected.y = projy;
  76073. projected.z = projz;
  76074. }
  76075. }
  76076. }
  76077. }
  76078. return closest;
  76079. };
  76080. /**
  76081. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  76082. * @returns the parameters
  76083. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  76084. */
  76085. AbstractMesh.prototype.getFacetDataParameters = function () {
  76086. return this._facetData.facetParameters;
  76087. };
  76088. /**
  76089. * Disables the feature FacetData and frees the related memory
  76090. * @returns the current mesh
  76091. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  76092. */
  76093. AbstractMesh.prototype.disableFacetData = function () {
  76094. if (this._facetData.facetDataEnabled) {
  76095. this._facetData.facetDataEnabled = false;
  76096. this._facetData.facetPositions = new Array();
  76097. this._facetData.facetNormals = new Array();
  76098. this._facetData.facetPartitioning = new Array();
  76099. this._facetData.facetParameters = null;
  76100. this._facetData.depthSortedIndices = new Uint32Array(0);
  76101. }
  76102. return this;
  76103. };
  76104. /**
  76105. * Updates the AbstractMesh indices array
  76106. * @param indices defines the data source
  76107. * @returns the current mesh
  76108. */
  76109. AbstractMesh.prototype.updateIndices = function (indices) {
  76110. return this;
  76111. };
  76112. /**
  76113. * Creates new normals data for the mesh
  76114. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  76115. * @returns the current mesh
  76116. */
  76117. AbstractMesh.prototype.createNormals = function (updatable) {
  76118. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  76119. var indices = this.getIndices();
  76120. var normals;
  76121. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  76122. normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  76123. }
  76124. else {
  76125. normals = [];
  76126. }
  76127. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, { useRightHandedSystem: this.getScene().useRightHandedSystem });
  76128. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind, normals, updatable);
  76129. return this;
  76130. };
  76131. /**
  76132. * Align the mesh with a normal
  76133. * @param normal defines the normal to use
  76134. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  76135. * @returns the current mesh
  76136. */
  76137. AbstractMesh.prototype.alignWithNormal = function (normal, upDirection) {
  76138. if (!upDirection) {
  76139. upDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y;
  76140. }
  76141. var axisX = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  76142. var axisZ = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  76143. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(upDirection, normal, axisZ);
  76144. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(normal, axisZ, axisX);
  76145. if (this.rotationQuaternion) {
  76146. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationQuaternionFromAxisToRef(axisX, normal, axisZ, this.rotationQuaternion);
  76147. }
  76148. else {
  76149. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].RotationFromAxisToRef(axisX, normal, axisZ, this.rotation);
  76150. }
  76151. return this;
  76152. };
  76153. /** @hidden */
  76154. AbstractMesh.prototype._checkOcclusionQuery = function () {
  76155. return false;
  76156. };
  76157. /** No occlusion */
  76158. AbstractMesh.OCCLUSION_TYPE_NONE = 0;
  76159. /** Occlusion set to optimisitic */
  76160. AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC = 1;
  76161. /** Occlusion set to strict */
  76162. AbstractMesh.OCCLUSION_TYPE_STRICT = 2;
  76163. /** Use an accurante occlusion algorithm */
  76164. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0;
  76165. /** Use a conservative occlusion algorithm */
  76166. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1;
  76167. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  76168. * Test order :
  76169. * Is the bounding sphere outside the frustum ?
  76170. * If not, are the bounding box vertices outside the frustum ?
  76171. * It not, then the cullable object is in the frustum.
  76172. */
  76173. AbstractMesh.CULLINGSTRATEGY_STANDARD = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD;
  76174. /** Culling strategy : Bounding Sphere Only.
  76175. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  76176. * It's also less accurate than the standard because some not visible objects can still be selected.
  76177. * Test : is the bounding sphere outside the frustum ?
  76178. * If not, then the cullable object is in the frustum.
  76179. */
  76180. AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  76181. /** Culling strategy : Optimistic Inclusion.
  76182. * This in an inclusion test first, then the standard exclusion test.
  76183. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  76184. * 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.
  76185. * Anyway, it's as accurate as the standard strategy.
  76186. * Test :
  76187. * Is the cullable object bounding sphere center in the frustum ?
  76188. * If not, apply the default culling strategy.
  76189. */
  76190. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION;
  76191. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  76192. * This in an inclusion test first, then the bounding sphere only exclusion test.
  76193. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  76194. * 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.
  76195. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  76196. * Test :
  76197. * Is the cullable object bounding sphere center in the frustum ?
  76198. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  76199. */
  76200. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;
  76201. return AbstractMesh;
  76202. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"]));
  76203. /***/ }),
  76204. /***/ "./Meshes/buffer.ts":
  76205. /*!**************************!*\
  76206. !*** ./Meshes/buffer.ts ***!
  76207. \**************************/
  76208. /*! exports provided: Buffer, VertexBuffer */
  76209. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76210. "use strict";
  76211. __webpack_require__.r(__webpack_exports__);
  76212. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return Buffer; });
  76213. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return VertexBuffer; });
  76214. /**
  76215. * Class used to store data that will be store in GPU memory
  76216. */
  76217. var Buffer = /** @class */ (function () {
  76218. /**
  76219. * Constructor
  76220. * @param engine the engine
  76221. * @param data the data to use for this buffer
  76222. * @param updatable whether the data is updatable
  76223. * @param stride the stride (optional)
  76224. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  76225. * @param instanced whether the buffer is instanced (optional)
  76226. * @param useBytes set to true if the stride in in bytes (optional)
  76227. */
  76228. function Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes) {
  76229. if (stride === void 0) { stride = 0; }
  76230. if (postponeInternalCreation === void 0) { postponeInternalCreation = false; }
  76231. if (instanced === void 0) { instanced = false; }
  76232. if (useBytes === void 0) { useBytes = false; }
  76233. if (engine.getScene) { // old versions of VertexBuffer accepted 'mesh' instead of 'engine'
  76234. this._engine = engine.getScene().getEngine();
  76235. }
  76236. else {
  76237. this._engine = engine;
  76238. }
  76239. this._updatable = updatable;
  76240. this._instanced = instanced;
  76241. this._data = data;
  76242. this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;
  76243. if (!postponeInternalCreation) { // by default
  76244. this.create();
  76245. }
  76246. }
  76247. /**
  76248. * Create a new VertexBuffer based on the current buffer
  76249. * @param kind defines the vertex buffer kind (position, normal, etc.)
  76250. * @param offset defines offset in the buffer (0 by default)
  76251. * @param size defines the size in floats of attributes (position is 3 for instance)
  76252. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  76253. * @param instanced defines if the vertex buffer contains indexed data
  76254. * @param useBytes defines if the offset and stride are in bytes
  76255. * @returns the new vertex buffer
  76256. */
  76257. Buffer.prototype.createVertexBuffer = function (kind, offset, size, stride, instanced, useBytes) {
  76258. if (useBytes === void 0) { useBytes = false; }
  76259. var byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;
  76260. var byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;
  76261. // a lot of these parameters are ignored as they are overriden by the buffer
  76262. return new VertexBuffer(this._engine, this, kind, this._updatable, true, byteStride, instanced === undefined ? this._instanced : instanced, byteOffset, size, undefined, undefined, true);
  76263. };
  76264. // Properties
  76265. /**
  76266. * Gets a boolean indicating if the Buffer is updatable?
  76267. * @returns true if the buffer is updatable
  76268. */
  76269. Buffer.prototype.isUpdatable = function () {
  76270. return this._updatable;
  76271. };
  76272. /**
  76273. * Gets current buffer's data
  76274. * @returns a DataArray or null
  76275. */
  76276. Buffer.prototype.getData = function () {
  76277. return this._data;
  76278. };
  76279. /**
  76280. * Gets underlying native buffer
  76281. * @returns underlying native buffer
  76282. */
  76283. Buffer.prototype.getBuffer = function () {
  76284. return this._buffer;
  76285. };
  76286. /**
  76287. * Gets the stride in float32 units (i.e. byte stride / 4).
  76288. * May not be an integer if the byte stride is not divisible by 4.
  76289. * DEPRECATED. Use byteStride instead.
  76290. * @returns the stride in float32 units
  76291. */
  76292. Buffer.prototype.getStrideSize = function () {
  76293. return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
  76294. };
  76295. // Methods
  76296. /**
  76297. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  76298. * @param data defines the data to store
  76299. */
  76300. Buffer.prototype.create = function (data) {
  76301. if (data === void 0) { data = null; }
  76302. if (!data && this._buffer) {
  76303. return; // nothing to do
  76304. }
  76305. data = data || this._data;
  76306. if (!data) {
  76307. return;
  76308. }
  76309. if (!this._buffer) { // create buffer
  76310. if (this._updatable) {
  76311. this._buffer = this._engine.createDynamicVertexBuffer(data);
  76312. this._data = data;
  76313. }
  76314. else {
  76315. this._buffer = this._engine.createVertexBuffer(data);
  76316. }
  76317. }
  76318. else if (this._updatable) { // update buffer
  76319. this._engine.updateDynamicVertexBuffer(this._buffer, data);
  76320. this._data = data;
  76321. }
  76322. };
  76323. /** @hidden */
  76324. Buffer.prototype._rebuild = function () {
  76325. this._buffer = null;
  76326. this.create(this._data);
  76327. };
  76328. /**
  76329. * Update current buffer data
  76330. * @param data defines the data to store
  76331. */
  76332. Buffer.prototype.update = function (data) {
  76333. this.create(data);
  76334. };
  76335. /**
  76336. * Updates the data directly.
  76337. * @param data the new data
  76338. * @param offset the new offset
  76339. * @param vertexCount the vertex count (optional)
  76340. * @param useBytes set to true if the offset is in bytes
  76341. */
  76342. Buffer.prototype.updateDirectly = function (data, offset, vertexCount, useBytes) {
  76343. if (useBytes === void 0) { useBytes = false; }
  76344. if (!this._buffer) {
  76345. return;
  76346. }
  76347. if (this._updatable) { // update buffer
  76348. this._engine.updateDynamicVertexBuffer(this._buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, (vertexCount ? vertexCount * this.byteStride : undefined));
  76349. this._data = null;
  76350. }
  76351. };
  76352. /**
  76353. * Release all resources
  76354. */
  76355. Buffer.prototype.dispose = function () {
  76356. if (!this._buffer) {
  76357. return;
  76358. }
  76359. if (this._engine._releaseBuffer(this._buffer)) {
  76360. this._buffer = null;
  76361. }
  76362. };
  76363. return Buffer;
  76364. }());
  76365. /**
  76366. * Specialized buffer used to store vertex data
  76367. */
  76368. var VertexBuffer = /** @class */ (function () {
  76369. /**
  76370. * Constructor
  76371. * @param engine the engine
  76372. * @param data the data to use for this vertex buffer
  76373. * @param kind the vertex buffer kind
  76374. * @param updatable whether the data is updatable
  76375. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  76376. * @param stride the stride (optional)
  76377. * @param instanced whether the buffer is instanced (optional)
  76378. * @param offset the offset of the data (optional)
  76379. * @param size the number of components (optional)
  76380. * @param type the type of the component (optional)
  76381. * @param normalized whether the data contains normalized data (optional)
  76382. * @param useBytes set to true if stride and offset are in bytes (optional)
  76383. */
  76384. function VertexBuffer(engine, data, kind, updatable, postponeInternalCreation, stride, instanced, offset, size, type, normalized, useBytes) {
  76385. if (normalized === void 0) { normalized = false; }
  76386. if (useBytes === void 0) { useBytes = false; }
  76387. if (data instanceof Buffer) {
  76388. this._buffer = data;
  76389. this._ownsBuffer = false;
  76390. }
  76391. else {
  76392. this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes);
  76393. this._ownsBuffer = true;
  76394. }
  76395. this._kind = kind;
  76396. if (type == undefined) {
  76397. var data_1 = this.getData();
  76398. this.type = VertexBuffer.FLOAT;
  76399. if (data_1 instanceof Int8Array) {
  76400. this.type = VertexBuffer.BYTE;
  76401. }
  76402. else if (data_1 instanceof Uint8Array) {
  76403. this.type = VertexBuffer.UNSIGNED_BYTE;
  76404. }
  76405. else if (data_1 instanceof Int16Array) {
  76406. this.type = VertexBuffer.SHORT;
  76407. }
  76408. else if (data_1 instanceof Uint16Array) {
  76409. this.type = VertexBuffer.UNSIGNED_SHORT;
  76410. }
  76411. else if (data_1 instanceof Int32Array) {
  76412. this.type = VertexBuffer.INT;
  76413. }
  76414. else if (data_1 instanceof Uint32Array) {
  76415. this.type = VertexBuffer.UNSIGNED_INT;
  76416. }
  76417. }
  76418. else {
  76419. this.type = type;
  76420. }
  76421. var typeByteLength = VertexBuffer.GetTypeByteLength(this.type);
  76422. if (useBytes) {
  76423. this._size = size || (stride ? (stride / typeByteLength) : VertexBuffer.DeduceStride(kind));
  76424. this.byteStride = stride || this._buffer.byteStride || (this._size * typeByteLength);
  76425. this.byteOffset = offset || 0;
  76426. }
  76427. else {
  76428. this._size = size || stride || VertexBuffer.DeduceStride(kind);
  76429. this.byteStride = stride ? (stride * typeByteLength) : (this._buffer.byteStride || (this._size * typeByteLength));
  76430. this.byteOffset = (offset || 0) * typeByteLength;
  76431. }
  76432. this.normalized = normalized;
  76433. this._instanced = instanced !== undefined ? instanced : false;
  76434. this._instanceDivisor = instanced ? 1 : 0;
  76435. }
  76436. Object.defineProperty(VertexBuffer.prototype, "instanceDivisor", {
  76437. /**
  76438. * Gets or sets the instance divisor when in instanced mode
  76439. */
  76440. get: function () {
  76441. return this._instanceDivisor;
  76442. },
  76443. set: function (value) {
  76444. this._instanceDivisor = value;
  76445. if (value == 0) {
  76446. this._instanced = false;
  76447. }
  76448. else {
  76449. this._instanced = true;
  76450. }
  76451. },
  76452. enumerable: true,
  76453. configurable: true
  76454. });
  76455. /** @hidden */
  76456. VertexBuffer.prototype._rebuild = function () {
  76457. if (!this._buffer) {
  76458. return;
  76459. }
  76460. this._buffer._rebuild();
  76461. };
  76462. /**
  76463. * Returns the kind of the VertexBuffer (string)
  76464. * @returns a string
  76465. */
  76466. VertexBuffer.prototype.getKind = function () {
  76467. return this._kind;
  76468. };
  76469. // Properties
  76470. /**
  76471. * Gets a boolean indicating if the VertexBuffer is updatable?
  76472. * @returns true if the buffer is updatable
  76473. */
  76474. VertexBuffer.prototype.isUpdatable = function () {
  76475. return this._buffer.isUpdatable();
  76476. };
  76477. /**
  76478. * Gets current buffer's data
  76479. * @returns a DataArray or null
  76480. */
  76481. VertexBuffer.prototype.getData = function () {
  76482. return this._buffer.getData();
  76483. };
  76484. /**
  76485. * Gets underlying native buffer
  76486. * @returns underlying native buffer
  76487. */
  76488. VertexBuffer.prototype.getBuffer = function () {
  76489. return this._buffer.getBuffer();
  76490. };
  76491. /**
  76492. * Gets the stride in float32 units (i.e. byte stride / 4).
  76493. * May not be an integer if the byte stride is not divisible by 4.
  76494. * DEPRECATED. Use byteStride instead.
  76495. * @returns the stride in float32 units
  76496. */
  76497. VertexBuffer.prototype.getStrideSize = function () {
  76498. return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);
  76499. };
  76500. /**
  76501. * Returns the offset as a multiple of the type byte length.
  76502. * DEPRECATED. Use byteOffset instead.
  76503. * @returns the offset in bytes
  76504. */
  76505. VertexBuffer.prototype.getOffset = function () {
  76506. return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);
  76507. };
  76508. /**
  76509. * Returns the number of components per vertex attribute (integer)
  76510. * @returns the size in float
  76511. */
  76512. VertexBuffer.prototype.getSize = function () {
  76513. return this._size;
  76514. };
  76515. /**
  76516. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  76517. * @returns true if this buffer is instanced
  76518. */
  76519. VertexBuffer.prototype.getIsInstanced = function () {
  76520. return this._instanced;
  76521. };
  76522. /**
  76523. * Returns the instancing divisor, zero for non-instanced (integer).
  76524. * @returns a number
  76525. */
  76526. VertexBuffer.prototype.getInstanceDivisor = function () {
  76527. return this._instanceDivisor;
  76528. };
  76529. // Methods
  76530. /**
  76531. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  76532. * @param data defines the data to store
  76533. */
  76534. VertexBuffer.prototype.create = function (data) {
  76535. this._buffer.create(data);
  76536. };
  76537. /**
  76538. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  76539. * This function will create a new buffer if the current one is not updatable
  76540. * @param data defines the data to store
  76541. */
  76542. VertexBuffer.prototype.update = function (data) {
  76543. this._buffer.update(data);
  76544. };
  76545. /**
  76546. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  76547. * Returns the directly updated WebGLBuffer.
  76548. * @param data the new data
  76549. * @param offset the new offset
  76550. * @param useBytes set to true if the offset is in bytes
  76551. */
  76552. VertexBuffer.prototype.updateDirectly = function (data, offset, useBytes) {
  76553. if (useBytes === void 0) { useBytes = false; }
  76554. this._buffer.updateDirectly(data, offset, undefined, useBytes);
  76555. };
  76556. /**
  76557. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  76558. */
  76559. VertexBuffer.prototype.dispose = function () {
  76560. if (this._ownsBuffer) {
  76561. this._buffer.dispose();
  76562. }
  76563. };
  76564. /**
  76565. * Enumerates each value of this vertex buffer as numbers.
  76566. * @param count the number of values to enumerate
  76567. * @param callback the callback function called for each value
  76568. */
  76569. VertexBuffer.prototype.forEach = function (count, callback) {
  76570. VertexBuffer.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);
  76571. };
  76572. /**
  76573. * Deduces the stride given a kind.
  76574. * @param kind The kind string to deduce
  76575. * @returns The deduced stride
  76576. */
  76577. VertexBuffer.DeduceStride = function (kind) {
  76578. switch (kind) {
  76579. case VertexBuffer.UVKind:
  76580. case VertexBuffer.UV2Kind:
  76581. case VertexBuffer.UV3Kind:
  76582. case VertexBuffer.UV4Kind:
  76583. case VertexBuffer.UV5Kind:
  76584. case VertexBuffer.UV6Kind:
  76585. return 2;
  76586. case VertexBuffer.NormalKind:
  76587. case VertexBuffer.PositionKind:
  76588. return 3;
  76589. case VertexBuffer.ColorKind:
  76590. case VertexBuffer.MatricesIndicesKind:
  76591. case VertexBuffer.MatricesIndicesExtraKind:
  76592. case VertexBuffer.MatricesWeightsKind:
  76593. case VertexBuffer.MatricesWeightsExtraKind:
  76594. case VertexBuffer.TangentKind:
  76595. return 4;
  76596. default:
  76597. throw new Error("Invalid kind '" + kind + "'");
  76598. }
  76599. };
  76600. /**
  76601. * Gets the byte length of the given type.
  76602. * @param type the type
  76603. * @returns the number of bytes
  76604. */
  76605. VertexBuffer.GetTypeByteLength = function (type) {
  76606. switch (type) {
  76607. case VertexBuffer.BYTE:
  76608. case VertexBuffer.UNSIGNED_BYTE:
  76609. return 1;
  76610. case VertexBuffer.SHORT:
  76611. case VertexBuffer.UNSIGNED_SHORT:
  76612. return 2;
  76613. case VertexBuffer.INT:
  76614. case VertexBuffer.FLOAT:
  76615. return 4;
  76616. default:
  76617. throw new Error("Invalid type '" + type + "'");
  76618. }
  76619. };
  76620. /**
  76621. * Enumerates each value of the given parameters as numbers.
  76622. * @param data the data to enumerate
  76623. * @param byteOffset the byte offset of the data
  76624. * @param byteStride the byte stride of the data
  76625. * @param componentCount the number of components per element
  76626. * @param componentType the type of the component
  76627. * @param count the total number of components
  76628. * @param normalized whether the data is normalized
  76629. * @param callback the callback function called for each value
  76630. */
  76631. VertexBuffer.ForEach = function (data, byteOffset, byteStride, componentCount, componentType, count, normalized, callback) {
  76632. if (data instanceof Array) {
  76633. var offset = byteOffset / 4;
  76634. var stride = byteStride / 4;
  76635. for (var index = 0; index < count; index += componentCount) {
  76636. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  76637. callback(data[offset + componentIndex], index + componentIndex);
  76638. }
  76639. offset += stride;
  76640. }
  76641. }
  76642. else {
  76643. var dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);
  76644. var componentByteLength = VertexBuffer.GetTypeByteLength(componentType);
  76645. for (var index = 0; index < count; index += componentCount) {
  76646. var componentByteOffset = byteOffset;
  76647. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  76648. var value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);
  76649. callback(value, index + componentIndex);
  76650. componentByteOffset += componentByteLength;
  76651. }
  76652. byteOffset += byteStride;
  76653. }
  76654. }
  76655. };
  76656. VertexBuffer._GetFloatValue = function (dataView, type, byteOffset, normalized) {
  76657. switch (type) {
  76658. case VertexBuffer.BYTE: {
  76659. var value = dataView.getInt8(byteOffset);
  76660. if (normalized) {
  76661. value = Math.max(value / 127, -1);
  76662. }
  76663. return value;
  76664. }
  76665. case VertexBuffer.UNSIGNED_BYTE: {
  76666. var value = dataView.getUint8(byteOffset);
  76667. if (normalized) {
  76668. value = value / 255;
  76669. }
  76670. return value;
  76671. }
  76672. case VertexBuffer.SHORT: {
  76673. var value = dataView.getInt16(byteOffset, true);
  76674. if (normalized) {
  76675. value = Math.max(value / 16383, -1);
  76676. }
  76677. return value;
  76678. }
  76679. case VertexBuffer.UNSIGNED_SHORT: {
  76680. var value = dataView.getUint16(byteOffset, true);
  76681. if (normalized) {
  76682. value = value / 65535;
  76683. }
  76684. return value;
  76685. }
  76686. case VertexBuffer.FLOAT: {
  76687. return dataView.getFloat32(byteOffset, true);
  76688. }
  76689. default: {
  76690. throw new Error("Invalid component type " + type);
  76691. }
  76692. }
  76693. };
  76694. /**
  76695. * The byte type.
  76696. */
  76697. VertexBuffer.BYTE = 5120;
  76698. /**
  76699. * The unsigned byte type.
  76700. */
  76701. VertexBuffer.UNSIGNED_BYTE = 5121;
  76702. /**
  76703. * The short type.
  76704. */
  76705. VertexBuffer.SHORT = 5122;
  76706. /**
  76707. * The unsigned short type.
  76708. */
  76709. VertexBuffer.UNSIGNED_SHORT = 5123;
  76710. /**
  76711. * The integer type.
  76712. */
  76713. VertexBuffer.INT = 5124;
  76714. /**
  76715. * The unsigned integer type.
  76716. */
  76717. VertexBuffer.UNSIGNED_INT = 5125;
  76718. /**
  76719. * The float type.
  76720. */
  76721. VertexBuffer.FLOAT = 5126;
  76722. // Enums
  76723. /**
  76724. * Positions
  76725. */
  76726. VertexBuffer.PositionKind = "position";
  76727. /**
  76728. * Normals
  76729. */
  76730. VertexBuffer.NormalKind = "normal";
  76731. /**
  76732. * Tangents
  76733. */
  76734. VertexBuffer.TangentKind = "tangent";
  76735. /**
  76736. * Texture coordinates
  76737. */
  76738. VertexBuffer.UVKind = "uv";
  76739. /**
  76740. * Texture coordinates 2
  76741. */
  76742. VertexBuffer.UV2Kind = "uv2";
  76743. /**
  76744. * Texture coordinates 3
  76745. */
  76746. VertexBuffer.UV3Kind = "uv3";
  76747. /**
  76748. * Texture coordinates 4
  76749. */
  76750. VertexBuffer.UV4Kind = "uv4";
  76751. /**
  76752. * Texture coordinates 5
  76753. */
  76754. VertexBuffer.UV5Kind = "uv5";
  76755. /**
  76756. * Texture coordinates 6
  76757. */
  76758. VertexBuffer.UV6Kind = "uv6";
  76759. /**
  76760. * Colors
  76761. */
  76762. VertexBuffer.ColorKind = "color";
  76763. /**
  76764. * Matrix indices (for bones)
  76765. */
  76766. VertexBuffer.MatricesIndicesKind = "matricesIndices";
  76767. /**
  76768. * Matrix weights (for bones)
  76769. */
  76770. VertexBuffer.MatricesWeightsKind = "matricesWeights";
  76771. /**
  76772. * Additional matrix indices (for bones)
  76773. */
  76774. VertexBuffer.MatricesIndicesExtraKind = "matricesIndicesExtra";
  76775. /**
  76776. * Additional matrix weights (for bones)
  76777. */
  76778. VertexBuffer.MatricesWeightsExtraKind = "matricesWeightsExtra";
  76779. return VertexBuffer;
  76780. }());
  76781. /***/ }),
  76782. /***/ "./Meshes/csg.ts":
  76783. /*!***********************!*\
  76784. !*** ./Meshes/csg.ts ***!
  76785. \***********************/
  76786. /*! exports provided: CSG */
  76787. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76788. "use strict";
  76789. __webpack_require__.r(__webpack_exports__);
  76790. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return CSG; });
  76791. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  76792. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  76793. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  76794. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  76795. /**
  76796. * Unique ID when we import meshes from Babylon to CSG
  76797. */
  76798. var currentCSGMeshId = 0;
  76799. /**
  76800. * Represents a vertex of a polygon. Use your own vertex class instead of this
  76801. * one to provide additional features like texture coordinates and vertex
  76802. * colors. Custom vertex classes need to provide a `pos` property and `clone()`,
  76803. * `flip()`, and `interpolate()` methods that behave analogous to the ones
  76804. * defined by `BABYLON.CSG.Vertex`. This class provides `normal` so convenience
  76805. * functions like `BABYLON.CSG.sphere()` can return a smooth vertex normal, but `normal`
  76806. * is not used anywhere else.
  76807. * Same goes for uv, it allows to keep the original vertex uv coordinates of the 2 meshes
  76808. */
  76809. var Vertex = /** @class */ (function () {
  76810. /**
  76811. * Initializes the vertex
  76812. * @param pos The position of the vertex
  76813. * @param normal The normal of the vertex
  76814. * @param uv The texture coordinate of the vertex
  76815. */
  76816. function Vertex(
  76817. /**
  76818. * The position of the vertex
  76819. */
  76820. pos,
  76821. /**
  76822. * The normal of the vertex
  76823. */
  76824. normal,
  76825. /**
  76826. * The texture coordinate of the vertex
  76827. */
  76828. uv) {
  76829. this.pos = pos;
  76830. this.normal = normal;
  76831. this.uv = uv;
  76832. }
  76833. /**
  76834. * Make a clone, or deep copy, of the vertex
  76835. * @returns A new Vertex
  76836. */
  76837. Vertex.prototype.clone = function () {
  76838. return new Vertex(this.pos.clone(), this.normal.clone(), this.uv.clone());
  76839. };
  76840. /**
  76841. * Invert all orientation-specific data (e.g. vertex normal). Called when the
  76842. * orientation of a polygon is flipped.
  76843. */
  76844. Vertex.prototype.flip = function () {
  76845. this.normal = this.normal.scale(-1);
  76846. };
  76847. /**
  76848. * Create a new vertex between this vertex and `other` by linearly
  76849. * interpolating all properties using a parameter of `t`. Subclasses should
  76850. * override this to interpolate additional properties.
  76851. * @param other the vertex to interpolate against
  76852. * @param t The factor used to linearly interpolate between the vertices
  76853. */
  76854. Vertex.prototype.interpolate = function (other, t) {
  76855. 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));
  76856. };
  76857. return Vertex;
  76858. }());
  76859. /**
  76860. * Represents a plane in 3D space.
  76861. */
  76862. var Plane = /** @class */ (function () {
  76863. /**
  76864. * Initializes the plane
  76865. * @param normal The normal for the plane
  76866. * @param w
  76867. */
  76868. function Plane(normal, w) {
  76869. this.normal = normal;
  76870. this.w = w;
  76871. }
  76872. /**
  76873. * Construct a plane from three points
  76874. * @param a Point a
  76875. * @param b Point b
  76876. * @param c Point c
  76877. */
  76878. Plane.FromPoints = function (a, b, c) {
  76879. var v0 = c.subtract(a);
  76880. var v1 = b.subtract(a);
  76881. if (v0.lengthSquared() === 0 || v1.lengthSquared() === 0) {
  76882. return null;
  76883. }
  76884. var n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v0, v1));
  76885. return new Plane(n, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(n, a));
  76886. };
  76887. /**
  76888. * Clone, or make a deep copy of the plane
  76889. * @returns a new Plane
  76890. */
  76891. Plane.prototype.clone = function () {
  76892. return new Plane(this.normal.clone(), this.w);
  76893. };
  76894. /**
  76895. * Flip the face of the plane
  76896. */
  76897. Plane.prototype.flip = function () {
  76898. this.normal.scaleInPlace(-1);
  76899. this.w = -this.w;
  76900. };
  76901. /**
  76902. * Split `polygon` by this plane if needed, then put the polygon or polygon
  76903. * fragments in the appropriate lists. Coplanar polygons go into either
  76904. `* coplanarFront` or `coplanarBack` depending on their orientation with
  76905. * respect to this plane. Polygons in front or in back of this plane go into
  76906. * either `front` or `back`
  76907. * @param polygon The polygon to be split
  76908. * @param coplanarFront Will contain polygons coplanar with the plane that are oriented to the front of the plane
  76909. * @param coplanarBack Will contain polygons coplanar with the plane that are oriented to the back of the plane
  76910. * @param front Will contain the polygons in front of the plane
  76911. * @param back Will contain the polygons begind the plane
  76912. */
  76913. Plane.prototype.splitPolygon = function (polygon, coplanarFront, coplanarBack, front, back) {
  76914. var COPLANAR = 0;
  76915. var FRONT = 1;
  76916. var BACK = 2;
  76917. var SPANNING = 3;
  76918. // Classify each point as well as the entire polygon into one of the above
  76919. // four classes.
  76920. var polygonType = 0;
  76921. var types = [];
  76922. var i;
  76923. var t;
  76924. for (i = 0; i < polygon.vertices.length; i++) {
  76925. t = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.vertices[i].pos) - this.w;
  76926. var type = (t < -Plane.EPSILON) ? BACK : (t > Plane.EPSILON) ? FRONT : COPLANAR;
  76927. polygonType |= type;
  76928. types.push(type);
  76929. }
  76930. // Put the polygon in the correct list, splitting it when necessary
  76931. switch (polygonType) {
  76932. case COPLANAR:
  76933. (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);
  76934. break;
  76935. case FRONT:
  76936. front.push(polygon);
  76937. break;
  76938. case BACK:
  76939. back.push(polygon);
  76940. break;
  76941. case SPANNING:
  76942. var f = [], b = [];
  76943. for (i = 0; i < polygon.vertices.length; i++) {
  76944. var j = (i + 1) % polygon.vertices.length;
  76945. var ti = types[i], tj = types[j];
  76946. var vi = polygon.vertices[i], vj = polygon.vertices[j];
  76947. if (ti !== BACK) {
  76948. f.push(vi);
  76949. }
  76950. if (ti !== FRONT) {
  76951. b.push(ti !== BACK ? vi.clone() : vi);
  76952. }
  76953. if ((ti | tj) === SPANNING) {
  76954. 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));
  76955. var v = vi.interpolate(vj, t);
  76956. f.push(v);
  76957. b.push(v.clone());
  76958. }
  76959. }
  76960. var poly;
  76961. if (f.length >= 3) {
  76962. poly = new Polygon(f, polygon.shared);
  76963. if (poly.plane) {
  76964. front.push(poly);
  76965. }
  76966. }
  76967. if (b.length >= 3) {
  76968. poly = new Polygon(b, polygon.shared);
  76969. if (poly.plane) {
  76970. back.push(poly);
  76971. }
  76972. }
  76973. break;
  76974. }
  76975. };
  76976. /**
  76977. * `CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a
  76978. * point is on the plane
  76979. */
  76980. Plane.EPSILON = 1e-5;
  76981. return Plane;
  76982. }());
  76983. /**
  76984. * Represents a convex polygon. The vertices used to initialize a polygon must
  76985. * be coplanar and form a convex loop.
  76986. *
  76987. * Each convex polygon has a `shared` property, which is shared between all
  76988. * polygons that are clones of each other or were split from the same polygon.
  76989. * This can be used to define per-polygon properties (such as surface color)
  76990. */
  76991. var Polygon = /** @class */ (function () {
  76992. /**
  76993. * Initializes the polygon
  76994. * @param vertices The vertices of the polygon
  76995. * @param shared The properties shared across all polygons
  76996. */
  76997. function Polygon(vertices, shared) {
  76998. this.vertices = vertices;
  76999. this.shared = shared;
  77000. this.plane = Plane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
  77001. }
  77002. /**
  77003. * Clones, or makes a deep copy, or the polygon
  77004. */
  77005. Polygon.prototype.clone = function () {
  77006. var vertices = this.vertices.map(function (v) { return v.clone(); });
  77007. return new Polygon(vertices, this.shared);
  77008. };
  77009. /**
  77010. * Flips the faces of the polygon
  77011. */
  77012. Polygon.prototype.flip = function () {
  77013. this.vertices.reverse().map(function (v) { v.flip(); });
  77014. this.plane.flip();
  77015. };
  77016. return Polygon;
  77017. }());
  77018. /**
  77019. * Holds a node in a BSP tree. A BSP tree is built from a collection of polygons
  77020. * by picking a polygon to split along. That polygon (and all other coplanar
  77021. * polygons) are added directly to that node and the other polygons are added to
  77022. * the front and/or back subtrees. This is not a leafy BSP tree since there is
  77023. * no distinction between internal and leaf nodes
  77024. */
  77025. var Node = /** @class */ (function () {
  77026. /**
  77027. * Initializes the node
  77028. * @param polygons A collection of polygons held in the node
  77029. */
  77030. function Node(polygons) {
  77031. this.plane = null;
  77032. this.front = null;
  77033. this.back = null;
  77034. this.polygons = new Array();
  77035. if (polygons) {
  77036. this.build(polygons);
  77037. }
  77038. }
  77039. /**
  77040. * Clones, or makes a deep copy, of the node
  77041. * @returns The cloned node
  77042. */
  77043. Node.prototype.clone = function () {
  77044. var node = new Node();
  77045. node.plane = this.plane && this.plane.clone();
  77046. node.front = this.front && this.front.clone();
  77047. node.back = this.back && this.back.clone();
  77048. node.polygons = this.polygons.map(function (p) { return p.clone(); });
  77049. return node;
  77050. };
  77051. /**
  77052. * Convert solid space to empty space and empty space to solid space
  77053. */
  77054. Node.prototype.invert = function () {
  77055. for (var i = 0; i < this.polygons.length; i++) {
  77056. this.polygons[i].flip();
  77057. }
  77058. if (this.plane) {
  77059. this.plane.flip();
  77060. }
  77061. if (this.front) {
  77062. this.front.invert();
  77063. }
  77064. if (this.back) {
  77065. this.back.invert();
  77066. }
  77067. var temp = this.front;
  77068. this.front = this.back;
  77069. this.back = temp;
  77070. };
  77071. /**
  77072. * Recursively remove all polygons in `polygons` that are inside this BSP
  77073. * tree.
  77074. * @param polygons Polygons to remove from the BSP
  77075. * @returns Polygons clipped from the BSP
  77076. */
  77077. Node.prototype.clipPolygons = function (polygons) {
  77078. if (!this.plane) {
  77079. return polygons.slice();
  77080. }
  77081. var front = new Array(), back = new Array();
  77082. for (var i = 0; i < polygons.length; i++) {
  77083. this.plane.splitPolygon(polygons[i], front, back, front, back);
  77084. }
  77085. if (this.front) {
  77086. front = this.front.clipPolygons(front);
  77087. }
  77088. if (this.back) {
  77089. back = this.back.clipPolygons(back);
  77090. }
  77091. else {
  77092. back = [];
  77093. }
  77094. return front.concat(back);
  77095. };
  77096. /**
  77097. * Remove all polygons in this BSP tree that are inside the other BSP tree
  77098. * `bsp`.
  77099. * @param bsp BSP containing polygons to remove from this BSP
  77100. */
  77101. Node.prototype.clipTo = function (bsp) {
  77102. this.polygons = bsp.clipPolygons(this.polygons);
  77103. if (this.front) {
  77104. this.front.clipTo(bsp);
  77105. }
  77106. if (this.back) {
  77107. this.back.clipTo(bsp);
  77108. }
  77109. };
  77110. /**
  77111. * Return a list of all polygons in this BSP tree
  77112. * @returns List of all polygons in this BSP tree
  77113. */
  77114. Node.prototype.allPolygons = function () {
  77115. var polygons = this.polygons.slice();
  77116. if (this.front) {
  77117. polygons = polygons.concat(this.front.allPolygons());
  77118. }
  77119. if (this.back) {
  77120. polygons = polygons.concat(this.back.allPolygons());
  77121. }
  77122. return polygons;
  77123. };
  77124. /**
  77125. * Build a BSP tree out of `polygons`. When called on an existing tree, the
  77126. * new polygons are filtered down to the bottom of the tree and become new
  77127. * nodes there. Each set of polygons is partitioned using the first polygon
  77128. * (no heuristic is used to pick a good split)
  77129. * @param polygons Polygons used to construct the BSP tree
  77130. */
  77131. Node.prototype.build = function (polygons) {
  77132. if (!polygons.length) {
  77133. return;
  77134. }
  77135. if (!this.plane) {
  77136. this.plane = polygons[0].plane.clone();
  77137. }
  77138. var front = new Array(), back = new Array();
  77139. for (var i = 0; i < polygons.length; i++) {
  77140. this.plane.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
  77141. }
  77142. if (front.length) {
  77143. if (!this.front) {
  77144. this.front = new Node();
  77145. }
  77146. this.front.build(front);
  77147. }
  77148. if (back.length) {
  77149. if (!this.back) {
  77150. this.back = new Node();
  77151. }
  77152. this.back.build(back);
  77153. }
  77154. };
  77155. return Node;
  77156. }());
  77157. /**
  77158. * Class for building Constructive Solid Geometry
  77159. */
  77160. var CSG = /** @class */ (function () {
  77161. function CSG() {
  77162. this.polygons = new Array();
  77163. }
  77164. /**
  77165. * Convert the Mesh to CSG
  77166. * @param mesh The Mesh to convert to CSG
  77167. * @returns A new CSG from the Mesh
  77168. */
  77169. CSG.FromMesh = function (mesh) {
  77170. var vertex, normal, uv, position, polygon, polygons = new Array(), vertices;
  77171. var matrix, meshPosition, meshRotation, meshRotationQuaternion = null, meshScaling;
  77172. if (mesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]) {
  77173. mesh.computeWorldMatrix(true);
  77174. matrix = mesh.getWorldMatrix();
  77175. meshPosition = mesh.position.clone();
  77176. meshRotation = mesh.rotation.clone();
  77177. if (mesh.rotationQuaternion) {
  77178. meshRotationQuaternion = mesh.rotationQuaternion.clone();
  77179. }
  77180. meshScaling = mesh.scaling.clone();
  77181. }
  77182. else {
  77183. throw 'BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh';
  77184. }
  77185. 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);
  77186. var subMeshes = mesh.subMeshes;
  77187. for (var sm = 0, sml = subMeshes.length; sm < sml; sm++) {
  77188. for (var i = subMeshes[sm].indexStart, il = subMeshes[sm].indexCount + subMeshes[sm].indexStart; i < il; i += 3) {
  77189. vertices = [];
  77190. for (var j = 0; j < 3; j++) {
  77191. 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]);
  77192. uv = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uvs[indices[i + j] * 2], uvs[indices[i + j] * 2 + 1]);
  77193. 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]);
  77194. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(sourcePosition, matrix);
  77195. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(sourceNormal, matrix);
  77196. vertex = new Vertex(position, normal, uv);
  77197. vertices.push(vertex);
  77198. }
  77199. polygon = new Polygon(vertices, { subMeshId: sm, meshId: currentCSGMeshId, materialIndex: subMeshes[sm].materialIndex });
  77200. // To handle the case of degenerated triangle
  77201. // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated
  77202. if (polygon.plane) {
  77203. polygons.push(polygon);
  77204. }
  77205. }
  77206. }
  77207. var csg = CSG.FromPolygons(polygons);
  77208. csg.matrix = matrix;
  77209. csg.position = meshPosition;
  77210. csg.rotation = meshRotation;
  77211. csg.scaling = meshScaling;
  77212. csg.rotationQuaternion = meshRotationQuaternion;
  77213. currentCSGMeshId++;
  77214. return csg;
  77215. };
  77216. /**
  77217. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  77218. * @param polygons Polygons used to construct a CSG solid
  77219. */
  77220. CSG.FromPolygons = function (polygons) {
  77221. var csg = new CSG();
  77222. csg.polygons = polygons;
  77223. return csg;
  77224. };
  77225. /**
  77226. * Clones, or makes a deep copy, of the CSG
  77227. * @returns A new CSG
  77228. */
  77229. CSG.prototype.clone = function () {
  77230. var csg = new CSG();
  77231. csg.polygons = this.polygons.map(function (p) { return p.clone(); });
  77232. csg.copyTransformAttributes(this);
  77233. return csg;
  77234. };
  77235. /**
  77236. * Unions this CSG with another CSG
  77237. * @param csg The CSG to union against this CSG
  77238. * @returns The unioned CSG
  77239. */
  77240. CSG.prototype.union = function (csg) {
  77241. var a = new Node(this.clone().polygons);
  77242. var b = new Node(csg.clone().polygons);
  77243. a.clipTo(b);
  77244. b.clipTo(a);
  77245. b.invert();
  77246. b.clipTo(a);
  77247. b.invert();
  77248. a.build(b.allPolygons());
  77249. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  77250. };
  77251. /**
  77252. * Unions this CSG with another CSG in place
  77253. * @param csg The CSG to union against this CSG
  77254. */
  77255. CSG.prototype.unionInPlace = function (csg) {
  77256. var a = new Node(this.polygons);
  77257. var b = new Node(csg.polygons);
  77258. a.clipTo(b);
  77259. b.clipTo(a);
  77260. b.invert();
  77261. b.clipTo(a);
  77262. b.invert();
  77263. a.build(b.allPolygons());
  77264. this.polygons = a.allPolygons();
  77265. };
  77266. /**
  77267. * Subtracts this CSG with another CSG
  77268. * @param csg The CSG to subtract against this CSG
  77269. * @returns A new CSG
  77270. */
  77271. CSG.prototype.subtract = function (csg) {
  77272. var a = new Node(this.clone().polygons);
  77273. var b = new Node(csg.clone().polygons);
  77274. a.invert();
  77275. a.clipTo(b);
  77276. b.clipTo(a);
  77277. b.invert();
  77278. b.clipTo(a);
  77279. b.invert();
  77280. a.build(b.allPolygons());
  77281. a.invert();
  77282. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  77283. };
  77284. /**
  77285. * Subtracts this CSG with another CSG in place
  77286. * @param csg The CSG to subtact against this CSG
  77287. */
  77288. CSG.prototype.subtractInPlace = function (csg) {
  77289. var a = new Node(this.polygons);
  77290. var b = new Node(csg.polygons);
  77291. a.invert();
  77292. a.clipTo(b);
  77293. b.clipTo(a);
  77294. b.invert();
  77295. b.clipTo(a);
  77296. b.invert();
  77297. a.build(b.allPolygons());
  77298. a.invert();
  77299. this.polygons = a.allPolygons();
  77300. };
  77301. /**
  77302. * Intersect this CSG with another CSG
  77303. * @param csg The CSG to intersect against this CSG
  77304. * @returns A new CSG
  77305. */
  77306. CSG.prototype.intersect = function (csg) {
  77307. var a = new Node(this.clone().polygons);
  77308. var b = new Node(csg.clone().polygons);
  77309. a.invert();
  77310. b.clipTo(a);
  77311. b.invert();
  77312. a.clipTo(b);
  77313. b.clipTo(a);
  77314. a.build(b.allPolygons());
  77315. a.invert();
  77316. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  77317. };
  77318. /**
  77319. * Intersects this CSG with another CSG in place
  77320. * @param csg The CSG to intersect against this CSG
  77321. */
  77322. CSG.prototype.intersectInPlace = function (csg) {
  77323. var a = new Node(this.polygons);
  77324. var b = new Node(csg.polygons);
  77325. a.invert();
  77326. b.clipTo(a);
  77327. b.invert();
  77328. a.clipTo(b);
  77329. b.clipTo(a);
  77330. a.build(b.allPolygons());
  77331. a.invert();
  77332. this.polygons = a.allPolygons();
  77333. };
  77334. /**
  77335. * Return a new CSG solid with solid and empty space switched. This solid is
  77336. * not modified.
  77337. * @returns A new CSG solid with solid and empty space switched
  77338. */
  77339. CSG.prototype.inverse = function () {
  77340. var csg = this.clone();
  77341. csg.inverseInPlace();
  77342. return csg;
  77343. };
  77344. /**
  77345. * Inverses the CSG in place
  77346. */
  77347. CSG.prototype.inverseInPlace = function () {
  77348. this.polygons.map(function (p) { p.flip(); });
  77349. };
  77350. /**
  77351. * This is used to keep meshes transformations so they can be restored
  77352. * when we build back a Babylon Mesh
  77353. * NB : All CSG operations are performed in world coordinates
  77354. * @param csg The CSG to copy the transform attributes from
  77355. * @returns This CSG
  77356. */
  77357. CSG.prototype.copyTransformAttributes = function (csg) {
  77358. this.matrix = csg.matrix;
  77359. this.position = csg.position;
  77360. this.rotation = csg.rotation;
  77361. this.scaling = csg.scaling;
  77362. this.rotationQuaternion = csg.rotationQuaternion;
  77363. return this;
  77364. };
  77365. /**
  77366. * Build Raw mesh from CSG
  77367. * Coordinates here are in world space
  77368. * @param name The name of the mesh geometry
  77369. * @param scene The Scene
  77370. * @param keepSubMeshes Specifies if the submeshes should be kept
  77371. * @returns A new Mesh
  77372. */
  77373. CSG.prototype.buildMeshGeometry = function (name, scene, keepSubMeshes) {
  77374. var matrix = this.matrix.clone();
  77375. matrix.invert();
  77376. 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;
  77377. if (keepSubMeshes) {
  77378. // Sort Polygons, since subMeshes are indices range
  77379. polygons.sort(function (a, b) {
  77380. if (a.shared.meshId === b.shared.meshId) {
  77381. return a.shared.subMeshId - b.shared.subMeshId;
  77382. }
  77383. else {
  77384. return a.shared.meshId - b.shared.meshId;
  77385. }
  77386. });
  77387. }
  77388. for (var i = 0, il = polygons.length; i < il; i++) {
  77389. polygon = polygons[i];
  77390. // Building SubMeshes
  77391. if (!subMesh_dict[polygon.shared.meshId]) {
  77392. subMesh_dict[polygon.shared.meshId] = {};
  77393. }
  77394. if (!subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId]) {
  77395. subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId] = {
  77396. indexStart: +Infinity,
  77397. indexEnd: -Infinity,
  77398. materialIndex: polygon.shared.materialIndex
  77399. };
  77400. }
  77401. subMesh_obj = subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId];
  77402. for (var j = 2, jl = polygon.vertices.length; j < jl; j++) {
  77403. polygonIndices[0] = 0;
  77404. polygonIndices[1] = j - 1;
  77405. polygonIndices[2] = j;
  77406. for (var k = 0; k < 3; k++) {
  77407. vertex.copyFrom(polygon.vertices[polygonIndices[k]].pos);
  77408. normal.copyFrom(polygon.vertices[polygonIndices[k]].normal);
  77409. uv.copyFrom(polygon.vertices[polygonIndices[k]].uv);
  77410. var localVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(vertex, matrix);
  77411. var localNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, matrix);
  77412. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z];
  77413. // Check if 2 points can be merged
  77414. if (!(typeof vertex_idx !== 'undefined' &&
  77415. normals[vertex_idx * 3] === localNormal.x &&
  77416. normals[vertex_idx * 3 + 1] === localNormal.y &&
  77417. normals[vertex_idx * 3 + 2] === localNormal.z &&
  77418. uvs[vertex_idx * 2] === uv.x &&
  77419. uvs[vertex_idx * 2 + 1] === uv.y)) {
  77420. vertices.push(localVertex.x, localVertex.y, localVertex.z);
  77421. uvs.push(uv.x, uv.y);
  77422. normals.push(normal.x, normal.y, normal.z);
  77423. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z] = (vertices.length / 3) - 1;
  77424. }
  77425. indices.push(vertex_idx);
  77426. subMesh_obj.indexStart = Math.min(currentIndex, subMesh_obj.indexStart);
  77427. subMesh_obj.indexEnd = Math.max(currentIndex, subMesh_obj.indexEnd);
  77428. currentIndex++;
  77429. }
  77430. }
  77431. }
  77432. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, vertices);
  77433. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals);
  77434. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs);
  77435. mesh.setIndices(indices, null);
  77436. if (keepSubMeshes) {
  77437. // We offset the materialIndex by the previous number of materials in the CSG mixed meshes
  77438. var materialIndexOffset = 0, materialMaxIndex;
  77439. mesh.subMeshes = new Array();
  77440. for (var m in subMesh_dict) {
  77441. materialMaxIndex = -1;
  77442. for (var sm in subMesh_dict[m]) {
  77443. subMesh_obj = subMesh_dict[m][sm];
  77444. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].CreateFromIndices(subMesh_obj.materialIndex + materialIndexOffset, subMesh_obj.indexStart, subMesh_obj.indexEnd - subMesh_obj.indexStart + 1, mesh);
  77445. materialMaxIndex = Math.max(subMesh_obj.materialIndex, materialMaxIndex);
  77446. }
  77447. materialIndexOffset += ++materialMaxIndex;
  77448. }
  77449. }
  77450. return mesh;
  77451. };
  77452. /**
  77453. * Build Mesh from CSG taking material and transforms into account
  77454. * @param name The name of the Mesh
  77455. * @param material The material of the Mesh
  77456. * @param scene The Scene
  77457. * @param keepSubMeshes Specifies if submeshes should be kept
  77458. * @returns The new Mesh
  77459. */
  77460. CSG.prototype.toMesh = function (name, material, scene, keepSubMeshes) {
  77461. var mesh = this.buildMeshGeometry(name, scene, keepSubMeshes);
  77462. mesh.material = material;
  77463. mesh.position.copyFrom(this.position);
  77464. mesh.rotation.copyFrom(this.rotation);
  77465. if (this.rotationQuaternion) {
  77466. mesh.rotationQuaternion = this.rotationQuaternion.clone();
  77467. }
  77468. mesh.scaling.copyFrom(this.scaling);
  77469. mesh.computeWorldMatrix(true);
  77470. return mesh;
  77471. };
  77472. return CSG;
  77473. }());
  77474. /***/ }),
  77475. /***/ "./Meshes/geometry.ts":
  77476. /*!****************************!*\
  77477. !*** ./Meshes/geometry.ts ***!
  77478. \****************************/
  77479. /*! exports provided: Geometry, _PrimitiveGeometry, RibbonGeometry, BoxGeometry, SphereGeometry, DiscGeometry, CylinderGeometry, TorusGeometry, GroundGeometry, TiledGroundGeometry, PlaneGeometry, TorusKnotGeometry */
  77480. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77481. "use strict";
  77482. __webpack_require__.r(__webpack_exports__);
  77483. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return Geometry; });
  77484. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_PrimitiveGeometry", function() { return _PrimitiveGeometry; });
  77485. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RibbonGeometry", function() { return RibbonGeometry; });
  77486. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxGeometry", function() { return BoxGeometry; });
  77487. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereGeometry", function() { return SphereGeometry; });
  77488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiscGeometry", function() { return DiscGeometry; });
  77489. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderGeometry", function() { return CylinderGeometry; });
  77490. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusGeometry", function() { return TorusGeometry; });
  77491. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundGeometry", function() { return GroundGeometry; });
  77492. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TiledGroundGeometry", function() { return TiledGroundGeometry; });
  77493. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneGeometry", function() { return PlaneGeometry; });
  77494. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusKnotGeometry", function() { return TorusKnotGeometry; });
  77495. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  77496. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  77497. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77498. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  77499. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  77500. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  77501. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  77502. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  77503. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  77504. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  77505. /**
  77506. * Class used to store geometry data (vertex buffers + index buffer)
  77507. */
  77508. var Geometry = /** @class */ (function () {
  77509. /**
  77510. * Creates a new geometry
  77511. * @param id defines the unique ID
  77512. * @param scene defines the hosting scene
  77513. * @param vertexData defines the VertexData used to get geometry data
  77514. * @param updatable defines if geometry must be updatable (false by default)
  77515. * @param mesh defines the mesh that will be associated with the geometry
  77516. */
  77517. function Geometry(id, scene, vertexData, updatable, mesh) {
  77518. if (updatable === void 0) { updatable = false; }
  77519. if (mesh === void 0) { mesh = null; }
  77520. /**
  77521. * Gets the delay loading state of the geometry (none by default which means not delayed)
  77522. */
  77523. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  77524. this._totalVertices = 0;
  77525. this._isDisposed = false;
  77526. this._indexBufferIsUpdatable = false;
  77527. this.id = id;
  77528. this.uniqueId = scene.getUniqueId();
  77529. this._engine = scene.getEngine();
  77530. this._meshes = [];
  77531. this._scene = scene;
  77532. //Init vertex buffer cache
  77533. this._vertexBuffers = {};
  77534. this._indices = [];
  77535. this._updatable = updatable;
  77536. // vertexData
  77537. if (vertexData) {
  77538. this.setAllVerticesData(vertexData, updatable);
  77539. }
  77540. else {
  77541. this._totalVertices = 0;
  77542. this._indices = [];
  77543. }
  77544. if (this._engine.getCaps().vertexArrayObject) {
  77545. this._vertexArrayObjects = {};
  77546. }
  77547. // applyToMesh
  77548. if (mesh) {
  77549. this.applyToMesh(mesh);
  77550. mesh.computeWorldMatrix(true);
  77551. }
  77552. }
  77553. Object.defineProperty(Geometry.prototype, "boundingBias", {
  77554. /**
  77555. * 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
  77556. */
  77557. get: function () {
  77558. return this._boundingBias;
  77559. },
  77560. /**
  77561. * 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
  77562. */
  77563. set: function (value) {
  77564. if (this._boundingBias) {
  77565. this._boundingBias.copyFrom(value);
  77566. }
  77567. else {
  77568. this._boundingBias = value.clone();
  77569. }
  77570. this._updateBoundingInfo(true, null);
  77571. },
  77572. enumerable: true,
  77573. configurable: true
  77574. });
  77575. /**
  77576. * Static function used to attach a new empty geometry to a mesh
  77577. * @param mesh defines the mesh to attach the geometry to
  77578. * @returns the new Geometry
  77579. */
  77580. Geometry.CreateGeometryForMesh = function (mesh) {
  77581. var geometry = new Geometry(Geometry.RandomId(), mesh.getScene());
  77582. geometry.applyToMesh(mesh);
  77583. return geometry;
  77584. };
  77585. Object.defineProperty(Geometry.prototype, "extend", {
  77586. /**
  77587. * Gets the current extend of the geometry
  77588. */
  77589. get: function () {
  77590. return this._extend;
  77591. },
  77592. enumerable: true,
  77593. configurable: true
  77594. });
  77595. /**
  77596. * Gets the hosting scene
  77597. * @returns the hosting Scene
  77598. */
  77599. Geometry.prototype.getScene = function () {
  77600. return this._scene;
  77601. };
  77602. /**
  77603. * Gets the hosting engine
  77604. * @returns the hosting Engine
  77605. */
  77606. Geometry.prototype.getEngine = function () {
  77607. return this._engine;
  77608. };
  77609. /**
  77610. * Defines if the geometry is ready to use
  77611. * @returns true if the geometry is ready to be used
  77612. */
  77613. Geometry.prototype.isReady = function () {
  77614. return this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_LOADED || this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  77615. };
  77616. Object.defineProperty(Geometry.prototype, "doNotSerialize", {
  77617. /**
  77618. * Gets a value indicating that the geometry should not be serialized
  77619. */
  77620. get: function () {
  77621. for (var index = 0; index < this._meshes.length; index++) {
  77622. if (!this._meshes[index].doNotSerialize) {
  77623. return false;
  77624. }
  77625. }
  77626. return true;
  77627. },
  77628. enumerable: true,
  77629. configurable: true
  77630. });
  77631. /** @hidden */
  77632. Geometry.prototype._rebuild = function () {
  77633. if (this._vertexArrayObjects) {
  77634. this._vertexArrayObjects = {};
  77635. }
  77636. // Index buffer
  77637. if (this._meshes.length !== 0 && this._indices) {
  77638. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  77639. }
  77640. // Vertex buffers
  77641. for (var key in this._vertexBuffers) {
  77642. var vertexBuffer = this._vertexBuffers[key];
  77643. vertexBuffer._rebuild();
  77644. }
  77645. };
  77646. /**
  77647. * Affects all geometry data in one call
  77648. * @param vertexData defines the geometry data
  77649. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  77650. */
  77651. Geometry.prototype.setAllVerticesData = function (vertexData, updatable) {
  77652. vertexData.applyToGeometry(this, updatable);
  77653. this.notifyUpdate();
  77654. };
  77655. /**
  77656. * Set specific vertex data
  77657. * @param kind defines the data kind (Position, normal, etc...)
  77658. * @param data defines the vertex data to use
  77659. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  77660. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  77661. */
  77662. Geometry.prototype.setVerticesData = function (kind, data, updatable, stride) {
  77663. if (updatable === void 0) { updatable = false; }
  77664. var buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"](this._engine, data, kind, updatable, this._meshes.length === 0, stride);
  77665. this.setVerticesBuffer(buffer);
  77666. };
  77667. /**
  77668. * Removes a specific vertex data
  77669. * @param kind defines the data kind (Position, normal, etc...)
  77670. */
  77671. Geometry.prototype.removeVerticesData = function (kind) {
  77672. if (this._vertexBuffers[kind]) {
  77673. this._vertexBuffers[kind].dispose();
  77674. delete this._vertexBuffers[kind];
  77675. }
  77676. };
  77677. /**
  77678. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  77679. * @param buffer defines the vertex buffer to use
  77680. * @param totalVertices defines the total number of vertices for position kind (could be null)
  77681. */
  77682. Geometry.prototype.setVerticesBuffer = function (buffer, totalVertices) {
  77683. if (totalVertices === void 0) { totalVertices = null; }
  77684. var kind = buffer.getKind();
  77685. if (this._vertexBuffers[kind]) {
  77686. this._vertexBuffers[kind].dispose();
  77687. }
  77688. this._vertexBuffers[kind] = buffer;
  77689. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind) {
  77690. var data = buffer.getData();
  77691. if (totalVertices != null) {
  77692. this._totalVertices = totalVertices;
  77693. }
  77694. else {
  77695. if (data != null) {
  77696. this._totalVertices = data.length / (buffer.byteStride / 4);
  77697. }
  77698. }
  77699. this._updateExtend(data);
  77700. this._resetPointsArrayCache();
  77701. var meshes = this._meshes;
  77702. var numOfMeshes = meshes.length;
  77703. for (var index = 0; index < numOfMeshes; index++) {
  77704. var mesh = meshes[index];
  77705. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  77706. mesh._createGlobalSubMesh(false);
  77707. mesh.computeWorldMatrix(true);
  77708. }
  77709. }
  77710. this.notifyUpdate(kind);
  77711. if (this._vertexArrayObjects) {
  77712. this._disposeVertexArrayObjects();
  77713. this._vertexArrayObjects = {}; // Will trigger a rebuild of the VAO if supported
  77714. }
  77715. };
  77716. /**
  77717. * Update a specific vertex buffer
  77718. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  77719. * It will do nothing if the buffer is not updatable
  77720. * @param kind defines the data kind (Position, normal, etc...)
  77721. * @param data defines the data to use
  77722. * @param offset defines the offset in the target buffer where to store the data
  77723. * @param useBytes set to true if the offset is in bytes
  77724. */
  77725. Geometry.prototype.updateVerticesDataDirectly = function (kind, data, offset, useBytes) {
  77726. if (useBytes === void 0) { useBytes = false; }
  77727. var vertexBuffer = this.getVertexBuffer(kind);
  77728. if (!vertexBuffer) {
  77729. return;
  77730. }
  77731. vertexBuffer.updateDirectly(data, offset, useBytes);
  77732. this.notifyUpdate(kind);
  77733. };
  77734. /**
  77735. * Update a specific vertex buffer
  77736. * This function will create a new buffer if the current one is not updatable
  77737. * @param kind defines the data kind (Position, normal, etc...)
  77738. * @param data defines the data to use
  77739. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  77740. */
  77741. Geometry.prototype.updateVerticesData = function (kind, data, updateExtends) {
  77742. if (updateExtends === void 0) { updateExtends = false; }
  77743. var vertexBuffer = this.getVertexBuffer(kind);
  77744. if (!vertexBuffer) {
  77745. return;
  77746. }
  77747. vertexBuffer.update(data);
  77748. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind) {
  77749. this._updateBoundingInfo(updateExtends, data);
  77750. }
  77751. this.notifyUpdate(kind);
  77752. };
  77753. Geometry.prototype._updateBoundingInfo = function (updateExtends, data) {
  77754. if (updateExtends) {
  77755. this._updateExtend(data);
  77756. }
  77757. this._resetPointsArrayCache();
  77758. if (updateExtends) {
  77759. var meshes = this._meshes;
  77760. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  77761. var mesh = meshes_1[_i];
  77762. if (mesh._boundingInfo) {
  77763. mesh._boundingInfo.reConstruct(this._extend.minimum, this._extend.maximum);
  77764. }
  77765. else {
  77766. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  77767. }
  77768. var subMeshes = mesh.subMeshes;
  77769. for (var _a = 0, subMeshes_1 = subMeshes; _a < subMeshes_1.length; _a++) {
  77770. var subMesh = subMeshes_1[_a];
  77771. subMesh.refreshBoundingInfo();
  77772. }
  77773. }
  77774. }
  77775. };
  77776. /** @hidden */
  77777. Geometry.prototype._bind = function (effect, indexToBind) {
  77778. if (!effect) {
  77779. return;
  77780. }
  77781. if (indexToBind === undefined) {
  77782. indexToBind = this._indexBuffer;
  77783. }
  77784. var vbs = this.getVertexBuffers();
  77785. if (!vbs) {
  77786. return;
  77787. }
  77788. if (indexToBind != this._indexBuffer || !this._vertexArrayObjects) {
  77789. this._engine.bindBuffers(vbs, indexToBind, effect);
  77790. return;
  77791. }
  77792. // Using VAO
  77793. if (!this._vertexArrayObjects[effect.key]) {
  77794. this._vertexArrayObjects[effect.key] = this._engine.recordVertexArrayObject(vbs, indexToBind, effect);
  77795. }
  77796. this._engine.bindVertexArrayObject(this._vertexArrayObjects[effect.key], indexToBind);
  77797. };
  77798. /**
  77799. * Gets total number of vertices
  77800. * @returns the total number of vertices
  77801. */
  77802. Geometry.prototype.getTotalVertices = function () {
  77803. if (!this.isReady()) {
  77804. return 0;
  77805. }
  77806. return this._totalVertices;
  77807. };
  77808. /**
  77809. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  77810. * @param kind defines the data kind (Position, normal, etc...)
  77811. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  77812. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77813. * @returns a float array containing vertex data
  77814. */
  77815. Geometry.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  77816. var vertexBuffer = this.getVertexBuffer(kind);
  77817. if (!vertexBuffer) {
  77818. return null;
  77819. }
  77820. var data = vertexBuffer.getData();
  77821. if (!data) {
  77822. return null;
  77823. }
  77824. var tightlyPackedByteStride = vertexBuffer.getSize() * _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].GetTypeByteLength(vertexBuffer.type);
  77825. var count = this._totalVertices * vertexBuffer.getSize();
  77826. if (vertexBuffer.type !== _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].FLOAT || vertexBuffer.byteStride !== tightlyPackedByteStride) {
  77827. var copy_1 = [];
  77828. vertexBuffer.forEach(count, function (value) { return copy_1.push(value); });
  77829. return copy_1;
  77830. }
  77831. if (!((data instanceof Array) || (data instanceof Float32Array)) || vertexBuffer.byteOffset !== 0 || data.length !== count) {
  77832. if (data instanceof Array) {
  77833. var offset = vertexBuffer.byteOffset / 4;
  77834. return _Misc_tools__WEBPACK_IMPORTED_MODULE_8__["Tools"].Slice(data, offset, offset + count);
  77835. }
  77836. else if (data instanceof ArrayBuffer) {
  77837. return new Float32Array(data, vertexBuffer.byteOffset, count);
  77838. }
  77839. else {
  77840. var offset = data.byteOffset + vertexBuffer.byteOffset;
  77841. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  77842. var result = new Float32Array(count);
  77843. var source = new Float32Array(data.buffer, offset, count);
  77844. result.set(source);
  77845. return result;
  77846. }
  77847. return new Float32Array(data.buffer, offset, count);
  77848. }
  77849. }
  77850. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  77851. return _Misc_tools__WEBPACK_IMPORTED_MODULE_8__["Tools"].Slice(data);
  77852. }
  77853. return data;
  77854. };
  77855. /**
  77856. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  77857. * @param kind defines the data kind (Position, normal, etc...)
  77858. * @returns true if the vertex buffer with the specified kind is updatable
  77859. */
  77860. Geometry.prototype.isVertexBufferUpdatable = function (kind) {
  77861. var vb = this._vertexBuffers[kind];
  77862. if (!vb) {
  77863. return false;
  77864. }
  77865. return vb.isUpdatable();
  77866. };
  77867. /**
  77868. * Gets a specific vertex buffer
  77869. * @param kind defines the data kind (Position, normal, etc...)
  77870. * @returns a VertexBuffer
  77871. */
  77872. Geometry.prototype.getVertexBuffer = function (kind) {
  77873. if (!this.isReady()) {
  77874. return null;
  77875. }
  77876. return this._vertexBuffers[kind];
  77877. };
  77878. /**
  77879. * Returns all vertex buffers
  77880. * @return an object holding all vertex buffers indexed by kind
  77881. */
  77882. Geometry.prototype.getVertexBuffers = function () {
  77883. if (!this.isReady()) {
  77884. return null;
  77885. }
  77886. return this._vertexBuffers;
  77887. };
  77888. /**
  77889. * Gets a boolean indicating if specific vertex buffer is present
  77890. * @param kind defines the data kind (Position, normal, etc...)
  77891. * @returns true if data is present
  77892. */
  77893. Geometry.prototype.isVerticesDataPresent = function (kind) {
  77894. if (!this._vertexBuffers) {
  77895. if (this._delayInfo) {
  77896. return this._delayInfo.indexOf(kind) !== -1;
  77897. }
  77898. return false;
  77899. }
  77900. return this._vertexBuffers[kind] !== undefined;
  77901. };
  77902. /**
  77903. * Gets a list of all attached data kinds (Position, normal, etc...)
  77904. * @returns a list of string containing all kinds
  77905. */
  77906. Geometry.prototype.getVerticesDataKinds = function () {
  77907. var result = [];
  77908. var kind;
  77909. if (!this._vertexBuffers && this._delayInfo) {
  77910. for (kind in this._delayInfo) {
  77911. result.push(kind);
  77912. }
  77913. }
  77914. else {
  77915. for (kind in this._vertexBuffers) {
  77916. result.push(kind);
  77917. }
  77918. }
  77919. return result;
  77920. };
  77921. /**
  77922. * Update index buffer
  77923. * @param indices defines the indices to store in the index buffer
  77924. * @param offset defines the offset in the target buffer where to store the data
  77925. */
  77926. Geometry.prototype.updateIndices = function (indices, offset) {
  77927. if (!this._indexBuffer) {
  77928. return;
  77929. }
  77930. if (!this._indexBufferIsUpdatable) {
  77931. this.setIndices(indices, null, true);
  77932. }
  77933. else {
  77934. var needToUpdateSubMeshes = indices.length !== this._indices.length;
  77935. this._indices = indices;
  77936. this._engine.updateDynamicIndexBuffer(this._indexBuffer, indices, offset);
  77937. if (needToUpdateSubMeshes) {
  77938. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  77939. var mesh = _a[_i];
  77940. mesh._createGlobalSubMesh(true);
  77941. }
  77942. }
  77943. }
  77944. };
  77945. /**
  77946. * Creates a new index buffer
  77947. * @param indices defines the indices to store in the index buffer
  77948. * @param totalVertices defines the total number of vertices (could be null)
  77949. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  77950. */
  77951. Geometry.prototype.setIndices = function (indices, totalVertices, updatable) {
  77952. if (totalVertices === void 0) { totalVertices = null; }
  77953. if (updatable === void 0) { updatable = false; }
  77954. if (this._indexBuffer) {
  77955. this._engine._releaseBuffer(this._indexBuffer);
  77956. }
  77957. this._disposeVertexArrayObjects();
  77958. this._indices = indices;
  77959. this._indexBufferIsUpdatable = updatable;
  77960. if (this._meshes.length !== 0 && this._indices) {
  77961. this._indexBuffer = this._engine.createIndexBuffer(this._indices, updatable);
  77962. }
  77963. if (totalVertices != undefined) { // including null and undefined
  77964. this._totalVertices = totalVertices;
  77965. }
  77966. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  77967. var mesh = _a[_i];
  77968. mesh._createGlobalSubMesh(true);
  77969. }
  77970. this.notifyUpdate();
  77971. };
  77972. /**
  77973. * Return the total number of indices
  77974. * @returns the total number of indices
  77975. */
  77976. Geometry.prototype.getTotalIndices = function () {
  77977. if (!this.isReady()) {
  77978. return 0;
  77979. }
  77980. return this._indices.length;
  77981. };
  77982. /**
  77983. * Gets the index buffer array
  77984. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  77985. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77986. * @returns the index buffer array
  77987. */
  77988. Geometry.prototype.getIndices = function (copyWhenShared, forceCopy) {
  77989. if (!this.isReady()) {
  77990. return null;
  77991. }
  77992. var orig = this._indices;
  77993. if (!forceCopy && (!copyWhenShared || this._meshes.length === 1)) {
  77994. return orig;
  77995. }
  77996. else {
  77997. var len = orig.length;
  77998. var copy = [];
  77999. for (var i = 0; i < len; i++) {
  78000. copy.push(orig[i]);
  78001. }
  78002. return copy;
  78003. }
  78004. };
  78005. /**
  78006. * Gets the index buffer
  78007. * @return the index buffer
  78008. */
  78009. Geometry.prototype.getIndexBuffer = function () {
  78010. if (!this.isReady()) {
  78011. return null;
  78012. }
  78013. return this._indexBuffer;
  78014. };
  78015. /** @hidden */
  78016. Geometry.prototype._releaseVertexArrayObject = function (effect) {
  78017. if (effect === void 0) { effect = null; }
  78018. if (!effect || !this._vertexArrayObjects) {
  78019. return;
  78020. }
  78021. if (this._vertexArrayObjects[effect.key]) {
  78022. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[effect.key]);
  78023. delete this._vertexArrayObjects[effect.key];
  78024. }
  78025. };
  78026. /**
  78027. * Release the associated resources for a specific mesh
  78028. * @param mesh defines the source mesh
  78029. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  78030. */
  78031. Geometry.prototype.releaseForMesh = function (mesh, shouldDispose) {
  78032. var meshes = this._meshes;
  78033. var index = meshes.indexOf(mesh);
  78034. if (index === -1) {
  78035. return;
  78036. }
  78037. meshes.splice(index, 1);
  78038. mesh._geometry = null;
  78039. if (meshes.length === 0 && shouldDispose) {
  78040. this.dispose();
  78041. }
  78042. };
  78043. /**
  78044. * Apply current geometry to a given mesh
  78045. * @param mesh defines the mesh to apply geometry to
  78046. */
  78047. Geometry.prototype.applyToMesh = function (mesh) {
  78048. if (mesh._geometry === this) {
  78049. return;
  78050. }
  78051. var previousGeometry = mesh._geometry;
  78052. if (previousGeometry) {
  78053. previousGeometry.releaseForMesh(mesh);
  78054. }
  78055. var meshes = this._meshes;
  78056. // must be done before setting vertexBuffers because of mesh._createGlobalSubMesh()
  78057. mesh._geometry = this;
  78058. this._scene.pushGeometry(this);
  78059. meshes.push(mesh);
  78060. if (this.isReady()) {
  78061. this._applyToMesh(mesh);
  78062. }
  78063. else {
  78064. mesh._boundingInfo = this._boundingInfo;
  78065. }
  78066. };
  78067. Geometry.prototype._updateExtend = function (data) {
  78068. if (data === void 0) { data = null; }
  78069. if (!data) {
  78070. data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind);
  78071. }
  78072. this._extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_8__["Tools"].ExtractMinAndMax(data, 0, this._totalVertices, this.boundingBias, 3);
  78073. };
  78074. Geometry.prototype._applyToMesh = function (mesh) {
  78075. var numOfMeshes = this._meshes.length;
  78076. // vertexBuffers
  78077. for (var kind in this._vertexBuffers) {
  78078. if (numOfMeshes === 1) {
  78079. this._vertexBuffers[kind].create();
  78080. }
  78081. var buffer = this._vertexBuffers[kind].getBuffer();
  78082. if (buffer) {
  78083. buffer.references = numOfMeshes;
  78084. }
  78085. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind) {
  78086. if (!this._extend) {
  78087. this._updateExtend();
  78088. }
  78089. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  78090. mesh._createGlobalSubMesh(false);
  78091. //bounding info was just created again, world matrix should be applied again.
  78092. mesh._updateBoundingInfo();
  78093. }
  78094. }
  78095. // indexBuffer
  78096. if (numOfMeshes === 1 && this._indices && this._indices.length > 0) {
  78097. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  78098. }
  78099. if (this._indexBuffer) {
  78100. this._indexBuffer.references = numOfMeshes;
  78101. }
  78102. // morphTargets
  78103. mesh._syncGeometryWithMorphTargetManager();
  78104. // instances
  78105. mesh.synchronizeInstances();
  78106. };
  78107. Geometry.prototype.notifyUpdate = function (kind) {
  78108. if (this.onGeometryUpdated) {
  78109. this.onGeometryUpdated(this, kind);
  78110. }
  78111. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  78112. var mesh = _a[_i];
  78113. mesh._markSubMeshesAsAttributesDirty();
  78114. }
  78115. };
  78116. /**
  78117. * Load the geometry if it was flagged as delay loaded
  78118. * @param scene defines the hosting scene
  78119. * @param onLoaded defines a callback called when the geometry is loaded
  78120. */
  78121. Geometry.prototype.load = function (scene, onLoaded) {
  78122. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_LOADING) {
  78123. return;
  78124. }
  78125. if (this.isReady()) {
  78126. if (onLoaded) {
  78127. onLoaded();
  78128. }
  78129. return;
  78130. }
  78131. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_LOADING;
  78132. this._queueLoad(scene, onLoaded);
  78133. };
  78134. Geometry.prototype._queueLoad = function (scene, onLoaded) {
  78135. var _this = this;
  78136. if (!this.delayLoadingFile) {
  78137. return;
  78138. }
  78139. scene._addPendingData(this);
  78140. scene._loadFile(this.delayLoadingFile, function (data) {
  78141. if (!_this._delayLoadingFunction) {
  78142. return;
  78143. }
  78144. _this._delayLoadingFunction(JSON.parse(data), _this);
  78145. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_LOADED;
  78146. _this._delayInfo = [];
  78147. scene._removePendingData(_this);
  78148. var meshes = _this._meshes;
  78149. var numOfMeshes = meshes.length;
  78150. for (var index = 0; index < numOfMeshes; index++) {
  78151. _this._applyToMesh(meshes[index]);
  78152. }
  78153. if (onLoaded) {
  78154. onLoaded();
  78155. }
  78156. }, undefined, true);
  78157. };
  78158. /**
  78159. * Invert the geometry to move from a right handed system to a left handed one.
  78160. */
  78161. Geometry.prototype.toLeftHanded = function () {
  78162. // Flip faces
  78163. var tIndices = this.getIndices(false);
  78164. if (tIndices != null && tIndices.length > 0) {
  78165. for (var i = 0; i < tIndices.length; i += 3) {
  78166. var tTemp = tIndices[i + 0];
  78167. tIndices[i + 0] = tIndices[i + 2];
  78168. tIndices[i + 2] = tTemp;
  78169. }
  78170. this.setIndices(tIndices);
  78171. }
  78172. // Negate position.z
  78173. var tPositions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, false);
  78174. if (tPositions != null && tPositions.length > 0) {
  78175. for (var i = 0; i < tPositions.length; i += 3) {
  78176. tPositions[i + 2] = -tPositions[i + 2];
  78177. }
  78178. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, tPositions, false);
  78179. }
  78180. // Negate normal.z
  78181. var tNormals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, false);
  78182. if (tNormals != null && tNormals.length > 0) {
  78183. for (var i = 0; i < tNormals.length; i += 3) {
  78184. tNormals[i + 2] = -tNormals[i + 2];
  78185. }
  78186. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, tNormals, false);
  78187. }
  78188. };
  78189. // Cache
  78190. /** @hidden */
  78191. Geometry.prototype._resetPointsArrayCache = function () {
  78192. this._positions = null;
  78193. };
  78194. /** @hidden */
  78195. Geometry.prototype._generatePointsArray = function () {
  78196. if (this._positions) {
  78197. return true;
  78198. }
  78199. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind);
  78200. if (!data || data.length === 0) {
  78201. return false;
  78202. }
  78203. this._positions = [];
  78204. for (var index = 0; index < data.length; index += 3) {
  78205. this._positions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(data, index));
  78206. }
  78207. return true;
  78208. };
  78209. /**
  78210. * Gets a value indicating if the geometry is disposed
  78211. * @returns true if the geometry was disposed
  78212. */
  78213. Geometry.prototype.isDisposed = function () {
  78214. return this._isDisposed;
  78215. };
  78216. Geometry.prototype._disposeVertexArrayObjects = function () {
  78217. if (this._vertexArrayObjects) {
  78218. for (var kind in this._vertexArrayObjects) {
  78219. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[kind]);
  78220. }
  78221. this._vertexArrayObjects = {};
  78222. }
  78223. };
  78224. /**
  78225. * Free all associated resources
  78226. */
  78227. Geometry.prototype.dispose = function () {
  78228. var meshes = this._meshes;
  78229. var numOfMeshes = meshes.length;
  78230. var index;
  78231. for (index = 0; index < numOfMeshes; index++) {
  78232. this.releaseForMesh(meshes[index]);
  78233. }
  78234. this._meshes = [];
  78235. this._disposeVertexArrayObjects();
  78236. for (var kind in this._vertexBuffers) {
  78237. this._vertexBuffers[kind].dispose();
  78238. }
  78239. this._vertexBuffers = {};
  78240. this._totalVertices = 0;
  78241. if (this._indexBuffer) {
  78242. this._engine._releaseBuffer(this._indexBuffer);
  78243. }
  78244. this._indexBuffer = null;
  78245. this._indices = [];
  78246. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  78247. this.delayLoadingFile = null;
  78248. this._delayLoadingFunction = null;
  78249. this._delayInfo = [];
  78250. this._boundingInfo = null;
  78251. this._scene.removeGeometry(this);
  78252. this._isDisposed = true;
  78253. };
  78254. /**
  78255. * Clone the current geometry into a new geometry
  78256. * @param id defines the unique ID of the new geometry
  78257. * @returns a new geometry object
  78258. */
  78259. Geometry.prototype.copy = function (id) {
  78260. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78261. vertexData.indices = [];
  78262. var indices = this.getIndices();
  78263. if (indices) {
  78264. for (var index = 0; index < indices.length; index++) {
  78265. vertexData.indices.push(indices[index]);
  78266. }
  78267. }
  78268. var updatable = false;
  78269. var stopChecking = false;
  78270. var kind;
  78271. for (kind in this._vertexBuffers) {
  78272. // using slice() to make a copy of the array and not just reference it
  78273. var data = this.getVerticesData(kind);
  78274. if (data) {
  78275. if (data instanceof Float32Array) {
  78276. vertexData.set(new Float32Array(data), kind);
  78277. }
  78278. else {
  78279. vertexData.set(data.slice(0), kind);
  78280. }
  78281. if (!stopChecking) {
  78282. var vb = this.getVertexBuffer(kind);
  78283. if (vb) {
  78284. updatable = vb.isUpdatable();
  78285. stopChecking = !updatable;
  78286. }
  78287. }
  78288. }
  78289. }
  78290. var geometry = new Geometry(id, this._scene, vertexData, updatable);
  78291. geometry.delayLoadState = this.delayLoadState;
  78292. geometry.delayLoadingFile = this.delayLoadingFile;
  78293. geometry._delayLoadingFunction = this._delayLoadingFunction;
  78294. for (kind in this._delayInfo) {
  78295. geometry._delayInfo = geometry._delayInfo || [];
  78296. geometry._delayInfo.push(kind);
  78297. }
  78298. // Bounding info
  78299. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  78300. return geometry;
  78301. };
  78302. /**
  78303. * Serialize the current geometry info (and not the vertices data) into a JSON object
  78304. * @return a JSON representation of the current geometry data (without the vertices data)
  78305. */
  78306. Geometry.prototype.serialize = function () {
  78307. var serializationObject = {};
  78308. serializationObject.id = this.id;
  78309. serializationObject.updatable = this._updatable;
  78310. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].HasTags(this)) {
  78311. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].GetTags(this);
  78312. }
  78313. return serializationObject;
  78314. };
  78315. Geometry.prototype.toNumberArray = function (origin) {
  78316. if (Array.isArray(origin)) {
  78317. return origin;
  78318. }
  78319. else {
  78320. return Array.prototype.slice.call(origin);
  78321. }
  78322. };
  78323. /**
  78324. * Serialize all vertices data into a JSON oject
  78325. * @returns a JSON representation of the current geometry data
  78326. */
  78327. Geometry.prototype.serializeVerticeData = function () {
  78328. var serializationObject = this.serialize();
  78329. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind)) {
  78330. serializationObject.positions = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind));
  78331. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind)) {
  78332. serializationObject.positions._updatable = true;
  78333. }
  78334. }
  78335. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  78336. serializationObject.normals = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  78337. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  78338. serializationObject.normals._updatable = true;
  78339. }
  78340. }
  78341. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  78342. serializationObject.tangets = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind));
  78343. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  78344. serializationObject.tangets._updatable = true;
  78345. }
  78346. }
  78347. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind)) {
  78348. serializationObject.uvs = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind));
  78349. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind)) {
  78350. serializationObject.uvs._updatable = true;
  78351. }
  78352. }
  78353. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind)) {
  78354. serializationObject.uv2s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind));
  78355. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind)) {
  78356. serializationObject.uv2s._updatable = true;
  78357. }
  78358. }
  78359. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind)) {
  78360. serializationObject.uv3s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind));
  78361. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind)) {
  78362. serializationObject.uv3s._updatable = true;
  78363. }
  78364. }
  78365. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind)) {
  78366. serializationObject.uv4s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind));
  78367. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind)) {
  78368. serializationObject.uv4s._updatable = true;
  78369. }
  78370. }
  78371. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind)) {
  78372. serializationObject.uv5s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind));
  78373. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind)) {
  78374. serializationObject.uv5s._updatable = true;
  78375. }
  78376. }
  78377. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind)) {
  78378. serializationObject.uv6s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind));
  78379. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind)) {
  78380. serializationObject.uv6s._updatable = true;
  78381. }
  78382. }
  78383. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  78384. serializationObject.colors = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind));
  78385. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  78386. serializationObject.colors._updatable = true;
  78387. }
  78388. }
  78389. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind)) {
  78390. serializationObject.matricesIndices = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind));
  78391. serializationObject.matricesIndices._isExpanded = true;
  78392. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind)) {
  78393. serializationObject.matricesIndices._updatable = true;
  78394. }
  78395. }
  78396. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind)) {
  78397. serializationObject.matricesWeights = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind));
  78398. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind)) {
  78399. serializationObject.matricesWeights._updatable = true;
  78400. }
  78401. }
  78402. serializationObject.indices = this.toNumberArray(this.getIndices());
  78403. return serializationObject;
  78404. };
  78405. // Statics
  78406. /**
  78407. * Extracts a clone of a mesh geometry
  78408. * @param mesh defines the source mesh
  78409. * @param id defines the unique ID of the new geometry object
  78410. * @returns the new geometry object
  78411. */
  78412. Geometry.ExtractFromMesh = function (mesh, id) {
  78413. var geometry = mesh._geometry;
  78414. if (!geometry) {
  78415. return null;
  78416. }
  78417. return geometry.copy(id);
  78418. };
  78419. /**
  78420. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  78421. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  78422. * Be aware Math.random() could cause collisions, but:
  78423. * "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"
  78424. * @returns a string containing a new GUID
  78425. */
  78426. Geometry.RandomId = function () {
  78427. return _Misc_tools__WEBPACK_IMPORTED_MODULE_8__["Tools"].RandomId();
  78428. };
  78429. /** @hidden */
  78430. Geometry._ImportGeometry = function (parsedGeometry, mesh) {
  78431. var scene = mesh.getScene();
  78432. // Geometry
  78433. var geometryId = parsedGeometry.geometryId;
  78434. if (geometryId) {
  78435. var geometry = scene.getGeometryByID(geometryId);
  78436. if (geometry) {
  78437. geometry.applyToMesh(mesh);
  78438. }
  78439. }
  78440. else if (parsedGeometry instanceof ArrayBuffer) {
  78441. var binaryInfo = mesh._binaryInfo;
  78442. if (binaryInfo.positionsAttrDesc && binaryInfo.positionsAttrDesc.count > 0) {
  78443. var positionsData = new Float32Array(parsedGeometry, binaryInfo.positionsAttrDesc.offset, binaryInfo.positionsAttrDesc.count);
  78444. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positionsData, false);
  78445. }
  78446. if (binaryInfo.normalsAttrDesc && binaryInfo.normalsAttrDesc.count > 0) {
  78447. var normalsData = new Float32Array(parsedGeometry, binaryInfo.normalsAttrDesc.offset, binaryInfo.normalsAttrDesc.count);
  78448. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normalsData, false);
  78449. }
  78450. if (binaryInfo.tangetsAttrDesc && binaryInfo.tangetsAttrDesc.count > 0) {
  78451. var tangentsData = new Float32Array(parsedGeometry, binaryInfo.tangetsAttrDesc.offset, binaryInfo.tangetsAttrDesc.count);
  78452. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind, tangentsData, false);
  78453. }
  78454. if (binaryInfo.uvsAttrDesc && binaryInfo.uvsAttrDesc.count > 0) {
  78455. var uvsData = new Float32Array(parsedGeometry, binaryInfo.uvsAttrDesc.offset, binaryInfo.uvsAttrDesc.count);
  78456. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, uvsData, false);
  78457. }
  78458. if (binaryInfo.uvs2AttrDesc && binaryInfo.uvs2AttrDesc.count > 0) {
  78459. var uvs2Data = new Float32Array(parsedGeometry, binaryInfo.uvs2AttrDesc.offset, binaryInfo.uvs2AttrDesc.count);
  78460. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind, uvs2Data, false);
  78461. }
  78462. if (binaryInfo.uvs3AttrDesc && binaryInfo.uvs3AttrDesc.count > 0) {
  78463. var uvs3Data = new Float32Array(parsedGeometry, binaryInfo.uvs3AttrDesc.offset, binaryInfo.uvs3AttrDesc.count);
  78464. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind, uvs3Data, false);
  78465. }
  78466. if (binaryInfo.uvs4AttrDesc && binaryInfo.uvs4AttrDesc.count > 0) {
  78467. var uvs4Data = new Float32Array(parsedGeometry, binaryInfo.uvs4AttrDesc.offset, binaryInfo.uvs4AttrDesc.count);
  78468. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind, uvs4Data, false);
  78469. }
  78470. if (binaryInfo.uvs5AttrDesc && binaryInfo.uvs5AttrDesc.count > 0) {
  78471. var uvs5Data = new Float32Array(parsedGeometry, binaryInfo.uvs5AttrDesc.offset, binaryInfo.uvs5AttrDesc.count);
  78472. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind, uvs5Data, false);
  78473. }
  78474. if (binaryInfo.uvs6AttrDesc && binaryInfo.uvs6AttrDesc.count > 0) {
  78475. var uvs6Data = new Float32Array(parsedGeometry, binaryInfo.uvs6AttrDesc.offset, binaryInfo.uvs6AttrDesc.count);
  78476. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind, uvs6Data, false);
  78477. }
  78478. if (binaryInfo.colorsAttrDesc && binaryInfo.colorsAttrDesc.count > 0) {
  78479. var colorsData = new Float32Array(parsedGeometry, binaryInfo.colorsAttrDesc.offset, binaryInfo.colorsAttrDesc.count);
  78480. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind, colorsData, false, binaryInfo.colorsAttrDesc.stride);
  78481. }
  78482. if (binaryInfo.matricesIndicesAttrDesc && binaryInfo.matricesIndicesAttrDesc.count > 0) {
  78483. var matricesIndicesData = new Int32Array(parsedGeometry, binaryInfo.matricesIndicesAttrDesc.offset, binaryInfo.matricesIndicesAttrDesc.count);
  78484. var floatIndices = [];
  78485. for (var i = 0; i < matricesIndicesData.length; i++) {
  78486. var index = matricesIndicesData[i];
  78487. floatIndices.push(index & 0x000000FF);
  78488. floatIndices.push((index & 0x0000FF00) >> 8);
  78489. floatIndices.push((index & 0x00FF0000) >> 16);
  78490. floatIndices.push(index >> 24);
  78491. }
  78492. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind, floatIndices, false);
  78493. }
  78494. if (binaryInfo.matricesWeightsAttrDesc && binaryInfo.matricesWeightsAttrDesc.count > 0) {
  78495. var matricesWeightsData = new Float32Array(parsedGeometry, binaryInfo.matricesWeightsAttrDesc.offset, binaryInfo.matricesWeightsAttrDesc.count);
  78496. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind, matricesWeightsData, false);
  78497. }
  78498. if (binaryInfo.indicesAttrDesc && binaryInfo.indicesAttrDesc.count > 0) {
  78499. var indicesData = new Int32Array(parsedGeometry, binaryInfo.indicesAttrDesc.offset, binaryInfo.indicesAttrDesc.count);
  78500. mesh.setIndices(indicesData, null);
  78501. }
  78502. if (binaryInfo.subMeshesAttrDesc && binaryInfo.subMeshesAttrDesc.count > 0) {
  78503. var subMeshesData = new Int32Array(parsedGeometry, binaryInfo.subMeshesAttrDesc.offset, binaryInfo.subMeshesAttrDesc.count * 5);
  78504. mesh.subMeshes = [];
  78505. for (var i = 0; i < binaryInfo.subMeshesAttrDesc.count; i++) {
  78506. var materialIndex = subMeshesData[(i * 5) + 0];
  78507. var verticesStart = subMeshesData[(i * 5) + 1];
  78508. var verticesCount = subMeshesData[(i * 5) + 2];
  78509. var indexStart = subMeshesData[(i * 5) + 3];
  78510. var indexCount = subMeshesData[(i * 5) + 4];
  78511. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_4__["SubMesh"].AddToMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh);
  78512. }
  78513. }
  78514. }
  78515. else if (parsedGeometry.positions && parsedGeometry.normals && parsedGeometry.indices) {
  78516. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, parsedGeometry.positions, parsedGeometry.positions._updatable);
  78517. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, parsedGeometry.normals, parsedGeometry.normals._updatable);
  78518. if (parsedGeometry.tangents) {
  78519. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind, parsedGeometry.tangents, parsedGeometry.tangents._updatable);
  78520. }
  78521. if (parsedGeometry.uvs) {
  78522. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, parsedGeometry.uvs, parsedGeometry.uvs._updatable);
  78523. }
  78524. if (parsedGeometry.uvs2) {
  78525. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind, parsedGeometry.uvs2, parsedGeometry.uvs2._updatable);
  78526. }
  78527. if (parsedGeometry.uvs3) {
  78528. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind, parsedGeometry.uvs3, parsedGeometry.uvs3._updatable);
  78529. }
  78530. if (parsedGeometry.uvs4) {
  78531. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind, parsedGeometry.uvs4, parsedGeometry.uvs4._updatable);
  78532. }
  78533. if (parsedGeometry.uvs5) {
  78534. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind, parsedGeometry.uvs5, parsedGeometry.uvs5._updatable);
  78535. }
  78536. if (parsedGeometry.uvs6) {
  78537. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind, parsedGeometry.uvs6, parsedGeometry.uvs6._updatable);
  78538. }
  78539. if (parsedGeometry.colors) {
  78540. 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);
  78541. }
  78542. if (parsedGeometry.matricesIndices) {
  78543. if (!parsedGeometry.matricesIndices._isExpanded) {
  78544. var floatIndices = [];
  78545. for (var i = 0; i < parsedGeometry.matricesIndices.length; i++) {
  78546. var matricesIndex = parsedGeometry.matricesIndices[i];
  78547. floatIndices.push(matricesIndex & 0x000000FF);
  78548. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  78549. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  78550. floatIndices.push(matricesIndex >> 24);
  78551. }
  78552. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind, floatIndices, parsedGeometry.matricesIndices._updatable);
  78553. }
  78554. else {
  78555. delete parsedGeometry.matricesIndices._isExpanded;
  78556. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind, parsedGeometry.matricesIndices, parsedGeometry.matricesIndices._updatable);
  78557. }
  78558. }
  78559. if (parsedGeometry.matricesIndicesExtra) {
  78560. if (!parsedGeometry.matricesIndicesExtra._isExpanded) {
  78561. var floatIndices = [];
  78562. for (var i = 0; i < parsedGeometry.matricesIndicesExtra.length; i++) {
  78563. var matricesIndex = parsedGeometry.matricesIndicesExtra[i];
  78564. floatIndices.push(matricesIndex & 0x000000FF);
  78565. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  78566. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  78567. floatIndices.push(matricesIndex >> 24);
  78568. }
  78569. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind, floatIndices, parsedGeometry.matricesIndicesExtra._updatable);
  78570. }
  78571. else {
  78572. delete parsedGeometry.matricesIndices._isExpanded;
  78573. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind, parsedGeometry.matricesIndicesExtra, parsedGeometry.matricesIndicesExtra._updatable);
  78574. }
  78575. }
  78576. if (parsedGeometry.matricesWeights) {
  78577. Geometry._CleanMatricesWeights(parsedGeometry, mesh);
  78578. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind, parsedGeometry.matricesWeights, parsedGeometry.matricesWeights._updatable);
  78579. }
  78580. if (parsedGeometry.matricesWeightsExtra) {
  78581. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind, parsedGeometry.matricesWeightsExtra, parsedGeometry.matricesWeights._updatable);
  78582. }
  78583. mesh.setIndices(parsedGeometry.indices, null);
  78584. }
  78585. // SubMeshes
  78586. if (parsedGeometry.subMeshes) {
  78587. mesh.subMeshes = [];
  78588. for (var subIndex = 0; subIndex < parsedGeometry.subMeshes.length; subIndex++) {
  78589. var parsedSubMesh = parsedGeometry.subMeshes[subIndex];
  78590. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_4__["SubMesh"].AddToMesh(parsedSubMesh.materialIndex, parsedSubMesh.verticesStart, parsedSubMesh.verticesCount, parsedSubMesh.indexStart, parsedSubMesh.indexCount, mesh);
  78591. }
  78592. }
  78593. // Flat shading
  78594. if (mesh._shouldGenerateFlatShading) {
  78595. mesh.convertToFlatShadedMesh();
  78596. delete mesh._shouldGenerateFlatShading;
  78597. }
  78598. // Update
  78599. mesh.computeWorldMatrix(true);
  78600. scene.onMeshImportedObservable.notifyObservers(mesh);
  78601. };
  78602. Geometry._CleanMatricesWeights = function (parsedGeometry, mesh) {
  78603. var epsilon = 1e-3;
  78604. if (!_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_5__["SceneLoaderFlags"].CleanBoneMatrixWeights) {
  78605. return;
  78606. }
  78607. var noInfluenceBoneIndex = 0.0;
  78608. if (parsedGeometry.skeletonId > -1) {
  78609. var skeleton = mesh.getScene().getLastSkeletonByID(parsedGeometry.skeletonId);
  78610. if (!skeleton) {
  78611. return;
  78612. }
  78613. noInfluenceBoneIndex = skeleton.bones.length;
  78614. }
  78615. else {
  78616. return;
  78617. }
  78618. var matricesIndices = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  78619. var matricesIndicesExtra = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  78620. var matricesWeights = parsedGeometry.matricesWeights;
  78621. var matricesWeightsExtra = parsedGeometry.matricesWeightsExtra;
  78622. var influencers = parsedGeometry.numBoneInfluencer;
  78623. var size = matricesWeights.length;
  78624. for (var i = 0; i < size; i += 4) {
  78625. var weight = 0.0;
  78626. var firstZeroWeight = -1;
  78627. for (var j = 0; j < 4; j++) {
  78628. var w = matricesWeights[i + j];
  78629. weight += w;
  78630. if (w < epsilon && firstZeroWeight < 0) {
  78631. firstZeroWeight = j;
  78632. }
  78633. }
  78634. if (matricesWeightsExtra) {
  78635. for (var j = 0; j < 4; j++) {
  78636. var w = matricesWeightsExtra[i + j];
  78637. weight += w;
  78638. if (w < epsilon && firstZeroWeight < 0) {
  78639. firstZeroWeight = j + 4;
  78640. }
  78641. }
  78642. }
  78643. if (firstZeroWeight < 0 || firstZeroWeight > (influencers - 1)) {
  78644. firstZeroWeight = influencers - 1;
  78645. }
  78646. if (weight > epsilon) {
  78647. var mweight = 1.0 / weight;
  78648. for (var j = 0; j < 4; j++) {
  78649. matricesWeights[i + j] *= mweight;
  78650. }
  78651. if (matricesWeightsExtra) {
  78652. for (var j = 0; j < 4; j++) {
  78653. matricesWeightsExtra[i + j] *= mweight;
  78654. }
  78655. }
  78656. }
  78657. else {
  78658. if (firstZeroWeight >= 4) {
  78659. matricesWeightsExtra[i + firstZeroWeight - 4] = 1.0 - weight;
  78660. matricesIndicesExtra[i + firstZeroWeight - 4] = noInfluenceBoneIndex;
  78661. }
  78662. else {
  78663. matricesWeights[i + firstZeroWeight] = 1.0 - weight;
  78664. matricesIndices[i + firstZeroWeight] = noInfluenceBoneIndex;
  78665. }
  78666. }
  78667. }
  78668. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind, matricesIndices);
  78669. if (parsedGeometry.matricesWeightsExtra) {
  78670. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind, matricesIndicesExtra);
  78671. }
  78672. };
  78673. /**
  78674. * Create a new geometry from persisted data (Using .babylon file format)
  78675. * @param parsedVertexData defines the persisted data
  78676. * @param scene defines the hosting scene
  78677. * @param rootUrl defines the root url to use to load assets (like delayed data)
  78678. * @returns the new geometry object
  78679. */
  78680. Geometry.Parse = function (parsedVertexData, scene, rootUrl) {
  78681. if (scene.getGeometryByID(parsedVertexData.id)) {
  78682. return null; // null since geometry could be something else than a box...
  78683. }
  78684. var geometry = new Geometry(parsedVertexData.id, scene, undefined, parsedVertexData.updatable);
  78685. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  78686. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(geometry, parsedVertexData.tags);
  78687. }
  78688. if (parsedVertexData.delayLoadingFile) {
  78689. geometry.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED;
  78690. geometry.delayLoadingFile = rootUrl + parsedVertexData.delayLoadingFile;
  78691. 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));
  78692. geometry._delayInfo = [];
  78693. if (parsedVertexData.hasUVs) {
  78694. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind);
  78695. }
  78696. if (parsedVertexData.hasUVs2) {
  78697. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind);
  78698. }
  78699. if (parsedVertexData.hasUVs3) {
  78700. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind);
  78701. }
  78702. if (parsedVertexData.hasUVs4) {
  78703. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind);
  78704. }
  78705. if (parsedVertexData.hasUVs5) {
  78706. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind);
  78707. }
  78708. if (parsedVertexData.hasUVs6) {
  78709. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind);
  78710. }
  78711. if (parsedVertexData.hasColors) {
  78712. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  78713. }
  78714. if (parsedVertexData.hasMatricesIndices) {
  78715. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  78716. }
  78717. if (parsedVertexData.hasMatricesWeights) {
  78718. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  78719. }
  78720. geometry._delayLoadingFunction = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ImportVertexData;
  78721. }
  78722. else {
  78723. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ImportVertexData(parsedVertexData, geometry);
  78724. }
  78725. scene.pushGeometry(geometry, true);
  78726. return geometry;
  78727. };
  78728. return Geometry;
  78729. }());
  78730. // Primitives
  78731. /// Abstract class
  78732. /**
  78733. * Abstract class used to provide common services for all typed geometries
  78734. * @hidden
  78735. */
  78736. var _PrimitiveGeometry = /** @class */ (function (_super) {
  78737. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](_PrimitiveGeometry, _super);
  78738. /**
  78739. * Creates a new typed geometry
  78740. * @param id defines the unique ID of the geometry
  78741. * @param scene defines the hosting scene
  78742. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78743. * @param mesh defines the hosting mesh (can be null)
  78744. */
  78745. function _PrimitiveGeometry(id, scene, _canBeRegenerated, mesh) {
  78746. if (_canBeRegenerated === void 0) { _canBeRegenerated = false; }
  78747. if (mesh === void 0) { mesh = null; }
  78748. var _this = _super.call(this, id, scene, undefined, false, mesh) || this;
  78749. _this._canBeRegenerated = _canBeRegenerated;
  78750. _this._beingRegenerated = true;
  78751. _this.regenerate();
  78752. _this._beingRegenerated = false;
  78753. return _this;
  78754. }
  78755. /**
  78756. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  78757. * @returns true if the geometry can be regenerated
  78758. */
  78759. _PrimitiveGeometry.prototype.canBeRegenerated = function () {
  78760. return this._canBeRegenerated;
  78761. };
  78762. /**
  78763. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  78764. */
  78765. _PrimitiveGeometry.prototype.regenerate = function () {
  78766. if (!this._canBeRegenerated) {
  78767. return;
  78768. }
  78769. this._beingRegenerated = true;
  78770. this.setAllVerticesData(this._regenerateVertexData(), false);
  78771. this._beingRegenerated = false;
  78772. };
  78773. /**
  78774. * Clone the geometry
  78775. * @param id defines the unique ID of the new geometry
  78776. * @returns the new geometry
  78777. */
  78778. _PrimitiveGeometry.prototype.asNewGeometry = function (id) {
  78779. return _super.prototype.copy.call(this, id);
  78780. };
  78781. // overrides
  78782. _PrimitiveGeometry.prototype.setAllVerticesData = function (vertexData, updatable) {
  78783. if (!this._beingRegenerated) {
  78784. return;
  78785. }
  78786. _super.prototype.setAllVerticesData.call(this, vertexData, false);
  78787. };
  78788. _PrimitiveGeometry.prototype.setVerticesData = function (kind, data, updatable) {
  78789. if (!this._beingRegenerated) {
  78790. return;
  78791. }
  78792. _super.prototype.setVerticesData.call(this, kind, data, false);
  78793. };
  78794. // to override
  78795. /** @hidden */
  78796. _PrimitiveGeometry.prototype._regenerateVertexData = function () {
  78797. throw new Error("Abstract method");
  78798. };
  78799. _PrimitiveGeometry.prototype.copy = function (id) {
  78800. throw new Error("Must be overriden in sub-classes.");
  78801. };
  78802. _PrimitiveGeometry.prototype.serialize = function () {
  78803. var serializationObject = _super.prototype.serialize.call(this);
  78804. serializationObject.canBeRegenerated = this.canBeRegenerated();
  78805. return serializationObject;
  78806. };
  78807. return _PrimitiveGeometry;
  78808. }(Geometry));
  78809. /**
  78810. * Creates a ribbon geometry
  78811. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  78812. */
  78813. var RibbonGeometry = /** @class */ (function (_super) {
  78814. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RibbonGeometry, _super);
  78815. /**
  78816. * Creates a ribbon geometry
  78817. * @param id defines the unique ID of the geometry
  78818. * @param scene defines the hosting scene
  78819. * @param pathArray defines the array of paths to use
  78820. * @param closeArray defines if the last path and the first path must be joined
  78821. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  78822. * @param offset defines the offset between points
  78823. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78824. * @param mesh defines the hosting mesh (can be null)
  78825. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78826. */
  78827. function RibbonGeometry(id, scene,
  78828. /**
  78829. * Defines the array of paths to use
  78830. */
  78831. pathArray,
  78832. /**
  78833. * Defines if the last and first points of each path in your pathArray must be joined
  78834. */
  78835. closeArray,
  78836. /**
  78837. * Defines if the last and first points of each path in your pathArray must be joined
  78838. */
  78839. closePath,
  78840. /**
  78841. * Defines the offset between points
  78842. */
  78843. offset, canBeRegenerated, mesh,
  78844. /**
  78845. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78846. */
  78847. side) {
  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.pathArray = pathArray;
  78851. _this.closeArray = closeArray;
  78852. _this.closePath = closePath;
  78853. _this.offset = offset;
  78854. _this.side = side;
  78855. return _this;
  78856. }
  78857. /** @hidden */
  78858. RibbonGeometry.prototype._regenerateVertexData = function () {
  78859. 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 });
  78860. };
  78861. RibbonGeometry.prototype.copy = function (id) {
  78862. return new RibbonGeometry(id, this.getScene(), this.pathArray, this.closeArray, this.closePath, this.offset, this.canBeRegenerated(), undefined, this.side);
  78863. };
  78864. return RibbonGeometry;
  78865. }(_PrimitiveGeometry));
  78866. /**
  78867. * Creates a box geometry
  78868. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  78869. */
  78870. var BoxGeometry = /** @class */ (function (_super) {
  78871. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoxGeometry, _super);
  78872. /**
  78873. * Creates a box geometry
  78874. * @param id defines the unique ID of the geometry
  78875. * @param scene defines the hosting scene
  78876. * @param size defines the zise of the box (width, height and depth are the same)
  78877. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78878. * @param mesh defines the hosting mesh (can be null)
  78879. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78880. */
  78881. function BoxGeometry(id, scene,
  78882. /**
  78883. * Defines the zise of the box (width, height and depth are the same)
  78884. */
  78885. size, canBeRegenerated, mesh,
  78886. /**
  78887. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78888. */
  78889. side) {
  78890. if (mesh === void 0) { mesh = null; }
  78891. if (side === void 0) { side = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE; }
  78892. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  78893. _this.size = size;
  78894. _this.side = side;
  78895. return _this;
  78896. }
  78897. /** @hidden */
  78898. BoxGeometry.prototype._regenerateVertexData = function () {
  78899. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox({ size: this.size, sideOrientation: this.side });
  78900. };
  78901. BoxGeometry.prototype.copy = function (id) {
  78902. return new BoxGeometry(id, this.getScene(), this.size, this.canBeRegenerated(), undefined, this.side);
  78903. };
  78904. BoxGeometry.prototype.serialize = function () {
  78905. var serializationObject = _super.prototype.serialize.call(this);
  78906. serializationObject.size = this.size;
  78907. return serializationObject;
  78908. };
  78909. BoxGeometry.Parse = function (parsedBox, scene) {
  78910. if (scene.getGeometryByID(parsedBox.id)) {
  78911. return null; // null since geometry could be something else than a box...
  78912. }
  78913. var box = new BoxGeometry(parsedBox.id, scene, parsedBox.size, parsedBox.canBeRegenerated, null);
  78914. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  78915. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(box, parsedBox.tags);
  78916. }
  78917. scene.pushGeometry(box, true);
  78918. return box;
  78919. };
  78920. return BoxGeometry;
  78921. }(_PrimitiveGeometry));
  78922. /**
  78923. * Creates a sphere geometry
  78924. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  78925. */
  78926. var SphereGeometry = /** @class */ (function (_super) {
  78927. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SphereGeometry, _super);
  78928. /**
  78929. * Create a new sphere geometry
  78930. * @param id defines the unique ID of the geometry
  78931. * @param scene defines the hosting scene
  78932. * @param segments defines the number of segments to use to create the sphere
  78933. * @param diameter defines the diameter of the sphere
  78934. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78935. * @param mesh defines the hosting mesh (can be null)
  78936. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78937. */
  78938. function SphereGeometry(id, scene,
  78939. /**
  78940. * Defines the number of segments to use to create the sphere
  78941. */
  78942. segments,
  78943. /**
  78944. * Defines the diameter of the sphere
  78945. */
  78946. diameter, canBeRegenerated, mesh,
  78947. /**
  78948. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78949. */
  78950. side) {
  78951. if (mesh === void 0) { mesh = null; }
  78952. if (side === void 0) { side = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE; }
  78953. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  78954. _this.segments = segments;
  78955. _this.diameter = diameter;
  78956. _this.side = side;
  78957. return _this;
  78958. }
  78959. /** @hidden */
  78960. SphereGeometry.prototype._regenerateVertexData = function () {
  78961. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere({ segments: this.segments, diameter: this.diameter, sideOrientation: this.side });
  78962. };
  78963. SphereGeometry.prototype.copy = function (id) {
  78964. return new SphereGeometry(id, this.getScene(), this.segments, this.diameter, this.canBeRegenerated(), null, this.side);
  78965. };
  78966. SphereGeometry.prototype.serialize = function () {
  78967. var serializationObject = _super.prototype.serialize.call(this);
  78968. serializationObject.segments = this.segments;
  78969. serializationObject.diameter = this.diameter;
  78970. return serializationObject;
  78971. };
  78972. SphereGeometry.Parse = function (parsedSphere, scene) {
  78973. if (scene.getGeometryByID(parsedSphere.id)) {
  78974. return null; // null since geometry could be something else than a sphere...
  78975. }
  78976. var sphere = new SphereGeometry(parsedSphere.id, scene, parsedSphere.segments, parsedSphere.diameter, parsedSphere.canBeRegenerated, null);
  78977. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  78978. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(sphere, parsedSphere.tags);
  78979. }
  78980. scene.pushGeometry(sphere, true);
  78981. return sphere;
  78982. };
  78983. return SphereGeometry;
  78984. }(_PrimitiveGeometry));
  78985. /**
  78986. * Creates a disc geometry
  78987. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  78988. */
  78989. var DiscGeometry = /** @class */ (function (_super) {
  78990. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DiscGeometry, _super);
  78991. /**
  78992. * Creates a new disc geometry
  78993. * @param id defines the unique ID of the geometry
  78994. * @param scene defines the hosting scene
  78995. * @param radius defines the radius of the disc
  78996. * @param tessellation defines the tesselation factor to apply to the disc
  78997. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78998. * @param mesh defines the hosting mesh (can be null)
  78999. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  79000. */
  79001. function DiscGeometry(id, scene,
  79002. /**
  79003. * Defines the radius of the disc
  79004. */
  79005. radius,
  79006. /**
  79007. * Defines the tesselation factor to apply to the disc
  79008. */
  79009. tessellation, canBeRegenerated, mesh,
  79010. /**
  79011. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  79012. */
  79013. side) {
  79014. if (mesh === void 0) { mesh = null; }
  79015. if (side === void 0) { side = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE; }
  79016. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  79017. _this.radius = radius;
  79018. _this.tessellation = tessellation;
  79019. _this.side = side;
  79020. return _this;
  79021. }
  79022. /** @hidden */
  79023. DiscGeometry.prototype._regenerateVertexData = function () {
  79024. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDisc({ radius: this.radius, tessellation: this.tessellation, sideOrientation: this.side });
  79025. };
  79026. DiscGeometry.prototype.copy = function (id) {
  79027. return new DiscGeometry(id, this.getScene(), this.radius, this.tessellation, this.canBeRegenerated(), null, this.side);
  79028. };
  79029. return DiscGeometry;
  79030. }(_PrimitiveGeometry));
  79031. /**
  79032. * Creates a new cylinder geometry
  79033. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  79034. */
  79035. var CylinderGeometry = /** @class */ (function (_super) {
  79036. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderGeometry, _super);
  79037. /**
  79038. * Creates a new cylinder geometry
  79039. * @param id defines the unique ID of the geometry
  79040. * @param scene defines the hosting scene
  79041. * @param height defines the height of the cylinder
  79042. * @param diameterTop defines the diameter of the cylinder's top cap
  79043. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  79044. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  79045. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  79046. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  79047. * @param mesh defines the hosting mesh (can be null)
  79048. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  79049. */
  79050. function CylinderGeometry(id, scene,
  79051. /**
  79052. * Defines the height of the cylinder
  79053. */
  79054. height,
  79055. /**
  79056. * Defines the diameter of the cylinder's top cap
  79057. */
  79058. diameterTop,
  79059. /**
  79060. * Defines the diameter of the cylinder's bottom cap
  79061. */
  79062. diameterBottom,
  79063. /**
  79064. * Defines the tessellation factor to apply to the cylinder
  79065. */
  79066. tessellation,
  79067. /**
  79068. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  79069. */
  79070. subdivisions, canBeRegenerated, mesh,
  79071. /**
  79072. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  79073. */
  79074. side) {
  79075. if (subdivisions === void 0) { subdivisions = 1; }
  79076. if (mesh === void 0) { mesh = null; }
  79077. if (side === void 0) { side = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE; }
  79078. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  79079. _this.height = height;
  79080. _this.diameterTop = diameterTop;
  79081. _this.diameterBottom = diameterBottom;
  79082. _this.tessellation = tessellation;
  79083. _this.subdivisions = subdivisions;
  79084. _this.side = side;
  79085. return _this;
  79086. }
  79087. /** @hidden */
  79088. CylinderGeometry.prototype._regenerateVertexData = function () {
  79089. 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 });
  79090. };
  79091. CylinderGeometry.prototype.copy = function (id) {
  79092. return new CylinderGeometry(id, this.getScene(), this.height, this.diameterTop, this.diameterBottom, this.tessellation, this.subdivisions, this.canBeRegenerated(), null, this.side);
  79093. };
  79094. CylinderGeometry.prototype.serialize = function () {
  79095. var serializationObject = _super.prototype.serialize.call(this);
  79096. serializationObject.height = this.height;
  79097. serializationObject.diameterTop = this.diameterTop;
  79098. serializationObject.diameterBottom = this.diameterBottom;
  79099. serializationObject.tessellation = this.tessellation;
  79100. return serializationObject;
  79101. };
  79102. CylinderGeometry.Parse = function (parsedCylinder, scene) {
  79103. if (scene.getGeometryByID(parsedCylinder.id)) {
  79104. return null; // null since geometry could be something else than a cylinder...
  79105. }
  79106. var cylinder = new CylinderGeometry(parsedCylinder.id, scene, parsedCylinder.height, parsedCylinder.diameterTop, parsedCylinder.diameterBottom, parsedCylinder.tessellation, parsedCylinder.subdivisions, parsedCylinder.canBeRegenerated, null);
  79107. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  79108. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(cylinder, parsedCylinder.tags);
  79109. }
  79110. scene.pushGeometry(cylinder, true);
  79111. return cylinder;
  79112. };
  79113. return CylinderGeometry;
  79114. }(_PrimitiveGeometry));
  79115. /**
  79116. * Creates a new torus geometry
  79117. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  79118. */
  79119. var TorusGeometry = /** @class */ (function (_super) {
  79120. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TorusGeometry, _super);
  79121. /**
  79122. * Creates a new torus geometry
  79123. * @param id defines the unique ID of the geometry
  79124. * @param scene defines the hosting scene
  79125. * @param diameter defines the diameter of the torus
  79126. * @param thickness defines the thickness of the torus (ie. internal diameter)
  79127. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  79128. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  79129. * @param mesh defines the hosting mesh (can be null)
  79130. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  79131. */
  79132. function TorusGeometry(id, scene,
  79133. /**
  79134. * Defines the diameter of the torus
  79135. */
  79136. diameter,
  79137. /**
  79138. * Defines the thickness of the torus (ie. internal diameter)
  79139. */
  79140. thickness,
  79141. /**
  79142. * Defines the tesselation factor to apply to the torus
  79143. */
  79144. tessellation, canBeRegenerated, mesh,
  79145. /**
  79146. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  79147. */
  79148. side) {
  79149. if (mesh === void 0) { mesh = null; }
  79150. if (side === void 0) { side = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE; }
  79151. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  79152. _this.diameter = diameter;
  79153. _this.thickness = thickness;
  79154. _this.tessellation = tessellation;
  79155. _this.side = side;
  79156. return _this;
  79157. }
  79158. /** @hidden */
  79159. TorusGeometry.prototype._regenerateVertexData = function () {
  79160. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus({ diameter: this.diameter, thickness: this.thickness, tessellation: this.tessellation, sideOrientation: this.side });
  79161. };
  79162. TorusGeometry.prototype.copy = function (id) {
  79163. return new TorusGeometry(id, this.getScene(), this.diameter, this.thickness, this.tessellation, this.canBeRegenerated(), null, this.side);
  79164. };
  79165. TorusGeometry.prototype.serialize = function () {
  79166. var serializationObject = _super.prototype.serialize.call(this);
  79167. serializationObject.diameter = this.diameter;
  79168. serializationObject.thickness = this.thickness;
  79169. serializationObject.tessellation = this.tessellation;
  79170. return serializationObject;
  79171. };
  79172. TorusGeometry.Parse = function (parsedTorus, scene) {
  79173. if (scene.getGeometryByID(parsedTorus.id)) {
  79174. return null; // null since geometry could be something else than a torus...
  79175. }
  79176. var torus = new TorusGeometry(parsedTorus.id, scene, parsedTorus.diameter, parsedTorus.thickness, parsedTorus.tessellation, parsedTorus.canBeRegenerated, null);
  79177. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  79178. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(torus, parsedTorus.tags);
  79179. }
  79180. scene.pushGeometry(torus, true);
  79181. return torus;
  79182. };
  79183. return TorusGeometry;
  79184. }(_PrimitiveGeometry));
  79185. /**
  79186. * Creates a new ground geometry
  79187. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  79188. */
  79189. var GroundGeometry = /** @class */ (function (_super) {
  79190. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GroundGeometry, _super);
  79191. /**
  79192. * Creates a new ground geometry
  79193. * @param id defines the unique ID of the geometry
  79194. * @param scene defines the hosting scene
  79195. * @param width defines the width of the ground
  79196. * @param height defines the height of the ground
  79197. * @param subdivisions defines the subdivisions to apply to the ground
  79198. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  79199. * @param mesh defines the hosting mesh (can be null)
  79200. */
  79201. function GroundGeometry(id, scene,
  79202. /**
  79203. * Defines the width of the ground
  79204. */
  79205. width,
  79206. /**
  79207. * Defines the height of the ground
  79208. */
  79209. height,
  79210. /**
  79211. * Defines the subdivisions to apply to the ground
  79212. */
  79213. subdivisions, canBeRegenerated, mesh) {
  79214. if (mesh === void 0) { mesh = null; }
  79215. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  79216. _this.width = width;
  79217. _this.height = height;
  79218. _this.subdivisions = subdivisions;
  79219. return _this;
  79220. }
  79221. /** @hidden */
  79222. GroundGeometry.prototype._regenerateVertexData = function () {
  79223. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround({ width: this.width, height: this.height, subdivisions: this.subdivisions });
  79224. };
  79225. GroundGeometry.prototype.copy = function (id) {
  79226. return new GroundGeometry(id, this.getScene(), this.width, this.height, this.subdivisions, this.canBeRegenerated(), null);
  79227. };
  79228. GroundGeometry.prototype.serialize = function () {
  79229. var serializationObject = _super.prototype.serialize.call(this);
  79230. serializationObject.width = this.width;
  79231. serializationObject.height = this.height;
  79232. serializationObject.subdivisions = this.subdivisions;
  79233. return serializationObject;
  79234. };
  79235. GroundGeometry.Parse = function (parsedGround, scene) {
  79236. if (scene.getGeometryByID(parsedGround.id)) {
  79237. return null; // null since geometry could be something else than a ground...
  79238. }
  79239. var ground = new GroundGeometry(parsedGround.id, scene, parsedGround.width, parsedGround.height, parsedGround.subdivisions, parsedGround.canBeRegenerated, null);
  79240. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  79241. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(ground, parsedGround.tags);
  79242. }
  79243. scene.pushGeometry(ground, true);
  79244. return ground;
  79245. };
  79246. return GroundGeometry;
  79247. }(_PrimitiveGeometry));
  79248. /**
  79249. * Creates a tiled ground geometry
  79250. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  79251. */
  79252. var TiledGroundGeometry = /** @class */ (function (_super) {
  79253. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TiledGroundGeometry, _super);
  79254. /**
  79255. * Creates a tiled ground geometry
  79256. * @param id defines the unique ID of the geometry
  79257. * @param scene defines the hosting scene
  79258. * @param xmin defines the minimum value on X axis
  79259. * @param zmin defines the minimum value on Z axis
  79260. * @param xmax defines the maximum value on X axis
  79261. * @param zmax defines the maximum value on Z axis
  79262. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  79263. * @param precision defines the precision to use when computing the tiles
  79264. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  79265. * @param mesh defines the hosting mesh (can be null)
  79266. */
  79267. function TiledGroundGeometry(id, scene,
  79268. /**
  79269. * Defines the minimum value on X axis
  79270. */
  79271. xmin,
  79272. /**
  79273. * Defines the minimum value on Z axis
  79274. */
  79275. zmin,
  79276. /**
  79277. * Defines the maximum value on X axis
  79278. */
  79279. xmax,
  79280. /**
  79281. * Defines the maximum value on Z axis
  79282. */
  79283. zmax,
  79284. /**
  79285. * Defines the subdivisions to apply to the ground
  79286. */
  79287. subdivisions,
  79288. /**
  79289. * Defines the precision to use when computing the tiles
  79290. */
  79291. precision, canBeRegenerated, mesh) {
  79292. if (mesh === void 0) { mesh = null; }
  79293. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  79294. _this.xmin = xmin;
  79295. _this.zmin = zmin;
  79296. _this.xmax = xmax;
  79297. _this.zmax = zmax;
  79298. _this.subdivisions = subdivisions;
  79299. _this.precision = precision;
  79300. return _this;
  79301. }
  79302. /** @hidden */
  79303. TiledGroundGeometry.prototype._regenerateVertexData = function () {
  79304. 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 });
  79305. };
  79306. TiledGroundGeometry.prototype.copy = function (id) {
  79307. return new TiledGroundGeometry(id, this.getScene(), this.xmin, this.zmin, this.xmax, this.zmax, this.subdivisions, this.precision, this.canBeRegenerated(), null);
  79308. };
  79309. return TiledGroundGeometry;
  79310. }(_PrimitiveGeometry));
  79311. /**
  79312. * Creates a plane geometry
  79313. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  79314. */
  79315. var PlaneGeometry = /** @class */ (function (_super) {
  79316. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaneGeometry, _super);
  79317. /**
  79318. * Creates a plane geometry
  79319. * @param id defines the unique ID of the geometry
  79320. * @param scene defines the hosting scene
  79321. * @param size defines the size of the plane (width === height)
  79322. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  79323. * @param mesh defines the hosting mesh (can be null)
  79324. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  79325. */
  79326. function PlaneGeometry(id, scene,
  79327. /**
  79328. * Defines the size of the plane (width === height)
  79329. */
  79330. size, canBeRegenerated, mesh,
  79331. /**
  79332. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  79333. */
  79334. side) {
  79335. if (mesh === void 0) { mesh = null; }
  79336. if (side === void 0) { side = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE; }
  79337. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  79338. _this.size = size;
  79339. _this.side = side;
  79340. return _this;
  79341. }
  79342. /** @hidden */
  79343. PlaneGeometry.prototype._regenerateVertexData = function () {
  79344. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePlane({ size: this.size, sideOrientation: this.side });
  79345. };
  79346. PlaneGeometry.prototype.copy = function (id) {
  79347. return new PlaneGeometry(id, this.getScene(), this.size, this.canBeRegenerated(), null, this.side);
  79348. };
  79349. PlaneGeometry.prototype.serialize = function () {
  79350. var serializationObject = _super.prototype.serialize.call(this);
  79351. serializationObject.size = this.size;
  79352. return serializationObject;
  79353. };
  79354. PlaneGeometry.Parse = function (parsedPlane, scene) {
  79355. if (scene.getGeometryByID(parsedPlane.id)) {
  79356. return null; // null since geometry could be something else than a ground...
  79357. }
  79358. var plane = new PlaneGeometry(parsedPlane.id, scene, parsedPlane.size, parsedPlane.canBeRegenerated, null);
  79359. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  79360. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(plane, parsedPlane.tags);
  79361. }
  79362. scene.pushGeometry(plane, true);
  79363. return plane;
  79364. };
  79365. return PlaneGeometry;
  79366. }(_PrimitiveGeometry));
  79367. /**
  79368. * Creates a torus knot geometry
  79369. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  79370. */
  79371. var TorusKnotGeometry = /** @class */ (function (_super) {
  79372. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TorusKnotGeometry, _super);
  79373. /**
  79374. * Creates a torus knot geometry
  79375. * @param id defines the unique ID of the geometry
  79376. * @param scene defines the hosting scene
  79377. * @param radius defines the radius of the torus knot
  79378. * @param tube defines the thickness of the torus knot tube
  79379. * @param radialSegments defines the number of radial segments
  79380. * @param tubularSegments defines the number of tubular segments
  79381. * @param p defines the first number of windings
  79382. * @param q defines the second number of windings
  79383. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  79384. * @param mesh defines the hosting mesh (can be null)
  79385. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  79386. */
  79387. function TorusKnotGeometry(id, scene,
  79388. /**
  79389. * Defines the radius of the torus knot
  79390. */
  79391. radius,
  79392. /**
  79393. * Defines the thickness of the torus knot tube
  79394. */
  79395. tube,
  79396. /**
  79397. * Defines the number of radial segments
  79398. */
  79399. radialSegments,
  79400. /**
  79401. * Defines the number of tubular segments
  79402. */
  79403. tubularSegments,
  79404. /**
  79405. * Defines the first number of windings
  79406. */
  79407. p,
  79408. /**
  79409. * Defines the second number of windings
  79410. */
  79411. q, canBeRegenerated, mesh,
  79412. /**
  79413. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  79414. */
  79415. side) {
  79416. if (mesh === void 0) { mesh = null; }
  79417. if (side === void 0) { side = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE; }
  79418. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  79419. _this.radius = radius;
  79420. _this.tube = tube;
  79421. _this.radialSegments = radialSegments;
  79422. _this.tubularSegments = tubularSegments;
  79423. _this.p = p;
  79424. _this.q = q;
  79425. _this.side = side;
  79426. return _this;
  79427. }
  79428. /** @hidden */
  79429. TorusKnotGeometry.prototype._regenerateVertexData = function () {
  79430. 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 });
  79431. };
  79432. TorusKnotGeometry.prototype.copy = function (id) {
  79433. return new TorusKnotGeometry(id, this.getScene(), this.radius, this.tube, this.radialSegments, this.tubularSegments, this.p, this.q, this.canBeRegenerated(), null, this.side);
  79434. };
  79435. TorusKnotGeometry.prototype.serialize = function () {
  79436. var serializationObject = _super.prototype.serialize.call(this);
  79437. serializationObject.radius = this.radius;
  79438. serializationObject.tube = this.tube;
  79439. serializationObject.radialSegments = this.radialSegments;
  79440. serializationObject.tubularSegments = this.tubularSegments;
  79441. serializationObject.p = this.p;
  79442. serializationObject.q = this.q;
  79443. return serializationObject;
  79444. };
  79445. TorusKnotGeometry.Parse = function (parsedTorusKnot, scene) {
  79446. if (scene.getGeometryByID(parsedTorusKnot.id)) {
  79447. return null; // null since geometry could be something else than a ground...
  79448. }
  79449. var torusKnot = new TorusKnotGeometry(parsedTorusKnot.id, scene, parsedTorusKnot.radius, parsedTorusKnot.tube, parsedTorusKnot.radialSegments, parsedTorusKnot.tubularSegments, parsedTorusKnot.p, parsedTorusKnot.q, parsedTorusKnot.canBeRegenerated, null);
  79450. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  79451. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(torusKnot, parsedTorusKnot.tags);
  79452. }
  79453. scene.pushGeometry(torusKnot, true);
  79454. return torusKnot;
  79455. };
  79456. return TorusKnotGeometry;
  79457. }(_PrimitiveGeometry));
  79458. //}
  79459. /***/ }),
  79460. /***/ "./Meshes/groundMesh.ts":
  79461. /*!******************************!*\
  79462. !*** ./Meshes/groundMesh.ts ***!
  79463. \******************************/
  79464. /*! exports provided: GroundMesh */
  79465. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79466. "use strict";
  79467. __webpack_require__.r(__webpack_exports__);
  79468. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return GroundMesh; });
  79469. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  79470. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  79471. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  79472. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  79473. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._GroundMeshParser = function (parsedMesh, scene) {
  79474. return GroundMesh.Parse(parsedMesh, scene);
  79475. };
  79476. /**
  79477. * Mesh representing the gorund
  79478. */
  79479. var GroundMesh = /** @class */ (function (_super) {
  79480. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GroundMesh, _super);
  79481. function GroundMesh(name, scene) {
  79482. var _this = _super.call(this, name, scene) || this;
  79483. /** If octree should be generated */
  79484. _this.generateOctree = false;
  79485. return _this;
  79486. }
  79487. /**
  79488. * "GroundMesh"
  79489. * @returns "GroundMesh"
  79490. */
  79491. GroundMesh.prototype.getClassName = function () {
  79492. return "GroundMesh";
  79493. };
  79494. Object.defineProperty(GroundMesh.prototype, "subdivisions", {
  79495. /**
  79496. * The minimum of x and y subdivisions
  79497. */
  79498. get: function () {
  79499. return Math.min(this._subdivisionsX, this._subdivisionsY);
  79500. },
  79501. enumerable: true,
  79502. configurable: true
  79503. });
  79504. Object.defineProperty(GroundMesh.prototype, "subdivisionsX", {
  79505. /**
  79506. * X subdivisions
  79507. */
  79508. get: function () {
  79509. return this._subdivisionsX;
  79510. },
  79511. enumerable: true,
  79512. configurable: true
  79513. });
  79514. Object.defineProperty(GroundMesh.prototype, "subdivisionsY", {
  79515. /**
  79516. * Y subdivisions
  79517. */
  79518. get: function () {
  79519. return this._subdivisionsY;
  79520. },
  79521. enumerable: true,
  79522. configurable: true
  79523. });
  79524. /**
  79525. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  79526. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  79527. * @param chunksCount the number of subdivisions for x and y
  79528. * @param octreeBlocksSize (Default: 32)
  79529. */
  79530. GroundMesh.prototype.optimize = function (chunksCount, octreeBlocksSize) {
  79531. if (octreeBlocksSize === void 0) { octreeBlocksSize = 32; }
  79532. this._subdivisionsX = chunksCount;
  79533. this._subdivisionsY = chunksCount;
  79534. this.subdivide(chunksCount);
  79535. // Call the octree system optimization if it is defined.
  79536. var thisAsAny = this;
  79537. if (thisAsAny.createOrUpdateSubmeshesOctree) {
  79538. thisAsAny.createOrUpdateSubmeshesOctree(octreeBlocksSize);
  79539. }
  79540. };
  79541. /**
  79542. * Returns a height (y) value in the Worl system :
  79543. * the ground altitude at the coordinates (x, z) expressed in the World system.
  79544. * @param x x coordinate
  79545. * @param z z coordinate
  79546. * @returns the ground y position if (x, z) are outside the ground surface.
  79547. */
  79548. GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {
  79549. var world = this.getWorldMatrix();
  79550. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  79551. world.invertToRef(invMat);
  79552. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  79553. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, invMat, tmpVect); // transform x,z in the mesh local space
  79554. x = tmpVect.x;
  79555. z = tmpVect.z;
  79556. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  79557. return this.position.y;
  79558. }
  79559. if (!this._heightQuads || this._heightQuads.length == 0) {
  79560. this._initHeightQuads();
  79561. this._computeHeightQuads();
  79562. }
  79563. var facet = this._getFacetAt(x, z);
  79564. var y = -(facet.x * x + facet.z * z + facet.w) / facet.y;
  79565. // return y in the World system
  79566. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0.0, y, 0.0, world, tmpVect);
  79567. return tmpVect.y;
  79568. };
  79569. /**
  79570. * Returns a normalized vector (Vector3) orthogonal to the ground
  79571. * at the ground coordinates (x, z) expressed in the World system.
  79572. * @param x x coordinate
  79573. * @param z z coordinate
  79574. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  79575. */
  79576. GroundMesh.prototype.getNormalAtCoordinates = function (x, z) {
  79577. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.0, 1.0, 0.0);
  79578. this.getNormalAtCoordinatesToRef(x, z, normal);
  79579. return normal;
  79580. };
  79581. /**
  79582. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  79583. * at the ground coordinates (x, z) expressed in the World system.
  79584. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  79585. * @param x x coordinate
  79586. * @param z z coordinate
  79587. * @param ref vector to store the result
  79588. * @returns the GroundMesh.
  79589. */
  79590. GroundMesh.prototype.getNormalAtCoordinatesToRef = function (x, z, ref) {
  79591. var world = this.getWorldMatrix();
  79592. var tmpMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  79593. world.invertToRef(tmpMat);
  79594. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  79595. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, tmpMat, tmpVect); // transform x,z in the mesh local space
  79596. x = tmpVect.x;
  79597. z = tmpVect.z;
  79598. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  79599. return this;
  79600. }
  79601. if (!this._heightQuads || this._heightQuads.length == 0) {
  79602. this._initHeightQuads();
  79603. this._computeHeightQuads();
  79604. }
  79605. var facet = this._getFacetAt(x, z);
  79606. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(facet.x, facet.y, facet.z, world, ref);
  79607. return this;
  79608. };
  79609. /**
  79610. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  79611. * if the ground has been updated.
  79612. * This can be used in the render loop.
  79613. * @returns the GroundMesh.
  79614. */
  79615. GroundMesh.prototype.updateCoordinateHeights = function () {
  79616. if (!this._heightQuads || this._heightQuads.length == 0) {
  79617. this._initHeightQuads();
  79618. }
  79619. this._computeHeightQuads();
  79620. return this;
  79621. };
  79622. // Returns the element "facet" from the heightQuads array relative to (x, z) local coordinates
  79623. GroundMesh.prototype._getFacetAt = function (x, z) {
  79624. // retrieve col and row from x, z coordinates in the ground local system
  79625. var col = Math.floor((x + this._maxX) * this._subdivisionsX / this._width);
  79626. var row = Math.floor(-(z + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY);
  79627. var quad = this._heightQuads[row * this._subdivisionsX + col];
  79628. var facet;
  79629. if (z < quad.slope.x * x + quad.slope.y) {
  79630. facet = quad.facet1;
  79631. }
  79632. else {
  79633. facet = quad.facet2;
  79634. }
  79635. return facet;
  79636. };
  79637. // Creates and populates the heightMap array with "facet" elements :
  79638. // a quad is two triangular facets separated by a slope, so a "facet" element is 1 slope + 2 facets
  79639. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  79640. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  79641. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  79642. // Returns the GroundMesh.
  79643. GroundMesh.prototype._initHeightQuads = function () {
  79644. var subdivisionsX = this._subdivisionsX;
  79645. var subdivisionsY = this._subdivisionsY;
  79646. this._heightQuads = new Array();
  79647. for (var row = 0; row < subdivisionsY; row++) {
  79648. for (var col = 0; col < subdivisionsX; col++) {
  79649. 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) };
  79650. this._heightQuads[row * subdivisionsX + col] = quad;
  79651. }
  79652. }
  79653. return this;
  79654. };
  79655. // Compute each quad element values and update the the heightMap array :
  79656. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  79657. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  79658. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  79659. // Returns the GroundMesh.
  79660. GroundMesh.prototype._computeHeightQuads = function () {
  79661. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  79662. if (!positions) {
  79663. return this;
  79664. }
  79665. var v1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  79666. var v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  79667. var v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  79668. var v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  79669. var v1v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  79670. var v1v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  79671. var v1v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  79672. var norm1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[7];
  79673. var norm2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  79674. var i = 0;
  79675. var j = 0;
  79676. var k = 0;
  79677. var cd = 0; // 2D slope coefficient : z = cd * x + h
  79678. var h = 0;
  79679. var d1 = 0; // facet plane equation : ax + by + cz + d = 0
  79680. var d2 = 0;
  79681. var subdivisionsX = this._subdivisionsX;
  79682. var subdivisionsY = this._subdivisionsY;
  79683. for (var row = 0; row < subdivisionsY; row++) {
  79684. for (var col = 0; col < subdivisionsX; col++) {
  79685. i = col * 3;
  79686. j = row * (subdivisionsX + 1) * 3;
  79687. k = (row + 1) * (subdivisionsX + 1) * 3;
  79688. v1.x = positions[j + i];
  79689. v1.y = positions[j + i + 1];
  79690. v1.z = positions[j + i + 2];
  79691. v2.x = positions[j + i + 3];
  79692. v2.y = positions[j + i + 4];
  79693. v2.z = positions[j + i + 5];
  79694. v3.x = positions[k + i];
  79695. v3.y = positions[k + i + 1];
  79696. v3.z = positions[k + i + 2];
  79697. v4.x = positions[k + i + 3];
  79698. v4.y = positions[k + i + 4];
  79699. v4.z = positions[k + i + 5];
  79700. // 2D slope V1V4
  79701. cd = (v4.z - v1.z) / (v4.x - v1.x);
  79702. h = v1.z - cd * v1.x; // v1 belongs to the slope
  79703. // facet equations :
  79704. // we compute each facet normal vector
  79705. // the equation of the facet plane is : norm.x * x + norm.y * y + norm.z * z + d = 0
  79706. // we compute the value d by applying the equation to v1 which belongs to the plane
  79707. // then we store the facet equation in a Vector4
  79708. v2.subtractToRef(v1, v1v2);
  79709. v3.subtractToRef(v1, v1v3);
  79710. v4.subtractToRef(v1, v1v4);
  79711. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v4, v1v3, norm1); // caution : CrossToRef uses the Tmp class
  79712. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v2, v1v4, norm2);
  79713. norm1.normalize();
  79714. norm2.normalize();
  79715. d1 = -(norm1.x * v1.x + norm1.y * v1.y + norm1.z * v1.z);
  79716. d2 = -(norm2.x * v2.x + norm2.y * v2.y + norm2.z * v2.z);
  79717. var quad = this._heightQuads[row * subdivisionsX + col];
  79718. quad.slope.copyFromFloats(cd, h);
  79719. quad.facet1.copyFromFloats(norm1.x, norm1.y, norm1.z, d1);
  79720. quad.facet2.copyFromFloats(norm2.x, norm2.y, norm2.z, d2);
  79721. }
  79722. }
  79723. return this;
  79724. };
  79725. /**
  79726. * Serializes this ground mesh
  79727. * @param serializationObject object to write serialization to
  79728. */
  79729. GroundMesh.prototype.serialize = function (serializationObject) {
  79730. _super.prototype.serialize.call(this, serializationObject);
  79731. serializationObject.subdivisionsX = this._subdivisionsX;
  79732. serializationObject.subdivisionsY = this._subdivisionsY;
  79733. serializationObject.minX = this._minX;
  79734. serializationObject.maxX = this._maxX;
  79735. serializationObject.minZ = this._minZ;
  79736. serializationObject.maxZ = this._maxZ;
  79737. serializationObject.width = this._width;
  79738. serializationObject.height = this._height;
  79739. };
  79740. /**
  79741. * Parses a serialized ground mesh
  79742. * @param parsedMesh the serialized mesh
  79743. * @param scene the scene to create the ground mesh in
  79744. * @returns the created ground mesh
  79745. */
  79746. GroundMesh.Parse = function (parsedMesh, scene) {
  79747. var result = new GroundMesh(parsedMesh.name, scene);
  79748. result._subdivisionsX = parsedMesh.subdivisionsX || 1;
  79749. result._subdivisionsY = parsedMesh.subdivisionsY || 1;
  79750. result._minX = parsedMesh.minX;
  79751. result._maxX = parsedMesh.maxX;
  79752. result._minZ = parsedMesh.minZ;
  79753. result._maxZ = parsedMesh.maxZ;
  79754. result._width = parsedMesh.width;
  79755. result._height = parsedMesh.height;
  79756. return result;
  79757. };
  79758. return GroundMesh;
  79759. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  79760. /***/ }),
  79761. /***/ "./Meshes/index.ts":
  79762. /*!*************************!*\
  79763. !*** ./Meshes/index.ts ***!
  79764. \*************************/
  79765. /*! 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 */
  79766. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79767. "use strict";
  79768. __webpack_require__.r(__webpack_exports__);
  79769. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  79770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  79771. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  79772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["Buffer"]; });
  79773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"]; });
  79774. /* harmony import */ var _Compression_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Compression/index */ "./Meshes/Compression/index.ts");
  79775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Compression_index__WEBPACK_IMPORTED_MODULE_2__["DracoCompression"]; });
  79776. /* harmony import */ var _csg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./csg */ "./Meshes/csg.ts");
  79777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _csg__WEBPACK_IMPORTED_MODULE_3__["CSG"]; });
  79778. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  79779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"]; });
  79780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_PrimitiveGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["_PrimitiveGeometry"]; });
  79781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["RibbonGeometry"]; });
  79782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["BoxGeometry"]; });
  79783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["SphereGeometry"]; });
  79784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["DiscGeometry"]; });
  79785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["CylinderGeometry"]; });
  79786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["TorusGeometry"]; });
  79787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["GroundGeometry"]; });
  79788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TiledGroundGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["TiledGroundGeometry"]; });
  79789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["PlaneGeometry"]; });
  79790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["TorusKnotGeometry"]; });
  79791. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./groundMesh */ "./Meshes/groundMesh.ts");
  79792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _groundMesh__WEBPACK_IMPORTED_MODULE_5__["GroundMesh"]; });
  79793. /* harmony import */ var _instancedMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./instancedMesh */ "./Meshes/instancedMesh.ts");
  79794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _instancedMesh__WEBPACK_IMPORTED_MODULE_6__["InstancedMesh"]; });
  79795. /* harmony import */ var _linesMesh__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./linesMesh */ "./Meshes/linesMesh.ts");
  79796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_7__["LinesMesh"]; });
  79797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_7__["InstancedLinesMesh"]; });
  79798. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  79799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["MeshLODLevel"]; });
  79800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["_CreationDataStorage"]; });
  79801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["_InstancesBatch"]; });
  79802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["Mesh"]; });
  79803. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__["VertexData"]; });
  79805. /* harmony import */ var _meshBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./meshBuilder */ "./Meshes/meshBuilder.ts");
  79806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _meshBuilder__WEBPACK_IMPORTED_MODULE_10__["MeshBuilder"]; });
  79807. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  79808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationSettings"]; });
  79809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationQueue"]; });
  79810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationType"]; });
  79811. /* harmony import */ var _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./meshSimplificationSceneComponent */ "./Meshes/meshSimplificationSceneComponent.ts");
  79812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_12__["SimplicationQueueSceneComponent"]; });
  79813. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./polygonMesh */ "./Meshes/polygonMesh.ts");
  79814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_13__["Polygon"]; });
  79815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_13__["PolygonMeshBuilder"]; });
  79816. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  79817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_14__["BaseSubMesh"]; });
  79818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_14__["SubMesh"]; });
  79819. /* harmony import */ var _transformNode__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./transformNode */ "./Meshes/transformNode.ts");
  79820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _transformNode__WEBPACK_IMPORTED_MODULE_15__["TransformNode"]; });
  79821. /***/ }),
  79822. /***/ "./Meshes/instancedMesh.ts":
  79823. /*!*********************************!*\
  79824. !*** ./Meshes/instancedMesh.ts ***!
  79825. \*********************************/
  79826. /*! exports provided: InstancedMesh */
  79827. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79828. "use strict";
  79829. __webpack_require__.r(__webpack_exports__);
  79830. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return InstancedMesh; });
  79831. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  79832. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  79833. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  79834. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  79835. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  79836. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._instancedMeshFactory = function (name, mesh) {
  79837. return new InstancedMesh(name, mesh);
  79838. };
  79839. /**
  79840. * Creates an instance based on a source mesh.
  79841. */
  79842. var InstancedMesh = /** @class */ (function (_super) {
  79843. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedMesh, _super);
  79844. function InstancedMesh(name, source) {
  79845. var _this = _super.call(this, name, source.getScene()) || this;
  79846. /** @hidden */
  79847. _this._indexInSourceMeshInstanceArray = -1;
  79848. source.addInstance(_this);
  79849. _this._sourceMesh = source;
  79850. _this.position.copyFrom(source.position);
  79851. _this.rotation.copyFrom(source.rotation);
  79852. _this.scaling.copyFrom(source.scaling);
  79853. if (source.rotationQuaternion) {
  79854. _this.rotationQuaternion = source.rotationQuaternion.clone();
  79855. }
  79856. _this.infiniteDistance = source.infiniteDistance;
  79857. _this.setPivotMatrix(source.getPivotMatrix());
  79858. _this.refreshBoundingInfo();
  79859. _this._syncSubMeshes();
  79860. return _this;
  79861. }
  79862. /**
  79863. * Returns the string "InstancedMesh".
  79864. */
  79865. InstancedMesh.prototype.getClassName = function () {
  79866. return "InstancedMesh";
  79867. };
  79868. Object.defineProperty(InstancedMesh.prototype, "receiveShadows", {
  79869. // Methods
  79870. /**
  79871. * If the source mesh receives shadows
  79872. */
  79873. get: function () {
  79874. return this._sourceMesh.receiveShadows;
  79875. },
  79876. enumerable: true,
  79877. configurable: true
  79878. });
  79879. Object.defineProperty(InstancedMesh.prototype, "material", {
  79880. /**
  79881. * The material of the source mesh
  79882. */
  79883. get: function () {
  79884. return this._sourceMesh.material;
  79885. },
  79886. enumerable: true,
  79887. configurable: true
  79888. });
  79889. Object.defineProperty(InstancedMesh.prototype, "visibility", {
  79890. /**
  79891. * Visibility of the source mesh
  79892. */
  79893. get: function () {
  79894. return this._sourceMesh.visibility;
  79895. },
  79896. enumerable: true,
  79897. configurable: true
  79898. });
  79899. Object.defineProperty(InstancedMesh.prototype, "skeleton", {
  79900. /**
  79901. * Skeleton of the source mesh
  79902. */
  79903. get: function () {
  79904. return this._sourceMesh.skeleton;
  79905. },
  79906. enumerable: true,
  79907. configurable: true
  79908. });
  79909. Object.defineProperty(InstancedMesh.prototype, "renderingGroupId", {
  79910. /**
  79911. * Rendering ground id of the source mesh
  79912. */
  79913. get: function () {
  79914. return this._sourceMesh.renderingGroupId;
  79915. },
  79916. set: function (value) {
  79917. if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {
  79918. return;
  79919. }
  79920. //no-op with warning
  79921. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene");
  79922. },
  79923. enumerable: true,
  79924. configurable: true
  79925. });
  79926. /**
  79927. * Returns the total number of vertices (integer).
  79928. */
  79929. InstancedMesh.prototype.getTotalVertices = function () {
  79930. return this._sourceMesh.getTotalVertices();
  79931. };
  79932. /**
  79933. * Returns a positive integer : the total number of indices in this mesh geometry.
  79934. * @returns the numner of indices or zero if the mesh has no geometry.
  79935. */
  79936. InstancedMesh.prototype.getTotalIndices = function () {
  79937. return this._sourceMesh.getTotalIndices();
  79938. };
  79939. Object.defineProperty(InstancedMesh.prototype, "sourceMesh", {
  79940. /**
  79941. * The source mesh of the instance
  79942. */
  79943. get: function () {
  79944. return this._sourceMesh;
  79945. },
  79946. enumerable: true,
  79947. configurable: true
  79948. });
  79949. /**
  79950. * Is this node ready to be used/rendered
  79951. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  79952. * @return {boolean} is it ready
  79953. */
  79954. InstancedMesh.prototype.isReady = function (completeCheck) {
  79955. if (completeCheck === void 0) { completeCheck = false; }
  79956. return this._sourceMesh.isReady(completeCheck, true);
  79957. };
  79958. /**
  79959. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79960. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  79961. * @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.
  79962. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  79963. */
  79964. InstancedMesh.prototype.getVerticesData = function (kind, copyWhenShared) {
  79965. return this._sourceMesh.getVerticesData(kind, copyWhenShared);
  79966. };
  79967. /**
  79968. * Sets the vertex data of the mesh geometry for the requested `kind`.
  79969. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  79970. * The `data` are either a numeric array either a Float32Array.
  79971. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  79972. * 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).
  79973. * Note that a new underlying VertexBuffer object is created each call.
  79974. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  79975. *
  79976. * Possible `kind` values :
  79977. * - VertexBuffer.PositionKind
  79978. * - VertexBuffer.UVKind
  79979. * - VertexBuffer.UV2Kind
  79980. * - VertexBuffer.UV3Kind
  79981. * - VertexBuffer.UV4Kind
  79982. * - VertexBuffer.UV5Kind
  79983. * - VertexBuffer.UV6Kind
  79984. * - VertexBuffer.ColorKind
  79985. * - VertexBuffer.MatricesIndicesKind
  79986. * - VertexBuffer.MatricesIndicesExtraKind
  79987. * - VertexBuffer.MatricesWeightsKind
  79988. * - VertexBuffer.MatricesWeightsExtraKind
  79989. *
  79990. * Returns the Mesh.
  79991. */
  79992. InstancedMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  79993. if (this.sourceMesh) {
  79994. this.sourceMesh.setVerticesData(kind, data, updatable, stride);
  79995. }
  79996. return this.sourceMesh;
  79997. };
  79998. /**
  79999. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  80000. * If the mesh has no geometry, it is simply returned as it is.
  80001. * The `data` are either a numeric array either a Float32Array.
  80002. * No new underlying VertexBuffer object is created.
  80003. * 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.
  80004. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  80005. *
  80006. * Possible `kind` values :
  80007. * - VertexBuffer.PositionKind
  80008. * - VertexBuffer.UVKind
  80009. * - VertexBuffer.UV2Kind
  80010. * - VertexBuffer.UV3Kind
  80011. * - VertexBuffer.UV4Kind
  80012. * - VertexBuffer.UV5Kind
  80013. * - VertexBuffer.UV6Kind
  80014. * - VertexBuffer.ColorKind
  80015. * - VertexBuffer.MatricesIndicesKind
  80016. * - VertexBuffer.MatricesIndicesExtraKind
  80017. * - VertexBuffer.MatricesWeightsKind
  80018. * - VertexBuffer.MatricesWeightsExtraKind
  80019. *
  80020. * Returns the Mesh.
  80021. */
  80022. InstancedMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  80023. if (this.sourceMesh) {
  80024. this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);
  80025. }
  80026. return this.sourceMesh;
  80027. };
  80028. /**
  80029. * Sets the mesh indices.
  80030. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  80031. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  80032. * This method creates a new index buffer each call.
  80033. * Returns the Mesh.
  80034. */
  80035. InstancedMesh.prototype.setIndices = function (indices, totalVertices) {
  80036. if (totalVertices === void 0) { totalVertices = null; }
  80037. if (this.sourceMesh) {
  80038. this.sourceMesh.setIndices(indices, totalVertices);
  80039. }
  80040. return this.sourceMesh;
  80041. };
  80042. /**
  80043. * Boolean : True if the mesh owns the requested kind of data.
  80044. */
  80045. InstancedMesh.prototype.isVerticesDataPresent = function (kind) {
  80046. return this._sourceMesh.isVerticesDataPresent(kind);
  80047. };
  80048. /**
  80049. * Returns an array of indices (IndicesArray).
  80050. */
  80051. InstancedMesh.prototype.getIndices = function () {
  80052. return this._sourceMesh.getIndices();
  80053. };
  80054. Object.defineProperty(InstancedMesh.prototype, "_positions", {
  80055. get: function () {
  80056. return this._sourceMesh._positions;
  80057. },
  80058. enumerable: true,
  80059. configurable: true
  80060. });
  80061. /**
  80062. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  80063. * This means the mesh underlying bounding box and sphere are recomputed.
  80064. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  80065. * @returns the current mesh
  80066. */
  80067. InstancedMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  80068. if (applySkeleton === void 0) { applySkeleton = false; }
  80069. if (this._boundingInfo && this._boundingInfo.isLocked) {
  80070. return this;
  80071. }
  80072. var bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
  80073. this._refreshBoundingInfo(this._sourceMesh._getPositionData(applySkeleton), bias);
  80074. return this;
  80075. };
  80076. /** @hidden */
  80077. InstancedMesh.prototype._preActivate = function () {
  80078. if (this._currentLOD) {
  80079. this._currentLOD._preActivate();
  80080. }
  80081. return this;
  80082. };
  80083. /** @hidden */
  80084. InstancedMesh.prototype._activate = function (renderId) {
  80085. if (this._currentLOD) {
  80086. this._currentLOD._registerInstanceForRenderId(this, renderId);
  80087. }
  80088. return this;
  80089. };
  80090. /**
  80091. * Returns the current associated LOD AbstractMesh.
  80092. */
  80093. InstancedMesh.prototype.getLOD = function (camera) {
  80094. if (!camera) {
  80095. return this;
  80096. }
  80097. var boundingInfo = this.getBoundingInfo();
  80098. this._currentLOD = this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);
  80099. if (this._currentLOD === this.sourceMesh) {
  80100. return this;
  80101. }
  80102. return this._currentLOD;
  80103. };
  80104. /** @hidden */
  80105. InstancedMesh.prototype._syncSubMeshes = function () {
  80106. this.releaseSubMeshes();
  80107. if (this._sourceMesh.subMeshes) {
  80108. for (var index = 0; index < this._sourceMesh.subMeshes.length; index++) {
  80109. this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);
  80110. }
  80111. }
  80112. return this;
  80113. };
  80114. /** @hidden */
  80115. InstancedMesh.prototype._generatePointsArray = function () {
  80116. return this._sourceMesh._generatePointsArray();
  80117. };
  80118. /**
  80119. * Creates a new InstancedMesh from the current mesh.
  80120. * - name (string) : the cloned mesh name
  80121. * - newParent (optional Node) : the optional Node to parent the clone to.
  80122. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  80123. *
  80124. * Returns the clone.
  80125. */
  80126. InstancedMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  80127. var result = this._sourceMesh.createInstance(name);
  80128. // Deep copy
  80129. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__["DeepCopier"].DeepCopy(this, result, ["name", "subMeshes", "uniqueId"], []);
  80130. // Bounding info
  80131. this.refreshBoundingInfo();
  80132. // Parent
  80133. if (newParent) {
  80134. result.parent = newParent;
  80135. }
  80136. if (!doNotCloneChildren) {
  80137. // Children
  80138. for (var index = 0; index < this.getScene().meshes.length; index++) {
  80139. var mesh = this.getScene().meshes[index];
  80140. if (mesh.parent === this) {
  80141. mesh.clone(mesh.name, result);
  80142. }
  80143. }
  80144. }
  80145. result.computeWorldMatrix(true);
  80146. return result;
  80147. };
  80148. /**
  80149. * Disposes the InstancedMesh.
  80150. * Returns nothing.
  80151. */
  80152. InstancedMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  80153. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  80154. // Remove from mesh
  80155. this._sourceMesh.removeInstance(this);
  80156. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  80157. };
  80158. return InstancedMesh;
  80159. }(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]));
  80160. /***/ }),
  80161. /***/ "./Meshes/linesMesh.ts":
  80162. /*!*****************************!*\
  80163. !*** ./Meshes/linesMesh.ts ***!
  80164. \*****************************/
  80165. /*! exports provided: LinesMesh, InstancedLinesMesh */
  80166. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80167. "use strict";
  80168. __webpack_require__.r(__webpack_exports__);
  80169. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return LinesMesh; });
  80170. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return InstancedLinesMesh; });
  80171. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  80172. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  80173. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  80174. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  80175. /* harmony import */ var _Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/instancedMesh */ "./Meshes/instancedMesh.ts");
  80176. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  80177. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  80178. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  80179. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  80180. /**
  80181. * Line mesh
  80182. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  80183. */
  80184. var LinesMesh = /** @class */ (function (_super) {
  80185. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LinesMesh, _super);
  80186. /**
  80187. * Creates a new LinesMesh
  80188. * @param name defines the name
  80189. * @param scene defines the hosting scene
  80190. * @param parent defines the parent mesh if any
  80191. * @param source defines the optional source LinesMesh used to clone data from
  80192. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  80193. * When false, achieved by calling a clone(), also passing False.
  80194. * This will make creation of children, recursive.
  80195. * @param useVertexColor defines if this LinesMesh supports vertex color
  80196. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  80197. */
  80198. function LinesMesh(name, scene, parent, source, doNotCloneChildren,
  80199. /**
  80200. * If vertex color should be applied to the mesh
  80201. */
  80202. useVertexColor,
  80203. /**
  80204. * If vertex alpha should be applied to the mesh
  80205. */
  80206. useVertexAlpha) {
  80207. if (scene === void 0) { scene = null; }
  80208. if (parent === void 0) { parent = null; }
  80209. var _this = _super.call(this, name, scene, parent, source, doNotCloneChildren) || this;
  80210. _this.useVertexColor = useVertexColor;
  80211. _this.useVertexAlpha = useVertexAlpha;
  80212. /**
  80213. * Color of the line (Default: White)
  80214. */
  80215. _this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
  80216. /**
  80217. * Alpha of the line (Default: 1)
  80218. */
  80219. _this.alpha = 1;
  80220. if (source) {
  80221. _this.color = source.color.clone();
  80222. _this.alpha = source.alpha;
  80223. _this.useVertexColor = source.useVertexColor;
  80224. _this.useVertexAlpha = source.useVertexAlpha;
  80225. }
  80226. _this.intersectionThreshold = 0.1;
  80227. var defines = [];
  80228. var options = {
  80229. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, "world0", "world1", "world2", "world3"],
  80230. uniforms: ["world", "viewProjection"],
  80231. needAlphaBlending: true,
  80232. defines: defines
  80233. };
  80234. if (useVertexAlpha === false) {
  80235. options.needAlphaBlending = false;
  80236. }
  80237. if (!useVertexColor) {
  80238. options.uniforms.push("color");
  80239. }
  80240. else {
  80241. options.defines.push("#define VERTEXCOLOR");
  80242. options.attributes.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  80243. }
  80244. _this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("colorShader", _this.getScene(), "color", options);
  80245. return _this;
  80246. }
  80247. /**
  80248. * Returns the string "LineMesh"
  80249. */
  80250. LinesMesh.prototype.getClassName = function () {
  80251. return "LinesMesh";
  80252. };
  80253. Object.defineProperty(LinesMesh.prototype, "material", {
  80254. /**
  80255. * @hidden
  80256. */
  80257. get: function () {
  80258. return this._colorShader;
  80259. },
  80260. /**
  80261. * @hidden
  80262. */
  80263. set: function (value) {
  80264. // Do nothing
  80265. },
  80266. enumerable: true,
  80267. configurable: true
  80268. });
  80269. Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
  80270. /**
  80271. * @hidden
  80272. */
  80273. get: function () {
  80274. return false;
  80275. },
  80276. enumerable: true,
  80277. configurable: true
  80278. });
  80279. /** @hidden */
  80280. LinesMesh.prototype._bind = function (subMesh, effect, fillMode) {
  80281. if (!this._geometry) {
  80282. return this;
  80283. }
  80284. // VBOs
  80285. this._geometry._bind(this._colorShader.getEffect());
  80286. // Color
  80287. if (!this.useVertexColor) {
  80288. this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
  80289. }
  80290. return this;
  80291. };
  80292. /** @hidden */
  80293. LinesMesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  80294. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  80295. return this;
  80296. }
  80297. var engine = this.getScene().getEngine();
  80298. // Draw order
  80299. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].LineListDrawMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  80300. return this;
  80301. };
  80302. /**
  80303. * Disposes of the line mesh
  80304. * @param doNotRecurse If children should be disposed
  80305. */
  80306. LinesMesh.prototype.dispose = function (doNotRecurse) {
  80307. this._colorShader.dispose(false, false, true);
  80308. _super.prototype.dispose.call(this, doNotRecurse);
  80309. };
  80310. /**
  80311. * Returns a new LineMesh object cloned from the current one.
  80312. */
  80313. LinesMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  80314. return new LinesMesh(name, this.getScene(), newParent, this, doNotCloneChildren);
  80315. };
  80316. /**
  80317. * Creates a new InstancedLinesMesh object from the mesh model.
  80318. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80319. * @param name defines the name of the new instance
  80320. * @returns a new InstancedLinesMesh
  80321. */
  80322. LinesMesh.prototype.createInstance = function (name) {
  80323. return new InstancedLinesMesh(name, this);
  80324. };
  80325. return LinesMesh;
  80326. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  80327. /**
  80328. * Creates an instance based on a source LinesMesh
  80329. */
  80330. var InstancedLinesMesh = /** @class */ (function (_super) {
  80331. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedLinesMesh, _super);
  80332. function InstancedLinesMesh(name, source) {
  80333. var _this = _super.call(this, name, source) || this;
  80334. _this.intersectionThreshold = source.intersectionThreshold;
  80335. return _this;
  80336. }
  80337. /**
  80338. * Returns the string "InstancedLinesMesh".
  80339. */
  80340. InstancedLinesMesh.prototype.getClassName = function () {
  80341. return "InstancedLinesMesh";
  80342. };
  80343. return InstancedLinesMesh;
  80344. }(_Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__["InstancedMesh"]));
  80345. /***/ }),
  80346. /***/ "./Meshes/mesh.ts":
  80347. /*!************************!*\
  80348. !*** ./Meshes/mesh.ts ***!
  80349. \************************/
  80350. /*! exports provided: MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh */
  80351. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80352. "use strict";
  80353. __webpack_require__.r(__webpack_exports__);
  80354. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return MeshLODLevel; });
  80355. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _CreationDataStorage; });
  80356. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _InstancesBatch; });
  80357. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return Mesh; });
  80358. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  80359. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  80360. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  80361. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  80362. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  80363. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  80364. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  80365. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  80366. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80367. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  80368. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  80369. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  80370. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  80371. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  80372. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  80373. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  80374. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  80375. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  80376. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  80377. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  80378. /**
  80379. * Class used to represent a specific level of detail of a mesh
  80380. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  80381. */
  80382. var MeshLODLevel = /** @class */ (function () {
  80383. /**
  80384. * Creates a new LOD level
  80385. * @param distance defines the distance where this level should star being displayed
  80386. * @param mesh defines the mesh to use to render this level
  80387. */
  80388. function MeshLODLevel(
  80389. /** Defines the distance where this level should star being displayed */
  80390. distance,
  80391. /** Defines the mesh to use to render this level */
  80392. mesh) {
  80393. this.distance = distance;
  80394. this.mesh = mesh;
  80395. }
  80396. return MeshLODLevel;
  80397. }());
  80398. /**
  80399. * @hidden
  80400. **/
  80401. var _CreationDataStorage = /** @class */ (function () {
  80402. function _CreationDataStorage() {
  80403. }
  80404. return _CreationDataStorage;
  80405. }());
  80406. /**
  80407. * @hidden
  80408. **/
  80409. var _InstanceDataStorage = /** @class */ (function () {
  80410. function _InstanceDataStorage() {
  80411. this.visibleInstances = {};
  80412. this.renderIdForInstances = new Array();
  80413. this.batchCache = new _InstancesBatch();
  80414. this.instancesBufferSize = 32 * 16 * 4; // let's start with a maximum of 32 instances
  80415. }
  80416. return _InstanceDataStorage;
  80417. }());
  80418. /**
  80419. * @hidden
  80420. **/
  80421. var _InstancesBatch = /** @class */ (function () {
  80422. function _InstancesBatch() {
  80423. this.mustReturn = false;
  80424. this.visibleInstances = new Array();
  80425. this.renderSelf = new Array();
  80426. }
  80427. return _InstancesBatch;
  80428. }());
  80429. /**
  80430. * Class used to represent renderable models
  80431. */
  80432. var Mesh = /** @class */ (function (_super) {
  80433. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Mesh, _super);
  80434. /**
  80435. * @constructor
  80436. * @param name The value used by scene.getMeshByName() to do a lookup.
  80437. * @param scene The scene to add this mesh to.
  80438. * @param parent The parent of this mesh, if it has one
  80439. * @param source An optional Mesh from which geometry is shared, cloned.
  80440. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  80441. * When false, achieved by calling a clone(), also passing False.
  80442. * This will make creation of children, recursive.
  80443. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  80444. */
  80445. function Mesh(name, scene, parent, source, doNotCloneChildren, clonePhysicsImpostor) {
  80446. if (scene === void 0) { scene = null; }
  80447. if (parent === void 0) { parent = null; }
  80448. if (source === void 0) { source = null; }
  80449. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  80450. var _this = _super.call(this, name, scene) || this;
  80451. // Members
  80452. /**
  80453. * Gets the delay loading state of the mesh (when delay loading is turned on)
  80454. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  80455. */
  80456. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_NONE;
  80457. /**
  80458. * Gets the list of instances created from this mesh
  80459. * it is not supposed to be modified manually.
  80460. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  80461. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80462. */
  80463. _this.instances = new Array();
  80464. _this._LODLevels = new Array();
  80465. /** @hidden */
  80466. _this._instanceDataStorage = new _InstanceDataStorage();
  80467. // Use by builder only to know what orientation were the mesh build in.
  80468. /** @hidden */
  80469. _this._originalBuilderSideOrientation = Mesh.DEFAULTSIDE;
  80470. /**
  80471. * Use this property to change the original side orientation defined at construction time
  80472. */
  80473. _this.overrideMaterialSideOrientation = null;
  80474. _this._areNormalsFrozen = false; // Will be used by ribbons mainly
  80475. // Will be used to save a source mesh reference, If any
  80476. _this._source = null;
  80477. /** @hidden */
  80478. _this._isMesh = true;
  80479. scene = _this.getScene();
  80480. if (source) {
  80481. // Geometry
  80482. if (source._geometry) {
  80483. source._geometry.applyToMesh(_this);
  80484. }
  80485. // Deep copy
  80486. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(source, _this, ["name", "material", "skeleton", "instances", "parent", "uniqueId",
  80487. "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen",
  80488. "onBeforeDrawObservable", "onBeforeRenderObservable", "onAfterRenderObservable", "onBeforeDraw",
  80489. "onAfterWorldMatrixUpdateObservable", "onCollideObservable", "onCollisionPositionChangeObservable", "onRebuildObservable",
  80490. "onDisposeObservable"
  80491. ], ["_poseMatrix"]);
  80492. // Source mesh
  80493. _this._source = source;
  80494. if (scene.useClonedMeshhMap) {
  80495. if (!source.meshMap) {
  80496. source.meshMap = {};
  80497. }
  80498. source.meshMap[_this.uniqueId] = _this;
  80499. }
  80500. // Construction Params
  80501. // Clone parameters allowing mesh to be updated in case of parametric shapes.
  80502. _this._originalBuilderSideOrientation = source._originalBuilderSideOrientation;
  80503. _this._creationDataStorage = source._creationDataStorage;
  80504. // Animation ranges
  80505. if (_this._source._ranges) {
  80506. var ranges = _this._source._ranges;
  80507. for (var name in ranges) {
  80508. if (!ranges.hasOwnProperty(name)) {
  80509. continue;
  80510. }
  80511. if (!ranges[name]) {
  80512. continue;
  80513. }
  80514. _this.createAnimationRange(name, ranges[name].from, ranges[name].to);
  80515. }
  80516. }
  80517. // Metadata
  80518. if (source.metadata && source.metadata.clone) {
  80519. _this.metadata = source.metadata.clone();
  80520. }
  80521. else {
  80522. _this.metadata = source.metadata;
  80523. }
  80524. // Tags
  80525. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(source)) {
  80526. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(_this, _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(source, true));
  80527. }
  80528. // Parent
  80529. _this.parent = source.parent;
  80530. // Pivot
  80531. _this.setPivotMatrix(source.getPivotMatrix());
  80532. _this.id = name + "." + source.id;
  80533. // Material
  80534. _this.material = source.material;
  80535. var index;
  80536. if (!doNotCloneChildren) {
  80537. // Children
  80538. var directDescendants = source.getDescendants(true);
  80539. for (var index_1 = 0; index_1 < directDescendants.length; index_1++) {
  80540. var child = directDescendants[index_1];
  80541. if (child.clone) {
  80542. child.clone(name + "." + child.name, _this);
  80543. }
  80544. }
  80545. }
  80546. // Physics clone
  80547. var physicsEngine = _this.getScene().getPhysicsEngine();
  80548. if (clonePhysicsImpostor && physicsEngine) {
  80549. var impostor = physicsEngine.getImpostorForPhysicsObject(source);
  80550. if (impostor) {
  80551. _this.physicsImpostor = impostor.clone(_this);
  80552. }
  80553. }
  80554. // Particles
  80555. for (index = 0; index < scene.particleSystems.length; index++) {
  80556. var system = scene.particleSystems[index];
  80557. if (system.emitter === source) {
  80558. system.clone(system.name, _this);
  80559. }
  80560. }
  80561. _this.refreshBoundingInfo();
  80562. _this.computeWorldMatrix(true);
  80563. }
  80564. // Parent
  80565. if (parent !== null) {
  80566. _this.parent = parent;
  80567. }
  80568. return _this;
  80569. }
  80570. Object.defineProperty(Mesh.prototype, "onBeforeRenderObservable", {
  80571. /**
  80572. * An event triggered before rendering the mesh
  80573. */
  80574. get: function () {
  80575. if (!this._onBeforeRenderObservable) {
  80576. this._onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  80577. }
  80578. return this._onBeforeRenderObservable;
  80579. },
  80580. enumerable: true,
  80581. configurable: true
  80582. });
  80583. Object.defineProperty(Mesh.prototype, "onBeforeBindObservable", {
  80584. /**
  80585. * An event triggered before binding the mesh
  80586. */
  80587. get: function () {
  80588. if (!this._onBeforeBindObservable) {
  80589. this._onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  80590. }
  80591. return this._onBeforeBindObservable;
  80592. },
  80593. enumerable: true,
  80594. configurable: true
  80595. });
  80596. Object.defineProperty(Mesh.prototype, "onAfterRenderObservable", {
  80597. /**
  80598. * An event triggered after rendering the mesh
  80599. */
  80600. get: function () {
  80601. if (!this._onAfterRenderObservable) {
  80602. this._onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  80603. }
  80604. return this._onAfterRenderObservable;
  80605. },
  80606. enumerable: true,
  80607. configurable: true
  80608. });
  80609. Object.defineProperty(Mesh.prototype, "onBeforeDrawObservable", {
  80610. /**
  80611. * An event triggered before drawing the mesh
  80612. */
  80613. get: function () {
  80614. if (!this._onBeforeDrawObservable) {
  80615. this._onBeforeDrawObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  80616. }
  80617. return this._onBeforeDrawObservable;
  80618. },
  80619. enumerable: true,
  80620. configurable: true
  80621. });
  80622. Object.defineProperty(Mesh.prototype, "onBeforeDraw", {
  80623. /**
  80624. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  80625. */
  80626. set: function (callback) {
  80627. if (this._onBeforeDrawObserver) {
  80628. this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver);
  80629. }
  80630. this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(callback);
  80631. },
  80632. enumerable: true,
  80633. configurable: true
  80634. });
  80635. Object.defineProperty(Mesh.prototype, "morphTargetManager", {
  80636. /**
  80637. * Gets or sets the morph target manager
  80638. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  80639. */
  80640. get: function () {
  80641. return this._morphTargetManager;
  80642. },
  80643. set: function (value) {
  80644. if (this._morphTargetManager === value) {
  80645. return;
  80646. }
  80647. this._morphTargetManager = value;
  80648. this._syncGeometryWithMorphTargetManager();
  80649. },
  80650. enumerable: true,
  80651. configurable: true
  80652. });
  80653. Object.defineProperty(Mesh.prototype, "source", {
  80654. /**
  80655. * Gets the source mesh (the one used to clone this one from)
  80656. */
  80657. get: function () {
  80658. return this._source;
  80659. },
  80660. enumerable: true,
  80661. configurable: true
  80662. });
  80663. Object.defineProperty(Mesh.prototype, "isUnIndexed", {
  80664. /**
  80665. * Gets or sets a boolean indicating that this mesh does not use index buffer
  80666. */
  80667. get: function () {
  80668. return this._unIndexed;
  80669. },
  80670. set: function (value) {
  80671. if (this._unIndexed !== value) {
  80672. this._unIndexed = value;
  80673. this._markSubMeshesAsAttributesDirty();
  80674. }
  80675. },
  80676. enumerable: true,
  80677. configurable: true
  80678. });
  80679. // Methods
  80680. /**
  80681. * Gets the class name
  80682. * @returns the string "Mesh".
  80683. */
  80684. Mesh.prototype.getClassName = function () {
  80685. return "Mesh";
  80686. };
  80687. /**
  80688. * Returns a description of this mesh
  80689. * @param fullDetails define if full details about this mesh must be used
  80690. * @returns a descriptive string representing this mesh
  80691. */
  80692. Mesh.prototype.toString = function (fullDetails) {
  80693. var ret = _super.prototype.toString.call(this, fullDetails);
  80694. ret += ", n vertices: " + this.getTotalVertices();
  80695. ret += ", parent: " + (this._waitingParentId ? this._waitingParentId : (this.parent ? this.parent.name : "NONE"));
  80696. if (this.animations) {
  80697. for (var i = 0; i < this.animations.length; i++) {
  80698. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  80699. }
  80700. }
  80701. if (fullDetails) {
  80702. if (this._geometry) {
  80703. var ib = this.getIndices();
  80704. var vb = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  80705. if (vb && ib) {
  80706. ret += ", flat shading: " + (vb.length / 3 === ib.length ? "YES" : "NO");
  80707. }
  80708. }
  80709. else {
  80710. ret += ", flat shading: UNKNOWN";
  80711. }
  80712. }
  80713. return ret;
  80714. };
  80715. /** @hidden */
  80716. Mesh.prototype._unBindEffect = function () {
  80717. _super.prototype._unBindEffect.call(this);
  80718. for (var _i = 0, _a = this.instances; _i < _a.length; _i++) {
  80719. var instance = _a[_i];
  80720. instance._unBindEffect();
  80721. }
  80722. };
  80723. Object.defineProperty(Mesh.prototype, "hasLODLevels", {
  80724. /**
  80725. * Gets a boolean indicating if this mesh has LOD
  80726. */
  80727. get: function () {
  80728. return this._LODLevels.length > 0;
  80729. },
  80730. enumerable: true,
  80731. configurable: true
  80732. });
  80733. /**
  80734. * Gets the list of MeshLODLevel associated with the current mesh
  80735. * @returns an array of MeshLODLevel
  80736. */
  80737. Mesh.prototype.getLODLevels = function () {
  80738. return this._LODLevels;
  80739. };
  80740. Mesh.prototype._sortLODLevels = function () {
  80741. this._LODLevels.sort(function (a, b) {
  80742. if (a.distance < b.distance) {
  80743. return 1;
  80744. }
  80745. if (a.distance > b.distance) {
  80746. return -1;
  80747. }
  80748. return 0;
  80749. });
  80750. };
  80751. /**
  80752. * Add a mesh as LOD level triggered at the given distance.
  80753. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80754. * @param distance The distance from the center of the object to show this level
  80755. * @param mesh The mesh to be added as LOD level (can be null)
  80756. * @return This mesh (for chaining)
  80757. */
  80758. Mesh.prototype.addLODLevel = function (distance, mesh) {
  80759. if (mesh && mesh._masterMesh) {
  80760. _Misc_logger__WEBPACK_IMPORTED_MODULE_19__["Logger"].Warn("You cannot use a mesh as LOD level twice");
  80761. return this;
  80762. }
  80763. var level = new MeshLODLevel(distance, mesh);
  80764. this._LODLevels.push(level);
  80765. if (mesh) {
  80766. mesh._masterMesh = this;
  80767. }
  80768. this._sortLODLevels();
  80769. return this;
  80770. };
  80771. /**
  80772. * Returns the LOD level mesh at the passed distance or null if not found.
  80773. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80774. * @param distance The distance from the center of the object to show this level
  80775. * @returns a Mesh or `null`
  80776. */
  80777. Mesh.prototype.getLODLevelAtDistance = function (distance) {
  80778. for (var index = 0; index < this._LODLevels.length; index++) {
  80779. var level = this._LODLevels[index];
  80780. if (level.distance === distance) {
  80781. return level.mesh;
  80782. }
  80783. }
  80784. return null;
  80785. };
  80786. /**
  80787. * Remove a mesh from the LOD array
  80788. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80789. * @param mesh defines the mesh to be removed
  80790. * @return This mesh (for chaining)
  80791. */
  80792. Mesh.prototype.removeLODLevel = function (mesh) {
  80793. for (var index = 0; index < this._LODLevels.length; index++) {
  80794. if (this._LODLevels[index].mesh === mesh) {
  80795. this._LODLevels.splice(index, 1);
  80796. if (mesh) {
  80797. mesh._masterMesh = null;
  80798. }
  80799. }
  80800. }
  80801. this._sortLODLevels();
  80802. return this;
  80803. };
  80804. /**
  80805. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  80806. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80807. * @param camera defines the camera to use to compute distance
  80808. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  80809. * @return This mesh (for chaining)
  80810. */
  80811. Mesh.prototype.getLOD = function (camera, boundingSphere) {
  80812. if (!this._LODLevels || this._LODLevels.length === 0) {
  80813. return this;
  80814. }
  80815. var bSphere;
  80816. if (boundingSphere) {
  80817. bSphere = boundingSphere;
  80818. }
  80819. else {
  80820. var boundingInfo = this.getBoundingInfo();
  80821. bSphere = boundingInfo.boundingSphere;
  80822. }
  80823. var distanceToCamera = bSphere.centerWorld.subtract(camera.globalPosition).length();
  80824. if (this._LODLevels[this._LODLevels.length - 1].distance > distanceToCamera) {
  80825. if (this.onLODLevelSelection) {
  80826. this.onLODLevelSelection(distanceToCamera, this, this._LODLevels[this._LODLevels.length - 1].mesh);
  80827. }
  80828. return this;
  80829. }
  80830. for (var index = 0; index < this._LODLevels.length; index++) {
  80831. var level = this._LODLevels[index];
  80832. if (level.distance < distanceToCamera) {
  80833. if (level.mesh) {
  80834. level.mesh._preActivate();
  80835. level.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
  80836. }
  80837. if (this.onLODLevelSelection) {
  80838. this.onLODLevelSelection(distanceToCamera, this, level.mesh);
  80839. }
  80840. return level.mesh;
  80841. }
  80842. }
  80843. if (this.onLODLevelSelection) {
  80844. this.onLODLevelSelection(distanceToCamera, this, this);
  80845. }
  80846. return this;
  80847. };
  80848. Object.defineProperty(Mesh.prototype, "geometry", {
  80849. /**
  80850. * Gets the mesh internal Geometry object
  80851. */
  80852. get: function () {
  80853. return this._geometry;
  80854. },
  80855. enumerable: true,
  80856. configurable: true
  80857. });
  80858. /**
  80859. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  80860. * @returns the total number of vertices
  80861. */
  80862. Mesh.prototype.getTotalVertices = function () {
  80863. if (this._geometry === null || this._geometry === undefined) {
  80864. return 0;
  80865. }
  80866. return this._geometry.getTotalVertices();
  80867. };
  80868. /**
  80869. * Returns the content of an associated vertex buffer
  80870. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80871. * - VertexBuffer.PositionKind
  80872. * - VertexBuffer.UVKind
  80873. * - VertexBuffer.UV2Kind
  80874. * - VertexBuffer.UV3Kind
  80875. * - VertexBuffer.UV4Kind
  80876. * - VertexBuffer.UV5Kind
  80877. * - VertexBuffer.UV6Kind
  80878. * - VertexBuffer.ColorKind
  80879. * - VertexBuffer.MatricesIndicesKind
  80880. * - VertexBuffer.MatricesIndicesExtraKind
  80881. * - VertexBuffer.MatricesWeightsKind
  80882. * - VertexBuffer.MatricesWeightsExtraKind
  80883. * @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
  80884. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  80885. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  80886. */
  80887. Mesh.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  80888. if (!this._geometry) {
  80889. return null;
  80890. }
  80891. return this._geometry.getVerticesData(kind, copyWhenShared, forceCopy);
  80892. };
  80893. /**
  80894. * Returns the mesh VertexBuffer object from the requested `kind`
  80895. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80896. * - VertexBuffer.PositionKind
  80897. * - VertexBuffer.UVKind
  80898. * - VertexBuffer.UV2Kind
  80899. * - VertexBuffer.UV3Kind
  80900. * - VertexBuffer.UV4Kind
  80901. * - VertexBuffer.UV5Kind
  80902. * - VertexBuffer.UV6Kind
  80903. * - VertexBuffer.ColorKind
  80904. * - VertexBuffer.MatricesIndicesKind
  80905. * - VertexBuffer.MatricesIndicesExtraKind
  80906. * - VertexBuffer.MatricesWeightsKind
  80907. * - VertexBuffer.MatricesWeightsExtraKind
  80908. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  80909. */
  80910. Mesh.prototype.getVertexBuffer = function (kind) {
  80911. if (!this._geometry) {
  80912. return null;
  80913. }
  80914. return this._geometry.getVertexBuffer(kind);
  80915. };
  80916. /**
  80917. * Tests if a specific vertex buffer is associated with this mesh
  80918. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80919. * - VertexBuffer.PositionKind
  80920. * - VertexBuffer.UVKind
  80921. * - VertexBuffer.UV2Kind
  80922. * - VertexBuffer.UV3Kind
  80923. * - VertexBuffer.UV4Kind
  80924. * - VertexBuffer.UV5Kind
  80925. * - VertexBuffer.UV6Kind
  80926. * - VertexBuffer.ColorKind
  80927. * - VertexBuffer.MatricesIndicesKind
  80928. * - VertexBuffer.MatricesIndicesExtraKind
  80929. * - VertexBuffer.MatricesWeightsKind
  80930. * - VertexBuffer.MatricesWeightsExtraKind
  80931. * @returns a boolean
  80932. */
  80933. Mesh.prototype.isVerticesDataPresent = function (kind) {
  80934. if (!this._geometry) {
  80935. if (this._delayInfo) {
  80936. return this._delayInfo.indexOf(kind) !== -1;
  80937. }
  80938. return false;
  80939. }
  80940. return this._geometry.isVerticesDataPresent(kind);
  80941. };
  80942. /**
  80943. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  80944. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80945. * - VertexBuffer.PositionKind
  80946. * - VertexBuffer.UVKind
  80947. * - VertexBuffer.UV2Kind
  80948. * - VertexBuffer.UV3Kind
  80949. * - VertexBuffer.UV4Kind
  80950. * - VertexBuffer.UV5Kind
  80951. * - VertexBuffer.UV6Kind
  80952. * - VertexBuffer.ColorKind
  80953. * - VertexBuffer.MatricesIndicesKind
  80954. * - VertexBuffer.MatricesIndicesExtraKind
  80955. * - VertexBuffer.MatricesWeightsKind
  80956. * - VertexBuffer.MatricesWeightsExtraKind
  80957. * @returns a boolean
  80958. */
  80959. Mesh.prototype.isVertexBufferUpdatable = function (kind) {
  80960. if (!this._geometry) {
  80961. if (this._delayInfo) {
  80962. return this._delayInfo.indexOf(kind) !== -1;
  80963. }
  80964. return false;
  80965. }
  80966. return this._geometry.isVertexBufferUpdatable(kind);
  80967. };
  80968. /**
  80969. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  80970. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80971. * - VertexBuffer.PositionKind
  80972. * - VertexBuffer.UVKind
  80973. * - VertexBuffer.UV2Kind
  80974. * - VertexBuffer.UV3Kind
  80975. * - VertexBuffer.UV4Kind
  80976. * - VertexBuffer.UV5Kind
  80977. * - VertexBuffer.UV6Kind
  80978. * - VertexBuffer.ColorKind
  80979. * - VertexBuffer.MatricesIndicesKind
  80980. * - VertexBuffer.MatricesIndicesExtraKind
  80981. * - VertexBuffer.MatricesWeightsKind
  80982. * - VertexBuffer.MatricesWeightsExtraKind
  80983. * @returns an array of strings
  80984. */
  80985. Mesh.prototype.getVerticesDataKinds = function () {
  80986. if (!this._geometry) {
  80987. var result = new Array();
  80988. if (this._delayInfo) {
  80989. this._delayInfo.forEach(function (kind) {
  80990. result.push(kind);
  80991. });
  80992. }
  80993. return result;
  80994. }
  80995. return this._geometry.getVerticesDataKinds();
  80996. };
  80997. /**
  80998. * Returns a positive integer : the total number of indices in this mesh geometry.
  80999. * @returns the numner of indices or zero if the mesh has no geometry.
  81000. */
  81001. Mesh.prototype.getTotalIndices = function () {
  81002. if (!this._geometry) {
  81003. return 0;
  81004. }
  81005. return this._geometry.getTotalIndices();
  81006. };
  81007. /**
  81008. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  81009. * @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.
  81010. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81011. * @returns the indices array or an empty array if the mesh has no geometry
  81012. */
  81013. Mesh.prototype.getIndices = function (copyWhenShared, forceCopy) {
  81014. if (!this._geometry) {
  81015. return [];
  81016. }
  81017. return this._geometry.getIndices(copyWhenShared, forceCopy);
  81018. };
  81019. Object.defineProperty(Mesh.prototype, "isBlocked", {
  81020. get: function () {
  81021. return this._masterMesh !== null && this._masterMesh !== undefined;
  81022. },
  81023. enumerable: true,
  81024. configurable: true
  81025. });
  81026. /**
  81027. * Determine if the current mesh is ready to be rendered
  81028. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81029. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  81030. * @returns true if all associated assets are ready (material, textures, shaders)
  81031. */
  81032. Mesh.prototype.isReady = function (completeCheck, forceInstanceSupport) {
  81033. if (completeCheck === void 0) { completeCheck = false; }
  81034. if (forceInstanceSupport === void 0) { forceInstanceSupport = false; }
  81035. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_LOADING) {
  81036. return false;
  81037. }
  81038. if (!_super.prototype.isReady.call(this, completeCheck)) {
  81039. return false;
  81040. }
  81041. if (!this.subMeshes || this.subMeshes.length === 0) {
  81042. return true;
  81043. }
  81044. if (!completeCheck) {
  81045. return true;
  81046. }
  81047. var engine = this.getEngine();
  81048. var scene = this.getScene();
  81049. var hardwareInstancedRendering = forceInstanceSupport || engine.getCaps().instancedArrays && this.instances.length > 0;
  81050. this.computeWorldMatrix();
  81051. var mat = this.material || scene.defaultMaterial;
  81052. if (mat) {
  81053. if (mat._storeEffectOnSubMeshes) {
  81054. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  81055. var subMesh = _a[_i];
  81056. var effectiveMaterial = subMesh.getMaterial();
  81057. if (effectiveMaterial) {
  81058. if (effectiveMaterial._storeEffectOnSubMeshes) {
  81059. if (!effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  81060. return false;
  81061. }
  81062. }
  81063. else {
  81064. if (!effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  81065. return false;
  81066. }
  81067. }
  81068. }
  81069. }
  81070. }
  81071. else {
  81072. if (!mat.isReady(this, hardwareInstancedRendering)) {
  81073. return false;
  81074. }
  81075. }
  81076. }
  81077. // Shadows
  81078. for (var _b = 0, _c = this._lightSources; _b < _c.length; _b++) {
  81079. var light = _c[_b];
  81080. var generator = light.getShadowGenerator();
  81081. if (generator) {
  81082. for (var _d = 0, _e = this.subMeshes; _d < _e.length; _d++) {
  81083. var subMesh = _e[_d];
  81084. if (!generator.isReady(subMesh, hardwareInstancedRendering)) {
  81085. return false;
  81086. }
  81087. }
  81088. }
  81089. }
  81090. // LOD
  81091. for (var _f = 0, _g = this._LODLevels; _f < _g.length; _f++) {
  81092. var lod = _g[_f];
  81093. if (lod.mesh && !lod.mesh.isReady(hardwareInstancedRendering)) {
  81094. return false;
  81095. }
  81096. }
  81097. return true;
  81098. };
  81099. Object.defineProperty(Mesh.prototype, "areNormalsFrozen", {
  81100. /**
  81101. * 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.
  81102. */
  81103. get: function () {
  81104. return this._areNormalsFrozen;
  81105. },
  81106. enumerable: true,
  81107. configurable: true
  81108. });
  81109. /**
  81110. * 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.
  81111. * @returns the current mesh
  81112. */
  81113. Mesh.prototype.freezeNormals = function () {
  81114. this._areNormalsFrozen = true;
  81115. return this;
  81116. };
  81117. /**
  81118. * 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
  81119. * @returns the current mesh
  81120. */
  81121. Mesh.prototype.unfreezeNormals = function () {
  81122. this._areNormalsFrozen = false;
  81123. return this;
  81124. };
  81125. Object.defineProperty(Mesh.prototype, "overridenInstanceCount", {
  81126. /**
  81127. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  81128. */
  81129. set: function (count) {
  81130. this._instanceDataStorage.overridenInstanceCount = count;
  81131. },
  81132. enumerable: true,
  81133. configurable: true
  81134. });
  81135. // Methods
  81136. /** @hidden */
  81137. Mesh.prototype._preActivate = function () {
  81138. var sceneRenderId = this.getScene().getRenderId();
  81139. if (this._preActivateId === sceneRenderId) {
  81140. return this;
  81141. }
  81142. this._preActivateId = sceneRenderId;
  81143. this._instanceDataStorage.visibleInstances = null;
  81144. return this;
  81145. };
  81146. /** @hidden */
  81147. Mesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  81148. if (this._instanceDataStorage.visibleInstances) {
  81149. this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = renderId;
  81150. }
  81151. return this;
  81152. };
  81153. /** @hidden */
  81154. Mesh.prototype._registerInstanceForRenderId = function (instance, renderId) {
  81155. if (!this._instanceDataStorage.visibleInstances) {
  81156. this._instanceDataStorage.visibleInstances = {
  81157. defaultRenderId: renderId,
  81158. selfDefaultRenderId: this._renderId
  81159. };
  81160. }
  81161. if (!this._instanceDataStorage.visibleInstances[renderId]) {
  81162. this._instanceDataStorage.visibleInstances[renderId] = new Array();
  81163. }
  81164. this._instanceDataStorage.visibleInstances[renderId].push(instance);
  81165. return this;
  81166. };
  81167. /**
  81168. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81169. * This means the mesh underlying bounding box and sphere are recomputed.
  81170. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81171. * @returns the current mesh
  81172. */
  81173. Mesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  81174. if (applySkeleton === void 0) { applySkeleton = false; }
  81175. if (this._boundingInfo && this._boundingInfo.isLocked) {
  81176. return this;
  81177. }
  81178. var bias = this.geometry ? this.geometry.boundingBias : null;
  81179. this._refreshBoundingInfo(this._getPositionData(applySkeleton), bias);
  81180. return this;
  81181. };
  81182. /** @hidden */
  81183. Mesh.prototype._createGlobalSubMesh = function (force) {
  81184. var totalVertices = this.getTotalVertices();
  81185. if (!totalVertices || !this.getIndices()) {
  81186. return null;
  81187. }
  81188. // Check if we need to recreate the submeshes
  81189. if (this.subMeshes && this.subMeshes.length > 0) {
  81190. var ib = this.getIndices();
  81191. if (!ib) {
  81192. return null;
  81193. }
  81194. var totalIndices = ib.length;
  81195. var needToRecreate = false;
  81196. if (force) {
  81197. needToRecreate = true;
  81198. }
  81199. else {
  81200. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  81201. var submesh = _a[_i];
  81202. if (submesh.indexStart + submesh.indexCount >= totalIndices) {
  81203. needToRecreate = true;
  81204. break;
  81205. }
  81206. if (submesh.verticesStart + submesh.verticesCount >= totalVertices) {
  81207. needToRecreate = true;
  81208. break;
  81209. }
  81210. }
  81211. }
  81212. if (!needToRecreate) {
  81213. return this.subMeshes[0];
  81214. }
  81215. }
  81216. this.releaseSubMeshes();
  81217. return new _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"](0, 0, totalVertices, 0, this.getTotalIndices(), this);
  81218. };
  81219. /**
  81220. * This function will subdivide the mesh into multiple submeshes
  81221. * @param count defines the expected number of submeshes
  81222. */
  81223. Mesh.prototype.subdivide = function (count) {
  81224. if (count < 1) {
  81225. return;
  81226. }
  81227. var totalIndices = this.getTotalIndices();
  81228. var subdivisionSize = (totalIndices / count) | 0;
  81229. var offset = 0;
  81230. // Ensure that subdivisionSize is a multiple of 3
  81231. while (subdivisionSize % 3 !== 0) {
  81232. subdivisionSize++;
  81233. }
  81234. this.releaseSubMeshes();
  81235. for (var index = 0; index < count; index++) {
  81236. if (offset >= totalIndices) {
  81237. break;
  81238. }
  81239. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, Math.min(subdivisionSize, totalIndices - offset), this);
  81240. offset += subdivisionSize;
  81241. }
  81242. this.synchronizeInstances();
  81243. };
  81244. /**
  81245. * Copy a FloatArray into a specific associated vertex buffer
  81246. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81247. * - VertexBuffer.PositionKind
  81248. * - VertexBuffer.UVKind
  81249. * - VertexBuffer.UV2Kind
  81250. * - VertexBuffer.UV3Kind
  81251. * - VertexBuffer.UV4Kind
  81252. * - VertexBuffer.UV5Kind
  81253. * - VertexBuffer.UV6Kind
  81254. * - VertexBuffer.ColorKind
  81255. * - VertexBuffer.MatricesIndicesKind
  81256. * - VertexBuffer.MatricesIndicesExtraKind
  81257. * - VertexBuffer.MatricesWeightsKind
  81258. * - VertexBuffer.MatricesWeightsExtraKind
  81259. * @param data defines the data source
  81260. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81261. * @param stride defines the data stride size (can be null)
  81262. * @returns the current mesh
  81263. */
  81264. Mesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  81265. if (updatable === void 0) { updatable = false; }
  81266. if (!this._geometry) {
  81267. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  81268. vertexData.set(data, kind);
  81269. var scene = this.getScene();
  81270. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  81271. }
  81272. else {
  81273. this._geometry.setVerticesData(kind, data, updatable, stride);
  81274. }
  81275. return this;
  81276. };
  81277. /**
  81278. * Flags an associated vertex buffer as updatable
  81279. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  81280. * - VertexBuffer.PositionKind
  81281. * - VertexBuffer.UVKind
  81282. * - VertexBuffer.UV2Kind
  81283. * - VertexBuffer.UV3Kind
  81284. * - VertexBuffer.UV4Kind
  81285. * - VertexBuffer.UV5Kind
  81286. * - VertexBuffer.UV6Kind
  81287. * - VertexBuffer.ColorKind
  81288. * - VertexBuffer.MatricesIndicesKind
  81289. * - VertexBuffer.MatricesIndicesExtraKind
  81290. * - VertexBuffer.MatricesWeightsKind
  81291. * - VertexBuffer.MatricesWeightsExtraKind
  81292. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81293. */
  81294. Mesh.prototype.markVerticesDataAsUpdatable = function (kind, updatable) {
  81295. if (updatable === void 0) { updatable = true; }
  81296. var vb = this.getVertexBuffer(kind);
  81297. if (!vb || vb.isUpdatable() === updatable) {
  81298. return;
  81299. }
  81300. this.setVerticesData(kind, this.getVerticesData(kind), updatable);
  81301. };
  81302. /**
  81303. * Sets the mesh global Vertex Buffer
  81304. * @param buffer defines the buffer to use
  81305. * @returns the current mesh
  81306. */
  81307. Mesh.prototype.setVerticesBuffer = function (buffer) {
  81308. if (!this._geometry) {
  81309. this._geometry = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].CreateGeometryForMesh(this);
  81310. }
  81311. this._geometry.setVerticesBuffer(buffer);
  81312. return this;
  81313. };
  81314. /**
  81315. * Update a specific associated vertex buffer
  81316. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81317. * - VertexBuffer.PositionKind
  81318. * - VertexBuffer.UVKind
  81319. * - VertexBuffer.UV2Kind
  81320. * - VertexBuffer.UV3Kind
  81321. * - VertexBuffer.UV4Kind
  81322. * - VertexBuffer.UV5Kind
  81323. * - VertexBuffer.UV6Kind
  81324. * - VertexBuffer.ColorKind
  81325. * - VertexBuffer.MatricesIndicesKind
  81326. * - VertexBuffer.MatricesIndicesExtraKind
  81327. * - VertexBuffer.MatricesWeightsKind
  81328. * - VertexBuffer.MatricesWeightsExtraKind
  81329. * @param data defines the data source
  81330. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  81331. * @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)
  81332. * @returns the current mesh
  81333. */
  81334. Mesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  81335. if (!this._geometry) {
  81336. return this;
  81337. }
  81338. if (!makeItUnique) {
  81339. this._geometry.updateVerticesData(kind, data, updateExtends);
  81340. }
  81341. else {
  81342. this.makeGeometryUnique();
  81343. this.updateVerticesData(kind, data, updateExtends, false);
  81344. }
  81345. return this;
  81346. };
  81347. /**
  81348. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  81349. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  81350. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  81351. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  81352. * @returns the current mesh
  81353. */
  81354. Mesh.prototype.updateMeshPositions = function (positionFunction, computeNormals) {
  81355. if (computeNormals === void 0) { computeNormals = true; }
  81356. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  81357. if (!positions) {
  81358. return this;
  81359. }
  81360. positionFunction(positions);
  81361. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions, false, false);
  81362. if (computeNormals) {
  81363. var indices = this.getIndices();
  81364. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  81365. if (!normals) {
  81366. return this;
  81367. }
  81368. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  81369. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, false, false);
  81370. }
  81371. return this;
  81372. };
  81373. /**
  81374. * Creates a un-shared specific occurence of the geometry for the mesh.
  81375. * @returns the current mesh
  81376. */
  81377. Mesh.prototype.makeGeometryUnique = function () {
  81378. if (!this._geometry) {
  81379. return this;
  81380. }
  81381. var oldGeometry = this._geometry;
  81382. var geometry = this._geometry.copy(_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId());
  81383. oldGeometry.releaseForMesh(this, true);
  81384. geometry.applyToMesh(this);
  81385. return this;
  81386. };
  81387. /**
  81388. * Set the index buffer of this mesh
  81389. * @param indices defines the source data
  81390. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  81391. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  81392. * @returns the current mesh
  81393. */
  81394. Mesh.prototype.setIndices = function (indices, totalVertices, updatable) {
  81395. if (totalVertices === void 0) { totalVertices = null; }
  81396. if (updatable === void 0) { updatable = false; }
  81397. if (!this._geometry) {
  81398. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  81399. vertexData.indices = indices;
  81400. var scene = this.getScene();
  81401. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  81402. }
  81403. else {
  81404. this._geometry.setIndices(indices, totalVertices, updatable);
  81405. }
  81406. return this;
  81407. };
  81408. /**
  81409. * Update the current index buffer
  81410. * @param indices defines the source data
  81411. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  81412. * @returns the current mesh
  81413. */
  81414. Mesh.prototype.updateIndices = function (indices, offset) {
  81415. if (!this._geometry) {
  81416. return this;
  81417. }
  81418. this._geometry.updateIndices(indices, offset);
  81419. return this;
  81420. };
  81421. /**
  81422. * Invert the geometry to move from a right handed system to a left handed one.
  81423. * @returns the current mesh
  81424. */
  81425. Mesh.prototype.toLeftHanded = function () {
  81426. if (!this._geometry) {
  81427. return this;
  81428. }
  81429. this._geometry.toLeftHanded();
  81430. return this;
  81431. };
  81432. /** @hidden */
  81433. Mesh.prototype._bind = function (subMesh, effect, fillMode) {
  81434. if (!this._geometry) {
  81435. return this;
  81436. }
  81437. var engine = this.getScene().getEngine();
  81438. // Wireframe
  81439. var indexToBind;
  81440. if (this._unIndexed) {
  81441. indexToBind = null;
  81442. }
  81443. else {
  81444. switch (fillMode) {
  81445. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode:
  81446. indexToBind = null;
  81447. break;
  81448. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode:
  81449. indexToBind = subMesh._getLinesIndexBuffer(this.getIndices(), engine);
  81450. break;
  81451. default:
  81452. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].TriangleFillMode:
  81453. indexToBind = this._unIndexed ? null : this._geometry.getIndexBuffer();
  81454. break;
  81455. }
  81456. }
  81457. // VBOs
  81458. this._geometry._bind(effect, indexToBind);
  81459. return this;
  81460. };
  81461. /** @hidden */
  81462. Mesh.prototype._draw = function (subMesh, fillMode, instancesCount, alternate) {
  81463. if (alternate === void 0) { alternate = false; }
  81464. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  81465. return this;
  81466. }
  81467. if (this._onBeforeDrawObservable) {
  81468. this._onBeforeDrawObservable.notifyObservers(this);
  81469. }
  81470. var scene = this.getScene();
  81471. var engine = scene.getEngine();
  81472. if (this._unIndexed || fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode) {
  81473. // or triangles as points
  81474. engine.drawArraysType(fillMode, subMesh.verticesStart, subMesh.verticesCount, instancesCount);
  81475. }
  81476. else if (fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode) {
  81477. // Triangles as wireframe
  81478. engine.drawElementsType(fillMode, 0, subMesh._linesIndexCount, instancesCount);
  81479. }
  81480. else {
  81481. engine.drawElementsType(fillMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  81482. }
  81483. if (scene._isAlternateRenderingEnabled && !alternate) {
  81484. var effect = subMesh.effect || this._effectiveMaterial.getEffect();
  81485. if (!effect || !scene.activeCamera) {
  81486. return this;
  81487. }
  81488. scene._switchToAlternateCameraConfiguration(true);
  81489. this._effectiveMaterial.bindView(effect);
  81490. this._effectiveMaterial.bindViewProjection(effect);
  81491. engine.setViewport(scene.activeCamera._alternateCamera.viewport);
  81492. this._draw(subMesh, fillMode, instancesCount, true);
  81493. engine.setViewport(scene.activeCamera.viewport);
  81494. scene._switchToAlternateCameraConfiguration(false);
  81495. this._effectiveMaterial.bindView(effect);
  81496. this._effectiveMaterial.bindViewProjection(effect);
  81497. }
  81498. return this;
  81499. };
  81500. /**
  81501. * Registers for this mesh a javascript function called just before the rendering process
  81502. * @param func defines the function to call before rendering this mesh
  81503. * @returns the current mesh
  81504. */
  81505. Mesh.prototype.registerBeforeRender = function (func) {
  81506. this.onBeforeRenderObservable.add(func);
  81507. return this;
  81508. };
  81509. /**
  81510. * Disposes a previously registered javascript function called before the rendering
  81511. * @param func defines the function to remove
  81512. * @returns the current mesh
  81513. */
  81514. Mesh.prototype.unregisterBeforeRender = function (func) {
  81515. this.onBeforeRenderObservable.removeCallback(func);
  81516. return this;
  81517. };
  81518. /**
  81519. * Registers for this mesh a javascript function called just after the rendering is complete
  81520. * @param func defines the function to call after rendering this mesh
  81521. * @returns the current mesh
  81522. */
  81523. Mesh.prototype.registerAfterRender = function (func) {
  81524. this.onAfterRenderObservable.add(func);
  81525. return this;
  81526. };
  81527. /**
  81528. * Disposes a previously registered javascript function called after the rendering.
  81529. * @param func defines the function to remove
  81530. * @returns the current mesh
  81531. */
  81532. Mesh.prototype.unregisterAfterRender = function (func) {
  81533. this.onAfterRenderObservable.removeCallback(func);
  81534. return this;
  81535. };
  81536. /** @hidden */
  81537. Mesh.prototype._getInstancesRenderList = function (subMeshId) {
  81538. var scene = this.getScene();
  81539. var batchCache = this._instanceDataStorage.batchCache;
  81540. batchCache.mustReturn = false;
  81541. batchCache.renderSelf[subMeshId] = this.isEnabled() && this.isVisible;
  81542. batchCache.visibleInstances[subMeshId] = null;
  81543. if (this._instanceDataStorage.visibleInstances) {
  81544. var visibleInstances = this._instanceDataStorage.visibleInstances;
  81545. var currentRenderId = scene.getRenderId();
  81546. var defaultRenderId = (scene._isInIntermediateRendering() ? visibleInstances.intermediateDefaultRenderId : visibleInstances.defaultRenderId);
  81547. batchCache.visibleInstances[subMeshId] = visibleInstances[currentRenderId];
  81548. var selfRenderId = this._renderId;
  81549. if (!batchCache.visibleInstances[subMeshId] && defaultRenderId) {
  81550. batchCache.visibleInstances[subMeshId] = visibleInstances[defaultRenderId];
  81551. currentRenderId = Math.max(defaultRenderId, currentRenderId);
  81552. selfRenderId = Math.max(visibleInstances.selfDefaultRenderId, currentRenderId);
  81553. }
  81554. var visibleInstancesForSubMesh = batchCache.visibleInstances[subMeshId];
  81555. if (visibleInstancesForSubMesh && visibleInstancesForSubMesh.length) {
  81556. if (this._instanceDataStorage.renderIdForInstances[subMeshId] === currentRenderId) {
  81557. batchCache.mustReturn = true;
  81558. return batchCache;
  81559. }
  81560. if (currentRenderId !== selfRenderId) {
  81561. batchCache.renderSelf[subMeshId] = false;
  81562. }
  81563. }
  81564. this._instanceDataStorage.renderIdForInstances[subMeshId] = currentRenderId;
  81565. }
  81566. return batchCache;
  81567. };
  81568. /** @hidden */
  81569. Mesh.prototype._renderWithInstances = function (subMesh, fillMode, batch, effect, engine) {
  81570. var visibleInstances = batch.visibleInstances[subMesh._id];
  81571. if (!visibleInstances) {
  81572. return this;
  81573. }
  81574. var matricesCount = visibleInstances.length + 1;
  81575. var bufferSize = matricesCount * 16 * 4;
  81576. var instanceStorage = this._instanceDataStorage;
  81577. var currentInstancesBufferSize = instanceStorage.instancesBufferSize;
  81578. var instancesBuffer = instanceStorage.instancesBuffer;
  81579. while (instanceStorage.instancesBufferSize < bufferSize) {
  81580. instanceStorage.instancesBufferSize *= 2;
  81581. }
  81582. if (!instanceStorage.instancesData || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  81583. instanceStorage.instancesData = new Float32Array(instanceStorage.instancesBufferSize / 4);
  81584. }
  81585. var offset = 0;
  81586. var instancesCount = 0;
  81587. var world = this.getWorldMatrix();
  81588. if (batch.renderSelf[subMesh._id]) {
  81589. world.copyToArray(instanceStorage.instancesData, offset);
  81590. offset += 16;
  81591. instancesCount++;
  81592. }
  81593. if (visibleInstances) {
  81594. for (var instanceIndex = 0; instanceIndex < visibleInstances.length; instanceIndex++) {
  81595. var instance = visibleInstances[instanceIndex];
  81596. instance.getWorldMatrix().copyToArray(instanceStorage.instancesData, offset);
  81597. offset += 16;
  81598. instancesCount++;
  81599. }
  81600. }
  81601. if (!instancesBuffer || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  81602. if (instancesBuffer) {
  81603. instancesBuffer.dispose();
  81604. }
  81605. instancesBuffer = new _buffer__WEBPACK_IMPORTED_MODULE_7__["Buffer"](engine, instanceStorage.instancesData, true, 16, false, true);
  81606. instanceStorage.instancesBuffer = instancesBuffer;
  81607. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world0", 0, 4));
  81608. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world1", 4, 4));
  81609. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world2", 8, 4));
  81610. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world3", 12, 4));
  81611. }
  81612. else {
  81613. instancesBuffer.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
  81614. }
  81615. this._bind(subMesh, effect, fillMode);
  81616. this._draw(subMesh, fillMode, instancesCount);
  81617. engine.unbindInstanceAttributes();
  81618. return this;
  81619. };
  81620. /** @hidden */
  81621. Mesh.prototype._processRendering = function (subMesh, effect, fillMode, batch, hardwareInstancedRendering, onBeforeDraw, effectiveMaterial) {
  81622. var scene = this.getScene();
  81623. var engine = scene.getEngine();
  81624. if (hardwareInstancedRendering) {
  81625. this._renderWithInstances(subMesh, fillMode, batch, effect, engine);
  81626. }
  81627. else {
  81628. if (batch.renderSelf[subMesh._id]) {
  81629. // Draw
  81630. if (onBeforeDraw) {
  81631. onBeforeDraw(false, this.getWorldMatrix(), effectiveMaterial);
  81632. }
  81633. this._draw(subMesh, fillMode, this._instanceDataStorage.overridenInstanceCount);
  81634. }
  81635. var visibleInstancesForSubMesh = batch.visibleInstances[subMesh._id];
  81636. if (visibleInstancesForSubMesh) {
  81637. for (var instanceIndex = 0; instanceIndex < visibleInstancesForSubMesh.length; instanceIndex++) {
  81638. var instance = visibleInstancesForSubMesh[instanceIndex];
  81639. // World
  81640. var world = instance.getWorldMatrix();
  81641. if (onBeforeDraw) {
  81642. onBeforeDraw(true, world, effectiveMaterial);
  81643. }
  81644. // Draw
  81645. this._draw(subMesh, fillMode);
  81646. }
  81647. }
  81648. }
  81649. return this;
  81650. };
  81651. /**
  81652. * 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
  81653. * @param subMesh defines the subMesh to render
  81654. * @param enableAlphaMode defines if alpha mode can be changed
  81655. * @returns the current mesh
  81656. */
  81657. Mesh.prototype.render = function (subMesh, enableAlphaMode) {
  81658. if (this._checkOcclusionQuery()) {
  81659. return this;
  81660. }
  81661. var scene = this.getScene();
  81662. // Managing instances
  81663. var batch = this._getInstancesRenderList(subMesh._id);
  81664. if (batch.mustReturn) {
  81665. return this;
  81666. }
  81667. // Checking geometry state
  81668. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  81669. return this;
  81670. }
  81671. if (this._onBeforeRenderObservable) {
  81672. this._onBeforeRenderObservable.notifyObservers(this);
  81673. }
  81674. var engine = scene.getEngine();
  81675. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  81676. // Material
  81677. var material = subMesh.getMaterial();
  81678. if (!material) {
  81679. return this;
  81680. }
  81681. this._effectiveMaterial = material;
  81682. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  81683. if (!this._effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  81684. return this;
  81685. }
  81686. }
  81687. else if (!this._effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  81688. return this;
  81689. }
  81690. // Alpha mode
  81691. if (enableAlphaMode) {
  81692. engine.setAlphaMode(this._effectiveMaterial.alphaMode);
  81693. }
  81694. for (var _i = 0, _a = scene._beforeRenderingMeshStage; _i < _a.length; _i++) {
  81695. var step = _a[_i];
  81696. step.action(this, subMesh, batch);
  81697. }
  81698. var effect;
  81699. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  81700. effect = subMesh.effect;
  81701. }
  81702. else {
  81703. effect = this._effectiveMaterial.getEffect();
  81704. }
  81705. if (!effect) {
  81706. return this;
  81707. }
  81708. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  81709. var sideOrientation = this.overrideMaterialSideOrientation;
  81710. if (sideOrientation == null) {
  81711. sideOrientation = this._effectiveMaterial.sideOrientation;
  81712. if (effectiveMesh._getWorldMatrixDeterminant() < 0) {
  81713. 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);
  81714. }
  81715. }
  81716. var reverse = this._effectiveMaterial._preBind(effect, sideOrientation);
  81717. if (this._effectiveMaterial.forceDepthWrite) {
  81718. engine.setDepthWrite(true);
  81719. }
  81720. // Bind
  81721. 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);
  81722. if (this._onBeforeBindObservable) {
  81723. this._onBeforeBindObservable.notifyObservers(this);
  81724. }
  81725. if (!hardwareInstancedRendering) { // Binding will be done later because we need to add more info to the VB
  81726. this._bind(subMesh, effect, fillMode);
  81727. }
  81728. var world = effectiveMesh.getWorldMatrix();
  81729. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  81730. this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
  81731. }
  81732. else {
  81733. this._effectiveMaterial.bind(world, this);
  81734. }
  81735. if (!this._effectiveMaterial.backFaceCulling && this._effectiveMaterial.separateCullingPass) {
  81736. engine.setState(true, this._effectiveMaterial.zOffset, false, !reverse);
  81737. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  81738. engine.setState(true, this._effectiveMaterial.zOffset, false, reverse);
  81739. }
  81740. // Draw
  81741. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  81742. // Unbind
  81743. this._effectiveMaterial.unbind();
  81744. for (var _b = 0, _c = scene._afterRenderingMeshStage; _b < _c.length; _b++) {
  81745. var step = _c[_b];
  81746. step.action(this, subMesh, batch);
  81747. }
  81748. if (this._onAfterRenderObservable) {
  81749. this._onAfterRenderObservable.notifyObservers(this);
  81750. }
  81751. return this;
  81752. };
  81753. Mesh.prototype._onBeforeDraw = function (isInstance, world, effectiveMaterial) {
  81754. if (isInstance && effectiveMaterial) {
  81755. effectiveMaterial.bindOnlyWorldMatrix(world);
  81756. }
  81757. };
  81758. /**
  81759. * Renormalize the mesh and patch it up if there are no weights
  81760. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  81761. * However in the case of zero weights then we set just a single influence to 1.
  81762. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  81763. */
  81764. Mesh.prototype.cleanMatrixWeights = function () {
  81765. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  81766. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind)) {
  81767. this.normalizeSkinWeightsAndExtra();
  81768. }
  81769. else {
  81770. this.normalizeSkinFourWeights();
  81771. }
  81772. }
  81773. };
  81774. // faster 4 weight version.
  81775. Mesh.prototype.normalizeSkinFourWeights = function () {
  81776. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  81777. var numWeights = matricesWeights.length;
  81778. for (var a = 0; a < numWeights; a += 4) {
  81779. // accumulate weights
  81780. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  81781. // check for invalid weight and just set it to 1.
  81782. if (t === 0) {
  81783. matricesWeights[a] = 1;
  81784. }
  81785. else {
  81786. // renormalize so everything adds to 1 use reciprical
  81787. var recip = 1 / t;
  81788. matricesWeights[a] *= recip;
  81789. matricesWeights[a + 1] *= recip;
  81790. matricesWeights[a + 2] *= recip;
  81791. matricesWeights[a + 3] *= recip;
  81792. }
  81793. }
  81794. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  81795. };
  81796. // handle special case of extra verts. (in theory gltf can handle 12 influences)
  81797. Mesh.prototype.normalizeSkinWeightsAndExtra = function () {
  81798. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  81799. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  81800. var numWeights = matricesWeights.length;
  81801. for (var a = 0; a < numWeights; a += 4) {
  81802. // accumulate weights
  81803. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  81804. t += matricesWeightsExtra[a] + matricesWeightsExtra[a + 1] + matricesWeightsExtra[a + 2] + matricesWeightsExtra[a + 3];
  81805. // check for invalid weight and just set it to 1.
  81806. if (t === 0) {
  81807. matricesWeights[a] = 1;
  81808. }
  81809. else {
  81810. // renormalize so everything adds to 1 use reciprical
  81811. var recip = 1 / t;
  81812. matricesWeights[a] *= recip;
  81813. matricesWeights[a + 1] *= recip;
  81814. matricesWeights[a + 2] *= recip;
  81815. matricesWeights[a + 3] *= recip;
  81816. // same goes for extras
  81817. matricesWeightsExtra[a] *= recip;
  81818. matricesWeightsExtra[a + 1] *= recip;
  81819. matricesWeightsExtra[a + 2] *= recip;
  81820. matricesWeightsExtra[a + 3] *= recip;
  81821. }
  81822. }
  81823. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  81824. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeightsExtra);
  81825. };
  81826. /**
  81827. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  81828. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  81829. * the user know there was an issue with importing the mesh
  81830. * @returns a validation object with skinned, valid and report string
  81831. */
  81832. Mesh.prototype.validateSkinning = function () {
  81833. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  81834. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  81835. if (matricesWeights === null || this.skeleton == null) {
  81836. return { skinned: false, valid: true, report: "not skinned" };
  81837. }
  81838. var numWeights = matricesWeights.length;
  81839. var numberNotSorted = 0;
  81840. var missingWeights = 0;
  81841. var maxUsedWeights = 0;
  81842. var numberNotNormalized = 0;
  81843. var numInfluences = matricesWeightsExtra === null ? 4 : 8;
  81844. var usedWeightCounts = new Array();
  81845. for (var a = 0; a <= numInfluences; a++) {
  81846. usedWeightCounts[a] = 0;
  81847. }
  81848. var toleranceEpsilon = 0.001;
  81849. for (var a = 0; a < numWeights; a += 4) {
  81850. var lastWeight = matricesWeights[a];
  81851. var t = lastWeight;
  81852. var usedWeights = t === 0 ? 0 : 1;
  81853. for (var b = 1; b < numInfluences; b++) {
  81854. var d = b < 4 ? matricesWeights[a + b] : matricesWeightsExtra[a + b - 4];
  81855. if (d > lastWeight) {
  81856. numberNotSorted++;
  81857. }
  81858. if (d !== 0) {
  81859. usedWeights++;
  81860. }
  81861. t += d;
  81862. lastWeight = d;
  81863. }
  81864. // count the buffer weights usage
  81865. usedWeightCounts[usedWeights]++;
  81866. // max influences
  81867. if (usedWeights > maxUsedWeights) {
  81868. maxUsedWeights = usedWeights;
  81869. }
  81870. // check for invalid weight and just set it to 1.
  81871. if (t === 0) {
  81872. missingWeights++;
  81873. }
  81874. else {
  81875. // renormalize so everything adds to 1 use reciprical
  81876. var recip = 1 / t;
  81877. var tolerance = 0;
  81878. for (b = 0; b < numInfluences; b++) {
  81879. if (b < 4) {
  81880. tolerance += Math.abs(matricesWeights[a + b] - (matricesWeights[a + b] * recip));
  81881. }
  81882. else {
  81883. tolerance += Math.abs(matricesWeightsExtra[a + b - 4] - (matricesWeightsExtra[a + b - 4] * recip));
  81884. }
  81885. }
  81886. // arbitary epsilon value for dicdating not normalized
  81887. if (tolerance > toleranceEpsilon) {
  81888. numberNotNormalized++;
  81889. }
  81890. }
  81891. }
  81892. // validate bone indices are in range of the skeleton
  81893. var numBones = this.skeleton.bones.length;
  81894. var matricesIndices = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  81895. var matricesIndicesExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind);
  81896. var numBadBoneIndices = 0;
  81897. for (var a = 0; a < numWeights; a++) {
  81898. for (var b = 0; b < numInfluences; b++) {
  81899. var index = b < 4 ? matricesIndices[b] : matricesIndicesExtra[b - 4];
  81900. if (index >= numBones || index < 0) {
  81901. numBadBoneIndices++;
  81902. }
  81903. }
  81904. }
  81905. // log mesh stats
  81906. var output = "Number of Weights = " + numWeights / 4 + "\nMaximum influences = " + maxUsedWeights +
  81907. "\nMissing Weights = " + missingWeights + "\nNot Sorted = " + numberNotSorted +
  81908. "\nNot Normalized = " + numberNotNormalized + "\nWeightCounts = [" + usedWeightCounts + "]" +
  81909. "\nNumber of bones = " + numBones + "\nBad Bone Indices = " + numBadBoneIndices;
  81910. return { skinned: true, valid: missingWeights === 0 && numberNotNormalized === 0 && numBadBoneIndices === 0, report: output };
  81911. };
  81912. /** @hidden */
  81913. Mesh.prototype._checkDelayState = function () {
  81914. var scene = this.getScene();
  81915. if (this._geometry) {
  81916. this._geometry.load(scene);
  81917. }
  81918. else if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  81919. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_LOADING;
  81920. this._queueLoad(scene);
  81921. }
  81922. return this;
  81923. };
  81924. Mesh.prototype._queueLoad = function (scene) {
  81925. var _this = this;
  81926. scene._addPendingData(this);
  81927. var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1);
  81928. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadFile(this.delayLoadingFile, function (data) {
  81929. if (data instanceof ArrayBuffer) {
  81930. _this._delayLoadingFunction(data, _this);
  81931. }
  81932. else {
  81933. _this._delayLoadingFunction(JSON.parse(data), _this);
  81934. }
  81935. _this.instances.forEach(function (instance) {
  81936. instance._syncSubMeshes();
  81937. });
  81938. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_LOADED;
  81939. scene._removePendingData(_this);
  81940. }, function () { }, scene.offlineProvider, getBinaryData);
  81941. return this;
  81942. };
  81943. /**
  81944. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81945. * A mesh is in the frustum if its bounding box intersects the frustum
  81946. * @param frustumPlanes defines the frustum to test
  81947. * @returns true if the mesh is in the frustum planes
  81948. */
  81949. Mesh.prototype.isInFrustum = function (frustumPlanes) {
  81950. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_LOADING) {
  81951. return false;
  81952. }
  81953. if (!_super.prototype.isInFrustum.call(this, frustumPlanes)) {
  81954. return false;
  81955. }
  81956. this._checkDelayState();
  81957. return true;
  81958. };
  81959. /**
  81960. * Sets the mesh material by the material or multiMaterial `id` property
  81961. * @param id is a string identifying the material or the multiMaterial
  81962. * @returns the current mesh
  81963. */
  81964. Mesh.prototype.setMaterialByID = function (id) {
  81965. var materials = this.getScene().materials;
  81966. var index;
  81967. for (index = materials.length - 1; index > -1; index--) {
  81968. if (materials[index].id === id) {
  81969. this.material = materials[index];
  81970. return this;
  81971. }
  81972. }
  81973. // Multi
  81974. var multiMaterials = this.getScene().multiMaterials;
  81975. for (index = multiMaterials.length - 1; index > -1; index--) {
  81976. if (multiMaterials[index].id === id) {
  81977. this.material = multiMaterials[index];
  81978. return this;
  81979. }
  81980. }
  81981. return this;
  81982. };
  81983. /**
  81984. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  81985. * @returns an array of IAnimatable
  81986. */
  81987. Mesh.prototype.getAnimatables = function () {
  81988. var results = new Array();
  81989. if (this.material) {
  81990. results.push(this.material);
  81991. }
  81992. if (this.skeleton) {
  81993. results.push(this.skeleton);
  81994. }
  81995. return results;
  81996. };
  81997. /**
  81998. * Modifies the mesh geometry according to the passed transformation matrix.
  81999. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  82000. * The mesh normals are modified using the same transformation.
  82001. * Note that, under the hood, this method sets a new VertexBuffer each call.
  82002. * @param transform defines the transform matrix to use
  82003. * @see http://doc.babylonjs.com/resources/baking_transformations
  82004. * @returns the current mesh
  82005. */
  82006. Mesh.prototype.bakeTransformIntoVertices = function (transform) {
  82007. // Position
  82008. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  82009. return this;
  82010. }
  82011. var submeshes = this.subMeshes.splice(0);
  82012. this._resetPointsArrayCache();
  82013. var data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  82014. var temp = new Array();
  82015. var index;
  82016. for (index = 0; index < data.length; index += 3) {
  82017. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).toArray(temp, index);
  82018. }
  82019. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind).isUpdatable());
  82020. // Normals
  82021. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  82022. data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  82023. temp = [];
  82024. for (index = 0; index < data.length; index += 3) {
  82025. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormal(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).normalize().toArray(temp, index);
  82026. }
  82027. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind).isUpdatable());
  82028. }
  82029. // flip faces?
  82030. if (transform.m[0] * transform.m[5] * transform.m[10] < 0) {
  82031. this.flipFaces();
  82032. }
  82033. // Restore submeshes
  82034. this.releaseSubMeshes();
  82035. this.subMeshes = submeshes;
  82036. return this;
  82037. };
  82038. /**
  82039. * Modifies the mesh geometry according to its own current World Matrix.
  82040. * The mesh World Matrix is then reset.
  82041. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  82042. * Note that, under the hood, this method sets a new VertexBuffer each call.
  82043. * @see http://doc.babylonjs.com/resources/baking_transformations
  82044. * @returns the current mesh
  82045. */
  82046. Mesh.prototype.bakeCurrentTransformIntoVertices = function () {
  82047. this.bakeTransformIntoVertices(this.computeWorldMatrix(true));
  82048. this.scaling.copyFromFloats(1, 1, 1);
  82049. this.position.copyFromFloats(0, 0, 0);
  82050. this.rotation.copyFromFloats(0, 0, 0);
  82051. //only if quaternion is already set
  82052. if (this.rotationQuaternion) {
  82053. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].Identity();
  82054. }
  82055. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  82056. return this;
  82057. };
  82058. Object.defineProperty(Mesh.prototype, "_positions", {
  82059. // Cache
  82060. /** @hidden */
  82061. get: function () {
  82062. if (this._geometry) {
  82063. return this._geometry._positions;
  82064. }
  82065. return null;
  82066. },
  82067. enumerable: true,
  82068. configurable: true
  82069. });
  82070. /** @hidden */
  82071. Mesh.prototype._resetPointsArrayCache = function () {
  82072. if (this._geometry) {
  82073. this._geometry._resetPointsArrayCache();
  82074. }
  82075. return this;
  82076. };
  82077. /** @hidden */
  82078. Mesh.prototype._generatePointsArray = function () {
  82079. if (this._geometry) {
  82080. return this._geometry._generatePointsArray();
  82081. }
  82082. return false;
  82083. };
  82084. /**
  82085. * Returns a new Mesh object generated from the current mesh properties.
  82086. * This method must not get confused with createInstance()
  82087. * @param name is a string, the name given to the new mesh
  82088. * @param newParent can be any Node object (default `null`)
  82089. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  82090. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  82091. * @returns a new mesh
  82092. */
  82093. Mesh.prototype.clone = function (name, newParent, doNotCloneChildren, clonePhysicsImpostor) {
  82094. if (name === void 0) { name = ""; }
  82095. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  82096. return new Mesh(name, this.getScene(), newParent, this, doNotCloneChildren, clonePhysicsImpostor);
  82097. };
  82098. /**
  82099. * Releases resources associated with this mesh.
  82100. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82101. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82102. */
  82103. Mesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  82104. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  82105. this.morphTargetManager = null;
  82106. if (this._geometry) {
  82107. this._geometry.releaseForMesh(this, true);
  82108. }
  82109. if (this._onBeforeDrawObservable) {
  82110. this._onBeforeDrawObservable.clear();
  82111. }
  82112. if (this._onBeforeBindObservable) {
  82113. this._onBeforeBindObservable.clear();
  82114. }
  82115. if (this._onBeforeRenderObservable) {
  82116. this._onBeforeRenderObservable.clear();
  82117. }
  82118. if (this._onAfterRenderObservable) {
  82119. this._onAfterRenderObservable.clear();
  82120. }
  82121. // Sources
  82122. if (this._scene.useClonedMeshhMap) {
  82123. if (this.meshMap) {
  82124. for (var uniqueId in this.meshMap) {
  82125. var mesh = this.meshMap[uniqueId];
  82126. if (mesh) {
  82127. mesh._source = null;
  82128. this.meshMap[uniqueId] = undefined;
  82129. }
  82130. }
  82131. }
  82132. if (this._source && this._source.meshMap) {
  82133. this._source.meshMap[this.uniqueId] = undefined;
  82134. }
  82135. }
  82136. else {
  82137. var meshes = this.getScene().meshes;
  82138. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  82139. var abstractMesh = meshes_1[_i];
  82140. var mesh = abstractMesh;
  82141. if (mesh._source && mesh._source === this) {
  82142. mesh._source = null;
  82143. }
  82144. }
  82145. }
  82146. this._source = null;
  82147. // Instances
  82148. if (this._instanceDataStorage.instancesBuffer) {
  82149. this._instanceDataStorage.instancesBuffer.dispose();
  82150. this._instanceDataStorage.instancesBuffer = null;
  82151. }
  82152. while (this.instances.length) {
  82153. this.instances[0].dispose();
  82154. }
  82155. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  82156. };
  82157. /**
  82158. * Modifies the mesh geometry according to a displacement map.
  82159. * 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.
  82160. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  82161. * @param url is a string, the URL from the image file is to be downloaded.
  82162. * @param minHeight is the lower limit of the displacement.
  82163. * @param maxHeight is the upper limit of the displacement.
  82164. * @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.
  82165. * @param uvOffset is an optional vector2 used to offset UV.
  82166. * @param uvScale is an optional vector2 used to scale UV.
  82167. * @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.
  82168. * @returns the Mesh.
  82169. */
  82170. Mesh.prototype.applyDisplacementMap = function (url, minHeight, maxHeight, onSuccess, uvOffset, uvScale, forceUpdate) {
  82171. var _this = this;
  82172. if (forceUpdate === void 0) { forceUpdate = false; }
  82173. var scene = this.getScene();
  82174. var onload = function (img) {
  82175. // Getting height map data
  82176. var canvas = document.createElement("canvas");
  82177. var context = canvas.getContext("2d");
  82178. var heightMapWidth = img.width;
  82179. var heightMapHeight = img.height;
  82180. canvas.width = heightMapWidth;
  82181. canvas.height = heightMapHeight;
  82182. context.drawImage(img, 0, 0);
  82183. // Create VertexData from map data
  82184. //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  82185. var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
  82186. _this.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate);
  82187. //execute success callback, if set
  82188. if (onSuccess) {
  82189. onSuccess(_this);
  82190. }
  82191. };
  82192. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  82193. return this;
  82194. };
  82195. /**
  82196. * Modifies the mesh geometry according to a displacementMap buffer.
  82197. * 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.
  82198. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  82199. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  82200. * @param heightMapWidth is the width of the buffer image.
  82201. * @param heightMapHeight is the height of the buffer image.
  82202. * @param minHeight is the lower limit of the displacement.
  82203. * @param maxHeight is the upper limit of the displacement.
  82204. * @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.
  82205. * @param uvOffset is an optional vector2 used to offset UV.
  82206. * @param uvScale is an optional vector2 used to scale UV.
  82207. * @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.
  82208. * @returns the Mesh.
  82209. */
  82210. Mesh.prototype.applyDisplacementMapFromBuffer = function (buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate) {
  82211. if (forceUpdate === void 0) { forceUpdate = false; }
  82212. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)
  82213. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)
  82214. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind)) {
  82215. _Misc_logger__WEBPACK_IMPORTED_MODULE_19__["Logger"].Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing");
  82216. return this;
  82217. }
  82218. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, true, true);
  82219. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  82220. var uvs = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  82221. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  82222. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  82223. var uv = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  82224. uvOffset = uvOffset || _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  82225. uvScale = uvScale || new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](1, 1);
  82226. for (var index = 0; index < positions.length; index += 3) {
  82227. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(positions, index, position);
  82228. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(normals, index, normal);
  82229. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].FromArrayToRef(uvs, (index / 3) * 2, uv);
  82230. // Compute height
  82231. var u = ((Math.abs(uv.x * uvScale.x + uvOffset.x) * heightMapWidth) % heightMapWidth) | 0;
  82232. var v = ((Math.abs(uv.y * uvScale.y + uvOffset.y) * heightMapHeight) % heightMapHeight) | 0;
  82233. var pos = (u + v * heightMapWidth) * 4;
  82234. var r = buffer[pos] / 255.0;
  82235. var g = buffer[pos + 1] / 255.0;
  82236. var b = buffer[pos + 2] / 255.0;
  82237. var gradient = r * 0.3 + g * 0.59 + b * 0.11;
  82238. normal.normalize();
  82239. normal.scaleInPlace(minHeight + (maxHeight - minHeight) * gradient);
  82240. position = position.add(normal);
  82241. position.toArray(positions, index);
  82242. }
  82243. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, this.getIndices(), normals);
  82244. if (forceUpdate) {
  82245. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  82246. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  82247. }
  82248. else {
  82249. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  82250. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  82251. }
  82252. return this;
  82253. };
  82254. /**
  82255. * Modify the mesh to get a flat shading rendering.
  82256. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  82257. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  82258. * @returns current mesh
  82259. */
  82260. Mesh.prototype.convertToFlatShadedMesh = function () {
  82261. var kinds = this.getVerticesDataKinds();
  82262. var vbs = {};
  82263. var data = {};
  82264. var newdata = {};
  82265. var updatableNormals = false;
  82266. var kindIndex;
  82267. var kind;
  82268. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  82269. kind = kinds[kindIndex];
  82270. var vertexBuffer = this.getVertexBuffer(kind);
  82271. if (kind === _buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) {
  82272. updatableNormals = vertexBuffer.isUpdatable();
  82273. kinds.splice(kindIndex, 1);
  82274. kindIndex--;
  82275. continue;
  82276. }
  82277. vbs[kind] = vertexBuffer;
  82278. data[kind] = vbs[kind].getData();
  82279. newdata[kind] = [];
  82280. }
  82281. // Save previous submeshes
  82282. var previousSubmeshes = this.subMeshes.slice(0);
  82283. var indices = this.getIndices();
  82284. var totalIndices = this.getTotalIndices();
  82285. // Generating unique vertices per face
  82286. var index;
  82287. for (index = 0; index < totalIndices; index++) {
  82288. var vertexIndex = indices[index];
  82289. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  82290. kind = kinds[kindIndex];
  82291. var stride = vbs[kind].getStrideSize();
  82292. for (var offset = 0; offset < stride; offset++) {
  82293. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  82294. }
  82295. }
  82296. }
  82297. // Updating faces & normal
  82298. var normals = [];
  82299. var positions = newdata[_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  82300. for (index = 0; index < totalIndices; index += 3) {
  82301. indices[index] = index;
  82302. indices[index + 1] = index + 1;
  82303. indices[index + 2] = index + 2;
  82304. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, index * 3);
  82305. var p2 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 1) * 3);
  82306. var p3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 2) * 3);
  82307. var p1p2 = p1.subtract(p2);
  82308. var p3p2 = p3.subtract(p2);
  82309. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Cross(p1p2, p3p2));
  82310. // Store same normals for every vertex
  82311. for (var localIndex = 0; localIndex < 3; localIndex++) {
  82312. normals.push(normal.x);
  82313. normals.push(normal.y);
  82314. normals.push(normal.z);
  82315. }
  82316. }
  82317. this.setIndices(indices);
  82318. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, updatableNormals);
  82319. // Updating vertex buffers
  82320. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  82321. kind = kinds[kindIndex];
  82322. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  82323. }
  82324. // Updating submeshes
  82325. this.releaseSubMeshes();
  82326. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  82327. var previousOne = previousSubmeshes[submeshIndex];
  82328. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  82329. }
  82330. this.synchronizeInstances();
  82331. return this;
  82332. };
  82333. /**
  82334. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  82335. * In other words, more vertices, no more indices and a single bigger VBO.
  82336. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  82337. * @returns current mesh
  82338. */
  82339. Mesh.prototype.convertToUnIndexedMesh = function () {
  82340. var kinds = this.getVerticesDataKinds();
  82341. var vbs = {};
  82342. var data = {};
  82343. var newdata = {};
  82344. var kindIndex;
  82345. var kind;
  82346. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  82347. kind = kinds[kindIndex];
  82348. var vertexBuffer = this.getVertexBuffer(kind);
  82349. vbs[kind] = vertexBuffer;
  82350. data[kind] = vbs[kind].getData();
  82351. newdata[kind] = [];
  82352. }
  82353. // Save previous submeshes
  82354. var previousSubmeshes = this.subMeshes.slice(0);
  82355. var indices = this.getIndices();
  82356. var totalIndices = this.getTotalIndices();
  82357. // Generating unique vertices per face
  82358. var index;
  82359. for (index = 0; index < totalIndices; index++) {
  82360. var vertexIndex = indices[index];
  82361. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  82362. kind = kinds[kindIndex];
  82363. var stride = vbs[kind].getStrideSize();
  82364. for (var offset = 0; offset < stride; offset++) {
  82365. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  82366. }
  82367. }
  82368. }
  82369. // Updating indices
  82370. for (index = 0; index < totalIndices; index += 3) {
  82371. indices[index] = index;
  82372. indices[index + 1] = index + 1;
  82373. indices[index + 2] = index + 2;
  82374. }
  82375. this.setIndices(indices);
  82376. // Updating vertex buffers
  82377. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  82378. kind = kinds[kindIndex];
  82379. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  82380. }
  82381. // Updating submeshes
  82382. this.releaseSubMeshes();
  82383. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  82384. var previousOne = previousSubmeshes[submeshIndex];
  82385. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  82386. }
  82387. this._unIndexed = true;
  82388. this.synchronizeInstances();
  82389. return this;
  82390. };
  82391. /**
  82392. * Inverses facet orientations.
  82393. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  82394. * @param flipNormals will also inverts the normals
  82395. * @returns current mesh
  82396. */
  82397. Mesh.prototype.flipFaces = function (flipNormals) {
  82398. if (flipNormals === void 0) { flipNormals = false; }
  82399. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  82400. var i;
  82401. if (flipNormals && this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) && vertex_data.normals) {
  82402. for (i = 0; i < vertex_data.normals.length; i++) {
  82403. vertex_data.normals[i] *= -1;
  82404. }
  82405. }
  82406. if (vertex_data.indices) {
  82407. var temp;
  82408. for (i = 0; i < vertex_data.indices.length; i += 3) {
  82409. // reassign indices
  82410. temp = vertex_data.indices[i + 1];
  82411. vertex_data.indices[i + 1] = vertex_data.indices[i + 2];
  82412. vertex_data.indices[i + 2] = temp;
  82413. }
  82414. }
  82415. vertex_data.applyToMesh(this);
  82416. return this;
  82417. };
  82418. /**
  82419. * Creates a new InstancedMesh object from the mesh model.
  82420. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  82421. * @param name defines the name of the new instance
  82422. * @returns a new InstancedMesh
  82423. */
  82424. Mesh.prototype.createInstance = function (name) {
  82425. return Mesh._instancedMeshFactory(name, this);
  82426. };
  82427. /**
  82428. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  82429. * After this call, all the mesh instances have the same submeshes than the current mesh.
  82430. * @returns the current mesh
  82431. */
  82432. Mesh.prototype.synchronizeInstances = function () {
  82433. for (var instanceIndex = 0; instanceIndex < this.instances.length; instanceIndex++) {
  82434. var instance = this.instances[instanceIndex];
  82435. instance._syncSubMeshes();
  82436. }
  82437. return this;
  82438. };
  82439. /**
  82440. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  82441. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  82442. * This should be used together with the simplification to avoid disappearing triangles.
  82443. * @param successCallback an optional success callback to be called after the optimization finished.
  82444. * @returns the current mesh
  82445. */
  82446. Mesh.prototype.optimizeIndices = function (successCallback) {
  82447. var _this = this;
  82448. var indices = this.getIndices();
  82449. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  82450. if (!positions || !indices) {
  82451. return this;
  82452. }
  82453. var vectorPositions = new Array();
  82454. for (var pos = 0; pos < positions.length; pos = pos + 3) {
  82455. vectorPositions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, pos));
  82456. }
  82457. var dupes = new Array();
  82458. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["AsyncLoop"].SyncAsyncForLoop(vectorPositions.length, 40, function (iteration) {
  82459. var realPos = vectorPositions.length - 1 - iteration;
  82460. var testedPosition = vectorPositions[realPos];
  82461. for (var j = 0; j < realPos; ++j) {
  82462. var againstPosition = vectorPositions[j];
  82463. if (testedPosition.equals(againstPosition)) {
  82464. dupes[realPos] = j;
  82465. break;
  82466. }
  82467. }
  82468. }, function () {
  82469. for (var i = 0; i < indices.length; ++i) {
  82470. indices[i] = dupes[indices[i]] || indices[i];
  82471. }
  82472. //indices are now reordered
  82473. var originalSubMeshes = _this.subMeshes.slice(0);
  82474. _this.setIndices(indices);
  82475. _this.subMeshes = originalSubMeshes;
  82476. if (successCallback) {
  82477. successCallback(_this);
  82478. }
  82479. });
  82480. return this;
  82481. };
  82482. /**
  82483. * Serialize current mesh
  82484. * @param serializationObject defines the object which will receive the serialization data
  82485. */
  82486. Mesh.prototype.serialize = function (serializationObject) {
  82487. serializationObject.name = this.name;
  82488. serializationObject.id = this.id;
  82489. serializationObject.type = this.getClassName();
  82490. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(this)) {
  82491. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(this);
  82492. }
  82493. serializationObject.position = this.position.asArray();
  82494. if (this.rotationQuaternion) {
  82495. serializationObject.rotationQuaternion = this.rotationQuaternion.asArray();
  82496. }
  82497. else if (this.rotation) {
  82498. serializationObject.rotation = this.rotation.asArray();
  82499. }
  82500. serializationObject.scaling = this.scaling.asArray();
  82501. if (this._postMultiplyPivotMatrix) {
  82502. serializationObject.pivotMatrix = this.getPivotMatrix().asArray();
  82503. }
  82504. else {
  82505. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  82506. }
  82507. serializationObject.isEnabled = this.isEnabled(false);
  82508. serializationObject.isVisible = this.isVisible;
  82509. serializationObject.infiniteDistance = this.infiniteDistance;
  82510. serializationObject.pickable = this.isPickable;
  82511. serializationObject.receiveShadows = this.receiveShadows;
  82512. serializationObject.billboardMode = this.billboardMode;
  82513. serializationObject.visibility = this.visibility;
  82514. serializationObject.checkCollisions = this.checkCollisions;
  82515. serializationObject.isBlocker = this.isBlocker;
  82516. // Parent
  82517. if (this.parent) {
  82518. serializationObject.parentId = this.parent.id;
  82519. }
  82520. // Geometry
  82521. serializationObject.isUnIndexed = this.isUnIndexed;
  82522. var geometry = this._geometry;
  82523. if (geometry) {
  82524. var geometryId = geometry.id;
  82525. serializationObject.geometryId = geometryId;
  82526. // SubMeshes
  82527. serializationObject.subMeshes = [];
  82528. for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
  82529. var subMesh = this.subMeshes[subIndex];
  82530. serializationObject.subMeshes.push({
  82531. materialIndex: subMesh.materialIndex,
  82532. verticesStart: subMesh.verticesStart,
  82533. verticesCount: subMesh.verticesCount,
  82534. indexStart: subMesh.indexStart,
  82535. indexCount: subMesh.indexCount
  82536. });
  82537. }
  82538. }
  82539. // Material
  82540. if (this.material) {
  82541. serializationObject.materialId = this.material.id;
  82542. }
  82543. else {
  82544. this.material = null;
  82545. }
  82546. // Morph targets
  82547. if (this.morphTargetManager) {
  82548. serializationObject.morphTargetManagerId = this.morphTargetManager.uniqueId;
  82549. }
  82550. // Skeleton
  82551. if (this.skeleton) {
  82552. serializationObject.skeletonId = this.skeleton.id;
  82553. }
  82554. // Physics
  82555. //TODO implement correct serialization for physics impostors.
  82556. var impostor = this.getPhysicsImpostor();
  82557. if (impostor) {
  82558. serializationObject.physicsMass = impostor.getParam("mass");
  82559. serializationObject.physicsFriction = impostor.getParam("friction");
  82560. serializationObject.physicsRestitution = impostor.getParam("mass");
  82561. serializationObject.physicsImpostor = impostor.type;
  82562. }
  82563. // Metadata
  82564. if (this.metadata) {
  82565. serializationObject.metadata = this.metadata;
  82566. }
  82567. // Instances
  82568. serializationObject.instances = [];
  82569. for (var index = 0; index < this.instances.length; index++) {
  82570. var instance = this.instances[index];
  82571. if (instance.doNotSerialize) {
  82572. continue;
  82573. }
  82574. var serializationInstance = {
  82575. name: instance.name,
  82576. id: instance.id,
  82577. position: instance.position.asArray(),
  82578. scaling: instance.scaling.asArray()
  82579. };
  82580. if (instance.parent) {
  82581. serializationInstance.parentId = instance.parent.id;
  82582. }
  82583. if (instance.rotationQuaternion) {
  82584. serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
  82585. }
  82586. else if (instance.rotation) {
  82587. serializationInstance.rotation = instance.rotation.asArray();
  82588. }
  82589. serializationObject.instances.push(serializationInstance);
  82590. // Animations
  82591. _Misc_decorators__WEBPACK_IMPORTED_MODULE_18__["SerializationHelper"].AppendSerializedAnimations(instance, serializationInstance);
  82592. serializationInstance.ranges = instance.serializeAnimationRanges();
  82593. }
  82594. //
  82595. // Animations
  82596. _Misc_decorators__WEBPACK_IMPORTED_MODULE_18__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  82597. serializationObject.ranges = this.serializeAnimationRanges();
  82598. // Layer mask
  82599. serializationObject.layerMask = this.layerMask;
  82600. // Alpha
  82601. serializationObject.alphaIndex = this.alphaIndex;
  82602. serializationObject.hasVertexAlpha = this.hasVertexAlpha;
  82603. // Overlay
  82604. serializationObject.overlayAlpha = this.overlayAlpha;
  82605. serializationObject.overlayColor = this.overlayColor.asArray();
  82606. serializationObject.renderOverlay = this.renderOverlay;
  82607. // Fog
  82608. serializationObject.applyFog = this.applyFog;
  82609. // Action Manager
  82610. if (this.actionManager) {
  82611. serializationObject.actions = this.actionManager.serialize(this.name);
  82612. }
  82613. };
  82614. /** @hidden */
  82615. Mesh.prototype._syncGeometryWithMorphTargetManager = function () {
  82616. if (!this.geometry) {
  82617. return;
  82618. }
  82619. this._markSubMeshesAsAttributesDirty();
  82620. var morphTargetManager = this._morphTargetManager;
  82621. if (morphTargetManager && morphTargetManager.vertexCount) {
  82622. if (morphTargetManager.vertexCount !== this.getTotalVertices()) {
  82623. _Misc_logger__WEBPACK_IMPORTED_MODULE_19__["Logger"].Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count.");
  82624. this.morphTargetManager = null;
  82625. return;
  82626. }
  82627. for (var index = 0; index < morphTargetManager.numInfluencers; index++) {
  82628. var morphTarget = morphTargetManager.getActiveTarget(index);
  82629. var positions = morphTarget.getPositions();
  82630. if (!positions) {
  82631. _Misc_logger__WEBPACK_IMPORTED_MODULE_19__["Logger"].Error("Invalid morph target. Target must have positions.");
  82632. return;
  82633. }
  82634. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index, positions, false, 3);
  82635. var normals = morphTarget.getNormals();
  82636. if (normals) {
  82637. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index, normals, false, 3);
  82638. }
  82639. var tangents = morphTarget.getTangents();
  82640. if (tangents) {
  82641. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index, tangents, false, 3);
  82642. }
  82643. }
  82644. }
  82645. else {
  82646. var index = 0;
  82647. // Positions
  82648. while (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index)) {
  82649. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index);
  82650. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index)) {
  82651. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index);
  82652. }
  82653. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index)) {
  82654. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index);
  82655. }
  82656. index++;
  82657. }
  82658. }
  82659. };
  82660. /**
  82661. * Returns a new Mesh object parsed from the source provided.
  82662. * @param parsedMesh is the source
  82663. * @param scene defines the hosting scene
  82664. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  82665. * @returns a new Mesh
  82666. */
  82667. Mesh.Parse = function (parsedMesh, scene, rootUrl) {
  82668. var mesh;
  82669. if (parsedMesh.type && parsedMesh.type === "GroundMesh") {
  82670. mesh = Mesh._GroundMeshParser(parsedMesh, scene);
  82671. }
  82672. else {
  82673. mesh = new Mesh(parsedMesh.name, scene);
  82674. }
  82675. mesh.id = parsedMesh.id;
  82676. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  82677. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(mesh, parsedMesh.tags);
  82678. }
  82679. mesh.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.position);
  82680. if (parsedMesh.metadata !== undefined) {
  82681. mesh.metadata = parsedMesh.metadata;
  82682. }
  82683. if (parsedMesh.rotationQuaternion) {
  82684. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedMesh.rotationQuaternion);
  82685. }
  82686. else if (parsedMesh.rotation) {
  82687. mesh.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.rotation);
  82688. }
  82689. mesh.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.scaling);
  82690. if (parsedMesh.localMatrix) {
  82691. mesh.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.localMatrix));
  82692. }
  82693. else if (parsedMesh.pivotMatrix) {
  82694. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.pivotMatrix));
  82695. }
  82696. mesh.setEnabled(parsedMesh.isEnabled);
  82697. mesh.isVisible = parsedMesh.isVisible;
  82698. mesh.infiniteDistance = parsedMesh.infiniteDistance;
  82699. mesh.showBoundingBox = parsedMesh.showBoundingBox;
  82700. mesh.showSubMeshesBoundingBox = parsedMesh.showSubMeshesBoundingBox;
  82701. if (parsedMesh.applyFog !== undefined) {
  82702. mesh.applyFog = parsedMesh.applyFog;
  82703. }
  82704. if (parsedMesh.pickable !== undefined) {
  82705. mesh.isPickable = parsedMesh.pickable;
  82706. }
  82707. if (parsedMesh.alphaIndex !== undefined) {
  82708. mesh.alphaIndex = parsedMesh.alphaIndex;
  82709. }
  82710. mesh.receiveShadows = parsedMesh.receiveShadows;
  82711. mesh.billboardMode = parsedMesh.billboardMode;
  82712. if (parsedMesh.visibility !== undefined) {
  82713. mesh.visibility = parsedMesh.visibility;
  82714. }
  82715. mesh.checkCollisions = parsedMesh.checkCollisions;
  82716. if (parsedMesh.isBlocker !== undefined) {
  82717. mesh.isBlocker = parsedMesh.isBlocker;
  82718. }
  82719. mesh._shouldGenerateFlatShading = parsedMesh.useFlatShading;
  82720. // freezeWorldMatrix
  82721. if (parsedMesh.freezeWorldMatrix) {
  82722. mesh._waitingFreezeWorldMatrix = parsedMesh.freezeWorldMatrix;
  82723. }
  82724. // Parent
  82725. if (parsedMesh.parentId) {
  82726. mesh._waitingParentId = parsedMesh.parentId;
  82727. }
  82728. // Actions
  82729. if (parsedMesh.actions !== undefined) {
  82730. mesh._waitingActions = parsedMesh.actions;
  82731. }
  82732. // Overlay
  82733. if (parsedMesh.overlayAlpha !== undefined) {
  82734. mesh.overlayAlpha = parsedMesh.overlayAlpha;
  82735. }
  82736. if (parsedMesh.overlayColor !== undefined) {
  82737. mesh.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].FromArray(parsedMesh.overlayColor);
  82738. }
  82739. if (parsedMesh.renderOverlay !== undefined) {
  82740. mesh.renderOverlay = parsedMesh.renderOverlay;
  82741. }
  82742. // Geometry
  82743. mesh.isUnIndexed = !!parsedMesh.isUnIndexed;
  82744. mesh.hasVertexAlpha = parsedMesh.hasVertexAlpha;
  82745. if (parsedMesh.delayLoadingFile) {
  82746. mesh.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_NOTLOADED;
  82747. mesh.delayLoadingFile = rootUrl + parsedMesh.delayLoadingFile;
  82748. 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));
  82749. if (parsedMesh._binaryInfo) {
  82750. mesh._binaryInfo = parsedMesh._binaryInfo;
  82751. }
  82752. mesh._delayInfo = [];
  82753. if (parsedMesh.hasUVs) {
  82754. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  82755. }
  82756. if (parsedMesh.hasUVs2) {
  82757. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  82758. }
  82759. if (parsedMesh.hasUVs3) {
  82760. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV3Kind);
  82761. }
  82762. if (parsedMesh.hasUVs4) {
  82763. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV4Kind);
  82764. }
  82765. if (parsedMesh.hasUVs5) {
  82766. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV5Kind);
  82767. }
  82768. if (parsedMesh.hasUVs6) {
  82769. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV6Kind);
  82770. }
  82771. if (parsedMesh.hasColors) {
  82772. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  82773. }
  82774. if (parsedMesh.hasMatricesIndices) {
  82775. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  82776. }
  82777. if (parsedMesh.hasMatricesWeights) {
  82778. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  82779. }
  82780. mesh._delayLoadingFunction = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry;
  82781. if (_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental) {
  82782. mesh._checkDelayState();
  82783. }
  82784. }
  82785. else {
  82786. _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry(parsedMesh, mesh);
  82787. }
  82788. // Material
  82789. if (parsedMesh.materialId) {
  82790. mesh.setMaterialByID(parsedMesh.materialId);
  82791. }
  82792. else {
  82793. mesh.material = null;
  82794. }
  82795. // Morph targets
  82796. if (parsedMesh.morphTargetManagerId > -1) {
  82797. mesh.morphTargetManager = scene.getMorphTargetManagerById(parsedMesh.morphTargetManagerId);
  82798. }
  82799. // Skeleton
  82800. if (parsedMesh.skeletonId > -1) {
  82801. mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
  82802. if (parsedMesh.numBoneInfluencers) {
  82803. mesh.numBoneInfluencers = parsedMesh.numBoneInfluencers;
  82804. }
  82805. }
  82806. // Animations
  82807. if (parsedMesh.animations) {
  82808. for (var animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
  82809. var parsedAnimation = parsedMesh.animations[animationIndex];
  82810. mesh.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_14__["Animation"].Parse(parsedAnimation));
  82811. }
  82812. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(mesh, parsedMesh, scene);
  82813. }
  82814. if (parsedMesh.autoAnimate) {
  82815. scene.beginAnimation(mesh, parsedMesh.autoAnimateFrom, parsedMesh.autoAnimateTo, parsedMesh.autoAnimateLoop, parsedMesh.autoAnimateSpeed || 1.0);
  82816. }
  82817. // Layer Mask
  82818. if (parsedMesh.layerMask && (!isNaN(parsedMesh.layerMask))) {
  82819. mesh.layerMask = Math.abs(parseInt(parsedMesh.layerMask));
  82820. }
  82821. else {
  82822. mesh.layerMask = 0x0FFFFFFF;
  82823. }
  82824. // Physics
  82825. if (parsedMesh.physicsImpostor) {
  82826. mesh.physicsImpostor = new _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_16__["PhysicsImpostor"](mesh, parsedMesh.physicsImpostor, {
  82827. mass: parsedMesh.physicsMass,
  82828. friction: parsedMesh.physicsFriction,
  82829. restitution: parsedMesh.physicsRestitution
  82830. }, scene);
  82831. }
  82832. // Instances
  82833. if (parsedMesh.instances) {
  82834. for (var index = 0; index < parsedMesh.instances.length; index++) {
  82835. var parsedInstance = parsedMesh.instances[index];
  82836. var instance = mesh.createInstance(parsedInstance.name);
  82837. if (parsedInstance.id) {
  82838. instance.id = parsedInstance.id;
  82839. }
  82840. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  82841. if (parsedInstance.tags) {
  82842. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedInstance.tags);
  82843. }
  82844. else {
  82845. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedMesh.tags);
  82846. }
  82847. }
  82848. instance.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.position);
  82849. if (parsedInstance.parentId) {
  82850. instance._waitingParentId = parsedInstance.parentId;
  82851. }
  82852. if (parsedInstance.rotationQuaternion) {
  82853. instance.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedInstance.rotationQuaternion);
  82854. }
  82855. else if (parsedInstance.rotation) {
  82856. instance.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.rotation);
  82857. }
  82858. instance.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.scaling);
  82859. if (parsedInstance.checkCollisions != undefined && parsedInstance.checkCollisions != null) {
  82860. instance.checkCollisions = parsedInstance.checkCollisions;
  82861. }
  82862. if (parsedInstance.pickable != undefined && parsedInstance.pickable != null) {
  82863. instance.isPickable = parsedInstance.pickable;
  82864. }
  82865. if (parsedInstance.showBoundingBox != undefined && parsedInstance.showBoundingBox != null) {
  82866. instance.showBoundingBox = parsedInstance.showBoundingBox;
  82867. }
  82868. if (parsedInstance.showSubMeshesBoundingBox != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  82869. instance.showSubMeshesBoundingBox = parsedInstance.showSubMeshesBoundingBox;
  82870. }
  82871. if (parsedInstance.alphaIndex != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  82872. instance.alphaIndex = parsedInstance.alphaIndex;
  82873. }
  82874. // Physics
  82875. if (parsedInstance.physicsImpostor) {
  82876. instance.physicsImpostor = new _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_16__["PhysicsImpostor"](instance, parsedInstance.physicsImpostor, {
  82877. mass: parsedInstance.physicsMass,
  82878. friction: parsedInstance.physicsFriction,
  82879. restitution: parsedInstance.physicsRestitution
  82880. }, scene);
  82881. }
  82882. // Animation
  82883. if (parsedInstance.animations) {
  82884. for (animationIndex = 0; animationIndex < parsedInstance.animations.length; animationIndex++) {
  82885. parsedAnimation = parsedInstance.animations[animationIndex];
  82886. instance.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_14__["Animation"].Parse(parsedAnimation));
  82887. }
  82888. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(instance, parsedInstance, scene);
  82889. if (parsedInstance.autoAnimate) {
  82890. scene.beginAnimation(instance, parsedInstance.autoAnimateFrom, parsedInstance.autoAnimateTo, parsedInstance.autoAnimateLoop, parsedInstance.autoAnimateSpeed || 1.0);
  82891. }
  82892. }
  82893. }
  82894. }
  82895. return mesh;
  82896. };
  82897. /**
  82898. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  82899. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  82900. * @param name defines the name of the mesh to create
  82901. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  82902. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  82903. * @param closePath creates a seam between the first and the last points of each path of the path array
  82904. * @param offset is taken in account only if the `pathArray` is containing a single path
  82905. * @param scene defines the hosting scene
  82906. * @param updatable defines if the mesh must be flagged as updatable
  82907. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82908. * @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)
  82909. * @returns a new Mesh
  82910. */
  82911. Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  82912. throw "Import MeshBuilder before creating meshes.";
  82913. };
  82914. /**
  82915. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  82916. * @param name defines the name of the mesh to create
  82917. * @param radius sets the radius size (float) of the polygon (default 0.5)
  82918. * @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
  82919. * @param scene defines the hosting scene
  82920. * @param updatable defines if the mesh must be flagged as updatable
  82921. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82922. * @returns a new Mesh
  82923. */
  82924. Mesh.CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  82925. if (scene === void 0) { scene = null; }
  82926. throw "Import MeshBuilder before creating meshes.";
  82927. };
  82928. /**
  82929. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  82930. * @param name defines the name of the mesh to create
  82931. * @param size sets the size (float) of each box side (default 1)
  82932. * @param scene defines the hosting scene
  82933. * @param updatable defines if the mesh must be flagged as updatable
  82934. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82935. * @returns a new Mesh
  82936. */
  82937. Mesh.CreateBox = function (name, size, scene, updatable, sideOrientation) {
  82938. if (scene === void 0) { scene = null; }
  82939. throw "Import MeshBuilder before creating meshes.";
  82940. };
  82941. /**
  82942. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  82943. * @param name defines the name of the mesh to create
  82944. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  82945. * @param diameter sets the diameter size (float) of the sphere (default 1)
  82946. * @param scene defines the hosting scene
  82947. * @param updatable defines if the mesh must be flagged as updatable
  82948. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82949. * @returns a new Mesh
  82950. */
  82951. Mesh.CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  82952. throw "Import MeshBuilder before creating meshes.";
  82953. };
  82954. /**
  82955. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  82956. * @param name defines the name of the mesh to create
  82957. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  82958. * @param diameterTop set the top cap diameter (floats, default 1)
  82959. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  82960. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  82961. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  82962. * @param scene defines the hosting scene
  82963. * @param updatable defines if the mesh must be flagged as updatable
  82964. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82965. * @returns a new Mesh
  82966. */
  82967. Mesh.CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  82968. throw "Import MeshBuilder before creating meshes.";
  82969. };
  82970. // Torus (Code from SharpDX.org)
  82971. /**
  82972. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  82973. * @param name defines the name of the mesh to create
  82974. * @param diameter sets the diameter size (float) of the torus (default 1)
  82975. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  82976. * @param tessellation sets the number of torus sides (postive integer, default 16)
  82977. * @param scene defines the hosting scene
  82978. * @param updatable defines if the mesh must be flagged as updatable
  82979. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82980. * @returns a new Mesh
  82981. */
  82982. Mesh.CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  82983. throw "Import MeshBuilder before creating meshes.";
  82984. };
  82985. /**
  82986. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  82987. * @param name defines the name of the mesh to create
  82988. * @param radius sets the global radius size (float) of the torus knot (default 2)
  82989. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  82990. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  82991. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  82992. * @param p the number of windings on X axis (positive integers, default 2)
  82993. * @param q the number of windings on Y axis (positive integers, default 3)
  82994. * @param scene defines the hosting scene
  82995. * @param updatable defines if the mesh must be flagged as updatable
  82996. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82997. * @returns a new Mesh
  82998. */
  82999. Mesh.CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  83000. throw "Import MeshBuilder before creating meshes.";
  83001. };
  83002. /**
  83003. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  83004. * @param name defines the name of the mesh to create
  83005. * @param points is an array successive Vector3
  83006. * @param scene defines the hosting scene
  83007. * @param updatable defines if the mesh must be flagged as updatable
  83008. * @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).
  83009. * @returns a new Mesh
  83010. */
  83011. Mesh.CreateLines = function (name, points, scene, updatable, instance) {
  83012. if (scene === void 0) { scene = null; }
  83013. if (updatable === void 0) { updatable = false; }
  83014. if (instance === void 0) { instance = null; }
  83015. throw "Import MeshBuilder before creating meshes.";
  83016. };
  83017. /**
  83018. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  83019. * @param name defines the name of the mesh to create
  83020. * @param points is an array successive Vector3
  83021. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  83022. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  83023. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  83024. * @param scene defines the hosting scene
  83025. * @param updatable defines if the mesh must be flagged as updatable
  83026. * @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)
  83027. * @returns a new Mesh
  83028. */
  83029. Mesh.CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  83030. if (scene === void 0) { scene = null; }
  83031. throw "Import MeshBuilder before creating meshes.";
  83032. };
  83033. /**
  83034. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  83035. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  83036. * 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.
  83037. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83038. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  83039. * Remember you can only change the shape positions, not their number when updating a polygon.
  83040. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  83041. * @param name defines the name of the mesh to create
  83042. * @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
  83043. * @param scene defines the hosting scene
  83044. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  83045. * @param updatable defines if the mesh must be flagged as updatable
  83046. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83047. * @returns a new Mesh
  83048. */
  83049. Mesh.CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation) {
  83050. throw "Import MeshBuilder before creating meshes.";
  83051. };
  83052. /**
  83053. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  83054. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  83055. * @param name defines the name of the mesh to create
  83056. * @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
  83057. * @param depth defines the height of extrusion
  83058. * @param scene defines the hosting scene
  83059. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  83060. * @param updatable defines if the mesh must be flagged as updatable
  83061. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83062. * @returns a new Mesh
  83063. */
  83064. Mesh.ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation) {
  83065. throw "Import MeshBuilder before creating meshes.";
  83066. };
  83067. /**
  83068. * Creates an extruded shape mesh.
  83069. * 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
  83070. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  83071. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  83072. * @param name defines the name of the mesh to create
  83073. * @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
  83074. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  83075. * @param scale is the value to scale the shape
  83076. * @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
  83077. * @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
  83078. * @param scene defines the hosting scene
  83079. * @param updatable defines if the mesh must be flagged as updatable
  83080. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83081. * @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)
  83082. * @returns a new Mesh
  83083. */
  83084. Mesh.ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  83085. if (scene === void 0) { scene = null; }
  83086. throw "Import MeshBuilder before creating meshes.";
  83087. };
  83088. /**
  83089. * Creates an custom extruded shape mesh.
  83090. * The custom extrusion is a parametric shape.
  83091. * It has no predefined shape. Its final shape will depend on the input parameters.
  83092. * Please consider using the same method from the MeshBuilder class instead
  83093. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  83094. * @param name defines the name of the mesh to create
  83095. * @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
  83096. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  83097. * @param scaleFunction is a custom Javascript function called on each path point
  83098. * @param rotationFunction is a custom Javascript function called on each path point
  83099. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  83100. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  83101. * @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
  83102. * @param scene defines the hosting scene
  83103. * @param updatable defines if the mesh must be flagged as updatable
  83104. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83105. * @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)
  83106. * @returns a new Mesh
  83107. */
  83108. Mesh.ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  83109. throw "Import MeshBuilder before creating meshes.";
  83110. };
  83111. /**
  83112. * Creates lathe mesh.
  83113. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  83114. * Please consider using the same method from the MeshBuilder class instead
  83115. * @param name defines the name of the mesh to create
  83116. * @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
  83117. * @param radius is the radius value of the lathe
  83118. * @param tessellation is the side number of the lathe.
  83119. * @param scene defines the hosting scene
  83120. * @param updatable defines if the mesh must be flagged as updatable
  83121. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83122. * @returns a new Mesh
  83123. */
  83124. Mesh.CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  83125. throw "Import MeshBuilder before creating meshes.";
  83126. };
  83127. /**
  83128. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  83129. * @param name defines the name of the mesh to create
  83130. * @param size sets the size (float) of both sides of the plane at once (default 1)
  83131. * @param scene defines the hosting scene
  83132. * @param updatable defines if the mesh must be flagged as updatable
  83133. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83134. * @returns a new Mesh
  83135. */
  83136. Mesh.CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  83137. throw "Import MeshBuilder before creating meshes.";
  83138. };
  83139. /**
  83140. * Creates a ground mesh.
  83141. * Please consider using the same method from the MeshBuilder class instead
  83142. * @param name defines the name of the mesh to create
  83143. * @param width set the width of the ground
  83144. * @param height set the height of the ground
  83145. * @param subdivisions sets the number of subdivisions per side
  83146. * @param scene defines the hosting scene
  83147. * @param updatable defines if the mesh must be flagged as updatable
  83148. * @returns a new Mesh
  83149. */
  83150. Mesh.CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  83151. throw "Import MeshBuilder before creating meshes.";
  83152. };
  83153. /**
  83154. * Creates a tiled ground mesh.
  83155. * Please consider using the same method from the MeshBuilder class instead
  83156. * @param name defines the name of the mesh to create
  83157. * @param xmin set the ground minimum X coordinate
  83158. * @param zmin set the ground minimum Y coordinate
  83159. * @param xmax set the ground maximum X coordinate
  83160. * @param zmax set the ground maximum Z coordinate
  83161. * @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
  83162. * @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
  83163. * @param scene defines the hosting scene
  83164. * @param updatable defines if the mesh must be flagged as updatable
  83165. * @returns a new Mesh
  83166. */
  83167. Mesh.CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  83168. throw "Import MeshBuilder before creating meshes.";
  83169. };
  83170. /**
  83171. * Creates a ground mesh from a height map.
  83172. * Please consider using the same method from the MeshBuilder class instead
  83173. * @see http://doc.babylonjs.com/babylon101/height_map
  83174. * @param name defines the name of the mesh to create
  83175. * @param url sets the URL of the height map image resource
  83176. * @param width set the ground width size
  83177. * @param height set the ground height size
  83178. * @param subdivisions sets the number of subdivision per side
  83179. * @param minHeight is the minimum altitude on the ground
  83180. * @param maxHeight is the maximum altitude on the ground
  83181. * @param scene defines the hosting scene
  83182. * @param updatable defines if the mesh must be flagged as updatable
  83183. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  83184. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  83185. * @returns a new Mesh
  83186. */
  83187. Mesh.CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  83188. throw "Import MeshBuilder before creating meshes.";
  83189. };
  83190. /**
  83191. * Creates a tube mesh.
  83192. * The tube is a parametric shape.
  83193. * It has no predefined shape. Its final shape will depend on the input parameters.
  83194. * Please consider using the same method from the MeshBuilder class instead
  83195. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  83196. * @param name defines the name of the mesh to create
  83197. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  83198. * @param radius sets the tube radius size
  83199. * @param tessellation is the number of sides on the tubular surface
  83200. * @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
  83201. * @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
  83202. * @param scene defines the hosting scene
  83203. * @param updatable defines if the mesh must be flagged as updatable
  83204. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83205. * @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)
  83206. * @returns a new Mesh
  83207. */
  83208. Mesh.CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  83209. throw "Import MeshBuilder before creating meshes.";
  83210. };
  83211. /**
  83212. * Creates a polyhedron mesh.
  83213. * Please consider using the same method from the MeshBuilder class instead.
  83214. * * 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
  83215. * * The parameter `size` (positive float, default 1) sets the polygon size
  83216. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  83217. * * 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`
  83218. * * 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
  83219. * * 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)`)
  83220. * * 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
  83221. * * 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
  83222. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83223. * * 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
  83224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  83225. * @param name defines the name of the mesh to create
  83226. * @param options defines the options used to create the mesh
  83227. * @param scene defines the hosting scene
  83228. * @returns a new Mesh
  83229. */
  83230. Mesh.CreatePolyhedron = function (name, options, scene) {
  83231. throw "Import MeshBuilder before creating meshes.";
  83232. };
  83233. /**
  83234. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  83235. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  83236. * * 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`)
  83237. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  83238. * * 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
  83239. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83240. * * 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
  83241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  83242. * @param name defines the name of the mesh
  83243. * @param options defines the options used to create the mesh
  83244. * @param scene defines the hosting scene
  83245. * @returns a new Mesh
  83246. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  83247. */
  83248. Mesh.CreateIcoSphere = function (name, options, scene) {
  83249. throw "Import MeshBuilder before creating meshes.";
  83250. };
  83251. /**
  83252. * Creates a decal mesh.
  83253. * Please consider using the same method from the MeshBuilder class instead.
  83254. * A decal is a mesh usually applied as a model onto the surface of another mesh
  83255. * @param name defines the name of the mesh
  83256. * @param sourceMesh defines the mesh receiving the decal
  83257. * @param position sets the position of the decal in world coordinates
  83258. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  83259. * @param size sets the decal scaling
  83260. * @param angle sets the angle to rotate the decal
  83261. * @returns a new Mesh
  83262. */
  83263. Mesh.CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  83264. throw "Import MeshBuilder before creating meshes.";
  83265. };
  83266. // Skeletons
  83267. /**
  83268. * Prepare internal position array for software CPU skinning
  83269. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  83270. */
  83271. Mesh.prototype.setPositionsForCPUSkinning = function () {
  83272. if (!this._sourcePositions) {
  83273. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  83274. if (!source) {
  83275. return this._sourcePositions;
  83276. }
  83277. this._sourcePositions = new Float32Array(source);
  83278. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  83279. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, source, true);
  83280. }
  83281. }
  83282. return this._sourcePositions;
  83283. };
  83284. /**
  83285. * Prepare internal normal array for software CPU skinning
  83286. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  83287. */
  83288. Mesh.prototype.setNormalsForCPUSkinning = function () {
  83289. if (!this._sourceNormals) {
  83290. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  83291. if (!source) {
  83292. return this._sourceNormals;
  83293. }
  83294. this._sourceNormals = new Float32Array(source);
  83295. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  83296. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, source, true);
  83297. }
  83298. }
  83299. return this._sourceNormals;
  83300. };
  83301. /**
  83302. * Updates the vertex buffer by applying transformation from the bones
  83303. * @param skeleton defines the skeleton to apply to current mesh
  83304. * @returns the current mesh
  83305. */
  83306. Mesh.prototype.applySkeleton = function (skeleton) {
  83307. if (!this.geometry) {
  83308. return this;
  83309. }
  83310. if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId()) {
  83311. return this;
  83312. }
  83313. this.geometry._softwareSkinningFrameId = this.getScene().getFrameId();
  83314. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  83315. return this;
  83316. }
  83317. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  83318. return this;
  83319. }
  83320. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind)) {
  83321. return this;
  83322. }
  83323. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  83324. return this;
  83325. }
  83326. if (!this._sourcePositions) {
  83327. var submeshes = this.subMeshes.slice();
  83328. this.setPositionsForCPUSkinning();
  83329. this.subMeshes = submeshes;
  83330. }
  83331. if (!this._sourceNormals) {
  83332. this.setNormalsForCPUSkinning();
  83333. }
  83334. // positionsData checks for not being Float32Array will only pass at most once
  83335. var positionsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  83336. if (!positionsData) {
  83337. return this;
  83338. }
  83339. if (!(positionsData instanceof Float32Array)) {
  83340. positionsData = new Float32Array(positionsData);
  83341. }
  83342. // normalsData checks for not being Float32Array will only pass at most once
  83343. var normalsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  83344. if (!normalsData) {
  83345. return this;
  83346. }
  83347. if (!(normalsData instanceof Float32Array)) {
  83348. normalsData = new Float32Array(normalsData);
  83349. }
  83350. var matricesIndicesData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  83351. var matricesWeightsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  83352. if (!matricesWeightsData || !matricesIndicesData) {
  83353. return this;
  83354. }
  83355. var needExtras = this.numBoneInfluencers > 4;
  83356. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  83357. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  83358. var skeletonMatrices = skeleton.getTransformMatrices(this);
  83359. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  83360. var finalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  83361. var tempMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  83362. var matWeightIdx = 0;
  83363. var inf;
  83364. for (var index = 0; index < positionsData.length; index += 3, matWeightIdx += 4) {
  83365. var weight;
  83366. for (inf = 0; inf < 4; inf++) {
  83367. weight = matricesWeightsData[matWeightIdx + inf];
  83368. if (weight > 0) {
  83369. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  83370. finalMatrix.addToSelf(tempMatrix);
  83371. }
  83372. }
  83373. if (needExtras) {
  83374. for (inf = 0; inf < 4; inf++) {
  83375. weight = matricesWeightsExtraData[matWeightIdx + inf];
  83376. if (weight > 0) {
  83377. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  83378. finalMatrix.addToSelf(tempMatrix);
  83379. }
  83380. }
  83381. }
  83382. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinatesFromFloatsToRef(this._sourcePositions[index], this._sourcePositions[index + 1], this._sourcePositions[index + 2], finalMatrix, tempVector3);
  83383. tempVector3.toArray(positionsData, index);
  83384. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalFromFloatsToRef(this._sourceNormals[index], this._sourceNormals[index + 1], this._sourceNormals[index + 2], finalMatrix, tempVector3);
  83385. tempVector3.toArray(normalsData, index);
  83386. finalMatrix.reset();
  83387. }
  83388. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positionsData);
  83389. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normalsData);
  83390. return this;
  83391. };
  83392. // Tools
  83393. /**
  83394. * 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
  83395. * @param meshes defines the list of meshes to scan
  83396. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  83397. */
  83398. Mesh.MinMax = function (meshes) {
  83399. var minVector = null;
  83400. var maxVector = null;
  83401. meshes.forEach(function (mesh) {
  83402. var boundingInfo = mesh.getBoundingInfo();
  83403. var boundingBox = boundingInfo.boundingBox;
  83404. if (!minVector || !maxVector) {
  83405. minVector = boundingBox.minimumWorld;
  83406. maxVector = boundingBox.maximumWorld;
  83407. }
  83408. else {
  83409. minVector.minimizeInPlace(boundingBox.minimumWorld);
  83410. maxVector.maximizeInPlace(boundingBox.maximumWorld);
  83411. }
  83412. });
  83413. if (!minVector || !maxVector) {
  83414. return {
  83415. min: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero(),
  83416. max: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero()
  83417. };
  83418. }
  83419. return {
  83420. min: minVector,
  83421. max: maxVector
  83422. };
  83423. };
  83424. /**
  83425. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  83426. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  83427. * @returns a vector3
  83428. */
  83429. Mesh.Center = function (meshesOrMinMaxVector) {
  83430. var minMaxVector = (meshesOrMinMaxVector instanceof Array) ? Mesh.MinMax(meshesOrMinMaxVector) : meshesOrMinMaxVector;
  83431. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Center(minMaxVector.min, minMaxVector.max);
  83432. };
  83433. /**
  83434. * Merge the array of meshes into a single mesh for performance reasons.
  83435. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  83436. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  83437. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  83438. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  83439. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  83440. * @returns a new mesh
  83441. */
  83442. Mesh.MergeMeshes = function (meshes, disposeSource, allow32BitsIndices, meshSubclass, subdivideWithSubMeshes) {
  83443. if (disposeSource === void 0) { disposeSource = true; }
  83444. var index;
  83445. if (!allow32BitsIndices) {
  83446. var totalVertices = 0;
  83447. // Counting vertices
  83448. for (index = 0; index < meshes.length; index++) {
  83449. if (meshes[index]) {
  83450. totalVertices += meshes[index].getTotalVertices();
  83451. if (totalVertices > 65536) {
  83452. _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");
  83453. return null;
  83454. }
  83455. }
  83456. }
  83457. }
  83458. // Merge
  83459. var vertexData = null;
  83460. var otherVertexData;
  83461. var indiceArray = new Array();
  83462. var source = null;
  83463. for (index = 0; index < meshes.length; index++) {
  83464. if (meshes[index]) {
  83465. var wm = meshes[index].computeWorldMatrix(true);
  83466. otherVertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(meshes[index], true, true);
  83467. otherVertexData.transform(wm);
  83468. if (vertexData) {
  83469. vertexData.merge(otherVertexData, allow32BitsIndices);
  83470. }
  83471. else {
  83472. vertexData = otherVertexData;
  83473. source = meshes[index];
  83474. }
  83475. if (subdivideWithSubMeshes) {
  83476. indiceArray.push(meshes[index].getTotalIndices());
  83477. }
  83478. }
  83479. }
  83480. source = source;
  83481. if (!meshSubclass) {
  83482. meshSubclass = new Mesh(source.name + "_merged", source.getScene());
  83483. }
  83484. vertexData.applyToMesh(meshSubclass);
  83485. // Setting properties
  83486. meshSubclass.material = source.material;
  83487. meshSubclass.checkCollisions = source.checkCollisions;
  83488. // Cleaning
  83489. if (disposeSource) {
  83490. for (index = 0; index < meshes.length; index++) {
  83491. if (meshes[index]) {
  83492. meshes[index].dispose();
  83493. }
  83494. }
  83495. }
  83496. // Subdivide
  83497. if (subdivideWithSubMeshes) {
  83498. //-- removal of global submesh
  83499. meshSubclass.releaseSubMeshes();
  83500. index = 0;
  83501. var offset = 0;
  83502. //-- apply subdivision according to index table
  83503. while (index < indiceArray.length) {
  83504. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, indiceArray[index], meshSubclass);
  83505. offset += indiceArray[index];
  83506. index++;
  83507. }
  83508. }
  83509. return meshSubclass;
  83510. };
  83511. /** @hidden */
  83512. Mesh.prototype.addInstance = function (instance) {
  83513. instance._indexInSourceMeshInstanceArray = this.instances.length;
  83514. this.instances.push(instance);
  83515. };
  83516. /** @hidden */
  83517. Mesh.prototype.removeInstance = function (instance) {
  83518. // Remove from mesh
  83519. var index = instance._indexInSourceMeshInstanceArray;
  83520. if (index != -1) {
  83521. if (index !== this.instances.length - 1) {
  83522. var last = this.instances[this.instances.length - 1];
  83523. this.instances[index] = last;
  83524. last._indexInSourceMeshInstanceArray = index;
  83525. }
  83526. instance._indexInSourceMeshInstanceArray = -1;
  83527. this.instances.pop();
  83528. }
  83529. };
  83530. // Consts
  83531. /**
  83532. * Mesh side orientation : usually the external or front surface
  83533. */
  83534. Mesh.FRONTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].FRONTSIDE;
  83535. /**
  83536. * Mesh side orientation : usually the internal or back surface
  83537. */
  83538. Mesh.BACKSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].BACKSIDE;
  83539. /**
  83540. * Mesh side orientation : both internal and external or front and back surfaces
  83541. */
  83542. Mesh.DOUBLESIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DOUBLESIDE;
  83543. /**
  83544. * Mesh side orientation : by default, `FRONTSIDE`
  83545. */
  83546. Mesh.DEFAULTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DEFAULTSIDE;
  83547. /**
  83548. * Mesh cap setting : no cap
  83549. */
  83550. Mesh.NO_CAP = 0;
  83551. /**
  83552. * Mesh cap setting : one cap at the beginning of the mesh
  83553. */
  83554. Mesh.CAP_START = 1;
  83555. /**
  83556. * Mesh cap setting : one cap at the end of the mesh
  83557. */
  83558. Mesh.CAP_END = 2;
  83559. /**
  83560. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  83561. */
  83562. Mesh.CAP_ALL = 3;
  83563. // Instances
  83564. /** @hidden */
  83565. Mesh._instancedMeshFactory = function (name, mesh) {
  83566. throw "Import InstancedMesh before creating instances.";
  83567. };
  83568. // Statics
  83569. /** @hidden */
  83570. Mesh._GroundMeshParser = function (parsedMesh, scene) {
  83571. throw "Import GroundMesh before trying to parse it.";
  83572. };
  83573. return Mesh;
  83574. }(_abstractMesh__WEBPACK_IMPORTED_MODULE_10__["AbstractMesh"]));
  83575. //import { MeshBuilder } from "./meshBuilder";
  83576. /***/ }),
  83577. /***/ "./Meshes/mesh.vertexData.ts":
  83578. /*!***********************************!*\
  83579. !*** ./Meshes/mesh.vertexData.ts ***!
  83580. \***********************************/
  83581. /*! exports provided: VertexData */
  83582. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83583. "use strict";
  83584. __webpack_require__.r(__webpack_exports__);
  83585. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return VertexData; });
  83586. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  83587. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  83588. /**
  83589. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  83590. */
  83591. var VertexData = /** @class */ (function () {
  83592. function VertexData() {
  83593. }
  83594. /**
  83595. * Uses the passed data array to set the set the values for the specified kind of data
  83596. * @param data a linear array of floating numbers
  83597. * @param kind the type of data that is being set, eg positions, colors etc
  83598. */
  83599. VertexData.prototype.set = function (data, kind) {
  83600. switch (kind) {
  83601. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind:
  83602. this.positions = data;
  83603. break;
  83604. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind:
  83605. this.normals = data;
  83606. break;
  83607. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind:
  83608. this.tangents = data;
  83609. break;
  83610. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind:
  83611. this.uvs = data;
  83612. break;
  83613. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind:
  83614. this.uvs2 = data;
  83615. break;
  83616. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind:
  83617. this.uvs3 = data;
  83618. break;
  83619. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind:
  83620. this.uvs4 = data;
  83621. break;
  83622. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind:
  83623. this.uvs5 = data;
  83624. break;
  83625. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind:
  83626. this.uvs6 = data;
  83627. break;
  83628. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind:
  83629. this.colors = data;
  83630. break;
  83631. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind:
  83632. this.matricesIndices = data;
  83633. break;
  83634. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind:
  83635. this.matricesWeights = data;
  83636. break;
  83637. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind:
  83638. this.matricesIndicesExtra = data;
  83639. break;
  83640. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind:
  83641. this.matricesWeightsExtra = data;
  83642. break;
  83643. }
  83644. };
  83645. /**
  83646. * Associates the vertexData to the passed Mesh.
  83647. * Sets it as updatable or not (default `false`)
  83648. * @param mesh the mesh the vertexData is applied to
  83649. * @param updatable when used and having the value true allows new data to update the vertexData
  83650. * @returns the VertexData
  83651. */
  83652. VertexData.prototype.applyToMesh = function (mesh, updatable) {
  83653. this._applyTo(mesh, updatable);
  83654. return this;
  83655. };
  83656. /**
  83657. * Associates the vertexData to the passed Geometry.
  83658. * Sets it as updatable or not (default `false`)
  83659. * @param geometry the geometry the vertexData is applied to
  83660. * @param updatable when used and having the value true allows new data to update the vertexData
  83661. * @returns VertexData
  83662. */
  83663. VertexData.prototype.applyToGeometry = function (geometry, updatable) {
  83664. this._applyTo(geometry, updatable);
  83665. return this;
  83666. };
  83667. /**
  83668. * Updates the associated mesh
  83669. * @param mesh the mesh to be updated
  83670. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83671. * @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
  83672. * @returns VertexData
  83673. */
  83674. VertexData.prototype.updateMesh = function (mesh) {
  83675. this._update(mesh);
  83676. return this;
  83677. };
  83678. /**
  83679. * Updates the associated geometry
  83680. * @param geometry the geometry to be updated
  83681. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83682. * @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
  83683. * @returns VertexData.
  83684. */
  83685. VertexData.prototype.updateGeometry = function (geometry) {
  83686. this._update(geometry);
  83687. return this;
  83688. };
  83689. VertexData.prototype._applyTo = function (meshOrGeometry, updatable) {
  83690. if (updatable === void 0) { updatable = false; }
  83691. if (this.positions) {
  83692. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updatable);
  83693. }
  83694. if (this.normals) {
  83695. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updatable);
  83696. }
  83697. if (this.tangents) {
  83698. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updatable);
  83699. }
  83700. if (this.uvs) {
  83701. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updatable);
  83702. }
  83703. if (this.uvs2) {
  83704. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updatable);
  83705. }
  83706. if (this.uvs3) {
  83707. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updatable);
  83708. }
  83709. if (this.uvs4) {
  83710. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updatable);
  83711. }
  83712. if (this.uvs5) {
  83713. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updatable);
  83714. }
  83715. if (this.uvs6) {
  83716. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updatable);
  83717. }
  83718. if (this.colors) {
  83719. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updatable);
  83720. }
  83721. if (this.matricesIndices) {
  83722. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updatable);
  83723. }
  83724. if (this.matricesWeights) {
  83725. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updatable);
  83726. }
  83727. if (this.matricesIndicesExtra) {
  83728. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updatable);
  83729. }
  83730. if (this.matricesWeightsExtra) {
  83731. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
  83732. }
  83733. if (this.indices) {
  83734. meshOrGeometry.setIndices(this.indices, null, updatable);
  83735. }
  83736. else {
  83737. meshOrGeometry.setIndices([], null);
  83738. }
  83739. return this;
  83740. };
  83741. VertexData.prototype._update = function (meshOrGeometry, updateExtends, makeItUnique) {
  83742. if (this.positions) {
  83743. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updateExtends, makeItUnique);
  83744. }
  83745. if (this.normals) {
  83746. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updateExtends, makeItUnique);
  83747. }
  83748. if (this.tangents) {
  83749. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updateExtends, makeItUnique);
  83750. }
  83751. if (this.uvs) {
  83752. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updateExtends, makeItUnique);
  83753. }
  83754. if (this.uvs2) {
  83755. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updateExtends, makeItUnique);
  83756. }
  83757. if (this.uvs3) {
  83758. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updateExtends, makeItUnique);
  83759. }
  83760. if (this.uvs4) {
  83761. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updateExtends, makeItUnique);
  83762. }
  83763. if (this.uvs5) {
  83764. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updateExtends, makeItUnique);
  83765. }
  83766. if (this.uvs6) {
  83767. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updateExtends, makeItUnique);
  83768. }
  83769. if (this.colors) {
  83770. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updateExtends, makeItUnique);
  83771. }
  83772. if (this.matricesIndices) {
  83773. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updateExtends, makeItUnique);
  83774. }
  83775. if (this.matricesWeights) {
  83776. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updateExtends, makeItUnique);
  83777. }
  83778. if (this.matricesIndicesExtra) {
  83779. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updateExtends, makeItUnique);
  83780. }
  83781. if (this.matricesWeightsExtra) {
  83782. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updateExtends, makeItUnique);
  83783. }
  83784. if (this.indices) {
  83785. meshOrGeometry.setIndices(this.indices, null);
  83786. }
  83787. return this;
  83788. };
  83789. /**
  83790. * Transforms each position and each normal of the vertexData according to the passed Matrix
  83791. * @param matrix the transforming matrix
  83792. * @returns the VertexData
  83793. */
  83794. VertexData.prototype.transform = function (matrix) {
  83795. var flip = matrix.m[0] * matrix.m[5] * matrix.m[10] < 0;
  83796. var transformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  83797. var index;
  83798. if (this.positions) {
  83799. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  83800. for (index = 0; index < this.positions.length; index += 3) {
  83801. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.positions, index, position);
  83802. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(position, matrix, transformed);
  83803. this.positions[index] = transformed.x;
  83804. this.positions[index + 1] = transformed.y;
  83805. this.positions[index + 2] = transformed.z;
  83806. }
  83807. }
  83808. if (this.normals) {
  83809. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  83810. for (index = 0; index < this.normals.length; index += 3) {
  83811. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.normals, index, normal);
  83812. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(normal, matrix, transformed);
  83813. this.normals[index] = transformed.x;
  83814. this.normals[index + 1] = transformed.y;
  83815. this.normals[index + 2] = transformed.z;
  83816. }
  83817. }
  83818. if (this.tangents) {
  83819. var tangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  83820. var tangentTransformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  83821. for (index = 0; index < this.tangents.length; index += 4) {
  83822. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].FromArrayToRef(this.tangents, index, tangent);
  83823. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].TransformNormalToRef(tangent, matrix, tangentTransformed);
  83824. this.tangents[index] = tangentTransformed.x;
  83825. this.tangents[index + 1] = tangentTransformed.y;
  83826. this.tangents[index + 2] = tangentTransformed.z;
  83827. this.tangents[index + 3] = tangentTransformed.w;
  83828. }
  83829. }
  83830. if (flip && this.indices) {
  83831. for (index = 0; index < this.indices.length; index += 3) {
  83832. var tmp = this.indices[index + 1];
  83833. this.indices[index + 1] = this.indices[index + 2];
  83834. this.indices[index + 2] = tmp;
  83835. }
  83836. }
  83837. return this;
  83838. };
  83839. /**
  83840. * Merges the passed VertexData into the current one
  83841. * @param other the VertexData to be merged into the current one
  83842. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  83843. * @returns the modified VertexData
  83844. */
  83845. VertexData.prototype.merge = function (other, use32BitsIndices) {
  83846. if (use32BitsIndices === void 0) { use32BitsIndices = false; }
  83847. this._validate();
  83848. other._validate();
  83849. if (!this.normals !== !other.normals ||
  83850. !this.tangents !== !other.tangents ||
  83851. !this.uvs !== !other.uvs ||
  83852. !this.uvs2 !== !other.uvs2 ||
  83853. !this.uvs3 !== !other.uvs3 ||
  83854. !this.uvs4 !== !other.uvs4 ||
  83855. !this.uvs5 !== !other.uvs5 ||
  83856. !this.uvs6 !== !other.uvs6 ||
  83857. !this.colors !== !other.colors ||
  83858. !this.matricesIndices !== !other.matricesIndices ||
  83859. !this.matricesWeights !== !other.matricesWeights ||
  83860. !this.matricesIndicesExtra !== !other.matricesIndicesExtra ||
  83861. !this.matricesWeightsExtra !== !other.matricesWeightsExtra) {
  83862. throw new Error("Cannot merge vertex data that do not have the same set of attributes");
  83863. }
  83864. if (other.indices) {
  83865. if (!this.indices) {
  83866. this.indices = [];
  83867. }
  83868. var offset = this.positions ? this.positions.length / 3 : 0;
  83869. var isSrcTypedArray = this.indices.BYTES_PER_ELEMENT !== undefined;
  83870. if (isSrcTypedArray) {
  83871. var len = this.indices.length + other.indices.length;
  83872. var temp = use32BitsIndices || this.indices instanceof Uint32Array ? new Uint32Array(len) : new Uint16Array(len);
  83873. temp.set(this.indices);
  83874. var decal = this.indices.length;
  83875. for (var index = 0; index < other.indices.length; index++) {
  83876. temp[decal + index] = other.indices[index] + offset;
  83877. }
  83878. this.indices = temp;
  83879. }
  83880. else {
  83881. for (var index = 0; index < other.indices.length; index++) {
  83882. this.indices.push(other.indices[index] + offset);
  83883. }
  83884. }
  83885. }
  83886. this.positions = this._mergeElement(this.positions, other.positions);
  83887. this.normals = this._mergeElement(this.normals, other.normals);
  83888. this.tangents = this._mergeElement(this.tangents, other.tangents);
  83889. this.uvs = this._mergeElement(this.uvs, other.uvs);
  83890. this.uvs2 = this._mergeElement(this.uvs2, other.uvs2);
  83891. this.uvs3 = this._mergeElement(this.uvs3, other.uvs3);
  83892. this.uvs4 = this._mergeElement(this.uvs4, other.uvs4);
  83893. this.uvs5 = this._mergeElement(this.uvs5, other.uvs5);
  83894. this.uvs6 = this._mergeElement(this.uvs6, other.uvs6);
  83895. this.colors = this._mergeElement(this.colors, other.colors);
  83896. this.matricesIndices = this._mergeElement(this.matricesIndices, other.matricesIndices);
  83897. this.matricesWeights = this._mergeElement(this.matricesWeights, other.matricesWeights);
  83898. this.matricesIndicesExtra = this._mergeElement(this.matricesIndicesExtra, other.matricesIndicesExtra);
  83899. this.matricesWeightsExtra = this._mergeElement(this.matricesWeightsExtra, other.matricesWeightsExtra);
  83900. return this;
  83901. };
  83902. VertexData.prototype._mergeElement = function (source, other) {
  83903. if (!source) {
  83904. return other;
  83905. }
  83906. if (!other) {
  83907. return source;
  83908. }
  83909. var len = other.length + source.length;
  83910. var isSrcTypedArray = source instanceof Float32Array;
  83911. var isOthTypedArray = other instanceof Float32Array;
  83912. // use non-loop method when the source is Float32Array
  83913. if (isSrcTypedArray) {
  83914. var ret32 = new Float32Array(len);
  83915. ret32.set(source);
  83916. ret32.set(other, source.length);
  83917. return ret32;
  83918. // source is number[], when other is also use concat
  83919. }
  83920. else if (!isOthTypedArray) {
  83921. return source.concat(other);
  83922. // source is a number[], but other is a Float32Array, loop required
  83923. }
  83924. else {
  83925. var ret = source.slice(0); // copy source to a separate array
  83926. for (var i = 0, len = other.length; i < len; i++) {
  83927. ret.push(other[i]);
  83928. }
  83929. return ret;
  83930. }
  83931. };
  83932. VertexData.prototype._validate = function () {
  83933. if (!this.positions) {
  83934. throw new Error("Positions are required");
  83935. }
  83936. var getElementCount = function (kind, values) {
  83937. var stride = _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].DeduceStride(kind);
  83938. if ((values.length % stride) !== 0) {
  83939. throw new Error("The " + kind + "s array count must be a multiple of " + stride);
  83940. }
  83941. return values.length / stride;
  83942. };
  83943. var positionsElementCount = getElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions);
  83944. var validateElementCount = function (kind, values) {
  83945. var elementCount = getElementCount(kind, values);
  83946. if (elementCount !== positionsElementCount) {
  83947. throw new Error("The " + kind + "s element count (" + elementCount + ") does not match the positions count (" + positionsElementCount + ")");
  83948. }
  83949. };
  83950. if (this.normals) {
  83951. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals);
  83952. }
  83953. if (this.tangents) {
  83954. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents);
  83955. }
  83956. if (this.uvs) {
  83957. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs);
  83958. }
  83959. if (this.uvs2) {
  83960. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2);
  83961. }
  83962. if (this.uvs3) {
  83963. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3);
  83964. }
  83965. if (this.uvs4) {
  83966. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4);
  83967. }
  83968. if (this.uvs5) {
  83969. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5);
  83970. }
  83971. if (this.uvs6) {
  83972. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6);
  83973. }
  83974. if (this.colors) {
  83975. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors);
  83976. }
  83977. if (this.matricesIndices) {
  83978. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices);
  83979. }
  83980. if (this.matricesWeights) {
  83981. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights);
  83982. }
  83983. if (this.matricesIndicesExtra) {
  83984. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra);
  83985. }
  83986. if (this.matricesWeightsExtra) {
  83987. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra);
  83988. }
  83989. };
  83990. /**
  83991. * Serializes the VertexData
  83992. * @returns a serialized object
  83993. */
  83994. VertexData.prototype.serialize = function () {
  83995. var serializationObject = this.serialize();
  83996. if (this.positions) {
  83997. serializationObject.positions = this.positions;
  83998. }
  83999. if (this.normals) {
  84000. serializationObject.normals = this.normals;
  84001. }
  84002. if (this.tangents) {
  84003. serializationObject.tangents = this.tangents;
  84004. }
  84005. if (this.uvs) {
  84006. serializationObject.uvs = this.uvs;
  84007. }
  84008. if (this.uvs2) {
  84009. serializationObject.uvs2 = this.uvs2;
  84010. }
  84011. if (this.uvs3) {
  84012. serializationObject.uvs3 = this.uvs3;
  84013. }
  84014. if (this.uvs4) {
  84015. serializationObject.uvs4 = this.uvs4;
  84016. }
  84017. if (this.uvs5) {
  84018. serializationObject.uvs5 = this.uvs5;
  84019. }
  84020. if (this.uvs6) {
  84021. serializationObject.uvs6 = this.uvs6;
  84022. }
  84023. if (this.colors) {
  84024. serializationObject.colors = this.colors;
  84025. }
  84026. if (this.matricesIndices) {
  84027. serializationObject.matricesIndices = this.matricesIndices;
  84028. serializationObject.matricesIndices._isExpanded = true;
  84029. }
  84030. if (this.matricesWeights) {
  84031. serializationObject.matricesWeights = this.matricesWeights;
  84032. }
  84033. if (this.matricesIndicesExtra) {
  84034. serializationObject.matricesIndicesExtra = this.matricesIndicesExtra;
  84035. serializationObject.matricesIndicesExtra._isExpanded = true;
  84036. }
  84037. if (this.matricesWeightsExtra) {
  84038. serializationObject.matricesWeightsExtra = this.matricesWeightsExtra;
  84039. }
  84040. serializationObject.indices = this.indices;
  84041. return serializationObject;
  84042. };
  84043. // Statics
  84044. /**
  84045. * Extracts the vertexData from a mesh
  84046. * @param mesh the mesh from which to extract the VertexData
  84047. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  84048. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  84049. * @returns the object VertexData associated to the passed mesh
  84050. */
  84051. VertexData.ExtractFromMesh = function (mesh, copyWhenShared, forceCopy) {
  84052. return VertexData._ExtractFrom(mesh, copyWhenShared, forceCopy);
  84053. };
  84054. /**
  84055. * Extracts the vertexData from the geometry
  84056. * @param geometry the geometry from which to extract the VertexData
  84057. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  84058. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  84059. * @returns the object VertexData associated to the passed mesh
  84060. */
  84061. VertexData.ExtractFromGeometry = function (geometry, copyWhenShared, forceCopy) {
  84062. return VertexData._ExtractFrom(geometry, copyWhenShared, forceCopy);
  84063. };
  84064. VertexData._ExtractFrom = function (meshOrGeometry, copyWhenShared, forceCopy) {
  84065. var result = new VertexData();
  84066. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind)) {
  84067. result.positions = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, copyWhenShared, forceCopy);
  84068. }
  84069. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  84070. result.normals = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, copyWhenShared, forceCopy);
  84071. }
  84072. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind)) {
  84073. result.tangents = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, copyWhenShared, forceCopy);
  84074. }
  84075. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  84076. result.uvs = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, copyWhenShared, forceCopy);
  84077. }
  84078. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  84079. result.uvs2 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, copyWhenShared, forceCopy);
  84080. }
  84081. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind)) {
  84082. result.uvs3 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, copyWhenShared, forceCopy);
  84083. }
  84084. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind)) {
  84085. result.uvs4 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, copyWhenShared, forceCopy);
  84086. }
  84087. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind)) {
  84088. result.uvs5 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, copyWhenShared, forceCopy);
  84089. }
  84090. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind)) {
  84091. result.uvs6 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, copyWhenShared, forceCopy);
  84092. }
  84093. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind)) {
  84094. result.colors = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, copyWhenShared, forceCopy);
  84095. }
  84096. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind)) {
  84097. result.matricesIndices = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, copyWhenShared, forceCopy);
  84098. }
  84099. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind)) {
  84100. result.matricesWeights = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, copyWhenShared, forceCopy);
  84101. }
  84102. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind)) {
  84103. result.matricesIndicesExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, copyWhenShared, forceCopy);
  84104. }
  84105. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind)) {
  84106. result.matricesWeightsExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, copyWhenShared, forceCopy);
  84107. }
  84108. result.indices = meshOrGeometry.getIndices(copyWhenShared, forceCopy);
  84109. return result;
  84110. };
  84111. /**
  84112. * Creates the VertexData for a Ribbon
  84113. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  84114. * * pathArray array of paths, each of which an array of successive Vector3
  84115. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  84116. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  84117. * * 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
  84118. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84119. * * 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)
  84120. * * 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)
  84121. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  84122. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  84123. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  84124. * @returns the VertexData of the ribbon
  84125. */
  84126. VertexData.CreateRibbon = function (options) {
  84127. var pathArray = options.pathArray;
  84128. var closeArray = options.closeArray || false;
  84129. var closePath = options.closePath || false;
  84130. var invertUV = options.invertUV || false;
  84131. var defaultOffset = Math.floor(pathArray[0].length / 2);
  84132. var offset = options.offset || defaultOffset;
  84133. offset = offset > defaultOffset ? defaultOffset : Math.floor(offset); // offset max allowed : defaultOffset
  84134. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  84135. var customUV = options.uvs;
  84136. var customColors = options.colors;
  84137. var positions = [];
  84138. var indices = [];
  84139. var normals = [];
  84140. var uvs = [];
  84141. var us = []; // us[path_id] = [uDist1, uDist2, uDist3 ... ] distances between points on path path_id
  84142. var vs = []; // vs[i] = [vDist1, vDist2, vDist3, ... ] distances between points i of consecutives paths from pathArray
  84143. var uTotalDistance = []; // uTotalDistance[p] : total distance of path p
  84144. var vTotalDistance = []; // vTotalDistance[i] : total distance between points i of first and last path from pathArray
  84145. var minlg; // minimal length among all paths from pathArray
  84146. var lg = []; // array of path lengths : nb of vertex per path
  84147. var idx = []; // array of path indexes : index of each path (first vertex) in the total vertex number
  84148. var p; // path iterator
  84149. var i; // point iterator
  84150. var j; // point iterator
  84151. // if single path in pathArray
  84152. if (pathArray.length < 2) {
  84153. var ar1 = [];
  84154. var ar2 = [];
  84155. for (i = 0; i < pathArray[0].length - offset; i++) {
  84156. ar1.push(pathArray[0][i]);
  84157. ar2.push(pathArray[0][i + offset]);
  84158. }
  84159. pathArray = [ar1, ar2];
  84160. }
  84161. // positions and horizontal distances (u)
  84162. var idc = 0;
  84163. var closePathCorr = (closePath) ? 1 : 0; // the final index will be +1 if closePath
  84164. var path;
  84165. var l;
  84166. minlg = pathArray[0].length;
  84167. var vectlg;
  84168. var dist;
  84169. for (p = 0; p < pathArray.length; p++) {
  84170. uTotalDistance[p] = 0;
  84171. us[p] = [0];
  84172. path = pathArray[p];
  84173. l = path.length;
  84174. minlg = (minlg < l) ? minlg : l;
  84175. j = 0;
  84176. while (j < l) {
  84177. positions.push(path[j].x, path[j].y, path[j].z);
  84178. if (j > 0) {
  84179. vectlg = path[j].subtract(path[j - 1]).length();
  84180. dist = vectlg + uTotalDistance[p];
  84181. us[p].push(dist);
  84182. uTotalDistance[p] = dist;
  84183. }
  84184. j++;
  84185. }
  84186. if (closePath) { // an extra hidden vertex is added in the "positions" array
  84187. j--;
  84188. positions.push(path[0].x, path[0].y, path[0].z);
  84189. vectlg = path[j].subtract(path[0]).length();
  84190. dist = vectlg + uTotalDistance[p];
  84191. us[p].push(dist);
  84192. uTotalDistance[p] = dist;
  84193. }
  84194. lg[p] = l + closePathCorr;
  84195. idx[p] = idc;
  84196. idc += (l + closePathCorr);
  84197. }
  84198. // vertical distances (v)
  84199. var path1;
  84200. var path2;
  84201. var vertex1 = null;
  84202. var vertex2 = null;
  84203. for (i = 0; i < minlg + closePathCorr; i++) {
  84204. vTotalDistance[i] = 0;
  84205. vs[i] = [0];
  84206. for (p = 0; p < pathArray.length - 1; p++) {
  84207. path1 = pathArray[p];
  84208. path2 = pathArray[p + 1];
  84209. if (i === minlg) { // closePath
  84210. vertex1 = path1[0];
  84211. vertex2 = path2[0];
  84212. }
  84213. else {
  84214. vertex1 = path1[i];
  84215. vertex2 = path2[i];
  84216. }
  84217. vectlg = vertex2.subtract(vertex1).length();
  84218. dist = vectlg + vTotalDistance[i];
  84219. vs[i].push(dist);
  84220. vTotalDistance[i] = dist;
  84221. }
  84222. if (closeArray && vertex2 && vertex1) {
  84223. path1 = pathArray[p];
  84224. path2 = pathArray[0];
  84225. if (i === minlg) { // closePath
  84226. vertex2 = path2[0];
  84227. }
  84228. vectlg = vertex2.subtract(vertex1).length();
  84229. dist = vectlg + vTotalDistance[i];
  84230. vTotalDistance[i] = dist;
  84231. }
  84232. }
  84233. // uvs
  84234. var u;
  84235. var v;
  84236. if (customUV) {
  84237. for (p = 0; p < customUV.length; p++) {
  84238. uvs.push(customUV[p].x, customUV[p].y);
  84239. }
  84240. }
  84241. else {
  84242. for (p = 0; p < pathArray.length; p++) {
  84243. for (i = 0; i < minlg + closePathCorr; i++) {
  84244. u = (uTotalDistance[p] != 0.0) ? us[p][i] / uTotalDistance[p] : 0.0;
  84245. v = (vTotalDistance[i] != 0.0) ? vs[i][p] / vTotalDistance[i] : 0.0;
  84246. if (invertUV) {
  84247. uvs.push(v, u);
  84248. }
  84249. else {
  84250. uvs.push(u, v);
  84251. }
  84252. }
  84253. }
  84254. }
  84255. // indices
  84256. p = 0; // path index
  84257. var pi = 0; // positions array index
  84258. var l1 = lg[p] - 1; // path1 length
  84259. var l2 = lg[p + 1] - 1; // path2 length
  84260. var min = (l1 < l2) ? l1 : l2; // current path stop index
  84261. var shft = idx[1] - idx[0]; // shift
  84262. var path1nb = closeArray ? lg.length : lg.length - 1; // number of path1 to iterate on
  84263. while (pi <= min && p < path1nb) { // stay under min and don't go over next to last path
  84264. // 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
  84265. indices.push(pi, pi + shft, pi + 1);
  84266. indices.push(pi + shft + 1, pi + 1, pi + shft);
  84267. pi += 1;
  84268. if (pi === min) { // if end of one of two consecutive paths reached, go to next existing path
  84269. p++;
  84270. if (p === lg.length - 1) { // last path of pathArray reached <=> closeArray == true
  84271. shft = idx[0] - idx[p];
  84272. l1 = lg[p] - 1;
  84273. l2 = lg[0] - 1;
  84274. }
  84275. else {
  84276. shft = idx[p + 1] - idx[p];
  84277. l1 = lg[p] - 1;
  84278. l2 = lg[p + 1] - 1;
  84279. }
  84280. pi = idx[p];
  84281. min = (l1 < l2) ? l1 + pi : l2 + pi;
  84282. }
  84283. }
  84284. // normals
  84285. VertexData.ComputeNormals(positions, indices, normals);
  84286. if (closePath) { // update both the first and last vertex normals to their average value
  84287. var indexFirst = 0;
  84288. var indexLast = 0;
  84289. for (p = 0; p < pathArray.length; p++) {
  84290. indexFirst = idx[p] * 3;
  84291. if (p + 1 < pathArray.length) {
  84292. indexLast = (idx[p + 1] - 1) * 3;
  84293. }
  84294. else {
  84295. indexLast = normals.length - 3;
  84296. }
  84297. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  84298. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  84299. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  84300. normals[indexLast] = normals[indexFirst];
  84301. normals[indexLast + 1] = normals[indexFirst + 1];
  84302. normals[indexLast + 2] = normals[indexFirst + 2];
  84303. }
  84304. }
  84305. // sides
  84306. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  84307. // Colors
  84308. var colors = null;
  84309. if (customColors) {
  84310. colors = new Float32Array(customColors.length * 4);
  84311. for (var c = 0; c < customColors.length; c++) {
  84312. colors[c * 4] = customColors[c].r;
  84313. colors[c * 4 + 1] = customColors[c].g;
  84314. colors[c * 4 + 2] = customColors[c].b;
  84315. colors[c * 4 + 3] = customColors[c].a;
  84316. }
  84317. }
  84318. // Result
  84319. var vertexData = new VertexData();
  84320. var positions32 = new Float32Array(positions);
  84321. var normals32 = new Float32Array(normals);
  84322. var uvs32 = new Float32Array(uvs);
  84323. vertexData.indices = indices;
  84324. vertexData.positions = positions32;
  84325. vertexData.normals = normals32;
  84326. vertexData.uvs = uvs32;
  84327. if (colors) {
  84328. vertexData.set(colors, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  84329. }
  84330. if (closePath) {
  84331. vertexData._idx = idx;
  84332. }
  84333. return vertexData;
  84334. };
  84335. /**
  84336. * Creates the VertexData for a box
  84337. * @param options an object used to set the following optional parameters for the box, required but can be empty
  84338. * * size sets the width, height and depth of the box to the value of size, optional default 1
  84339. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  84340. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  84341. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  84342. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  84343. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  84344. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84345. * * 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)
  84346. * * 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)
  84347. * @returns the VertexData of the box
  84348. */
  84349. VertexData.CreateBox = function (options) {
  84350. var normalsSource = [
  84351. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1),
  84352. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1),
  84353. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0),
  84354. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0),
  84355. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0),
  84356. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)
  84357. ];
  84358. var indices = [];
  84359. var positions = [];
  84360. var normals = [];
  84361. var uvs = [];
  84362. var width = options.width || options.size || 1;
  84363. var height = options.height || options.size || 1;
  84364. var depth = options.depth || options.size || 1;
  84365. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  84366. var faceUV = options.faceUV || new Array(6);
  84367. var faceColors = options.faceColors;
  84368. var colors = [];
  84369. // default face colors and UV if undefined
  84370. for (var f = 0; f < 6; f++) {
  84371. if (faceUV[f] === undefined) {
  84372. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  84373. }
  84374. if (faceColors && faceColors[f] === undefined) {
  84375. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  84376. }
  84377. }
  84378. var scaleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](width / 2, height / 2, depth / 2);
  84379. // Create each face in turn.
  84380. for (var index = 0; index < normalsSource.length; index++) {
  84381. var normal = normalsSource[index];
  84382. // Get two vectors perpendicular to the face normal and to each other.
  84383. var side1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normal.y, normal.z, normal.x);
  84384. var side2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(normal, side1);
  84385. // Six indices (two triangles) per face.
  84386. var verticesLength = positions.length / 3;
  84387. indices.push(verticesLength);
  84388. indices.push(verticesLength + 1);
  84389. indices.push(verticesLength + 2);
  84390. indices.push(verticesLength);
  84391. indices.push(verticesLength + 2);
  84392. indices.push(verticesLength + 3);
  84393. // Four vertices per face.
  84394. var vertex = normal.subtract(side1).subtract(side2).multiply(scaleVector);
  84395. positions.push(vertex.x, vertex.y, vertex.z);
  84396. normals.push(normal.x, normal.y, normal.z);
  84397. uvs.push(faceUV[index].z, faceUV[index].w);
  84398. if (faceColors) {
  84399. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  84400. }
  84401. vertex = normal.subtract(side1).add(side2).multiply(scaleVector);
  84402. positions.push(vertex.x, vertex.y, vertex.z);
  84403. normals.push(normal.x, normal.y, normal.z);
  84404. uvs.push(faceUV[index].x, faceUV[index].w);
  84405. if (faceColors) {
  84406. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  84407. }
  84408. vertex = normal.add(side1).add(side2).multiply(scaleVector);
  84409. positions.push(vertex.x, vertex.y, vertex.z);
  84410. normals.push(normal.x, normal.y, normal.z);
  84411. uvs.push(faceUV[index].x, faceUV[index].y);
  84412. if (faceColors) {
  84413. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  84414. }
  84415. vertex = normal.add(side1).subtract(side2).multiply(scaleVector);
  84416. positions.push(vertex.x, vertex.y, vertex.z);
  84417. normals.push(normal.x, normal.y, normal.z);
  84418. uvs.push(faceUV[index].z, faceUV[index].y);
  84419. if (faceColors) {
  84420. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  84421. }
  84422. }
  84423. // sides
  84424. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  84425. // Result
  84426. var vertexData = new VertexData();
  84427. vertexData.indices = indices;
  84428. vertexData.positions = positions;
  84429. vertexData.normals = normals;
  84430. vertexData.uvs = uvs;
  84431. if (faceColors) {
  84432. var totalColors = (sideOrientation === VertexData.DOUBLESIDE) ? colors.concat(colors) : colors;
  84433. vertexData.colors = totalColors;
  84434. }
  84435. return vertexData;
  84436. };
  84437. /**
  84438. * Creates the VertexData for an ellipsoid, defaults to a sphere
  84439. * @param options an object used to set the following optional parameters for the box, required but can be empty
  84440. * * segments sets the number of horizontal strips optional, default 32
  84441. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  84442. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  84443. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  84444. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  84445. * * 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
  84446. * * 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
  84447. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84448. * * 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)
  84449. * * 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)
  84450. * @returns the VertexData of the ellipsoid
  84451. */
  84452. VertexData.CreateSphere = function (options) {
  84453. var segments = options.segments || 32;
  84454. var diameterX = options.diameterX || options.diameter || 1;
  84455. var diameterY = options.diameterY || options.diameter || 1;
  84456. var diameterZ = options.diameterZ || options.diameter || 1;
  84457. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  84458. var slice = options.slice && (options.slice <= 0) ? 1.0 : options.slice || 1.0;
  84459. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  84460. var radius = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](diameterX / 2, diameterY / 2, diameterZ / 2);
  84461. var totalZRotationSteps = 2 + segments;
  84462. var totalYRotationSteps = 2 * totalZRotationSteps;
  84463. var indices = [];
  84464. var positions = [];
  84465. var normals = [];
  84466. var uvs = [];
  84467. for (var zRotationStep = 0; zRotationStep <= totalZRotationSteps; zRotationStep++) {
  84468. var normalizedZ = zRotationStep / totalZRotationSteps;
  84469. var angleZ = normalizedZ * Math.PI * slice;
  84470. for (var yRotationStep = 0; yRotationStep <= totalYRotationSteps; yRotationStep++) {
  84471. var normalizedY = yRotationStep / totalYRotationSteps;
  84472. var angleY = normalizedY * Math.PI * 2 * arc;
  84473. var rotationZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationZ(-angleZ);
  84474. var rotationY = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(angleY);
  84475. var afterRotZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), rotationZ);
  84476. var complete = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(afterRotZ, rotationY);
  84477. var vertex = complete.multiply(radius);
  84478. var normal = complete.divide(radius).normalize();
  84479. positions.push(vertex.x, vertex.y, vertex.z);
  84480. normals.push(normal.x, normal.y, normal.z);
  84481. uvs.push(normalizedY, normalizedZ);
  84482. }
  84483. if (zRotationStep > 0) {
  84484. var verticesCount = positions.length / 3;
  84485. for (var firstIndex = verticesCount - 2 * (totalYRotationSteps + 1); (firstIndex + totalYRotationSteps + 2) < verticesCount; firstIndex++) {
  84486. indices.push((firstIndex));
  84487. indices.push((firstIndex + 1));
  84488. indices.push(firstIndex + totalYRotationSteps + 1);
  84489. indices.push((firstIndex + totalYRotationSteps + 1));
  84490. indices.push((firstIndex + 1));
  84491. indices.push((firstIndex + totalYRotationSteps + 2));
  84492. }
  84493. }
  84494. }
  84495. // Sides
  84496. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  84497. // Result
  84498. var vertexData = new VertexData();
  84499. vertexData.indices = indices;
  84500. vertexData.positions = positions;
  84501. vertexData.normals = normals;
  84502. vertexData.uvs = uvs;
  84503. return vertexData;
  84504. };
  84505. /**
  84506. * Creates the VertexData for a cylinder, cone or prism
  84507. * @param options an object used to set the following optional parameters for the box, required but can be empty
  84508. * * height sets the height (y direction) of the cylinder, optional, default 2
  84509. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  84510. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  84511. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  84512. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  84513. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  84514. * * 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
  84515. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  84516. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  84517. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  84518. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  84519. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84520. * * 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)
  84521. * * 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)
  84522. * @returns the VertexData of the cylinder, cone or prism
  84523. */
  84524. VertexData.CreateCylinder = function (options) {
  84525. var height = options.height || 2;
  84526. var diameterTop = (options.diameterTop === 0) ? 0 : options.diameterTop || options.diameter || 1;
  84527. var diameterBottom = (options.diameterBottom === 0) ? 0 : options.diameterBottom || options.diameter || 1;
  84528. var tessellation = options.tessellation || 24;
  84529. var subdivisions = options.subdivisions || 1;
  84530. var hasRings = options.hasRings ? true : false;
  84531. var enclose = options.enclose ? true : false;
  84532. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  84533. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  84534. var faceUV = options.faceUV || new Array(3);
  84535. var faceColors = options.faceColors;
  84536. // default face colors and UV if undefined
  84537. var quadNb = (arc !== 1 && enclose) ? 2 : 0;
  84538. var ringNb = (hasRings) ? subdivisions : 1;
  84539. var surfaceNb = 2 + (1 + quadNb) * ringNb;
  84540. var f;
  84541. for (f = 0; f < surfaceNb; f++) {
  84542. if (faceColors && faceColors[f] === undefined) {
  84543. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  84544. }
  84545. }
  84546. for (f = 0; f < surfaceNb; f++) {
  84547. if (faceUV && faceUV[f] === undefined) {
  84548. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  84549. }
  84550. }
  84551. var indices = new Array();
  84552. var positions = new Array();
  84553. var normals = new Array();
  84554. var uvs = new Array();
  84555. var colors = new Array();
  84556. var angle_step = Math.PI * 2 * arc / tessellation;
  84557. var angle;
  84558. var h;
  84559. var radius;
  84560. var tan = (diameterBottom - diameterTop) / 2 / height;
  84561. var ringVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  84562. var ringNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  84563. var ringFirstVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  84564. var ringFirstNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  84565. var quadNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  84566. var Y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Y;
  84567. // positions, normals, uvs
  84568. var i;
  84569. var j;
  84570. var r;
  84571. var ringIdx = 1;
  84572. var s = 1; // surface index
  84573. var cs = 0;
  84574. var v = 0;
  84575. for (i = 0; i <= subdivisions; i++) {
  84576. h = i / subdivisions;
  84577. radius = (h * (diameterTop - diameterBottom) + diameterBottom) / 2;
  84578. ringIdx = (hasRings && i !== 0 && i !== subdivisions) ? 2 : 1;
  84579. for (r = 0; r < ringIdx; r++) {
  84580. if (hasRings) {
  84581. s += r;
  84582. }
  84583. if (enclose) {
  84584. s += 2 * r;
  84585. }
  84586. for (j = 0; j <= tessellation; j++) {
  84587. angle = j * angle_step;
  84588. // position
  84589. ringVertex.x = Math.cos(-angle) * radius;
  84590. ringVertex.y = -height / 2 + h * height;
  84591. ringVertex.z = Math.sin(-angle) * radius;
  84592. // normal
  84593. if (diameterTop === 0 && i === subdivisions) {
  84594. // if no top cap, reuse former normals
  84595. ringNormal.x = normals[normals.length - (tessellation + 1) * 3];
  84596. ringNormal.y = normals[normals.length - (tessellation + 1) * 3 + 1];
  84597. ringNormal.z = normals[normals.length - (tessellation + 1) * 3 + 2];
  84598. }
  84599. else {
  84600. ringNormal.x = ringVertex.x;
  84601. ringNormal.z = ringVertex.z;
  84602. ringNormal.y = Math.sqrt(ringNormal.x * ringNormal.x + ringNormal.z * ringNormal.z) * tan;
  84603. ringNormal.normalize();
  84604. }
  84605. // keep first ring vertex values for enclose
  84606. if (j === 0) {
  84607. ringFirstVertex.copyFrom(ringVertex);
  84608. ringFirstNormal.copyFrom(ringNormal);
  84609. }
  84610. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  84611. normals.push(ringNormal.x, ringNormal.y, ringNormal.z);
  84612. if (hasRings) {
  84613. v = (cs !== s) ? faceUV[s].y : faceUV[s].w;
  84614. }
  84615. else {
  84616. v = faceUV[s].y + (faceUV[s].w - faceUV[s].y) * h;
  84617. }
  84618. uvs.push(faceUV[s].x + (faceUV[s].z - faceUV[s].x) * j / tessellation, v);
  84619. if (faceColors) {
  84620. colors.push(faceColors[s].r, faceColors[s].g, faceColors[s].b, faceColors[s].a);
  84621. }
  84622. }
  84623. // if enclose, add four vertices and their dedicated normals
  84624. if (arc !== 1 && enclose) {
  84625. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  84626. positions.push(0, ringVertex.y, 0);
  84627. positions.push(0, ringVertex.y, 0);
  84628. positions.push(ringFirstVertex.x, ringFirstVertex.y, ringFirstVertex.z);
  84629. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(Y, ringNormal, quadNormal);
  84630. quadNormal.normalize();
  84631. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  84632. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(ringFirstNormal, Y, quadNormal);
  84633. quadNormal.normalize();
  84634. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  84635. if (hasRings) {
  84636. v = (cs !== s) ? faceUV[s + 1].y : faceUV[s + 1].w;
  84637. }
  84638. else {
  84639. v = faceUV[s + 1].y + (faceUV[s + 1].w - faceUV[s + 1].y) * h;
  84640. }
  84641. uvs.push(faceUV[s + 1].x, v);
  84642. uvs.push(faceUV[s + 1].z, v);
  84643. if (hasRings) {
  84644. v = (cs !== s) ? faceUV[s + 2].y : faceUV[s + 2].w;
  84645. }
  84646. else {
  84647. v = faceUV[s + 2].y + (faceUV[s + 2].w - faceUV[s + 2].y) * h;
  84648. }
  84649. uvs.push(faceUV[s + 2].x, v);
  84650. uvs.push(faceUV[s + 2].z, v);
  84651. if (faceColors) {
  84652. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  84653. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  84654. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  84655. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  84656. }
  84657. }
  84658. if (cs !== s) {
  84659. cs = s;
  84660. }
  84661. }
  84662. }
  84663. // indices
  84664. var e = (arc !== 1 && enclose) ? tessellation + 4 : tessellation; // correction of number of iteration if enclose
  84665. var s;
  84666. i = 0;
  84667. for (s = 0; s < subdivisions; s++) {
  84668. var i0 = 0;
  84669. var i1 = 0;
  84670. var i2 = 0;
  84671. var i3 = 0;
  84672. for (j = 0; j < tessellation; j++) {
  84673. i0 = i * (e + 1) + j;
  84674. i1 = (i + 1) * (e + 1) + j;
  84675. i2 = i * (e + 1) + (j + 1);
  84676. i3 = (i + 1) * (e + 1) + (j + 1);
  84677. indices.push(i0, i1, i2);
  84678. indices.push(i3, i2, i1);
  84679. }
  84680. if (arc !== 1 && enclose) { // if enclose, add two quads
  84681. indices.push(i0 + 2, i1 + 2, i2 + 2);
  84682. indices.push(i3 + 2, i2 + 2, i1 + 2);
  84683. indices.push(i0 + 4, i1 + 4, i2 + 4);
  84684. indices.push(i3 + 4, i2 + 4, i1 + 4);
  84685. }
  84686. i = (hasRings) ? (i + 2) : (i + 1);
  84687. }
  84688. // Caps
  84689. var createCylinderCap = function (isTop) {
  84690. var radius = isTop ? diameterTop / 2 : diameterBottom / 2;
  84691. if (radius === 0) {
  84692. return;
  84693. }
  84694. // Cap positions, normals & uvs
  84695. var angle;
  84696. var circleVector;
  84697. var i;
  84698. var u = (isTop) ? faceUV[surfaceNb - 1] : faceUV[0];
  84699. var c = null;
  84700. if (faceColors) {
  84701. c = (isTop) ? faceColors[surfaceNb - 1] : faceColors[0];
  84702. }
  84703. // cap center
  84704. var vbase = positions.length / 3;
  84705. var offset = isTop ? height / 2 : -height / 2;
  84706. var center = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, offset, 0);
  84707. positions.push(center.x, center.y, center.z);
  84708. normals.push(0, isTop ? 1 : -1, 0);
  84709. uvs.push(u.x + (u.z - u.x) * 0.5, u.y + (u.w - u.y) * 0.5);
  84710. if (c) {
  84711. colors.push(c.r, c.g, c.b, c.a);
  84712. }
  84713. var textureScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0.5, 0.5);
  84714. for (i = 0; i <= tessellation; i++) {
  84715. angle = Math.PI * 2 * i * arc / tessellation;
  84716. var cos = Math.cos(-angle);
  84717. var sin = Math.sin(-angle);
  84718. circleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](cos * radius, offset, sin * radius);
  84719. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](cos * textureScale.x + 0.5, sin * textureScale.y + 0.5);
  84720. positions.push(circleVector.x, circleVector.y, circleVector.z);
  84721. normals.push(0, isTop ? 1 : -1, 0);
  84722. uvs.push(u.x + (u.z - u.x) * textureCoordinate.x, u.y + (u.w - u.y) * textureCoordinate.y);
  84723. if (c) {
  84724. colors.push(c.r, c.g, c.b, c.a);
  84725. }
  84726. }
  84727. // Cap indices
  84728. for (i = 0; i < tessellation; i++) {
  84729. if (!isTop) {
  84730. indices.push(vbase);
  84731. indices.push(vbase + (i + 1));
  84732. indices.push(vbase + (i + 2));
  84733. }
  84734. else {
  84735. indices.push(vbase);
  84736. indices.push(vbase + (i + 2));
  84737. indices.push(vbase + (i + 1));
  84738. }
  84739. }
  84740. };
  84741. // add caps to geometry
  84742. createCylinderCap(false);
  84743. createCylinderCap(true);
  84744. // Sides
  84745. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  84746. var vertexData = new VertexData();
  84747. vertexData.indices = indices;
  84748. vertexData.positions = positions;
  84749. vertexData.normals = normals;
  84750. vertexData.uvs = uvs;
  84751. if (faceColors) {
  84752. vertexData.colors = colors;
  84753. }
  84754. return vertexData;
  84755. };
  84756. /**
  84757. * Creates the VertexData for a torus
  84758. * @param options an object used to set the following optional parameters for the box, required but can be empty
  84759. * * diameter the diameter of the torus, optional default 1
  84760. * * thickness the diameter of the tube forming the torus, optional default 0.5
  84761. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  84762. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84763. * * 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)
  84764. * * 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)
  84765. * @returns the VertexData of the torus
  84766. */
  84767. VertexData.CreateTorus = function (options) {
  84768. var indices = [];
  84769. var positions = [];
  84770. var normals = [];
  84771. var uvs = [];
  84772. var diameter = options.diameter || 1;
  84773. var thickness = options.thickness || 0.5;
  84774. var tessellation = options.tessellation || 16;
  84775. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  84776. var stride = tessellation + 1;
  84777. for (var i = 0; i <= tessellation; i++) {
  84778. var u = i / tessellation;
  84779. var outerAngle = i * Math.PI * 2.0 / tessellation - Math.PI / 2.0;
  84780. 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));
  84781. for (var j = 0; j <= tessellation; j++) {
  84782. var v = 1 - j / tessellation;
  84783. var innerAngle = j * Math.PI * 2.0 / tessellation + Math.PI;
  84784. var dx = Math.cos(innerAngle);
  84785. var dy = Math.sin(innerAngle);
  84786. // Create a vertex.
  84787. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](dx, dy, 0);
  84788. var position = normal.scale(thickness / 2);
  84789. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](u, v);
  84790. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(position, transform);
  84791. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, transform);
  84792. positions.push(position.x, position.y, position.z);
  84793. normals.push(normal.x, normal.y, normal.z);
  84794. uvs.push(textureCoordinate.x, textureCoordinate.y);
  84795. // And create indices for two triangles.
  84796. var nextI = (i + 1) % stride;
  84797. var nextJ = (j + 1) % stride;
  84798. indices.push(i * stride + j);
  84799. indices.push(i * stride + nextJ);
  84800. indices.push(nextI * stride + j);
  84801. indices.push(i * stride + nextJ);
  84802. indices.push(nextI * stride + nextJ);
  84803. indices.push(nextI * stride + j);
  84804. }
  84805. }
  84806. // Sides
  84807. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  84808. // Result
  84809. var vertexData = new VertexData();
  84810. vertexData.indices = indices;
  84811. vertexData.positions = positions;
  84812. vertexData.normals = normals;
  84813. vertexData.uvs = uvs;
  84814. return vertexData;
  84815. };
  84816. /**
  84817. * Creates the VertexData of the LineSystem
  84818. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  84819. * - lines an array of lines, each line being an array of successive Vector3
  84820. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  84821. * @returns the VertexData of the LineSystem
  84822. */
  84823. VertexData.CreateLineSystem = function (options) {
  84824. var indices = [];
  84825. var positions = [];
  84826. var lines = options.lines;
  84827. var colors = options.colors;
  84828. var vertexColors = [];
  84829. var idx = 0;
  84830. for (var l = 0; l < lines.length; l++) {
  84831. var points = lines[l];
  84832. for (var index = 0; index < points.length; index++) {
  84833. positions.push(points[index].x, points[index].y, points[index].z);
  84834. if (colors) {
  84835. var color = colors[l];
  84836. vertexColors.push(color[index].r, color[index].g, color[index].b, color[index].a);
  84837. }
  84838. if (index > 0) {
  84839. indices.push(idx - 1);
  84840. indices.push(idx);
  84841. }
  84842. idx++;
  84843. }
  84844. }
  84845. var vertexData = new VertexData();
  84846. vertexData.indices = indices;
  84847. vertexData.positions = positions;
  84848. if (colors) {
  84849. vertexData.colors = vertexColors;
  84850. }
  84851. return vertexData;
  84852. };
  84853. /**
  84854. * Create the VertexData for a DashedLines
  84855. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  84856. * - points an array successive Vector3
  84857. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  84858. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  84859. * - dashNb the intended total number of dashes, optional, default 200
  84860. * @returns the VertexData for the DashedLines
  84861. */
  84862. VertexData.CreateDashedLines = function (options) {
  84863. var dashSize = options.dashSize || 3;
  84864. var gapSize = options.gapSize || 1;
  84865. var dashNb = options.dashNb || 200;
  84866. var points = options.points;
  84867. var positions = new Array();
  84868. var indices = new Array();
  84869. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  84870. var lg = 0;
  84871. var nb = 0;
  84872. var shft = 0;
  84873. var dashshft = 0;
  84874. var curshft = 0;
  84875. var idx = 0;
  84876. var i = 0;
  84877. for (i = 0; i < points.length - 1; i++) {
  84878. points[i + 1].subtractToRef(points[i], curvect);
  84879. lg += curvect.length();
  84880. }
  84881. shft = lg / dashNb;
  84882. dashshft = dashSize * shft / (dashSize + gapSize);
  84883. for (i = 0; i < points.length - 1; i++) {
  84884. points[i + 1].subtractToRef(points[i], curvect);
  84885. nb = Math.floor(curvect.length() / shft);
  84886. curvect.normalize();
  84887. for (var j = 0; j < nb; j++) {
  84888. curshft = shft * j;
  84889. positions.push(points[i].x + curshft * curvect.x, points[i].y + curshft * curvect.y, points[i].z + curshft * curvect.z);
  84890. positions.push(points[i].x + (curshft + dashshft) * curvect.x, points[i].y + (curshft + dashshft) * curvect.y, points[i].z + (curshft + dashshft) * curvect.z);
  84891. indices.push(idx, idx + 1);
  84892. idx += 2;
  84893. }
  84894. }
  84895. // Result
  84896. var vertexData = new VertexData();
  84897. vertexData.positions = positions;
  84898. vertexData.indices = indices;
  84899. return vertexData;
  84900. };
  84901. /**
  84902. * Creates the VertexData for a Ground
  84903. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  84904. * - width the width (x direction) of the ground, optional, default 1
  84905. * - height the height (z direction) of the ground, optional, default 1
  84906. * - subdivisions the number of subdivisions per side, optional, default 1
  84907. * @returns the VertexData of the Ground
  84908. */
  84909. VertexData.CreateGround = function (options) {
  84910. var indices = [];
  84911. var positions = [];
  84912. var normals = [];
  84913. var uvs = [];
  84914. var row, col;
  84915. var width = options.width || 1;
  84916. var height = options.height || 1;
  84917. var subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  84918. var subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  84919. for (row = 0; row <= subdivisionsY; row++) {
  84920. for (col = 0; col <= subdivisionsX; col++) {
  84921. var position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((col * width) / subdivisionsX - (width / 2.0), 0, ((subdivisionsY - row) * height) / subdivisionsY - (height / 2.0));
  84922. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  84923. positions.push(position.x, position.y, position.z);
  84924. normals.push(normal.x, normal.y, normal.z);
  84925. uvs.push(col / subdivisionsX, 1.0 - row / subdivisionsY);
  84926. }
  84927. }
  84928. for (row = 0; row < subdivisionsY; row++) {
  84929. for (col = 0; col < subdivisionsX; col++) {
  84930. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  84931. indices.push(col + 1 + row * (subdivisionsX + 1));
  84932. indices.push(col + row * (subdivisionsX + 1));
  84933. indices.push(col + (row + 1) * (subdivisionsX + 1));
  84934. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  84935. indices.push(col + row * (subdivisionsX + 1));
  84936. }
  84937. }
  84938. // Result
  84939. var vertexData = new VertexData();
  84940. vertexData.indices = indices;
  84941. vertexData.positions = positions;
  84942. vertexData.normals = normals;
  84943. vertexData.uvs = uvs;
  84944. return vertexData;
  84945. };
  84946. /**
  84947. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  84948. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  84949. * * xmin the ground minimum X coordinate, optional, default -1
  84950. * * zmin the ground minimum Z coordinate, optional, default -1
  84951. * * xmax the ground maximum X coordinate, optional, default 1
  84952. * * zmax the ground maximum Z coordinate, optional, default 1
  84953. * * 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}
  84954. * * 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}
  84955. * @returns the VertexData of the TiledGround
  84956. */
  84957. VertexData.CreateTiledGround = function (options) {
  84958. var xmin = (options.xmin !== undefined && options.xmin !== null) ? options.xmin : -1.0;
  84959. var zmin = (options.zmin !== undefined && options.zmin !== null) ? options.zmin : -1.0;
  84960. var xmax = (options.xmax !== undefined && options.xmax !== null) ? options.xmax : 1.0;
  84961. var zmax = (options.zmax !== undefined && options.zmax !== null) ? options.zmax : 1.0;
  84962. var subdivisions = options.subdivisions || { w: 1, h: 1 };
  84963. var precision = options.precision || { w: 1, h: 1 };
  84964. var indices = new Array();
  84965. var positions = new Array();
  84966. var normals = new Array();
  84967. var uvs = new Array();
  84968. var row, col, tileRow, tileCol;
  84969. subdivisions.h = (subdivisions.h < 1) ? 1 : subdivisions.h;
  84970. subdivisions.w = (subdivisions.w < 1) ? 1 : subdivisions.w;
  84971. precision.w = (precision.w < 1) ? 1 : precision.w;
  84972. precision.h = (precision.h < 1) ? 1 : precision.h;
  84973. var tileSize = {
  84974. 'w': (xmax - xmin) / subdivisions.w,
  84975. 'h': (zmax - zmin) / subdivisions.h
  84976. };
  84977. function applyTile(xTileMin, zTileMin, xTileMax, zTileMax) {
  84978. // Indices
  84979. var base = positions.length / 3;
  84980. var rowLength = precision.w + 1;
  84981. for (row = 0; row < precision.h; row++) {
  84982. for (col = 0; col < precision.w; col++) {
  84983. var square = [
  84984. base + col + row * rowLength,
  84985. base + (col + 1) + row * rowLength,
  84986. base + (col + 1) + (row + 1) * rowLength,
  84987. base + col + (row + 1) * rowLength
  84988. ];
  84989. indices.push(square[1]);
  84990. indices.push(square[2]);
  84991. indices.push(square[3]);
  84992. indices.push(square[0]);
  84993. indices.push(square[1]);
  84994. indices.push(square[3]);
  84995. }
  84996. }
  84997. // Position, normals and uvs
  84998. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  84999. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  85000. for (row = 0; row <= precision.h; row++) {
  85001. position.z = (row * (zTileMax - zTileMin)) / precision.h + zTileMin;
  85002. for (col = 0; col <= precision.w; col++) {
  85003. position.x = (col * (xTileMax - xTileMin)) / precision.w + xTileMin;
  85004. position.y = 0;
  85005. positions.push(position.x, position.y, position.z);
  85006. normals.push(normal.x, normal.y, normal.z);
  85007. uvs.push(col / precision.w, row / precision.h);
  85008. }
  85009. }
  85010. }
  85011. for (tileRow = 0; tileRow < subdivisions.h; tileRow++) {
  85012. for (tileCol = 0; tileCol < subdivisions.w; tileCol++) {
  85013. applyTile(xmin + tileCol * tileSize.w, zmin + tileRow * tileSize.h, xmin + (tileCol + 1) * tileSize.w, zmin + (tileRow + 1) * tileSize.h);
  85014. }
  85015. }
  85016. // Result
  85017. var vertexData = new VertexData();
  85018. vertexData.indices = indices;
  85019. vertexData.positions = positions;
  85020. vertexData.normals = normals;
  85021. vertexData.uvs = uvs;
  85022. return vertexData;
  85023. };
  85024. /**
  85025. * Creates the VertexData of the Ground designed from a heightmap
  85026. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  85027. * * width the width (x direction) of the ground
  85028. * * height the height (z direction) of the ground
  85029. * * subdivisions the number of subdivisions per side
  85030. * * minHeight the minimum altitude on the ground, optional, default 0
  85031. * * maxHeight the maximum altitude on the ground, optional default 1
  85032. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  85033. * * buffer the array holding the image color data
  85034. * * bufferWidth the width of image
  85035. * * bufferHeight the height of image
  85036. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  85037. * @returns the VertexData of the Ground designed from a heightmap
  85038. */
  85039. VertexData.CreateGroundFromHeightMap = function (options) {
  85040. var indices = [];
  85041. var positions = [];
  85042. var normals = [];
  85043. var uvs = [];
  85044. var row, col;
  85045. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  85046. var alphaFilter = options.alphaFilter || 0.0;
  85047. // Vertices
  85048. for (row = 0; row <= options.subdivisions; row++) {
  85049. for (col = 0; col <= options.subdivisions; col++) {
  85050. 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));
  85051. // Compute height
  85052. var heightMapX = (((position.x + options.width / 2) / options.width) * (options.bufferWidth - 1)) | 0;
  85053. var heightMapY = ((1.0 - (position.z + options.height / 2) / options.height) * (options.bufferHeight - 1)) | 0;
  85054. var pos = (heightMapX + heightMapY * options.bufferWidth) * 4;
  85055. var r = options.buffer[pos] / 255.0;
  85056. var g = options.buffer[pos + 1] / 255.0;
  85057. var b = options.buffer[pos + 2] / 255.0;
  85058. var a = options.buffer[pos + 3] / 255.0;
  85059. var gradient = r * filter.r + g * filter.g + b * filter.b;
  85060. // If our alpha channel is not within our filter then we will assign a 'special' height
  85061. // Then when building the indices, we will ignore any vertex that is using the special height
  85062. if (a >= alphaFilter) {
  85063. position.y = options.minHeight + (options.maxHeight - options.minHeight) * gradient;
  85064. }
  85065. else {
  85066. position.y = options.minHeight - _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; // We can't have a height below minHeight, normally.
  85067. }
  85068. // Add vertex
  85069. positions.push(position.x, position.y, position.z);
  85070. normals.push(0, 0, 0);
  85071. uvs.push(col / options.subdivisions, 1.0 - row / options.subdivisions);
  85072. }
  85073. }
  85074. // Indices
  85075. for (row = 0; row < options.subdivisions; row++) {
  85076. for (col = 0; col < options.subdivisions; col++) {
  85077. // Calculate Indices
  85078. var idx1 = (col + 1 + (row + 1) * (options.subdivisions + 1));
  85079. var idx2 = (col + 1 + row * (options.subdivisions + 1));
  85080. var idx3 = (col + row * (options.subdivisions + 1));
  85081. var idx4 = (col + (row + 1) * (options.subdivisions + 1));
  85082. // Check that all indices are visible (based on our special height)
  85083. // Only display the vertex if all Indices are visible
  85084. // Positions are stored x,y,z for each vertex, hence the * 3 and + 1 for height
  85085. var isVisibleIdx1 = positions[idx1 * 3 + 1] >= options.minHeight;
  85086. var isVisibleIdx2 = positions[idx2 * 3 + 1] >= options.minHeight;
  85087. var isVisibleIdx3 = positions[idx3 * 3 + 1] >= options.minHeight;
  85088. if (isVisibleIdx1 && isVisibleIdx2 && isVisibleIdx3) {
  85089. indices.push(idx1);
  85090. indices.push(idx2);
  85091. indices.push(idx3);
  85092. }
  85093. var isVisibleIdx4 = positions[idx4 * 3 + 1] >= options.minHeight;
  85094. if (isVisibleIdx4 && isVisibleIdx1 && isVisibleIdx3) {
  85095. indices.push(idx4);
  85096. indices.push(idx1);
  85097. indices.push(idx3);
  85098. }
  85099. }
  85100. }
  85101. // Normals
  85102. VertexData.ComputeNormals(positions, indices, normals);
  85103. // Result
  85104. var vertexData = new VertexData();
  85105. vertexData.indices = indices;
  85106. vertexData.positions = positions;
  85107. vertexData.normals = normals;
  85108. vertexData.uvs = uvs;
  85109. return vertexData;
  85110. };
  85111. /**
  85112. * Creates the VertexData for a Plane
  85113. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  85114. * * size sets the width and height of the plane to the value of size, optional default 1
  85115. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  85116. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  85117. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85118. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  85119. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  85120. * @returns the VertexData of the box
  85121. */
  85122. VertexData.CreatePlane = function (options) {
  85123. var indices = [];
  85124. var positions = [];
  85125. var normals = [];
  85126. var uvs = [];
  85127. var width = options.width || options.size || 1;
  85128. var height = options.height || options.size || 1;
  85129. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  85130. // Vertices
  85131. var halfWidth = width / 2.0;
  85132. var halfHeight = height / 2.0;
  85133. positions.push(-halfWidth, -halfHeight, 0);
  85134. normals.push(0, 0, -1.0);
  85135. uvs.push(0.0, 0.0);
  85136. positions.push(halfWidth, -halfHeight, 0);
  85137. normals.push(0, 0, -1.0);
  85138. uvs.push(1.0, 0.0);
  85139. positions.push(halfWidth, halfHeight, 0);
  85140. normals.push(0, 0, -1.0);
  85141. uvs.push(1.0, 1.0);
  85142. positions.push(-halfWidth, halfHeight, 0);
  85143. normals.push(0, 0, -1.0);
  85144. uvs.push(0.0, 1.0);
  85145. // Indices
  85146. indices.push(0);
  85147. indices.push(1);
  85148. indices.push(2);
  85149. indices.push(0);
  85150. indices.push(2);
  85151. indices.push(3);
  85152. // Sides
  85153. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  85154. // Result
  85155. var vertexData = new VertexData();
  85156. vertexData.indices = indices;
  85157. vertexData.positions = positions;
  85158. vertexData.normals = normals;
  85159. vertexData.uvs = uvs;
  85160. return vertexData;
  85161. };
  85162. /**
  85163. * Creates the VertexData of the Disc or regular Polygon
  85164. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  85165. * * radius the radius of the disc, optional default 0.5
  85166. * * tessellation the number of polygon sides, optional, default 64
  85167. * * 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
  85168. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85169. * * 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)
  85170. * * 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)
  85171. * @returns the VertexData of the box
  85172. */
  85173. VertexData.CreateDisc = function (options) {
  85174. var positions = new Array();
  85175. var indices = new Array();
  85176. var normals = new Array();
  85177. var uvs = new Array();
  85178. var radius = options.radius || 0.5;
  85179. var tessellation = options.tessellation || 64;
  85180. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  85181. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  85182. // positions and uvs
  85183. positions.push(0, 0, 0); // disc center first
  85184. uvs.push(0.5, 0.5);
  85185. var theta = Math.PI * 2 * arc;
  85186. var step = theta / tessellation;
  85187. for (var a = 0; a < theta; a += step) {
  85188. var x = Math.cos(a);
  85189. var y = Math.sin(a);
  85190. var u = (x + 1) / 2;
  85191. var v = (1 - y) / 2;
  85192. positions.push(radius * x, radius * y, 0);
  85193. uvs.push(u, v);
  85194. }
  85195. if (arc === 1) {
  85196. positions.push(positions[3], positions[4], positions[5]); // close the circle
  85197. uvs.push(uvs[2], uvs[3]);
  85198. }
  85199. //indices
  85200. var vertexNb = positions.length / 3;
  85201. for (var i = 1; i < vertexNb - 1; i++) {
  85202. indices.push(i + 1, 0, i);
  85203. }
  85204. // result
  85205. VertexData.ComputeNormals(positions, indices, normals);
  85206. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  85207. var vertexData = new VertexData();
  85208. vertexData.indices = indices;
  85209. vertexData.positions = positions;
  85210. vertexData.normals = normals;
  85211. vertexData.uvs = uvs;
  85212. return vertexData;
  85213. };
  85214. /**
  85215. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  85216. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  85217. * @param polygon a mesh built from polygonTriangulation.build()
  85218. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85219. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85220. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85221. * @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)
  85222. * @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)
  85223. * @returns the VertexData of the Polygon
  85224. */
  85225. VertexData.CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  85226. var faceUV = fUV || new Array(3);
  85227. var faceColors = fColors;
  85228. var colors = [];
  85229. // default face colors and UV if undefined
  85230. for (var f = 0; f < 3; f++) {
  85231. if (faceUV[f] === undefined) {
  85232. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  85233. }
  85234. if (faceColors && faceColors[f] === undefined) {
  85235. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  85236. }
  85237. }
  85238. var positions = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  85239. var normals = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  85240. var uvs = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  85241. var indices = polygon.getIndices();
  85242. // set face colours and textures
  85243. var idx = 0;
  85244. var face = 0;
  85245. for (var index = 0; index < normals.length; index += 3) {
  85246. //Edge Face no. 1
  85247. if (Math.abs(normals[index + 1]) < 0.001) {
  85248. face = 1;
  85249. }
  85250. //Top Face no. 0
  85251. if (Math.abs(normals[index + 1] - 1) < 0.001) {
  85252. face = 0;
  85253. }
  85254. //Bottom Face no. 2
  85255. if (Math.abs(normals[index + 1] + 1) < 0.001) {
  85256. face = 2;
  85257. }
  85258. idx = index / 3;
  85259. uvs[2 * idx] = (1 - uvs[2 * idx]) * faceUV[face].x + uvs[2 * idx] * faceUV[face].z;
  85260. uvs[2 * idx + 1] = (1 - uvs[2 * idx + 1]) * faceUV[face].y + uvs[2 * idx + 1] * faceUV[face].w;
  85261. if (faceColors) {
  85262. colors.push(faceColors[face].r, faceColors[face].g, faceColors[face].b, faceColors[face].a);
  85263. }
  85264. }
  85265. // sides
  85266. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs);
  85267. // Result
  85268. var vertexData = new VertexData();
  85269. vertexData.indices = indices;
  85270. vertexData.positions = positions;
  85271. vertexData.normals = normals;
  85272. vertexData.uvs = uvs;
  85273. if (faceColors) {
  85274. var totalColors = (sideOrientation === VertexData.DOUBLESIDE) ? colors.concat(colors) : colors;
  85275. vertexData.colors = totalColors;
  85276. }
  85277. return vertexData;
  85278. };
  85279. /**
  85280. * Creates the VertexData of the IcoSphere
  85281. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  85282. * * radius the radius of the IcoSphere, optional default 1
  85283. * * radiusX allows stretching in the x direction, optional, default radius
  85284. * * radiusY allows stretching in the y direction, optional, default radius
  85285. * * radiusZ allows stretching in the z direction, optional, default radius
  85286. * * flat when true creates a flat shaded mesh, optional, default true
  85287. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85288. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85289. * * 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)
  85290. * * 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)
  85291. * @returns the VertexData of the IcoSphere
  85292. */
  85293. VertexData.CreateIcoSphere = function (options) {
  85294. var sideOrientation = options.sideOrientation || VertexData.DEFAULTSIDE;
  85295. var radius = options.radius || 1;
  85296. var flat = (options.flat === undefined) ? true : options.flat;
  85297. var subdivisions = options.subdivisions || 4;
  85298. var radiusX = options.radiusX || radius;
  85299. var radiusY = options.radiusY || radius;
  85300. var radiusZ = options.radiusZ || radius;
  85301. var t = (1 + Math.sqrt(5)) / 2;
  85302. // 12 vertex x,y,z
  85303. var ico_vertices = [
  85304. -1, t, -0, 1, t, 0, -1, -t, 0, 1, -t, 0,
  85305. 0, -1, -t, 0, 1, -t, 0, -1, t, 0, 1, t,
  85306. t, 0, 1, t, 0, -1, -t, 0, 1, -t, 0, -1 // v8-11
  85307. ];
  85308. // index of 3 vertex makes a face of icopshere
  85309. var ico_indices = [
  85310. 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23,
  85311. 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8,
  85312. 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9,
  85313. 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1
  85314. ];
  85315. // vertex for uv have aliased position, not for UV
  85316. var vertices_unalias_id = [
  85317. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  85318. // vertex alias
  85319. 0,
  85320. 2,
  85321. 3,
  85322. 3,
  85323. 3,
  85324. 4,
  85325. 7,
  85326. 8,
  85327. 9,
  85328. 9,
  85329. 10,
  85330. 11 // 23: B + 12
  85331. ];
  85332. // uv as integer step (not pixels !)
  85333. var ico_vertexuv = [
  85334. 5, 1, 3, 1, 6, 4, 0, 0,
  85335. 5, 3, 4, 2, 2, 2, 4, 0,
  85336. 2, 0, 1, 1, 6, 0, 6, 2,
  85337. // vertex alias (for same vertex on different faces)
  85338. 0, 4,
  85339. 3, 3,
  85340. 4, 4,
  85341. 3, 1,
  85342. 4, 2,
  85343. 4, 4,
  85344. 0, 2,
  85345. 1, 1,
  85346. 2, 2,
  85347. 3, 3,
  85348. 1, 3,
  85349. 2, 4 // 23: B + 12
  85350. ];
  85351. // Vertices[0, 1, ...9, A, B] : position on UV plane
  85352. // '+' indicate duplicate position to be fixed (3,9:0,2,3,4,7,8,A,B)
  85353. // First island of uv mapping
  85354. // v = 4h 3+ 2
  85355. // v = 3h 9+ 4
  85356. // v = 2h 9+ 5 B
  85357. // v = 1h 9 1 0
  85358. // v = 0h 3 8 7 A
  85359. // u = 0 1 2 3 4 5 6 *a
  85360. // Second island of uv mapping
  85361. // v = 4h 0+ B+ 4+
  85362. // v = 3h A+ 2+
  85363. // v = 2h 7+ 6 3+
  85364. // v = 1h 8+ 3+
  85365. // v = 0h
  85366. // u = 0 1 2 3 4 5 6 *a
  85367. // Face layout on texture UV mapping
  85368. // ============
  85369. // \ 4 /\ 16 / ======
  85370. // \ / \ / /\ 11 /
  85371. // \/ 7 \/ / \ /
  85372. // ======= / 10 \/
  85373. // /\ 17 /\ =======
  85374. // / \ / \ \ 15 /\
  85375. // / 8 \/ 12 \ \ / \
  85376. // ============ \/ 6 \
  85377. // \ 18 /\ ============
  85378. // \ / \ \ 5 /\ 0 /
  85379. // \/ 13 \ \ / \ /
  85380. // ======= \/ 1 \/
  85381. // =============
  85382. // /\ 19 /\ 2 /\
  85383. // / \ / \ / \
  85384. // / 14 \/ 9 \/ 3 \
  85385. // ===================
  85386. // uv step is u:1 or 0.5, v:cos(30)=sqrt(3)/2, ratio approx is 84/97
  85387. var ustep = 138 / 1024;
  85388. var vstep = 239 / 1024;
  85389. var uoffset = 60 / 1024;
  85390. var voffset = 26 / 1024;
  85391. // Second island should have margin, not to touch the first island
  85392. // avoid any borderline artefact in pixel rounding
  85393. var island_u_offset = -40 / 1024;
  85394. var island_v_offset = +20 / 1024;
  85395. // face is either island 0 or 1 :
  85396. // second island is for faces : [4, 7, 8, 12, 13, 16, 17, 18]
  85397. var island = [
  85398. 0, 0, 0, 0, 1,
  85399. 0, 0, 1, 1, 0,
  85400. 0, 0, 1, 1, 0,
  85401. 0, 1, 1, 1, 0 // 15 - 19
  85402. ];
  85403. var indices = new Array();
  85404. var positions = new Array();
  85405. var normals = new Array();
  85406. var uvs = new Array();
  85407. var current_indice = 0;
  85408. // prepare array of 3 vector (empty) (to be worked in place, shared for each face)
  85409. var face_vertex_pos = new Array(3);
  85410. var face_vertex_uv = new Array(3);
  85411. var v012;
  85412. for (v012 = 0; v012 < 3; v012++) {
  85413. face_vertex_pos[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  85414. face_vertex_uv[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  85415. }
  85416. // create all with normals
  85417. for (var face = 0; face < 20; face++) {
  85418. // 3 vertex per face
  85419. for (v012 = 0; v012 < 3; v012++) {
  85420. // look up vertex 0,1,2 to its index in 0 to 11 (or 23 including alias)
  85421. var v_id = ico_indices[3 * face + v012];
  85422. // vertex have 3D position (x,y,z)
  85423. 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]);
  85424. // Normalize to get normal, then scale to radius
  85425. face_vertex_pos[v012].normalize().scaleInPlace(radius);
  85426. // uv Coordinates from vertex ID
  85427. 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);
  85428. }
  85429. // Subdivide the face (interpolate pos, norm, uv)
  85430. // - pos is linear interpolation, then projected to sphere (converge polyhedron to sphere)
  85431. // - norm is linear interpolation of vertex corner normal
  85432. // (to be checked if better to re-calc from face vertex, or if approximation is OK ??? )
  85433. // - uv is linear interpolation
  85434. //
  85435. // Topology is as below for sub-divide by 2
  85436. // vertex shown as v0,v1,v2
  85437. // interp index is i1 to progress in range [v0,v1[
  85438. // interp index is i2 to progress in range [v0,v2[
  85439. // face index as (i1,i2) for /\ : (i1,i2),(i1+1,i2),(i1,i2+1)
  85440. // and (i1,i2)' for \/ : (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  85441. //
  85442. //
  85443. // i2 v2
  85444. // ^ ^
  85445. // / / \
  85446. // / / \
  85447. // / / \
  85448. // / / (0,1) \
  85449. // / #---------\
  85450. // / / \ (0,0)'/ \
  85451. // / / \ / \
  85452. // / / \ / \
  85453. // / / (0,0) \ / (1,0) \
  85454. // / #---------#---------\
  85455. // v0 v1
  85456. //
  85457. // --------------------> i1
  85458. //
  85459. // interp of (i1,i2):
  85460. // along i2 : x0=lerp(v0,v2, i2/S) <---> x1=lerp(v1,v2, i2/S)
  85461. // along i1 : lerp(x0,x1, i1/(S-i2))
  85462. //
  85463. // centroid of triangle is needed to get help normal computation
  85464. // (c1,c2) are used for centroid location
  85465. var interp_vertex = function (i1, i2, c1, c2) {
  85466. // vertex is interpolated from
  85467. // - face_vertex_pos[0..2]
  85468. // - face_vertex_uv[0..2]
  85469. var pos_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], i2 / subdivisions);
  85470. var pos_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], i2 / subdivisions);
  85471. var pos_interp = (subdivisions === i2) ? face_vertex_pos[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(pos_x0, pos_x1, i1 / (subdivisions - i2));
  85472. pos_interp.normalize();
  85473. var vertex_normal;
  85474. if (flat) {
  85475. // in flat mode, recalculate normal as face centroid normal
  85476. var centroid_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], c2 / subdivisions);
  85477. var centroid_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], c2 / subdivisions);
  85478. vertex_normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(centroid_x0, centroid_x1, c1 / (subdivisions - c2));
  85479. }
  85480. else {
  85481. // in smooth mode, recalculate normal from each single vertex position
  85482. vertex_normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pos_interp.x, pos_interp.y, pos_interp.z);
  85483. }
  85484. // Vertex normal need correction due to X,Y,Z radius scaling
  85485. vertex_normal.x /= radiusX;
  85486. vertex_normal.y /= radiusY;
  85487. vertex_normal.z /= radiusZ;
  85488. vertex_normal.normalize();
  85489. var uv_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[0], face_vertex_uv[2], i2 / subdivisions);
  85490. var uv_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[1], face_vertex_uv[2], i2 / subdivisions);
  85491. var uv_interp = (subdivisions === i2) ? face_vertex_uv[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(uv_x0, uv_x1, i1 / (subdivisions - i2));
  85492. positions.push(pos_interp.x * radiusX, pos_interp.y * radiusY, pos_interp.z * radiusZ);
  85493. normals.push(vertex_normal.x, vertex_normal.y, vertex_normal.z);
  85494. uvs.push(uv_interp.x, uv_interp.y);
  85495. // push each vertex has member of a face
  85496. // Same vertex can bleong to multiple face, it is pushed multiple time (duplicate vertex are present)
  85497. indices.push(current_indice);
  85498. current_indice++;
  85499. };
  85500. for (var i2 = 0; i2 < subdivisions; i2++) {
  85501. for (var i1 = 0; i1 + i2 < subdivisions; i1++) {
  85502. // face : (i1,i2) for /\ :
  85503. // interp for : (i1,i2),(i1+1,i2),(i1,i2+1)
  85504. interp_vertex(i1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  85505. interp_vertex(i1 + 1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  85506. interp_vertex(i1, i2 + 1, i1 + 1.0 / 3, i2 + 1.0 / 3);
  85507. if (i1 + i2 + 1 < subdivisions) {
  85508. // face : (i1,i2)' for \/ :
  85509. // interp for (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  85510. interp_vertex(i1 + 1, i2, i1 + 2.0 / 3, i2 + 2.0 / 3);
  85511. interp_vertex(i1 + 1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  85512. interp_vertex(i1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  85513. }
  85514. }
  85515. }
  85516. }
  85517. // Sides
  85518. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  85519. // Result
  85520. var vertexData = new VertexData();
  85521. vertexData.indices = indices;
  85522. vertexData.positions = positions;
  85523. vertexData.normals = normals;
  85524. vertexData.uvs = uvs;
  85525. return vertexData;
  85526. };
  85527. // inspired from // http://stemkoski.github.io/Three.js/Polyhedra.html
  85528. /**
  85529. * Creates the VertexData for a Polyhedron
  85530. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  85531. * * type provided types are:
  85532. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  85533. * * 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)
  85534. * * size the size of the IcoSphere, optional default 1
  85535. * * sizeX allows stretching in the x direction, optional, default size
  85536. * * sizeY allows stretching in the y direction, optional, default size
  85537. * * sizeZ allows stretching in the z direction, optional, default size
  85538. * * 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
  85539. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85540. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85541. * * flat when true creates a flat shaded mesh, optional, default true
  85542. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85543. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85544. * * 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)
  85545. * * 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)
  85546. * @returns the VertexData of the Polyhedron
  85547. */
  85548. VertexData.CreatePolyhedron = function (options) {
  85549. // provided polyhedron types :
  85550. // 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  85551. // 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)
  85552. var polyhedra = [];
  85553. 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]] };
  85554. 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]] };
  85555. polyhedra[2] = {
  85556. 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]],
  85557. 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]]
  85558. };
  85559. polyhedra[3] = {
  85560. 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]],
  85561. 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]]
  85562. };
  85563. polyhedra[4] = {
  85564. 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]],
  85565. 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]]
  85566. };
  85567. 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]] };
  85568. 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]] };
  85569. 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]] };
  85570. 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]] };
  85571. 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]] };
  85572. 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]] };
  85573. 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]] };
  85574. 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]] };
  85575. 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]] };
  85576. polyhedra[14] = {
  85577. 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]],
  85578. 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]]
  85579. };
  85580. var type = options.type && (options.type < 0 || options.type >= polyhedra.length) ? 0 : options.type || 0;
  85581. var size = options.size;
  85582. var sizeX = options.sizeX || size || 1;
  85583. var sizeY = options.sizeY || size || 1;
  85584. var sizeZ = options.sizeZ || size || 1;
  85585. var data = options.custom || polyhedra[type];
  85586. var nbfaces = data.face.length;
  85587. var faceUV = options.faceUV || new Array(nbfaces);
  85588. var faceColors = options.faceColors;
  85589. var flat = (options.flat === undefined) ? true : options.flat;
  85590. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  85591. var positions = new Array();
  85592. var indices = new Array();
  85593. var normals = new Array();
  85594. var uvs = new Array();
  85595. var colors = new Array();
  85596. var index = 0;
  85597. var faceIdx = 0; // face cursor in the array "indexes"
  85598. var indexes = new Array();
  85599. var i = 0;
  85600. var f = 0;
  85601. var u, v, ang, x, y, tmp;
  85602. // default face colors and UV if undefined
  85603. if (flat) {
  85604. for (f = 0; f < nbfaces; f++) {
  85605. if (faceColors && faceColors[f] === undefined) {
  85606. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  85607. }
  85608. if (faceUV && faceUV[f] === undefined) {
  85609. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  85610. }
  85611. }
  85612. }
  85613. if (!flat) {
  85614. for (i = 0; i < data.vertex.length; i++) {
  85615. positions.push(data.vertex[i][0] * sizeX, data.vertex[i][1] * sizeY, data.vertex[i][2] * sizeZ);
  85616. uvs.push(0, 0);
  85617. }
  85618. for (f = 0; f < nbfaces; f++) {
  85619. for (i = 0; i < data.face[f].length - 2; i++) {
  85620. indices.push(data.face[f][0], data.face[f][i + 2], data.face[f][i + 1]);
  85621. }
  85622. }
  85623. }
  85624. else {
  85625. for (f = 0; f < nbfaces; f++) {
  85626. var fl = data.face[f].length; // number of vertices of the current face
  85627. ang = 2 * Math.PI / fl;
  85628. x = 0.5 * Math.tan(ang / 2);
  85629. y = 0.5;
  85630. // positions, uvs, colors
  85631. for (i = 0; i < fl; i++) {
  85632. // positions
  85633. 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);
  85634. indexes.push(index);
  85635. index++;
  85636. // uvs
  85637. u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
  85638. v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
  85639. uvs.push(u, v);
  85640. tmp = x * Math.cos(ang) - y * Math.sin(ang);
  85641. y = x * Math.sin(ang) + y * Math.cos(ang);
  85642. x = tmp;
  85643. // colors
  85644. if (faceColors) {
  85645. colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
  85646. }
  85647. }
  85648. // indices from indexes
  85649. for (i = 0; i < fl - 2; i++) {
  85650. indices.push(indexes[0 + faceIdx], indexes[i + 2 + faceIdx], indexes[i + 1 + faceIdx]);
  85651. }
  85652. faceIdx += fl;
  85653. }
  85654. }
  85655. VertexData.ComputeNormals(positions, indices, normals);
  85656. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  85657. var vertexData = new VertexData();
  85658. vertexData.positions = positions;
  85659. vertexData.indices = indices;
  85660. vertexData.normals = normals;
  85661. vertexData.uvs = uvs;
  85662. if (faceColors && flat) {
  85663. vertexData.colors = colors;
  85664. }
  85665. return vertexData;
  85666. };
  85667. // based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
  85668. /**
  85669. * Creates the VertexData for a TorusKnot
  85670. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  85671. * * radius the radius of the torus knot, optional, default 2
  85672. * * tube the thickness of the tube, optional, default 0.5
  85673. * * radialSegments the number of sides on each tube segments, optional, default 32
  85674. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  85675. * * p the number of windings around the z axis, optional, default 2
  85676. * * q the number of windings around the x axis, optional, default 3
  85677. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85678. * * 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)
  85679. * * 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)
  85680. * @returns the VertexData of the Torus Knot
  85681. */
  85682. VertexData.CreateTorusKnot = function (options) {
  85683. var indices = new Array();
  85684. var positions = new Array();
  85685. var normals = new Array();
  85686. var uvs = new Array();
  85687. var radius = options.radius || 2;
  85688. var tube = options.tube || 0.5;
  85689. var radialSegments = options.radialSegments || 32;
  85690. var tubularSegments = options.tubularSegments || 32;
  85691. var p = options.p || 2;
  85692. var q = options.q || 3;
  85693. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  85694. // Helper
  85695. var getPos = function (angle) {
  85696. var cu = Math.cos(angle);
  85697. var su = Math.sin(angle);
  85698. var quOverP = q / p * angle;
  85699. var cs = Math.cos(quOverP);
  85700. var tx = radius * (2 + cs) * 0.5 * cu;
  85701. var ty = radius * (2 + cs) * su * 0.5;
  85702. var tz = radius * Math.sin(quOverP) * 0.5;
  85703. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](tx, ty, tz);
  85704. };
  85705. // Vertices
  85706. var i;
  85707. var j;
  85708. for (i = 0; i <= radialSegments; i++) {
  85709. var modI = i % radialSegments;
  85710. var u = modI / radialSegments * 2 * p * Math.PI;
  85711. var p1 = getPos(u);
  85712. var p2 = getPos(u + 0.01);
  85713. var tang = p2.subtract(p1);
  85714. var n = p2.add(p1);
  85715. var bitan = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(tang, n);
  85716. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(bitan, tang);
  85717. bitan.normalize();
  85718. n.normalize();
  85719. for (j = 0; j < tubularSegments; j++) {
  85720. var modJ = j % tubularSegments;
  85721. var v = modJ / tubularSegments * 2 * Math.PI;
  85722. var cx = -tube * Math.cos(v);
  85723. var cy = tube * Math.sin(v);
  85724. positions.push(p1.x + cx * n.x + cy * bitan.x);
  85725. positions.push(p1.y + cx * n.y + cy * bitan.y);
  85726. positions.push(p1.z + cx * n.z + cy * bitan.z);
  85727. uvs.push(i / radialSegments);
  85728. uvs.push(j / tubularSegments);
  85729. }
  85730. }
  85731. for (i = 0; i < radialSegments; i++) {
  85732. for (j = 0; j < tubularSegments; j++) {
  85733. var jNext = (j + 1) % tubularSegments;
  85734. var a = i * tubularSegments + j;
  85735. var b = (i + 1) * tubularSegments + j;
  85736. var c = (i + 1) * tubularSegments + jNext;
  85737. var d = i * tubularSegments + jNext;
  85738. indices.push(d);
  85739. indices.push(b);
  85740. indices.push(a);
  85741. indices.push(d);
  85742. indices.push(c);
  85743. indices.push(b);
  85744. }
  85745. }
  85746. // Normals
  85747. VertexData.ComputeNormals(positions, indices, normals);
  85748. // Sides
  85749. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  85750. // Result
  85751. var vertexData = new VertexData();
  85752. vertexData.indices = indices;
  85753. vertexData.positions = positions;
  85754. vertexData.normals = normals;
  85755. vertexData.uvs = uvs;
  85756. return vertexData;
  85757. };
  85758. // Tools
  85759. /**
  85760. * Compute normals for given positions and indices
  85761. * @param positions an array of vertex positions, [...., x, y, z, ......]
  85762. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  85763. * @param normals an array of vertex normals, [...., x, y, z, ......]
  85764. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  85765. * * facetNormals : optional array of facet normals (vector3)
  85766. * * facetPositions : optional array of facet positions (vector3)
  85767. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  85768. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  85769. * * bInfo : optional bounding info, required for facetPartitioning computation
  85770. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  85771. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  85772. * * useRightHandedSystem: optional boolean to for right handed system computation
  85773. * * depthSort : optional boolean to enable the facet depth sort computation
  85774. * * distanceTo : optional Vector3 to compute the facet depth from this location
  85775. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  85776. */
  85777. VertexData.ComputeNormals = function (positions, indices, normals, options) {
  85778. // temporary scalar variables
  85779. var index = 0; // facet index
  85780. var p1p2x = 0.0; // p1p2 vector x coordinate
  85781. var p1p2y = 0.0; // p1p2 vector y coordinate
  85782. var p1p2z = 0.0; // p1p2 vector z coordinate
  85783. var p3p2x = 0.0; // p3p2 vector x coordinate
  85784. var p3p2y = 0.0; // p3p2 vector y coordinate
  85785. var p3p2z = 0.0; // p3p2 vector z coordinate
  85786. var faceNormalx = 0.0; // facet normal x coordinate
  85787. var faceNormaly = 0.0; // facet normal y coordinate
  85788. var faceNormalz = 0.0; // facet normal z coordinate
  85789. var length = 0.0; // facet normal length before normalization
  85790. var v1x = 0; // vector1 x index in the positions array
  85791. var v1y = 0; // vector1 y index in the positions array
  85792. var v1z = 0; // vector1 z index in the positions array
  85793. var v2x = 0; // vector2 x index in the positions array
  85794. var v2y = 0; // vector2 y index in the positions array
  85795. var v2z = 0; // vector2 z index in the positions array
  85796. var v3x = 0; // vector3 x index in the positions array
  85797. var v3y = 0; // vector3 y index in the positions array
  85798. var v3z = 0; // vector3 z index in the positions array
  85799. var computeFacetNormals = false;
  85800. var computeFacetPositions = false;
  85801. var computeFacetPartitioning = false;
  85802. var computeDepthSort = false;
  85803. var faceNormalSign = 1;
  85804. var ratio = 0;
  85805. var distanceTo = null;
  85806. if (options) {
  85807. computeFacetNormals = (options.facetNormals) ? true : false;
  85808. computeFacetPositions = (options.facetPositions) ? true : false;
  85809. computeFacetPartitioning = (options.facetPartitioning) ? true : false;
  85810. faceNormalSign = (options.useRightHandedSystem === true) ? -1 : 1;
  85811. ratio = options.ratio || 0;
  85812. computeDepthSort = (options.depthSort) ? true : false;
  85813. distanceTo = (options.distanceTo);
  85814. if (computeDepthSort) {
  85815. if (distanceTo === undefined) {
  85816. distanceTo = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  85817. }
  85818. var depthSortedFacets = options.depthSortedFacets;
  85819. }
  85820. }
  85821. // facetPartitioning reinit if needed
  85822. var xSubRatio = 0;
  85823. var ySubRatio = 0;
  85824. var zSubRatio = 0;
  85825. var subSq = 0;
  85826. if (computeFacetPartitioning && options && options.bbSize) {
  85827. var ox = 0; // X partitioning index for facet position
  85828. var oy = 0; // Y partinioning index for facet position
  85829. var oz = 0; // Z partinioning index for facet position
  85830. var b1x = 0; // X partitioning index for facet v1 vertex
  85831. var b1y = 0; // Y partitioning index for facet v1 vertex
  85832. var b1z = 0; // z partitioning index for facet v1 vertex
  85833. var b2x = 0; // X partitioning index for facet v2 vertex
  85834. var b2y = 0; // Y partitioning index for facet v2 vertex
  85835. var b2z = 0; // Z partitioning index for facet v2 vertex
  85836. var b3x = 0; // X partitioning index for facet v3 vertex
  85837. var b3y = 0; // Y partitioning index for facet v3 vertex
  85838. var b3z = 0; // Z partitioning index for facet v3 vertex
  85839. var block_idx_o = 0; // facet barycenter block index
  85840. var block_idx_v1 = 0; // v1 vertex block index
  85841. var block_idx_v2 = 0; // v2 vertex block index
  85842. var block_idx_v3 = 0; // v3 vertex block index
  85843. var bbSizeMax = (options.bbSize.x > options.bbSize.y) ? options.bbSize.x : options.bbSize.y;
  85844. bbSizeMax = (bbSizeMax > options.bbSize.z) ? bbSizeMax : options.bbSize.z;
  85845. xSubRatio = options.subDiv.X * ratio / options.bbSize.x;
  85846. ySubRatio = options.subDiv.Y * ratio / options.bbSize.y;
  85847. zSubRatio = options.subDiv.Z * ratio / options.bbSize.z;
  85848. subSq = options.subDiv.max * options.subDiv.max;
  85849. options.facetPartitioning.length = 0;
  85850. }
  85851. // reset the normals
  85852. for (index = 0; index < positions.length; index++) {
  85853. normals[index] = 0.0;
  85854. }
  85855. // Loop : 1 indice triplet = 1 facet
  85856. var nbFaces = (indices.length / 3) | 0;
  85857. for (index = 0; index < nbFaces; index++) {
  85858. // get the indexes of the coordinates of each vertex of the facet
  85859. v1x = indices[index * 3] * 3;
  85860. v1y = v1x + 1;
  85861. v1z = v1x + 2;
  85862. v2x = indices[index * 3 + 1] * 3;
  85863. v2y = v2x + 1;
  85864. v2z = v2x + 2;
  85865. v3x = indices[index * 3 + 2] * 3;
  85866. v3y = v3x + 1;
  85867. v3z = v3x + 2;
  85868. p1p2x = positions[v1x] - positions[v2x]; // compute two vectors per facet : p1p2 and p3p2
  85869. p1p2y = positions[v1y] - positions[v2y];
  85870. p1p2z = positions[v1z] - positions[v2z];
  85871. p3p2x = positions[v3x] - positions[v2x];
  85872. p3p2y = positions[v3y] - positions[v2y];
  85873. p3p2z = positions[v3z] - positions[v2z];
  85874. // compute the face normal with the cross product
  85875. faceNormalx = faceNormalSign * (p1p2y * p3p2z - p1p2z * p3p2y);
  85876. faceNormaly = faceNormalSign * (p1p2z * p3p2x - p1p2x * p3p2z);
  85877. faceNormalz = faceNormalSign * (p1p2x * p3p2y - p1p2y * p3p2x);
  85878. // normalize this normal and store it in the array facetData
  85879. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  85880. length = (length === 0) ? 1.0 : length;
  85881. faceNormalx /= length;
  85882. faceNormaly /= length;
  85883. faceNormalz /= length;
  85884. if (computeFacetNormals && options) {
  85885. options.facetNormals[index].x = faceNormalx;
  85886. options.facetNormals[index].y = faceNormaly;
  85887. options.facetNormals[index].z = faceNormalz;
  85888. }
  85889. if (computeFacetPositions && options) {
  85890. // compute and the facet barycenter coordinates in the array facetPositions
  85891. options.facetPositions[index].x = (positions[v1x] + positions[v2x] + positions[v3x]) / 3.0;
  85892. options.facetPositions[index].y = (positions[v1y] + positions[v2y] + positions[v3y]) / 3.0;
  85893. options.facetPositions[index].z = (positions[v1z] + positions[v2z] + positions[v3z]) / 3.0;
  85894. }
  85895. if (computeFacetPartitioning && options) {
  85896. // store the facet indexes in arrays in the main facetPartitioning array :
  85897. // compute each facet vertex (+ facet barycenter) index in the partiniong array
  85898. ox = Math.floor((options.facetPositions[index].x - options.bInfo.minimum.x * ratio) * xSubRatio);
  85899. oy = Math.floor((options.facetPositions[index].y - options.bInfo.minimum.y * ratio) * ySubRatio);
  85900. oz = Math.floor((options.facetPositions[index].z - options.bInfo.minimum.z * ratio) * zSubRatio);
  85901. b1x = Math.floor((positions[v1x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  85902. b1y = Math.floor((positions[v1y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  85903. b1z = Math.floor((positions[v1z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  85904. b2x = Math.floor((positions[v2x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  85905. b2y = Math.floor((positions[v2y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  85906. b2z = Math.floor((positions[v2z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  85907. b3x = Math.floor((positions[v3x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  85908. b3y = Math.floor((positions[v3y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  85909. b3z = Math.floor((positions[v3z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  85910. block_idx_v1 = b1x + options.subDiv.max * b1y + subSq * b1z;
  85911. block_idx_v2 = b2x + options.subDiv.max * b2y + subSq * b2z;
  85912. block_idx_v3 = b3x + options.subDiv.max * b3y + subSq * b3z;
  85913. block_idx_o = ox + options.subDiv.max * oy + subSq * oz;
  85914. options.facetPartitioning[block_idx_o] = options.facetPartitioning[block_idx_o] ? options.facetPartitioning[block_idx_o] : new Array();
  85915. options.facetPartitioning[block_idx_v1] = options.facetPartitioning[block_idx_v1] ? options.facetPartitioning[block_idx_v1] : new Array();
  85916. options.facetPartitioning[block_idx_v2] = options.facetPartitioning[block_idx_v2] ? options.facetPartitioning[block_idx_v2] : new Array();
  85917. options.facetPartitioning[block_idx_v3] = options.facetPartitioning[block_idx_v3] ? options.facetPartitioning[block_idx_v3] : new Array();
  85918. // push each facet index in each block containing the vertex
  85919. options.facetPartitioning[block_idx_v1].push(index);
  85920. if (block_idx_v2 != block_idx_v1) {
  85921. options.facetPartitioning[block_idx_v2].push(index);
  85922. }
  85923. if (!(block_idx_v3 == block_idx_v2 || block_idx_v3 == block_idx_v1)) {
  85924. options.facetPartitioning[block_idx_v3].push(index);
  85925. }
  85926. if (!(block_idx_o == block_idx_v1 || block_idx_o == block_idx_v2 || block_idx_o == block_idx_v3)) {
  85927. options.facetPartitioning[block_idx_o].push(index);
  85928. }
  85929. }
  85930. if (computeDepthSort && options && options.facetPositions) {
  85931. var dsf = depthSortedFacets[index];
  85932. dsf.ind = index * 3;
  85933. dsf.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(options.facetPositions[index], distanceTo);
  85934. }
  85935. // compute the normals anyway
  85936. normals[v1x] += faceNormalx; // accumulate all the normals per face
  85937. normals[v1y] += faceNormaly;
  85938. normals[v1z] += faceNormalz;
  85939. normals[v2x] += faceNormalx;
  85940. normals[v2y] += faceNormaly;
  85941. normals[v2z] += faceNormalz;
  85942. normals[v3x] += faceNormalx;
  85943. normals[v3y] += faceNormaly;
  85944. normals[v3z] += faceNormalz;
  85945. }
  85946. // last normalization of each normal
  85947. for (index = 0; index < normals.length / 3; index++) {
  85948. faceNormalx = normals[index * 3];
  85949. faceNormaly = normals[index * 3 + 1];
  85950. faceNormalz = normals[index * 3 + 2];
  85951. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  85952. length = (length === 0) ? 1.0 : length;
  85953. faceNormalx /= length;
  85954. faceNormaly /= length;
  85955. faceNormalz /= length;
  85956. normals[index * 3] = faceNormalx;
  85957. normals[index * 3 + 1] = faceNormaly;
  85958. normals[index * 3 + 2] = faceNormalz;
  85959. }
  85960. };
  85961. VertexData._ComputeSides = function (sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs) {
  85962. var li = indices.length;
  85963. var ln = normals.length;
  85964. var i;
  85965. var n;
  85966. sideOrientation = sideOrientation || VertexData.DEFAULTSIDE;
  85967. switch (sideOrientation) {
  85968. case VertexData.FRONTSIDE:
  85969. // nothing changed
  85970. break;
  85971. case VertexData.BACKSIDE:
  85972. var tmp;
  85973. // indices
  85974. for (i = 0; i < li; i += 3) {
  85975. tmp = indices[i];
  85976. indices[i] = indices[i + 2];
  85977. indices[i + 2] = tmp;
  85978. }
  85979. // normals
  85980. for (n = 0; n < ln; n++) {
  85981. normals[n] = -normals[n];
  85982. }
  85983. break;
  85984. case VertexData.DOUBLESIDE:
  85985. // positions
  85986. var lp = positions.length;
  85987. var l = lp / 3;
  85988. for (var p = 0; p < lp; p++) {
  85989. positions[lp + p] = positions[p];
  85990. }
  85991. // indices
  85992. for (i = 0; i < li; i += 3) {
  85993. indices[i + li] = indices[i + 2] + l;
  85994. indices[i + 1 + li] = indices[i + 1] + l;
  85995. indices[i + 2 + li] = indices[i] + l;
  85996. }
  85997. // normals
  85998. for (n = 0; n < ln; n++) {
  85999. normals[ln + n] = -normals[n];
  86000. }
  86001. // uvs
  86002. var lu = uvs.length;
  86003. var u = 0;
  86004. for (u = 0; u < lu; u++) {
  86005. uvs[u + lu] = uvs[u];
  86006. }
  86007. frontUVs = frontUVs ? frontUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  86008. backUVs = backUVs ? backUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  86009. u = 0;
  86010. for (i = 0; i < lu / 2; i++) {
  86011. uvs[u] = frontUVs.x + (frontUVs.z - frontUVs.x) * uvs[u];
  86012. uvs[u + 1] = frontUVs.y + (frontUVs.w - frontUVs.y) * uvs[u + 1];
  86013. uvs[u + lu] = backUVs.x + (backUVs.z - backUVs.x) * uvs[u + lu];
  86014. uvs[u + lu + 1] = backUVs.y + (backUVs.w - backUVs.y) * uvs[u + lu + 1];
  86015. u += 2;
  86016. }
  86017. break;
  86018. }
  86019. };
  86020. /**
  86021. * Applies VertexData created from the imported parameters to the geometry
  86022. * @param parsedVertexData the parsed data from an imported file
  86023. * @param geometry the geometry to apply the VertexData to
  86024. */
  86025. VertexData.ImportVertexData = function (parsedVertexData, geometry) {
  86026. var vertexData = new VertexData();
  86027. // positions
  86028. var positions = parsedVertexData.positions;
  86029. if (positions) {
  86030. vertexData.set(positions, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  86031. }
  86032. // normals
  86033. var normals = parsedVertexData.normals;
  86034. if (normals) {
  86035. vertexData.set(normals, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  86036. }
  86037. // tangents
  86038. var tangents = parsedVertexData.tangents;
  86039. if (tangents) {
  86040. vertexData.set(tangents, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind);
  86041. }
  86042. // uvs
  86043. var uvs = parsedVertexData.uvs;
  86044. if (uvs) {
  86045. vertexData.set(uvs, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  86046. }
  86047. // uv2s
  86048. var uv2s = parsedVertexData.uv2s;
  86049. if (uv2s) {
  86050. vertexData.set(uv2s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  86051. }
  86052. // uv3s
  86053. var uv3s = parsedVertexData.uv3s;
  86054. if (uv3s) {
  86055. vertexData.set(uv3s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind);
  86056. }
  86057. // uv4s
  86058. var uv4s = parsedVertexData.uv4s;
  86059. if (uv4s) {
  86060. vertexData.set(uv4s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind);
  86061. }
  86062. // uv5s
  86063. var uv5s = parsedVertexData.uv5s;
  86064. if (uv5s) {
  86065. vertexData.set(uv5s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind);
  86066. }
  86067. // uv6s
  86068. var uv6s = parsedVertexData.uv6s;
  86069. if (uv6s) {
  86070. vertexData.set(uv6s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind);
  86071. }
  86072. // colors
  86073. var colors = parsedVertexData.colors;
  86074. if (colors) {
  86075. vertexData.set(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].CheckColors4(colors, positions.length / 3), _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  86076. }
  86077. // matricesIndices
  86078. var matricesIndices = parsedVertexData.matricesIndices;
  86079. if (matricesIndices) {
  86080. vertexData.set(matricesIndices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  86081. }
  86082. // matricesWeights
  86083. var matricesWeights = parsedVertexData.matricesWeights;
  86084. if (matricesWeights) {
  86085. vertexData.set(matricesWeights, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  86086. }
  86087. // indices
  86088. var indices = parsedVertexData.indices;
  86089. if (indices) {
  86090. vertexData.indices = indices;
  86091. }
  86092. geometry.setAllVerticesData(vertexData, parsedVertexData.updatable);
  86093. };
  86094. /**
  86095. * Mesh side orientation : usually the external or front surface
  86096. */
  86097. VertexData.FRONTSIDE = 0;
  86098. /**
  86099. * Mesh side orientation : usually the internal or back surface
  86100. */
  86101. VertexData.BACKSIDE = 1;
  86102. /**
  86103. * Mesh side orientation : both internal and external or front and back surfaces
  86104. */
  86105. VertexData.DOUBLESIDE = 2;
  86106. /**
  86107. * Mesh side orientation : by default, `FRONTSIDE`
  86108. */
  86109. VertexData.DEFAULTSIDE = 0;
  86110. return VertexData;
  86111. }());
  86112. /***/ }),
  86113. /***/ "./Meshes/meshBuilder.ts":
  86114. /*!*******************************!*\
  86115. !*** ./Meshes/meshBuilder.ts ***!
  86116. \*******************************/
  86117. /*! exports provided: MeshBuilder */
  86118. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  86119. "use strict";
  86120. __webpack_require__.r(__webpack_exports__);
  86121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return MeshBuilder; });
  86122. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  86123. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  86124. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  86125. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  86126. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  86127. /* harmony import */ var _linesMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./linesMesh */ "./Meshes/linesMesh.ts");
  86128. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  86129. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./groundMesh */ "./Meshes/groundMesh.ts");
  86130. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./polygonMesh */ "./Meshes/polygonMesh.ts");
  86131. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  86132. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  86133. if (closeArray === void 0) { closeArray = false; }
  86134. if (updatable === void 0) { updatable = false; }
  86135. return MeshBuilder.CreateRibbon(name, {
  86136. pathArray: pathArray,
  86137. closeArray: closeArray,
  86138. closePath: closePath,
  86139. offset: offset,
  86140. updatable: updatable,
  86141. sideOrientation: sideOrientation,
  86142. instance: instance
  86143. }, scene);
  86144. };
  86145. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  86146. if (scene === void 0) { scene = null; }
  86147. var options = {
  86148. radius: radius,
  86149. tessellation: tessellation,
  86150. sideOrientation: sideOrientation,
  86151. updatable: updatable
  86152. };
  86153. return MeshBuilder.CreateDisc(name, options, scene);
  86154. };
  86155. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateBox = function (name, size, scene, updatable, sideOrientation) {
  86156. if (scene === void 0) { scene = null; }
  86157. var options = {
  86158. size: size,
  86159. sideOrientation: sideOrientation,
  86160. updatable: updatable
  86161. };
  86162. return MeshBuilder.CreateBox(name, options, scene);
  86163. };
  86164. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  86165. var options = {
  86166. segments: segments,
  86167. diameterX: diameter,
  86168. diameterY: diameter,
  86169. diameterZ: diameter,
  86170. sideOrientation: sideOrientation,
  86171. updatable: updatable
  86172. };
  86173. return MeshBuilder.CreateSphere(name, options, scene);
  86174. };
  86175. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  86176. if (scene === undefined || !(scene instanceof _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"])) {
  86177. if (scene !== undefined) {
  86178. sideOrientation = updatable || _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].DEFAULTSIDE;
  86179. updatable = scene;
  86180. }
  86181. scene = subdivisions;
  86182. subdivisions = 1;
  86183. }
  86184. var options = {
  86185. height: height,
  86186. diameterTop: diameterTop,
  86187. diameterBottom: diameterBottom,
  86188. tessellation: tessellation,
  86189. subdivisions: subdivisions,
  86190. sideOrientation: sideOrientation,
  86191. updatable: updatable
  86192. };
  86193. return MeshBuilder.CreateCylinder(name, options, scene);
  86194. };
  86195. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  86196. var options = {
  86197. diameter: diameter,
  86198. thickness: thickness,
  86199. tessellation: tessellation,
  86200. sideOrientation: sideOrientation,
  86201. updatable: updatable
  86202. };
  86203. return MeshBuilder.CreateTorus(name, options, scene);
  86204. };
  86205. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  86206. var options = {
  86207. radius: radius,
  86208. tube: tube,
  86209. radialSegments: radialSegments,
  86210. tubularSegments: tubularSegments,
  86211. p: p,
  86212. q: q,
  86213. sideOrientation: sideOrientation,
  86214. updatable: updatable
  86215. };
  86216. return MeshBuilder.CreateTorusKnot(name, options, scene);
  86217. };
  86218. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateLines = function (name, points, scene, updatable, instance) {
  86219. if (scene === void 0) { scene = null; }
  86220. if (updatable === void 0) { updatable = false; }
  86221. if (instance === void 0) { instance = null; }
  86222. var options = {
  86223. points: points,
  86224. updatable: updatable,
  86225. instance: instance
  86226. };
  86227. return MeshBuilder.CreateLines(name, options, scene);
  86228. };
  86229. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  86230. if (scene === void 0) { scene = null; }
  86231. var options = {
  86232. points: points,
  86233. dashSize: dashSize,
  86234. gapSize: gapSize,
  86235. dashNb: dashNb,
  86236. updatable: updatable,
  86237. instance: instance
  86238. };
  86239. return MeshBuilder.CreateDashedLines(name, options, scene);
  86240. };
  86241. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation) {
  86242. var options = {
  86243. shape: shape,
  86244. holes: holes,
  86245. updatable: updatable,
  86246. sideOrientation: sideOrientation
  86247. };
  86248. return MeshBuilder.CreatePolygon(name, options, scene);
  86249. };
  86250. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation) {
  86251. var options = {
  86252. shape: shape,
  86253. holes: holes,
  86254. depth: depth,
  86255. updatable: updatable,
  86256. sideOrientation: sideOrientation
  86257. };
  86258. return MeshBuilder.ExtrudePolygon(name, options, scene);
  86259. };
  86260. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  86261. if (scene === void 0) { scene = null; }
  86262. var options = {
  86263. shape: shape,
  86264. path: path,
  86265. scale: scale,
  86266. rotation: rotation,
  86267. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP,
  86268. sideOrientation: sideOrientation,
  86269. instance: instance,
  86270. updatable: updatable
  86271. };
  86272. return MeshBuilder.ExtrudeShape(name, options, scene);
  86273. };
  86274. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  86275. var options = {
  86276. shape: shape,
  86277. path: path,
  86278. scaleFunction: scaleFunction,
  86279. rotationFunction: rotationFunction,
  86280. ribbonCloseArray: ribbonCloseArray,
  86281. ribbonClosePath: ribbonClosePath,
  86282. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP,
  86283. sideOrientation: sideOrientation,
  86284. instance: instance,
  86285. updatable: updatable
  86286. };
  86287. return MeshBuilder.ExtrudeShapeCustom(name, options, scene);
  86288. };
  86289. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  86290. var options = {
  86291. shape: shape,
  86292. radius: radius,
  86293. tessellation: tessellation,
  86294. sideOrientation: sideOrientation,
  86295. updatable: updatable
  86296. };
  86297. return MeshBuilder.CreateLathe(name, options, scene);
  86298. };
  86299. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  86300. var options = {
  86301. size: size,
  86302. width: size,
  86303. height: size,
  86304. sideOrientation: sideOrientation,
  86305. updatable: updatable
  86306. };
  86307. return MeshBuilder.CreatePlane(name, options, scene);
  86308. };
  86309. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  86310. var options = {
  86311. width: width,
  86312. height: height,
  86313. subdivisions: subdivisions,
  86314. updatable: updatable
  86315. };
  86316. return MeshBuilder.CreateGround(name, options, scene);
  86317. };
  86318. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  86319. var options = {
  86320. xmin: xmin,
  86321. zmin: zmin,
  86322. xmax: xmax,
  86323. zmax: zmax,
  86324. subdivisions: subdivisions,
  86325. precision: precision,
  86326. updatable: updatable
  86327. };
  86328. return MeshBuilder.CreateTiledGround(name, options, scene);
  86329. };
  86330. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  86331. var options = {
  86332. width: width,
  86333. height: height,
  86334. subdivisions: subdivisions,
  86335. minHeight: minHeight,
  86336. maxHeight: maxHeight,
  86337. updatable: updatable,
  86338. onReady: onReady,
  86339. alphaFilter: alphaFilter
  86340. };
  86341. return MeshBuilder.CreateGroundFromHeightMap(name, url, options, scene);
  86342. };
  86343. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  86344. var options = {
  86345. path: path,
  86346. radius: radius,
  86347. tessellation: tessellation,
  86348. radiusFunction: radiusFunction,
  86349. arc: 1,
  86350. cap: cap,
  86351. updatable: updatable,
  86352. sideOrientation: sideOrientation,
  86353. instance: instance
  86354. };
  86355. return MeshBuilder.CreateTube(name, options, scene);
  86356. };
  86357. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreatePolyhedron = function (name, options, scene) {
  86358. return MeshBuilder.CreatePolyhedron(name, options, scene);
  86359. };
  86360. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateIcoSphere = function (name, options, scene) {
  86361. return MeshBuilder.CreateIcoSphere(name, options, scene);
  86362. };
  86363. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  86364. var options = {
  86365. position: position,
  86366. normal: normal,
  86367. size: size,
  86368. angle: angle
  86369. };
  86370. return MeshBuilder.CreateDecal(name, sourceMesh, options);
  86371. };
  86372. /**
  86373. * Class containing static functions to help procedurally build meshes
  86374. */
  86375. var MeshBuilder = /** @class */ (function () {
  86376. function MeshBuilder() {
  86377. }
  86378. MeshBuilder._UpdateSideOrientation = function (orientation) {
  86379. if (orientation == _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].DOUBLESIDE) {
  86380. return _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].DOUBLESIDE;
  86381. }
  86382. if (orientation === undefined || orientation === null) {
  86383. return _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].FRONTSIDE;
  86384. }
  86385. return orientation;
  86386. };
  86387. /**
  86388. * Creates a box mesh
  86389. * * The parameter `size` sets the size (float) of each box side (default 1)
  86390. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  86391. * * 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)
  86392. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  86393. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86394. * * 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
  86395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86396. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  86397. * @param name defines the name of the mesh
  86398. * @param options defines the options used to create the mesh
  86399. * @param scene defines the hosting scene
  86400. * @returns the box mesh
  86401. */
  86402. MeshBuilder.CreateBox = function (name, options, scene) {
  86403. if (scene === void 0) { scene = null; }
  86404. var box = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86405. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86406. box._originalBuilderSideOrientation = options.sideOrientation;
  86407. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateBox(options);
  86408. vertexData.applyToMesh(box, options.updatable);
  86409. return box;
  86410. };
  86411. /**
  86412. * Creates a sphere mesh
  86413. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  86414. * * 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`)
  86415. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  86416. * * 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
  86417. * * 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)
  86418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86419. * * 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
  86420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86421. * @param name defines the name of the mesh
  86422. * @param options defines the options used to create the mesh
  86423. * @param scene defines the hosting scene
  86424. * @returns the sphere mesh
  86425. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  86426. */
  86427. MeshBuilder.CreateSphere = function (name, options, scene) {
  86428. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86429. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86430. sphere._originalBuilderSideOrientation = options.sideOrientation;
  86431. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateSphere(options);
  86432. vertexData.applyToMesh(sphere, options.updatable);
  86433. return sphere;
  86434. };
  86435. /**
  86436. * Creates a plane polygonal mesh. By default, this is a disc
  86437. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  86438. * * 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
  86439. * * 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
  86440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86441. * * 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
  86442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86443. * @param name defines the name of the mesh
  86444. * @param options defines the options used to create the mesh
  86445. * @param scene defines the hosting scene
  86446. * @returns the plane polygonal mesh
  86447. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  86448. */
  86449. MeshBuilder.CreateDisc = function (name, options, scene) {
  86450. if (scene === void 0) { scene = null; }
  86451. var disc = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86452. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86453. disc._originalBuilderSideOrientation = options.sideOrientation;
  86454. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateDisc(options);
  86455. vertexData.applyToMesh(disc, options.updatable);
  86456. return disc;
  86457. };
  86458. /**
  86459. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  86460. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  86461. * * 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`)
  86462. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  86463. * * 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
  86464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86465. * * 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
  86466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86467. * @param name defines the name of the mesh
  86468. * @param options defines the options used to create the mesh
  86469. * @param scene defines the hosting scene
  86470. * @returns the icosahedron mesh
  86471. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  86472. */
  86473. MeshBuilder.CreateIcoSphere = function (name, options, scene) {
  86474. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86475. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86476. sphere._originalBuilderSideOrientation = options.sideOrientation;
  86477. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateIcoSphere(options);
  86478. vertexData.applyToMesh(sphere, options.updatable);
  86479. return sphere;
  86480. };
  86481. /**
  86482. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  86483. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  86484. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  86485. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  86486. * * 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
  86487. * * 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
  86488. * * 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
  86489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86490. * * 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
  86491. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  86492. * * 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
  86493. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  86494. * * 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
  86495. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  86496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86497. * @param name defines the name of the mesh
  86498. * @param options defines the options used to create the mesh
  86499. * @param scene defines the hosting scene
  86500. * @returns the ribbon mesh
  86501. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  86502. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  86503. */
  86504. MeshBuilder.CreateRibbon = function (name, options, scene) {
  86505. if (scene === void 0) { scene = null; }
  86506. var pathArray = options.pathArray;
  86507. var closeArray = options.closeArray;
  86508. var closePath = options.closePath;
  86509. var sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86510. var instance = options.instance;
  86511. var updatable = options.updatable;
  86512. if (instance) { // existing ribbon instance update
  86513. // positionFunction : ribbon case
  86514. // only pathArray and sideOrientation parameters are taken into account for positions update
  86515. var minimum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0].setAll(Number.MAX_VALUE);
  86516. var maximum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[1].setAll(-Number.MAX_VALUE);
  86517. var positionFunction = function (positions) {
  86518. var minlg = pathArray[0].length;
  86519. var mesh = instance;
  86520. var i = 0;
  86521. var ns = (mesh._originalBuilderSideOrientation === _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].DOUBLESIDE) ? 2 : 1;
  86522. for (var si = 1; si <= ns; ++si) {
  86523. for (var p = 0; p < pathArray.length; ++p) {
  86524. var path = pathArray[p];
  86525. var l = path.length;
  86526. minlg = (minlg < l) ? minlg : l;
  86527. for (var j = 0; j < minlg; ++j) {
  86528. var pathPoint = path[j];
  86529. positions[i] = pathPoint.x;
  86530. positions[i + 1] = pathPoint.y;
  86531. positions[i + 2] = pathPoint.z;
  86532. minimum_1.minimizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  86533. maximum_1.maximizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  86534. i += 3;
  86535. }
  86536. if (mesh._creationDataStorage && mesh._creationDataStorage.closePath) {
  86537. var pathPoint = path[0];
  86538. positions[i] = pathPoint.x;
  86539. positions[i + 1] = pathPoint.y;
  86540. positions[i + 2] = pathPoint.z;
  86541. i += 3;
  86542. }
  86543. }
  86544. }
  86545. };
  86546. var positions = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  86547. positionFunction(positions);
  86548. if (instance._boundingInfo) {
  86549. instance._boundingInfo.reConstruct(minimum_1, maximum_1, instance._worldMatrix);
  86550. }
  86551. else {
  86552. instance._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](minimum_1, maximum_1, instance._worldMatrix);
  86553. }
  86554. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, positions, false, false);
  86555. if (options.colors) {
  86556. var colors = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  86557. for (var c = 0, colorIndex = 0; c < options.colors.length; c++, colorIndex += 4) {
  86558. var color = options.colors[c];
  86559. colors[colorIndex] = color.r;
  86560. colors[colorIndex + 1] = color.g;
  86561. colors[colorIndex + 2] = color.b;
  86562. colors[colorIndex + 3] = color.a;
  86563. }
  86564. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind, colors, false, false);
  86565. }
  86566. if (options.uvs) {
  86567. var uvs = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  86568. for (var i = 0; i < options.uvs.length; i++) {
  86569. uvs[i * 2] = options.uvs[i].x;
  86570. uvs[i * 2 + 1] = options.uvs[i].y;
  86571. }
  86572. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind, uvs, false, false);
  86573. }
  86574. if (!instance.areNormalsFrozen || instance.isFacetDataEnabled) {
  86575. var indices = instance.getIndices();
  86576. var normals = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  86577. var params = instance.isFacetDataEnabled ? instance.getFacetDataParameters() : null;
  86578. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, params);
  86579. if (instance._creationDataStorage && instance._creationDataStorage.closePath) {
  86580. var indexFirst = 0;
  86581. var indexLast = 0;
  86582. for (var p = 0; p < pathArray.length; p++) {
  86583. indexFirst = instance._creationDataStorage.idx[p] * 3;
  86584. if (p + 1 < pathArray.length) {
  86585. indexLast = (instance._creationDataStorage.idx[p + 1] - 1) * 3;
  86586. }
  86587. else {
  86588. indexLast = normals.length - 3;
  86589. }
  86590. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  86591. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  86592. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  86593. normals[indexLast] = normals[indexFirst];
  86594. normals[indexLast + 1] = normals[indexFirst + 1];
  86595. normals[indexLast + 2] = normals[indexFirst + 2];
  86596. }
  86597. }
  86598. if (!(instance.areNormalsFrozen)) {
  86599. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind, normals, false, false);
  86600. }
  86601. }
  86602. return instance;
  86603. }
  86604. else { // new ribbon creation
  86605. var ribbon = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86606. ribbon._originalBuilderSideOrientation = sideOrientation;
  86607. ribbon._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_3__["_CreationDataStorage"]();
  86608. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateRibbon(options);
  86609. if (closePath) {
  86610. ribbon._creationDataStorage.idx = vertexData._idx;
  86611. }
  86612. ribbon._creationDataStorage.closePath = closePath;
  86613. ribbon._creationDataStorage.closeArray = closeArray;
  86614. vertexData.applyToMesh(ribbon, updatable);
  86615. return ribbon;
  86616. }
  86617. };
  86618. /**
  86619. * Creates a cylinder or a cone mesh
  86620. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  86621. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  86622. * * 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.
  86623. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  86624. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  86625. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  86626. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  86627. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  86628. * * 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).
  86629. * * 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
  86630. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  86631. * * 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
  86632. * * 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.
  86633. * * If `enclose` is false, a ring surface is one element.
  86634. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  86635. * * 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
  86636. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86637. * * 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
  86638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  86639. * @param name defines the name of the mesh
  86640. * @param options defines the options used to create the mesh
  86641. * @param scene defines the hosting scene
  86642. * @returns the cylinder mesh
  86643. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  86644. */
  86645. MeshBuilder.CreateCylinder = function (name, options, scene) {
  86646. var cylinder = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86647. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86648. cylinder._originalBuilderSideOrientation = options.sideOrientation;
  86649. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateCylinder(options);
  86650. vertexData.applyToMesh(cylinder, options.updatable);
  86651. return cylinder;
  86652. };
  86653. /**
  86654. * Creates a torus mesh
  86655. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  86656. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  86657. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  86658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86659. * * 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
  86660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  86661. * @param name defines the name of the mesh
  86662. * @param options defines the options used to create the mesh
  86663. * @param scene defines the hosting scene
  86664. * @returns the torus mesh
  86665. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  86666. */
  86667. MeshBuilder.CreateTorus = function (name, options, scene) {
  86668. var torus = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86669. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86670. torus._originalBuilderSideOrientation = options.sideOrientation;
  86671. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateTorus(options);
  86672. vertexData.applyToMesh(torus, options.updatable);
  86673. return torus;
  86674. };
  86675. /**
  86676. * Creates a torus knot mesh
  86677. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  86678. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  86679. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  86680. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  86681. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86682. * * 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
  86683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  86684. * @param name defines the name of the mesh
  86685. * @param options defines the options used to create the mesh
  86686. * @param scene defines the hosting scene
  86687. * @returns the torus knot mesh
  86688. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  86689. */
  86690. MeshBuilder.CreateTorusKnot = function (name, options, scene) {
  86691. var torusKnot = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86692. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86693. torusKnot._originalBuilderSideOrientation = options.sideOrientation;
  86694. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateTorusKnot(options);
  86695. vertexData.applyToMesh(torusKnot, options.updatable);
  86696. return torusKnot;
  86697. };
  86698. /**
  86699. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  86700. * * 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
  86701. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  86702. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  86703. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  86704. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  86705. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  86706. * * 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
  86707. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  86708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86709. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  86710. * @param name defines the name of the new line system
  86711. * @param options defines the options used to create the line system
  86712. * @param scene defines the hosting scene
  86713. * @returns a new line system mesh
  86714. */
  86715. MeshBuilder.CreateLineSystem = function (name, options, scene) {
  86716. var instance = options.instance;
  86717. var lines = options.lines;
  86718. var colors = options.colors;
  86719. if (instance) { // lines update
  86720. var positions = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  86721. var vertexColor;
  86722. var lineColors;
  86723. if (colors) {
  86724. vertexColor = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  86725. }
  86726. var i = 0;
  86727. var c = 0;
  86728. for (var l = 0; l < lines.length; l++) {
  86729. var points = lines[l];
  86730. for (var p = 0; p < points.length; p++) {
  86731. positions[i] = points[p].x;
  86732. positions[i + 1] = points[p].y;
  86733. positions[i + 2] = points[p].z;
  86734. if (colors && vertexColor) {
  86735. lineColors = colors[l];
  86736. vertexColor[c] = lineColors[p].r;
  86737. vertexColor[c + 1] = lineColors[p].g;
  86738. vertexColor[c + 2] = lineColors[p].b;
  86739. vertexColor[c + 3] = lineColors[p].a;
  86740. c += 4;
  86741. }
  86742. i += 3;
  86743. }
  86744. }
  86745. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, positions, false, false);
  86746. if (colors && vertexColor) {
  86747. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind, vertexColor, false, false);
  86748. }
  86749. return instance;
  86750. }
  86751. // line system creation
  86752. var useVertexColor = (colors) ? true : false;
  86753. var lineSystem = new _linesMesh__WEBPACK_IMPORTED_MODULE_5__["LinesMesh"](name, scene, null, undefined, undefined, useVertexColor, options.useVertexAlpha);
  86754. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateLineSystem(options);
  86755. vertexData.applyToMesh(lineSystem, options.updatable);
  86756. return lineSystem;
  86757. };
  86758. /**
  86759. * Creates a line mesh
  86760. * 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
  86761. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  86762. * * The parameter `points` is an array successive Vector3
  86763. * * 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
  86764. * * The optional parameter `colors` is an array of successive Color4, one per line point
  86765. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  86766. * * When updating an instance, remember that only point positions can change, not the number of points
  86767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86768. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  86769. * @param name defines the name of the new line system
  86770. * @param options defines the options used to create the line system
  86771. * @param scene defines the hosting scene
  86772. * @returns a new line mesh
  86773. */
  86774. MeshBuilder.CreateLines = function (name, options, scene) {
  86775. if (scene === void 0) { scene = null; }
  86776. var colors = (options.colors) ? [options.colors] : null;
  86777. var lines = MeshBuilder.CreateLineSystem(name, { lines: [options.points], updatable: options.updatable, instance: options.instance, colors: colors, useVertexAlpha: options.useVertexAlpha }, scene);
  86778. return lines;
  86779. };
  86780. /**
  86781. * Creates a dashed line mesh
  86782. * * 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
  86783. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  86784. * * The parameter `points` is an array successive Vector3
  86785. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  86786. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  86787. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  86788. * * 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
  86789. * * When updating an instance, remember that only point positions can change, not the number of points
  86790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86791. * @param name defines the name of the mesh
  86792. * @param options defines the options used to create the mesh
  86793. * @param scene defines the hosting scene
  86794. * @returns the dashed line mesh
  86795. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  86796. */
  86797. MeshBuilder.CreateDashedLines = function (name, options, scene) {
  86798. if (scene === void 0) { scene = null; }
  86799. var points = options.points;
  86800. var instance = options.instance;
  86801. var gapSize = options.gapSize || 1;
  86802. var dashSize = options.dashSize || 3;
  86803. if (instance) { // dashed lines update
  86804. var positionFunction = function (positions) {
  86805. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  86806. var nbSeg = positions.length / 6;
  86807. var lg = 0;
  86808. var nb = 0;
  86809. var shft = 0;
  86810. var dashshft = 0;
  86811. var curshft = 0;
  86812. var p = 0;
  86813. var i = 0;
  86814. var j = 0;
  86815. for (i = 0; i < points.length - 1; i++) {
  86816. points[i + 1].subtractToRef(points[i], curvect);
  86817. lg += curvect.length();
  86818. }
  86819. shft = lg / nbSeg;
  86820. var dashSize = instance._creationDataStorage.dashSize;
  86821. var gapSize = instance._creationDataStorage.gapSize;
  86822. dashshft = dashSize * shft / (dashSize + gapSize);
  86823. for (i = 0; i < points.length - 1; i++) {
  86824. points[i + 1].subtractToRef(points[i], curvect);
  86825. nb = Math.floor(curvect.length() / shft);
  86826. curvect.normalize();
  86827. j = 0;
  86828. while (j < nb && p < positions.length) {
  86829. curshft = shft * j;
  86830. positions[p] = points[i].x + curshft * curvect.x;
  86831. positions[p + 1] = points[i].y + curshft * curvect.y;
  86832. positions[p + 2] = points[i].z + curshft * curvect.z;
  86833. positions[p + 3] = points[i].x + (curshft + dashshft) * curvect.x;
  86834. positions[p + 4] = points[i].y + (curshft + dashshft) * curvect.y;
  86835. positions[p + 5] = points[i].z + (curshft + dashshft) * curvect.z;
  86836. p += 6;
  86837. j++;
  86838. }
  86839. }
  86840. while (p < positions.length) {
  86841. positions[p] = points[i].x;
  86842. positions[p + 1] = points[i].y;
  86843. positions[p + 2] = points[i].z;
  86844. p += 3;
  86845. }
  86846. };
  86847. instance.updateMeshPositions(positionFunction, false);
  86848. return instance;
  86849. }
  86850. // dashed lines creation
  86851. var dashedLines = new _linesMesh__WEBPACK_IMPORTED_MODULE_5__["LinesMesh"](name, scene);
  86852. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateDashedLines(options);
  86853. vertexData.applyToMesh(dashedLines, options.updatable);
  86854. dashedLines._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_3__["_CreationDataStorage"]();
  86855. dashedLines._creationDataStorage.dashSize = dashSize;
  86856. dashedLines._creationDataStorage.gapSize = gapSize;
  86857. return dashedLines;
  86858. };
  86859. /**
  86860. * 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.
  86861. * * 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.
  86862. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  86863. * * 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.
  86864. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  86865. * * 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
  86866. * * 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
  86867. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  86868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86869. * * 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
  86870. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  86871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  86872. * @param name defines the name of the mesh
  86873. * @param options defines the options used to create the mesh
  86874. * @param scene defines the hosting scene
  86875. * @returns the extruded shape mesh
  86876. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  86877. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  86878. */
  86879. MeshBuilder.ExtrudeShape = function (name, options, scene) {
  86880. if (scene === void 0) { scene = null; }
  86881. var path = options.path;
  86882. var shape = options.shape;
  86883. var scale = options.scale || 1;
  86884. var rotation = options.rotation || 0;
  86885. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP;
  86886. var updatable = options.updatable;
  86887. var sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86888. var instance = options.instance || null;
  86889. var invertUV = options.invertUV || false;
  86890. 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);
  86891. };
  86892. /**
  86893. * Creates an custom extruded shape mesh.
  86894. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  86895. * * 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.
  86896. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  86897. * * 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
  86898. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  86899. * * 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
  86900. * * It must returns a float value that will be the scale value applied to the shape on each path point
  86901. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  86902. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  86903. * * 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
  86904. * * 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
  86905. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  86906. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86907. * * 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
  86908. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  86909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86910. * @param name defines the name of the mesh
  86911. * @param options defines the options used to create the mesh
  86912. * @param scene defines the hosting scene
  86913. * @returns the custom extruded shape mesh
  86914. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  86915. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  86916. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  86917. */
  86918. MeshBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  86919. var path = options.path;
  86920. var shape = options.shape;
  86921. var scaleFunction = options.scaleFunction || (function () { return 1; });
  86922. var rotationFunction = options.rotationFunction || (function () { return 0; });
  86923. var ribbonCloseArray = options.ribbonCloseArray || false;
  86924. var ribbonClosePath = options.ribbonClosePath || false;
  86925. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP;
  86926. var updatable = options.updatable;
  86927. var sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86928. var instance = options.instance;
  86929. var invertUV = options.invertUV || false;
  86930. 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);
  86931. };
  86932. /**
  86933. * Creates lathe mesh.
  86934. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  86935. * * 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
  86936. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  86937. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  86938. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  86939. * * 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
  86940. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  86941. * * 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
  86942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86943. * * 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
  86944. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  86945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86946. * @param name defines the name of the mesh
  86947. * @param options defines the options used to create the mesh
  86948. * @param scene defines the hosting scene
  86949. * @returns the lathe mesh
  86950. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  86951. */
  86952. MeshBuilder.CreateLathe = function (name, options, scene) {
  86953. var arc = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
  86954. var closed = (options.closed === undefined) ? true : options.closed;
  86955. var shape = options.shape;
  86956. var radius = options.radius || 1;
  86957. var tessellation = options.tessellation || 64;
  86958. var clip = options.clip || 0;
  86959. var updatable = options.updatable;
  86960. var sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86961. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP;
  86962. var pi2 = Math.PI * 2;
  86963. var paths = new Array();
  86964. var invertUV = options.invertUV || false;
  86965. var i = 0;
  86966. var p = 0;
  86967. var step = pi2 / tessellation * arc;
  86968. var rotated;
  86969. var path = new Array();
  86970. for (i = 0; i <= tessellation - clip; i++) {
  86971. var path = [];
  86972. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_START || cap == _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_ALL) {
  86973. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, shape[0].y, 0));
  86974. 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));
  86975. }
  86976. for (p = 0; p < shape.length; p++) {
  86977. 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);
  86978. path.push(rotated);
  86979. }
  86980. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_END || cap == _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_ALL) {
  86981. 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));
  86982. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, shape[shape.length - 1].y, 0));
  86983. }
  86984. paths.push(path);
  86985. }
  86986. // lathe ribbon
  86987. var lathe = MeshBuilder.CreateRibbon(name, { pathArray: paths, closeArray: closed, sideOrientation: sideOrientation, updatable: updatable, invertUV: invertUV, frontUVs: options.frontUVs, backUVs: options.backUVs }, scene);
  86988. return lathe;
  86989. };
  86990. /**
  86991. * Creates a plane mesh
  86992. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  86993. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  86994. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  86995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86996. * * 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
  86997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86998. * @param name defines the name of the mesh
  86999. * @param options defines the options used to create the mesh
  87000. * @param scene defines the hosting scene
  87001. * @returns the plane mesh
  87002. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  87003. */
  87004. MeshBuilder.CreatePlane = function (name, options, scene) {
  87005. var plane = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  87006. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  87007. plane._originalBuilderSideOrientation = options.sideOrientation;
  87008. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreatePlane(options);
  87009. vertexData.applyToMesh(plane, options.updatable);
  87010. if (options.sourcePlane) {
  87011. plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);
  87012. plane.setDirection(options.sourcePlane.normal.scale(-1));
  87013. }
  87014. return plane;
  87015. };
  87016. /**
  87017. * Creates a ground mesh
  87018. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  87019. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  87020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87021. * @param name defines the name of the mesh
  87022. * @param options defines the options used to create the mesh
  87023. * @param scene defines the hosting scene
  87024. * @returns the ground mesh
  87025. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  87026. */
  87027. MeshBuilder.CreateGround = function (name, options, scene) {
  87028. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_7__["GroundMesh"](name, scene);
  87029. ground._setReady(false);
  87030. ground._subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  87031. ground._subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  87032. ground._width = options.width || 1;
  87033. ground._height = options.height || 1;
  87034. ground._maxX = ground._width / 2;
  87035. ground._maxZ = ground._height / 2;
  87036. ground._minX = -ground._maxX;
  87037. ground._minZ = -ground._maxZ;
  87038. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateGround(options);
  87039. vertexData.applyToMesh(ground, options.updatable);
  87040. ground._setReady(true);
  87041. return ground;
  87042. };
  87043. /**
  87044. * Creates a tiled ground mesh
  87045. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  87046. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  87047. * * 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
  87048. * * 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
  87049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  87050. * @param name defines the name of the mesh
  87051. * @param options defines the options used to create the mesh
  87052. * @param scene defines the hosting scene
  87053. * @returns the tiled ground mesh
  87054. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  87055. */
  87056. MeshBuilder.CreateTiledGround = function (name, options, scene) {
  87057. var tiledGround = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  87058. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateTiledGround(options);
  87059. vertexData.applyToMesh(tiledGround, options.updatable);
  87060. return tiledGround;
  87061. };
  87062. /**
  87063. * Creates a ground mesh from a height map
  87064. * * The parameter `url` sets the URL of the height map image resource.
  87065. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  87066. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  87067. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  87068. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  87069. * * 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.
  87070. * * 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).
  87071. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  87072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  87073. * @param name defines the name of the mesh
  87074. * @param url defines the url to the height map
  87075. * @param options defines the options used to create the mesh
  87076. * @param scene defines the hosting scene
  87077. * @returns the ground mesh
  87078. * @see https://doc.babylonjs.com/babylon101/height_map
  87079. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  87080. */
  87081. MeshBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  87082. var width = options.width || 10.0;
  87083. var height = options.height || 10.0;
  87084. var subdivisions = options.subdivisions || 1 | 0;
  87085. var minHeight = options.minHeight || 0.0;
  87086. var maxHeight = options.maxHeight || 1.0;
  87087. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.59, 0.11);
  87088. var alphaFilter = options.alphaFilter || 0.0;
  87089. var updatable = options.updatable;
  87090. var onReady = options.onReady;
  87091. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_7__["GroundMesh"](name, scene);
  87092. ground._subdivisionsX = subdivisions;
  87093. ground._subdivisionsY = subdivisions;
  87094. ground._width = width;
  87095. ground._height = height;
  87096. ground._maxX = ground._width / 2.0;
  87097. ground._maxZ = ground._height / 2.0;
  87098. ground._minX = -ground._maxX;
  87099. ground._minZ = -ground._maxZ;
  87100. ground._setReady(false);
  87101. var onload = function (img) {
  87102. // Getting height map data
  87103. var canvas = document.createElement("canvas");
  87104. var context = canvas.getContext("2d");
  87105. if (!context) {
  87106. throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");
  87107. }
  87108. if (scene.isDisposed) {
  87109. return;
  87110. }
  87111. var bufferWidth = img.width;
  87112. var bufferHeight = img.height;
  87113. canvas.width = bufferWidth;
  87114. canvas.height = bufferHeight;
  87115. context.drawImage(img, 0, 0);
  87116. // Create VertexData from map data
  87117. // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  87118. var buffer = context.getImageData(0, 0, bufferWidth, bufferHeight).data;
  87119. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateGroundFromHeightMap({
  87120. width: width, height: height,
  87121. subdivisions: subdivisions,
  87122. minHeight: minHeight, maxHeight: maxHeight, colorFilter: filter,
  87123. buffer: buffer, bufferWidth: bufferWidth, bufferHeight: bufferHeight,
  87124. alphaFilter: alphaFilter
  87125. });
  87126. vertexData.applyToMesh(ground, updatable);
  87127. //execute ready callback, if set
  87128. if (onReady) {
  87129. onReady(ground);
  87130. }
  87131. ground._setReady(true);
  87132. };
  87133. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  87134. return ground;
  87135. };
  87136. /**
  87137. * Creates a polygon mesh
  87138. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  87139. * * 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
  87140. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87142. * * 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)
  87143. * * Remember you can only change the shape positions, not their number when updating a polygon
  87144. * @param name defines the name of the mesh
  87145. * @param options defines the options used to create the mesh
  87146. * @param scene defines the hosting scene
  87147. * @returns the polygon mesh
  87148. */
  87149. MeshBuilder.CreatePolygon = function (name, options, scene) {
  87150. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  87151. var shape = options.shape;
  87152. var holes = options.holes || [];
  87153. var depth = options.depth || 0;
  87154. var contours = [];
  87155. var hole = [];
  87156. for (var i = 0; i < shape.length; i++) {
  87157. contours[i] = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](shape[i].x, shape[i].z);
  87158. }
  87159. var epsilon = 0.00000001;
  87160. if (contours[0].equalsWithEpsilon(contours[contours.length - 1], epsilon)) {
  87161. contours.pop();
  87162. }
  87163. var polygonTriangulation = new _polygonMesh__WEBPACK_IMPORTED_MODULE_8__["PolygonMeshBuilder"](name, contours, scene);
  87164. for (var hNb = 0; hNb < holes.length; hNb++) {
  87165. hole = [];
  87166. for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {
  87167. hole.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](holes[hNb][hPoint].x, holes[hNb][hPoint].z));
  87168. }
  87169. polygonTriangulation.addHole(hole);
  87170. }
  87171. var polygon = polygonTriangulation.build(options.updatable, depth);
  87172. polygon._originalBuilderSideOrientation = options.sideOrientation;
  87173. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreatePolygon(polygon, options.sideOrientation, options.faceUV, options.faceColors, options.frontUVs, options.backUVs);
  87174. vertexData.applyToMesh(polygon, options.updatable);
  87175. return polygon;
  87176. };
  87177. /**
  87178. * Creates an extruded polygon mesh, with depth in the Y direction.
  87179. * * 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)
  87180. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  87181. * @param name defines the name of the mesh
  87182. * @param options defines the options used to create the mesh
  87183. * @param scene defines the hosting scene
  87184. * @returns the polygon mesh
  87185. */
  87186. MeshBuilder.ExtrudePolygon = function (name, options, scene) {
  87187. return MeshBuilder.CreatePolygon(name, options, scene);
  87188. };
  87189. /**
  87190. * Creates a tube mesh.
  87191. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  87192. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  87193. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  87194. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  87195. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  87196. * * 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)
  87197. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  87198. * * 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
  87199. * * 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
  87200. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  87201. * * 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
  87202. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  87203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87204. * @param name defines the name of the mesh
  87205. * @param options defines the options used to create the mesh
  87206. * @param scene defines the hosting scene
  87207. * @returns the tube mesh
  87208. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  87209. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  87210. */
  87211. MeshBuilder.CreateTube = function (name, options, scene) {
  87212. var path = options.path;
  87213. var instance = options.instance;
  87214. var radius = 1.0;
  87215. if (options.radius !== undefined) {
  87216. radius = options.radius;
  87217. }
  87218. else if (instance) {
  87219. radius = instance._creationDataStorage.radius;
  87220. }
  87221. var tessellation = options.tessellation || 64 | 0;
  87222. var radiusFunction = options.radiusFunction || null;
  87223. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP;
  87224. var invertUV = options.invertUV || false;
  87225. var updatable = options.updatable;
  87226. var sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  87227. options.arc = options.arc && (options.arc <= 0.0 || options.arc > 1.0) ? 1.0 : options.arc || 1.0;
  87228. // tube geometry
  87229. var tubePathArray = function (path, path3D, circlePaths, radius, tessellation, radiusFunction, cap, arc) {
  87230. var tangents = path3D.getTangents();
  87231. var normals = path3D.getNormals();
  87232. var distances = path3D.getDistances();
  87233. var pi2 = Math.PI * 2;
  87234. var step = pi2 / tessellation * arc;
  87235. var returnRadius = function () { return radius; };
  87236. var radiusFunctionFinal = radiusFunction || returnRadius;
  87237. var circlePath;
  87238. var rad;
  87239. var normal;
  87240. var rotated;
  87241. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0];
  87242. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_END) ? 0 : 2;
  87243. for (var i = 0; i < path.length; i++) {
  87244. rad = radiusFunctionFinal(i, distances[i]); // current radius
  87245. circlePath = Array(); // current circle array
  87246. normal = normals[i]; // current normal
  87247. for (var t = 0; t < tessellation; t++) {
  87248. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationAxisToRef(tangents[i], step * t, rotationMatrix);
  87249. rotated = circlePath[t] ? circlePath[t] : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  87250. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(normal, rotationMatrix, rotated);
  87251. rotated.scaleInPlace(rad).addInPlace(path[i]);
  87252. circlePath[t] = rotated;
  87253. }
  87254. circlePaths[index] = circlePath;
  87255. index++;
  87256. }
  87257. // cap
  87258. var capPath = function (nbPoints, pathIndex) {
  87259. var pointCap = Array();
  87260. for (var i = 0; i < nbPoints; i++) {
  87261. pointCap.push(path[pathIndex]);
  87262. }
  87263. return pointCap;
  87264. };
  87265. switch (cap) {
  87266. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP:
  87267. break;
  87268. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_START:
  87269. circlePaths[0] = capPath(tessellation, 0);
  87270. circlePaths[1] = circlePaths[2].slice(0);
  87271. break;
  87272. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_END:
  87273. circlePaths[index] = circlePaths[index - 1].slice(0);
  87274. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  87275. break;
  87276. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_ALL:
  87277. circlePaths[0] = capPath(tessellation, 0);
  87278. circlePaths[1] = circlePaths[2].slice(0);
  87279. circlePaths[index] = circlePaths[index - 1].slice(0);
  87280. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  87281. break;
  87282. default:
  87283. break;
  87284. }
  87285. return circlePaths;
  87286. };
  87287. var path3D;
  87288. var pathArray;
  87289. if (instance) { // tube update
  87290. var storage = instance._creationDataStorage;
  87291. var arc = options.arc || storage.arc;
  87292. path3D = storage.path3D.update(path);
  87293. pathArray = tubePathArray(path, path3D, storage.pathArray, radius, storage.tessellation, radiusFunction, storage.cap, arc);
  87294. instance = MeshBuilder.CreateRibbon("", { pathArray: pathArray, instance: instance });
  87295. // Update mode, no need to recreate the storage.
  87296. storage.path3D = path3D;
  87297. storage.pathArray = pathArray;
  87298. storage.arc = arc;
  87299. storage.radius = radius;
  87300. return instance;
  87301. }
  87302. // tube creation
  87303. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path3D"](path);
  87304. var newPathArray = new Array();
  87305. cap = (cap < 0 || cap > 3) ? 0 : cap;
  87306. pathArray = tubePathArray(path, path3D, newPathArray, radius, tessellation, radiusFunction, cap, options.arc);
  87307. var tube = MeshBuilder.CreateRibbon(name, { pathArray: pathArray, closePath: true, closeArray: false, updatable: updatable, sideOrientation: sideOrientation, invertUV: invertUV, frontUVs: options.frontUVs, backUVs: options.backUVs }, scene);
  87308. tube._creationDataStorage.pathArray = pathArray;
  87309. tube._creationDataStorage.path3D = path3D;
  87310. tube._creationDataStorage.tessellation = tessellation;
  87311. tube._creationDataStorage.cap = cap;
  87312. tube._creationDataStorage.arc = options.arc;
  87313. tube._creationDataStorage.radius = radius;
  87314. return tube;
  87315. };
  87316. /**
  87317. * Creates a polyhedron mesh
  87318. * * 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
  87319. * * The parameter `size` (positive float, default 1) sets the polygon size
  87320. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  87321. * * 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`
  87322. * * 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
  87323. * * 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)`)
  87324. * * 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
  87325. * * 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
  87326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  87327. * * 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
  87328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87329. * @param name defines the name of the mesh
  87330. * @param options defines the options used to create the mesh
  87331. * @param scene defines the hosting scene
  87332. * @returns the polyhedron mesh
  87333. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  87334. */
  87335. MeshBuilder.CreatePolyhedron = function (name, options, scene) {
  87336. var polyhedron = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  87337. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  87338. polyhedron._originalBuilderSideOrientation = options.sideOrientation;
  87339. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreatePolyhedron(options);
  87340. vertexData.applyToMesh(polyhedron, options.updatable);
  87341. return polyhedron;
  87342. };
  87343. /**
  87344. * Creates a decal mesh.
  87345. * 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
  87346. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  87347. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  87348. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  87349. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  87350. * @param name defines the name of the mesh
  87351. * @param sourceMesh defines the mesh where the decal must be applied
  87352. * @param options defines the options used to create the mesh
  87353. * @param scene defines the hosting scene
  87354. * @returns the decal mesh
  87355. * @see https://doc.babylonjs.com/how_to/decals
  87356. */
  87357. MeshBuilder.CreateDecal = function (name, sourceMesh, options) {
  87358. var indices = sourceMesh.getIndices();
  87359. var positions = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  87360. var normals = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  87361. var position = options.position || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  87362. var normal = options.normal || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  87363. var size = options.size || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].One();
  87364. var angle = options.angle || 0;
  87365. // Getting correct rotation
  87366. if (!normal) {
  87367. var target = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 1);
  87368. var camera = sourceMesh.getScene().activeCamera;
  87369. var cameraWorldTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(target, camera.getWorldMatrix());
  87370. normal = camera.globalPosition.subtract(cameraWorldTarget);
  87371. }
  87372. var yaw = -Math.atan2(normal.z, normal.x) - Math.PI / 2;
  87373. var len = Math.sqrt(normal.x * normal.x + normal.z * normal.z);
  87374. var pitch = Math.atan2(normal.y, len);
  87375. // Matrix
  87376. 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));
  87377. var inverseDecalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Invert(decalWorldMatrix);
  87378. var meshWorldMatrix = sourceMesh.getWorldMatrix();
  87379. var transformMatrix = meshWorldMatrix.multiply(inverseDecalWorldMatrix);
  87380. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"]();
  87381. vertexData.indices = [];
  87382. vertexData.positions = [];
  87383. vertexData.normals = [];
  87384. vertexData.uvs = [];
  87385. var currentVertexDataIndex = 0;
  87386. var extractDecalVector3 = function (indexId) {
  87387. var result = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["PositionNormalVertex"]();
  87388. if (!indices || !positions || !normals) {
  87389. return result;
  87390. }
  87391. var vertexId = indices[indexId];
  87392. result.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](positions[vertexId * 3], positions[vertexId * 3 + 1], positions[vertexId * 3 + 2]);
  87393. // Send vector to decal local world
  87394. result.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(result.position, transformMatrix);
  87395. // Get normal
  87396. result.normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](normals[vertexId * 3], normals[vertexId * 3 + 1], normals[vertexId * 3 + 2]);
  87397. result.normal = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(result.normal, transformMatrix);
  87398. return result;
  87399. }; // Inspired by https://github.com/mrdoob/three.js/blob/eee231960882f6f3b6113405f524956145148146/examples/js/geometries/DecalGeometry.js
  87400. var clip = function (vertices, axis) {
  87401. if (vertices.length === 0) {
  87402. return vertices;
  87403. }
  87404. var clipSize = 0.5 * Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(size, axis));
  87405. var clipVertices = function (v0, v1) {
  87406. var clipFactor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].GetClipFactor(v0.position, v1.position, axis, clipSize);
  87407. 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));
  87408. };
  87409. var result = new Array();
  87410. for (var index = 0; index < vertices.length; index += 3) {
  87411. var v1Out;
  87412. var v2Out;
  87413. var v3Out;
  87414. var total = 0;
  87415. var nV1 = null;
  87416. var nV2 = null;
  87417. var nV3 = null;
  87418. var nV4 = null;
  87419. var d1 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(vertices[index].position, axis) - clipSize;
  87420. var d2 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(vertices[index + 1].position, axis) - clipSize;
  87421. var d3 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(vertices[index + 2].position, axis) - clipSize;
  87422. v1Out = d1 > 0;
  87423. v2Out = d2 > 0;
  87424. v3Out = d3 > 0;
  87425. total = (v1Out ? 1 : 0) + (v2Out ? 1 : 0) + (v3Out ? 1 : 0);
  87426. switch (total) {
  87427. case 0:
  87428. result.push(vertices[index]);
  87429. result.push(vertices[index + 1]);
  87430. result.push(vertices[index + 2]);
  87431. break;
  87432. case 1:
  87433. if (v1Out) {
  87434. nV1 = vertices[index + 1];
  87435. nV2 = vertices[index + 2];
  87436. nV3 = clipVertices(vertices[index], nV1);
  87437. nV4 = clipVertices(vertices[index], nV2);
  87438. }
  87439. if (v2Out) {
  87440. nV1 = vertices[index];
  87441. nV2 = vertices[index + 2];
  87442. nV3 = clipVertices(vertices[index + 1], nV1);
  87443. nV4 = clipVertices(vertices[index + 1], nV2);
  87444. result.push(nV3);
  87445. result.push(nV2.clone());
  87446. result.push(nV1.clone());
  87447. result.push(nV2.clone());
  87448. result.push(nV3.clone());
  87449. result.push(nV4);
  87450. break;
  87451. }
  87452. if (v3Out) {
  87453. nV1 = vertices[index];
  87454. nV2 = vertices[index + 1];
  87455. nV3 = clipVertices(vertices[index + 2], nV1);
  87456. nV4 = clipVertices(vertices[index + 2], nV2);
  87457. }
  87458. if (nV1 && nV2 && nV3 && nV4) {
  87459. result.push(nV1.clone());
  87460. result.push(nV2.clone());
  87461. result.push(nV3);
  87462. result.push(nV4);
  87463. result.push(nV3.clone());
  87464. result.push(nV2.clone());
  87465. }
  87466. break;
  87467. case 2:
  87468. if (!v1Out) {
  87469. nV1 = vertices[index].clone();
  87470. nV2 = clipVertices(nV1, vertices[index + 1]);
  87471. nV3 = clipVertices(nV1, vertices[index + 2]);
  87472. result.push(nV1);
  87473. result.push(nV2);
  87474. result.push(nV3);
  87475. }
  87476. if (!v2Out) {
  87477. nV1 = vertices[index + 1].clone();
  87478. nV2 = clipVertices(nV1, vertices[index + 2]);
  87479. nV3 = clipVertices(nV1, vertices[index]);
  87480. result.push(nV1);
  87481. result.push(nV2);
  87482. result.push(nV3);
  87483. }
  87484. if (!v3Out) {
  87485. nV1 = vertices[index + 2].clone();
  87486. nV2 = clipVertices(nV1, vertices[index]);
  87487. nV3 = clipVertices(nV1, vertices[index + 1]);
  87488. result.push(nV1);
  87489. result.push(nV2);
  87490. result.push(nV3);
  87491. }
  87492. break;
  87493. case 3:
  87494. break;
  87495. }
  87496. }
  87497. return result;
  87498. };
  87499. for (var index = 0; index < indices.length; index += 3) {
  87500. var faceVertices = new Array();
  87501. faceVertices.push(extractDecalVector3(index));
  87502. faceVertices.push(extractDecalVector3(index + 1));
  87503. faceVertices.push(extractDecalVector3(index + 2));
  87504. // Clip
  87505. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 0, 0));
  87506. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](-1, 0, 0));
  87507. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1, 0));
  87508. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, -1, 0));
  87509. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 1));
  87510. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, -1));
  87511. if (faceVertices.length === 0) {
  87512. continue;
  87513. }
  87514. // Add UVs and get back to world
  87515. for (var vIndex = 0; vIndex < faceVertices.length; vIndex++) {
  87516. var vertex = faceVertices[vIndex];
  87517. //TODO check for Int32Array | Uint32Array | Uint16Array
  87518. vertexData.indices.push(currentVertexDataIndex);
  87519. vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);
  87520. vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);
  87521. vertexData.uvs.push(0.5 + vertex.position.x / size.x);
  87522. vertexData.uvs.push(0.5 + vertex.position.y / size.y);
  87523. currentVertexDataIndex++;
  87524. }
  87525. }
  87526. // Return mesh
  87527. var decal = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, sourceMesh.getScene());
  87528. vertexData.applyToMesh(decal);
  87529. decal.position = position.clone();
  87530. decal.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](pitch, yaw, angle);
  87531. return decal;
  87532. };
  87533. // Privates
  87534. MeshBuilder._ExtrudeShapeGeneric = function (name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs) {
  87535. // extrusion geometry
  87536. var extrusionPathArray = function (shape, curve, path3D, shapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom) {
  87537. var tangents = path3D.getTangents();
  87538. var normals = path3D.getNormals();
  87539. var binormals = path3D.getBinormals();
  87540. var distances = path3D.getDistances();
  87541. var angle = 0;
  87542. var returnScale = function () { return scale !== null ? scale : 1; };
  87543. var returnRotation = function () { return rotation !== null ? rotation : 0; };
  87544. var rotate = custom && rotateFunction ? rotateFunction : returnRotation;
  87545. var scl = custom && scaleFunction ? scaleFunction : returnScale;
  87546. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_END) ? 0 : 2;
  87547. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0];
  87548. for (var i = 0; i < curve.length; i++) {
  87549. var shapePath = new Array();
  87550. var angleStep = rotate(i, distances[i]);
  87551. var scaleRatio = scl(i, distances[i]);
  87552. for (var p = 0; p < shape.length; p++) {
  87553. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationAxisToRef(tangents[i], angle, rotationMatrix);
  87554. var planed = ((tangents[i].scale(shape[p].z)).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y)));
  87555. var rotated = shapePath[p] ? shapePath[p] : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  87556. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(planed, rotationMatrix, rotated);
  87557. rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);
  87558. shapePath[p] = rotated;
  87559. }
  87560. shapePaths[index] = shapePath;
  87561. angle += angleStep;
  87562. index++;
  87563. }
  87564. // cap
  87565. var capPath = function (shapePath) {
  87566. var pointCap = Array();
  87567. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  87568. var i;
  87569. for (i = 0; i < shapePath.length; i++) {
  87570. barycenter.addInPlace(shapePath[i]);
  87571. }
  87572. barycenter.scaleInPlace(1.0 / shapePath.length);
  87573. for (i = 0; i < shapePath.length; i++) {
  87574. pointCap.push(barycenter);
  87575. }
  87576. return pointCap;
  87577. };
  87578. switch (cap) {
  87579. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP:
  87580. break;
  87581. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_START:
  87582. shapePaths[0] = capPath(shapePaths[2]);
  87583. shapePaths[1] = shapePaths[2];
  87584. break;
  87585. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_END:
  87586. shapePaths[index] = shapePaths[index - 1];
  87587. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  87588. break;
  87589. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_ALL:
  87590. shapePaths[0] = capPath(shapePaths[2]);
  87591. shapePaths[1] = shapePaths[2];
  87592. shapePaths[index] = shapePaths[index - 1];
  87593. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  87594. break;
  87595. default:
  87596. break;
  87597. }
  87598. return shapePaths;
  87599. };
  87600. var path3D;
  87601. var pathArray;
  87602. if (instance) { // instance update
  87603. var storage = instance._creationDataStorage;
  87604. path3D = storage.path3D.update(curve);
  87605. pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom);
  87606. instance = _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateRibbon("", pathArray, false, false, 0, scene || undefined, false, 0, instance);
  87607. return instance;
  87608. }
  87609. // extruded shape creation
  87610. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path3D"](curve);
  87611. var newShapePaths = new Array();
  87612. cap = (cap < 0 || cap > 3) ? 0 : cap;
  87613. pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom);
  87614. var extrudedGeneric = MeshBuilder.CreateRibbon(name, { pathArray: pathArray, closeArray: rbCA, closePath: rbCP, updatable: updtbl, sideOrientation: side, invertUV: invertUV, frontUVs: frontUVs || undefined, backUVs: backUVs || undefined }, scene);
  87615. extrudedGeneric._creationDataStorage.pathArray = pathArray;
  87616. extrudedGeneric._creationDataStorage.path3D = path3D;
  87617. extrudedGeneric._creationDataStorage.cap = cap;
  87618. return extrudedGeneric;
  87619. };
  87620. return MeshBuilder;
  87621. }());
  87622. /***/ }),
  87623. /***/ "./Meshes/meshSimplification.ts":
  87624. /*!**************************************!*\
  87625. !*** ./Meshes/meshSimplification.ts ***!
  87626. \**************************************/
  87627. /*! exports provided: SimplificationSettings, SimplificationQueue, SimplificationType */
  87628. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  87629. "use strict";
  87630. __webpack_require__.r(__webpack_exports__);
  87631. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return SimplificationSettings; });
  87632. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return SimplificationQueue; });
  87633. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return SimplificationType; });
  87634. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  87635. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  87636. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  87637. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  87638. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  87639. /**
  87640. * Class used to specify simplification options
  87641. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  87642. */
  87643. var SimplificationSettings = /** @class */ (function () {
  87644. /**
  87645. * Creates a SimplificationSettings
  87646. * @param quality expected quality
  87647. * @param distance distance when this optimized version should be used
  87648. * @param optimizeMesh already optimized mesh
  87649. */
  87650. function SimplificationSettings(
  87651. /** expected quality */
  87652. quality,
  87653. /** distance when this optimized version should be used */
  87654. distance,
  87655. /** already optimized mesh */
  87656. optimizeMesh) {
  87657. this.quality = quality;
  87658. this.distance = distance;
  87659. this.optimizeMesh = optimizeMesh;
  87660. }
  87661. return SimplificationSettings;
  87662. }());
  87663. /**
  87664. * Queue used to order the simplification tasks
  87665. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  87666. */
  87667. var SimplificationQueue = /** @class */ (function () {
  87668. /**
  87669. * Creates a new queue
  87670. */
  87671. function SimplificationQueue() {
  87672. this.running = false;
  87673. this._simplificationArray = [];
  87674. }
  87675. /**
  87676. * Adds a new simplification task
  87677. * @param task defines a task to add
  87678. */
  87679. SimplificationQueue.prototype.addTask = function (task) {
  87680. this._simplificationArray.push(task);
  87681. };
  87682. /**
  87683. * Execute next task
  87684. */
  87685. SimplificationQueue.prototype.executeNext = function () {
  87686. var task = this._simplificationArray.pop();
  87687. if (task) {
  87688. this.running = true;
  87689. this.runSimplification(task);
  87690. }
  87691. else {
  87692. this.running = false;
  87693. }
  87694. };
  87695. /**
  87696. * Execute a simplification task
  87697. * @param task defines the task to run
  87698. */
  87699. SimplificationQueue.prototype.runSimplification = function (task) {
  87700. var _this = this;
  87701. if (task.parallelProcessing) {
  87702. //parallel simplifier
  87703. task.settings.forEach(function (setting) {
  87704. var simplifier = _this.getSimplifier(task);
  87705. simplifier.simplify(setting, function (newMesh) {
  87706. task.mesh.addLODLevel(setting.distance, newMesh);
  87707. newMesh.isVisible = true;
  87708. //check if it is the last
  87709. if (setting.quality === task.settings[task.settings.length - 1].quality && task.successCallback) {
  87710. //all done, run the success callback.
  87711. task.successCallback();
  87712. }
  87713. _this.executeNext();
  87714. });
  87715. });
  87716. }
  87717. else {
  87718. //single simplifier.
  87719. var simplifier = this.getSimplifier(task);
  87720. var runDecimation = function (setting, callback) {
  87721. simplifier.simplify(setting, function (newMesh) {
  87722. task.mesh.addLODLevel(setting.distance, newMesh);
  87723. newMesh.isVisible = true;
  87724. //run the next quality level
  87725. callback();
  87726. });
  87727. };
  87728. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(task.settings.length, function (loop) {
  87729. runDecimation(task.settings[loop.index], function () {
  87730. loop.executeNext();
  87731. });
  87732. }, function () {
  87733. //execution ended, run the success callback.
  87734. if (task.successCallback) {
  87735. task.successCallback();
  87736. }
  87737. _this.executeNext();
  87738. });
  87739. }
  87740. };
  87741. SimplificationQueue.prototype.getSimplifier = function (task) {
  87742. switch (task.simplificationType) {
  87743. case SimplificationType.QUADRATIC:
  87744. default:
  87745. return new QuadraticErrorSimplification(task.mesh);
  87746. }
  87747. };
  87748. return SimplificationQueue;
  87749. }());
  87750. /**
  87751. * The implemented types of simplification
  87752. * At the moment only Quadratic Error Decimation is implemented
  87753. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  87754. */
  87755. var SimplificationType;
  87756. (function (SimplificationType) {
  87757. /** Quadratic error decimation */
  87758. SimplificationType[SimplificationType["QUADRATIC"] = 0] = "QUADRATIC";
  87759. })(SimplificationType || (SimplificationType = {}));
  87760. var DecimationTriangle = /** @class */ (function () {
  87761. function DecimationTriangle(vertices) {
  87762. this.vertices = vertices;
  87763. this.error = new Array(4);
  87764. this.deleted = false;
  87765. this.isDirty = false;
  87766. this.deletePending = false;
  87767. this.borderFactor = 0;
  87768. }
  87769. return DecimationTriangle;
  87770. }());
  87771. var DecimationVertex = /** @class */ (function () {
  87772. function DecimationVertex(position, id) {
  87773. this.position = position;
  87774. this.id = id;
  87775. this.isBorder = true;
  87776. this.q = new QuadraticMatrix();
  87777. this.triangleCount = 0;
  87778. this.triangleStart = 0;
  87779. this.originalOffsets = [];
  87780. }
  87781. DecimationVertex.prototype.updatePosition = function (newPosition) {
  87782. this.position.copyFrom(newPosition);
  87783. };
  87784. return DecimationVertex;
  87785. }());
  87786. var QuadraticMatrix = /** @class */ (function () {
  87787. function QuadraticMatrix(data) {
  87788. this.data = new Array(10);
  87789. for (var i = 0; i < 10; ++i) {
  87790. if (data && data[i]) {
  87791. this.data[i] = data[i];
  87792. }
  87793. else {
  87794. this.data[i] = 0;
  87795. }
  87796. }
  87797. }
  87798. QuadraticMatrix.prototype.det = function (a11, a12, a13, a21, a22, a23, a31, a32, a33) {
  87799. var det = this.data[a11] * this.data[a22] * this.data[a33] + this.data[a13] * this.data[a21] * this.data[a32] +
  87800. this.data[a12] * this.data[a23] * this.data[a31] - this.data[a13] * this.data[a22] * this.data[a31] -
  87801. this.data[a11] * this.data[a23] * this.data[a32] - this.data[a12] * this.data[a21] * this.data[a33];
  87802. return det;
  87803. };
  87804. QuadraticMatrix.prototype.addInPlace = function (matrix) {
  87805. for (var i = 0; i < 10; ++i) {
  87806. this.data[i] += matrix.data[i];
  87807. }
  87808. };
  87809. QuadraticMatrix.prototype.addArrayInPlace = function (data) {
  87810. for (var i = 0; i < 10; ++i) {
  87811. this.data[i] += data[i];
  87812. }
  87813. };
  87814. QuadraticMatrix.prototype.add = function (matrix) {
  87815. var m = new QuadraticMatrix();
  87816. for (var i = 0; i < 10; ++i) {
  87817. m.data[i] = this.data[i] + matrix.data[i];
  87818. }
  87819. return m;
  87820. };
  87821. QuadraticMatrix.FromData = function (a, b, c, d) {
  87822. return new QuadraticMatrix(QuadraticMatrix.DataFromNumbers(a, b, c, d));
  87823. };
  87824. //returning an array to avoid garbage collection
  87825. QuadraticMatrix.DataFromNumbers = function (a, b, c, d) {
  87826. return [a * a, a * b, a * c, a * d, b * b, b * c, b * d, c * c, c * d, d * d];
  87827. };
  87828. return QuadraticMatrix;
  87829. }());
  87830. var Reference = /** @class */ (function () {
  87831. function Reference(vertexId, triangleId) {
  87832. this.vertexId = vertexId;
  87833. this.triangleId = triangleId;
  87834. }
  87835. return Reference;
  87836. }());
  87837. /**
  87838. * An implementation of the Quadratic Error simplification algorithm.
  87839. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  87840. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  87841. * @author RaananW
  87842. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  87843. */
  87844. var QuadraticErrorSimplification = /** @class */ (function () {
  87845. function QuadraticErrorSimplification(_mesh) {
  87846. this._mesh = _mesh;
  87847. this.syncIterations = 5000;
  87848. this.aggressiveness = 7;
  87849. this.decimationIterations = 100;
  87850. this.boundingBoxEpsilon = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"];
  87851. }
  87852. QuadraticErrorSimplification.prototype.simplify = function (settings, successCallback) {
  87853. var _this = this;
  87854. this.initDecimatedMesh();
  87855. //iterating through the submeshes array, one after the other.
  87856. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this._mesh.subMeshes.length, function (loop) {
  87857. _this.initWithMesh(loop.index, function () {
  87858. _this.runDecimation(settings, loop.index, function () {
  87859. loop.executeNext();
  87860. });
  87861. }, settings.optimizeMesh);
  87862. }, function () {
  87863. setTimeout(function () {
  87864. successCallback(_this._reconstructedMesh);
  87865. }, 0);
  87866. });
  87867. };
  87868. QuadraticErrorSimplification.prototype.runDecimation = function (settings, submeshIndex, successCallback) {
  87869. var _this = this;
  87870. var targetCount = ~~(this.triangles.length * settings.quality);
  87871. var deletedTriangles = 0;
  87872. var triangleCount = this.triangles.length;
  87873. var iterationFunction = function (iteration, callback) {
  87874. setTimeout(function () {
  87875. if (iteration % 5 === 0) {
  87876. _this.updateMesh(iteration === 0);
  87877. }
  87878. for (var i = 0; i < _this.triangles.length; ++i) {
  87879. _this.triangles[i].isDirty = false;
  87880. }
  87881. var threshold = 0.000000001 * Math.pow((iteration + 3), _this.aggressiveness);
  87882. var trianglesIterator = function (i) {
  87883. var tIdx = ~~(((_this.triangles.length / 2) + i) % _this.triangles.length);
  87884. var t = _this.triangles[tIdx];
  87885. if (!t) {
  87886. return;
  87887. }
  87888. if (t.error[3] > threshold || t.deleted || t.isDirty) {
  87889. return;
  87890. }
  87891. for (var j = 0; j < 3; ++j) {
  87892. if (t.error[j] < threshold) {
  87893. var deleted0 = [];
  87894. var deleted1 = [];
  87895. var v0 = t.vertices[j];
  87896. var v1 = t.vertices[(j + 1) % 3];
  87897. if (v0.isBorder || v1.isBorder) {
  87898. continue;
  87899. }
  87900. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87901. // var n = Vector3.Zero();
  87902. // var uv = Vector2.Zero();
  87903. // var color = new Color4(0, 0, 0, 1);
  87904. _this.calculateError(v0, v1, p);
  87905. var delTr = new Array();
  87906. if (_this.isFlipped(v0, v1, p, deleted0, delTr)) {
  87907. continue;
  87908. }
  87909. if (_this.isFlipped(v1, v0, p, deleted1, delTr)) {
  87910. continue;
  87911. }
  87912. if (deleted0.indexOf(true) < 0 || deleted1.indexOf(true) < 0) {
  87913. continue;
  87914. }
  87915. var uniqueArray = new Array();
  87916. delTr.forEach(function (deletedT) {
  87917. if (uniqueArray.indexOf(deletedT) === -1) {
  87918. deletedT.deletePending = true;
  87919. uniqueArray.push(deletedT);
  87920. }
  87921. });
  87922. if (uniqueArray.length % 2 !== 0) {
  87923. continue;
  87924. }
  87925. v0.q = v1.q.add(v0.q);
  87926. v0.updatePosition(p);
  87927. var tStart = _this.references.length;
  87928. deletedTriangles = _this.updateTriangles(v0, v0, deleted0, deletedTriangles);
  87929. deletedTriangles = _this.updateTriangles(v0, v1, deleted1, deletedTriangles);
  87930. var tCount = _this.references.length - tStart;
  87931. if (tCount <= v0.triangleCount) {
  87932. if (tCount) {
  87933. for (var c = 0; c < tCount; c++) {
  87934. _this.references[v0.triangleStart + c] = _this.references[tStart + c];
  87935. }
  87936. }
  87937. }
  87938. else {
  87939. v0.triangleStart = tStart;
  87940. }
  87941. v0.triangleCount = tCount;
  87942. break;
  87943. }
  87944. }
  87945. };
  87946. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, trianglesIterator, callback, function () { return (triangleCount - deletedTriangles <= targetCount); });
  87947. }, 0);
  87948. };
  87949. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this.decimationIterations, function (loop) {
  87950. if (triangleCount - deletedTriangles <= targetCount) {
  87951. loop.breakLoop();
  87952. }
  87953. else {
  87954. iterationFunction(loop.index, function () {
  87955. loop.executeNext();
  87956. });
  87957. }
  87958. }, function () {
  87959. setTimeout(function () {
  87960. //reconstruct this part of the mesh
  87961. _this.reconstructMesh(submeshIndex);
  87962. successCallback();
  87963. }, 0);
  87964. });
  87965. };
  87966. QuadraticErrorSimplification.prototype.initWithMesh = function (submeshIndex, callback, optimizeMesh) {
  87967. var _this = this;
  87968. this.vertices = [];
  87969. this.triangles = [];
  87970. var positionData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  87971. var indices = this._mesh.getIndices();
  87972. var submesh = this._mesh.subMeshes[submeshIndex];
  87973. var findInVertices = function (positionToSearch) {
  87974. if (optimizeMesh) {
  87975. for (var ii = 0; ii < _this.vertices.length; ++ii) {
  87976. if (_this.vertices[ii].position.equals(positionToSearch)) {
  87977. return _this.vertices[ii];
  87978. }
  87979. }
  87980. }
  87981. return null;
  87982. };
  87983. var vertexReferences = [];
  87984. var vertexInit = function (i) {
  87985. if (!positionData) {
  87986. return;
  87987. }
  87988. var offset = i + submesh.verticesStart;
  87989. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positionData, offset * 3);
  87990. var vertex = findInVertices(position) || new DecimationVertex(position, _this.vertices.length);
  87991. vertex.originalOffsets.push(offset);
  87992. if (vertex.id === _this.vertices.length) {
  87993. _this.vertices.push(vertex);
  87994. }
  87995. vertexReferences.push(vertex.id);
  87996. };
  87997. //var totalVertices = mesh.getTotalVertices();
  87998. var totalVertices = submesh.verticesCount;
  87999. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(totalVertices, (this.syncIterations / 4) >> 0, vertexInit, function () {
  88000. var indicesInit = function (i) {
  88001. if (!indices) {
  88002. return;
  88003. }
  88004. var offset = (submesh.indexStart / 3) + i;
  88005. var pos = (offset * 3);
  88006. var i0 = indices[pos + 0];
  88007. var i1 = indices[pos + 1];
  88008. var i2 = indices[pos + 2];
  88009. var v0 = _this.vertices[vertexReferences[i0 - submesh.verticesStart]];
  88010. var v1 = _this.vertices[vertexReferences[i1 - submesh.verticesStart]];
  88011. var v2 = _this.vertices[vertexReferences[i2 - submesh.verticesStart]];
  88012. var triangle = new DecimationTriangle([v0, v1, v2]);
  88013. triangle.originalOffset = pos;
  88014. _this.triangles.push(triangle);
  88015. };
  88016. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(submesh.indexCount / 3, _this.syncIterations, indicesInit, function () {
  88017. _this.init(callback);
  88018. });
  88019. });
  88020. };
  88021. QuadraticErrorSimplification.prototype.init = function (callback) {
  88022. var _this = this;
  88023. var triangleInit1 = function (i) {
  88024. var t = _this.triangles[i];
  88025. 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();
  88026. for (var j = 0; j < 3; j++) {
  88027. 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))));
  88028. }
  88029. };
  88030. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(this.triangles.length, this.syncIterations, triangleInit1, function () {
  88031. var triangleInit2 = function (i) {
  88032. var t = _this.triangles[i];
  88033. for (var j = 0; j < 3; ++j) {
  88034. t.error[j] = _this.calculateError(t.vertices[j], t.vertices[(j + 1) % 3]);
  88035. }
  88036. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  88037. };
  88038. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, triangleInit2, function () {
  88039. callback();
  88040. });
  88041. });
  88042. };
  88043. QuadraticErrorSimplification.prototype.reconstructMesh = function (submeshIndex) {
  88044. var newTriangles = [];
  88045. var i;
  88046. for (i = 0; i < this.vertices.length; ++i) {
  88047. this.vertices[i].triangleCount = 0;
  88048. }
  88049. var t;
  88050. var j;
  88051. for (i = 0; i < this.triangles.length; ++i) {
  88052. if (!this.triangles[i].deleted) {
  88053. t = this.triangles[i];
  88054. for (j = 0; j < 3; ++j) {
  88055. t.vertices[j].triangleCount = 1;
  88056. }
  88057. newTriangles.push(t);
  88058. }
  88059. }
  88060. var newPositionData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind) || []);
  88061. var newNormalData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind) || []);
  88062. var newUVsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind) || []);
  88063. var newColorsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind) || []);
  88064. var normalData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  88065. var uvs = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  88066. var colorsData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  88067. var vertexCount = 0;
  88068. for (i = 0; i < this.vertices.length; ++i) {
  88069. var vertex = this.vertices[i];
  88070. vertex.id = vertexCount;
  88071. if (vertex.triangleCount) {
  88072. vertex.originalOffsets.forEach(function (originalOffset) {
  88073. if (!normalData) {
  88074. return;
  88075. }
  88076. newPositionData.push(vertex.position.x);
  88077. newPositionData.push(vertex.position.y);
  88078. newPositionData.push(vertex.position.z);
  88079. newNormalData.push(normalData[originalOffset * 3]);
  88080. newNormalData.push(normalData[(originalOffset * 3) + 1]);
  88081. newNormalData.push(normalData[(originalOffset * 3) + 2]);
  88082. if (uvs && uvs.length) {
  88083. newUVsData.push(uvs[(originalOffset * 2)]);
  88084. newUVsData.push(uvs[(originalOffset * 2) + 1]);
  88085. }
  88086. else if (colorsData && colorsData.length) {
  88087. newColorsData.push(colorsData[(originalOffset * 4)]);
  88088. newColorsData.push(colorsData[(originalOffset * 4) + 1]);
  88089. newColorsData.push(colorsData[(originalOffset * 4) + 2]);
  88090. newColorsData.push(colorsData[(originalOffset * 4) + 3]);
  88091. }
  88092. ++vertexCount;
  88093. });
  88094. }
  88095. }
  88096. var startingIndex = this._reconstructedMesh.getTotalIndices();
  88097. var startingVertex = this._reconstructedMesh.getTotalVertices();
  88098. var submeshesArray = this._reconstructedMesh.subMeshes;
  88099. this._reconstructedMesh.subMeshes = [];
  88100. var newIndicesArray = this._reconstructedMesh.getIndices(); //[];
  88101. var originalIndices = this._mesh.getIndices();
  88102. for (i = 0; i < newTriangles.length; ++i) {
  88103. t = newTriangles[i]; //now get the new referencing point for each vertex
  88104. [0, 1, 2].forEach(function (idx) {
  88105. var id = originalIndices[t.originalOffset + idx];
  88106. var offset = t.vertices[idx].originalOffsets.indexOf(id);
  88107. if (offset < 0) {
  88108. offset = 0;
  88109. }
  88110. newIndicesArray.push(t.vertices[idx].id + offset + startingVertex);
  88111. });
  88112. }
  88113. //overwriting the old vertex buffers and indices.
  88114. this._reconstructedMesh.setIndices(newIndicesArray);
  88115. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, newPositionData);
  88116. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, newNormalData);
  88117. if (newUVsData.length > 0) {
  88118. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, newUVsData);
  88119. }
  88120. if (newColorsData.length > 0) {
  88121. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, newColorsData);
  88122. }
  88123. //create submesh
  88124. var originalSubmesh = this._mesh.subMeshes[submeshIndex];
  88125. if (submeshIndex > 0) {
  88126. this._reconstructedMesh.subMeshes = [];
  88127. submeshesArray.forEach(function (submesh) {
  88128. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(submesh.materialIndex, submesh.verticesStart, submesh.verticesCount, /* 0, newPositionData.length/3, */ submesh.indexStart, submesh.indexCount, submesh.getMesh());
  88129. });
  88130. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(originalSubmesh.materialIndex, startingVertex, vertexCount, /* 0, newPositionData.length / 3, */ startingIndex, newTriangles.length * 3, this._reconstructedMesh);
  88131. }
  88132. };
  88133. QuadraticErrorSimplification.prototype.initDecimatedMesh = function () {
  88134. this._reconstructedMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this._mesh.name + "Decimated", this._mesh.getScene());
  88135. this._reconstructedMesh.material = this._mesh.material;
  88136. this._reconstructedMesh.parent = this._mesh.parent;
  88137. this._reconstructedMesh.isVisible = false;
  88138. this._reconstructedMesh.renderingGroupId = this._mesh.renderingGroupId;
  88139. };
  88140. QuadraticErrorSimplification.prototype.isFlipped = function (vertex1, vertex2, point, deletedArray, delTr) {
  88141. for (var i = 0; i < vertex1.triangleCount; ++i) {
  88142. var t = this.triangles[this.references[vertex1.triangleStart + i].triangleId];
  88143. if (t.deleted) {
  88144. continue;
  88145. }
  88146. var s = this.references[vertex1.triangleStart + i].vertexId;
  88147. var v1 = t.vertices[(s + 1) % 3];
  88148. var v2 = t.vertices[(s + 2) % 3];
  88149. if ((v1 === vertex2 || v2 === vertex2)) {
  88150. deletedArray[i] = true;
  88151. delTr.push(t);
  88152. continue;
  88153. }
  88154. var d1 = v1.position.subtract(point);
  88155. d1 = d1.normalize();
  88156. var d2 = v2.position.subtract(point);
  88157. d2 = d2.normalize();
  88158. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(d1, d2)) > 0.999) {
  88159. return true;
  88160. }
  88161. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(d1, d2).normalize();
  88162. deletedArray[i] = false;
  88163. if (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(normal, t.normal) < 0.2) {
  88164. return true;
  88165. }
  88166. }
  88167. return false;
  88168. };
  88169. QuadraticErrorSimplification.prototype.updateTriangles = function (origVertex, vertex, deletedArray, deletedTriangles) {
  88170. var newDeleted = deletedTriangles;
  88171. for (var i = 0; i < vertex.triangleCount; ++i) {
  88172. var ref = this.references[vertex.triangleStart + i];
  88173. var t = this.triangles[ref.triangleId];
  88174. if (t.deleted) {
  88175. continue;
  88176. }
  88177. if (deletedArray[i] && t.deletePending) {
  88178. t.deleted = true;
  88179. newDeleted++;
  88180. continue;
  88181. }
  88182. t.vertices[ref.vertexId] = origVertex;
  88183. t.isDirty = true;
  88184. t.error[0] = this.calculateError(t.vertices[0], t.vertices[1]) + (t.borderFactor / 2);
  88185. t.error[1] = this.calculateError(t.vertices[1], t.vertices[2]) + (t.borderFactor / 2);
  88186. t.error[2] = this.calculateError(t.vertices[2], t.vertices[0]) + (t.borderFactor / 2);
  88187. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  88188. this.references.push(ref);
  88189. }
  88190. return newDeleted;
  88191. };
  88192. QuadraticErrorSimplification.prototype.identifyBorder = function () {
  88193. for (var i = 0; i < this.vertices.length; ++i) {
  88194. var vCount = [];
  88195. var vId = [];
  88196. var v = this.vertices[i];
  88197. var j;
  88198. for (j = 0; j < v.triangleCount; ++j) {
  88199. var triangle = this.triangles[this.references[v.triangleStart + j].triangleId];
  88200. for (var ii = 0; ii < 3; ii++) {
  88201. var ofs = 0;
  88202. var vv = triangle.vertices[ii];
  88203. while (ofs < vCount.length) {
  88204. if (vId[ofs] === vv.id) {
  88205. break;
  88206. }
  88207. ++ofs;
  88208. }
  88209. if (ofs === vCount.length) {
  88210. vCount.push(1);
  88211. vId.push(vv.id);
  88212. }
  88213. else {
  88214. vCount[ofs]++;
  88215. }
  88216. }
  88217. }
  88218. for (j = 0; j < vCount.length; ++j) {
  88219. if (vCount[j] === 1) {
  88220. this.vertices[vId[j]].isBorder = true;
  88221. }
  88222. else {
  88223. this.vertices[vId[j]].isBorder = false;
  88224. }
  88225. }
  88226. }
  88227. };
  88228. QuadraticErrorSimplification.prototype.updateMesh = function (identifyBorders) {
  88229. if (identifyBorders === void 0) { identifyBorders = false; }
  88230. var i;
  88231. if (!identifyBorders) {
  88232. var newTrianglesVector = [];
  88233. for (i = 0; i < this.triangles.length; ++i) {
  88234. if (!this.triangles[i].deleted) {
  88235. newTrianglesVector.push(this.triangles[i]);
  88236. }
  88237. }
  88238. this.triangles = newTrianglesVector;
  88239. }
  88240. for (i = 0; i < this.vertices.length; ++i) {
  88241. this.vertices[i].triangleCount = 0;
  88242. this.vertices[i].triangleStart = 0;
  88243. }
  88244. var t;
  88245. var j;
  88246. var v;
  88247. for (i = 0; i < this.triangles.length; ++i) {
  88248. t = this.triangles[i];
  88249. for (j = 0; j < 3; ++j) {
  88250. v = t.vertices[j];
  88251. v.triangleCount++;
  88252. }
  88253. }
  88254. var tStart = 0;
  88255. for (i = 0; i < this.vertices.length; ++i) {
  88256. this.vertices[i].triangleStart = tStart;
  88257. tStart += this.vertices[i].triangleCount;
  88258. this.vertices[i].triangleCount = 0;
  88259. }
  88260. var newReferences = new Array(this.triangles.length * 3);
  88261. for (i = 0; i < this.triangles.length; ++i) {
  88262. t = this.triangles[i];
  88263. for (j = 0; j < 3; ++j) {
  88264. v = t.vertices[j];
  88265. newReferences[v.triangleStart + v.triangleCount] = new Reference(j, i);
  88266. v.triangleCount++;
  88267. }
  88268. }
  88269. this.references = newReferences;
  88270. if (identifyBorders) {
  88271. this.identifyBorder();
  88272. }
  88273. };
  88274. QuadraticErrorSimplification.prototype.vertexError = function (q, point) {
  88275. var x = point.x;
  88276. var y = point.y;
  88277. var z = point.z;
  88278. 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
  88279. + 2 * q.data[5] * y * z + 2 * q.data[6] * y + q.data[7] * z * z + 2 * q.data[8] * z + q.data[9];
  88280. };
  88281. QuadraticErrorSimplification.prototype.calculateError = function (vertex1, vertex2, pointResult) {
  88282. var q = vertex1.q.add(vertex2.q);
  88283. var border = vertex1.isBorder && vertex2.isBorder;
  88284. var error = 0;
  88285. var qDet = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
  88286. if (qDet !== 0 && !border) {
  88287. if (!pointResult) {
  88288. pointResult = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  88289. }
  88290. pointResult.x = -1 / qDet * (q.det(1, 2, 3, 4, 5, 6, 5, 7, 8));
  88291. pointResult.y = 1 / qDet * (q.det(0, 2, 3, 1, 5, 6, 2, 7, 8));
  88292. pointResult.z = -1 / qDet * (q.det(0, 1, 3, 1, 4, 6, 2, 5, 8));
  88293. error = this.vertexError(q, pointResult);
  88294. }
  88295. else {
  88296. var p3 = (vertex1.position.add(vertex2.position)).divide(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](2, 2, 2));
  88297. //var norm3 = (vertex1.normal.add(vertex2.normal)).divide(new Vector3(2, 2, 2)).normalize();
  88298. var error1 = this.vertexError(q, vertex1.position);
  88299. var error2 = this.vertexError(q, vertex2.position);
  88300. var error3 = this.vertexError(q, p3);
  88301. error = Math.min(error1, error2, error3);
  88302. if (error === error1) {
  88303. if (pointResult) {
  88304. pointResult.copyFrom(vertex1.position);
  88305. }
  88306. }
  88307. else if (error === error2) {
  88308. if (pointResult) {
  88309. pointResult.copyFrom(vertex2.position);
  88310. }
  88311. }
  88312. else {
  88313. if (pointResult) {
  88314. pointResult.copyFrom(p3);
  88315. }
  88316. }
  88317. }
  88318. return error;
  88319. };
  88320. return QuadraticErrorSimplification;
  88321. }());
  88322. /***/ }),
  88323. /***/ "./Meshes/meshSimplificationSceneComponent.ts":
  88324. /*!****************************************************!*\
  88325. !*** ./Meshes/meshSimplificationSceneComponent.ts ***!
  88326. \****************************************************/
  88327. /*! exports provided: SimplicationQueueSceneComponent */
  88328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88329. "use strict";
  88330. __webpack_require__.r(__webpack_exports__);
  88331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return SimplicationQueueSceneComponent; });
  88332. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  88333. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  88334. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  88335. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  88336. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "simplificationQueue", {
  88337. get: function () {
  88338. if (!this._simplificationQueue) {
  88339. this._simplificationQueue = new _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationQueue"]();
  88340. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE);
  88341. if (!component) {
  88342. component = new SimplicationQueueSceneComponent(this);
  88343. this._addComponent(component);
  88344. }
  88345. }
  88346. return this._simplificationQueue;
  88347. },
  88348. set: function (value) {
  88349. this._simplificationQueue = value;
  88350. },
  88351. enumerable: true,
  88352. configurable: true
  88353. });
  88354. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].prototype.simplify = function (settings, parallelProcessing, simplificationType, successCallback) {
  88355. if (parallelProcessing === void 0) { parallelProcessing = true; }
  88356. if (simplificationType === void 0) { simplificationType = _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationType"].QUADRATIC; }
  88357. this.getScene().simplificationQueue.addTask({
  88358. settings: settings,
  88359. parallelProcessing: parallelProcessing,
  88360. mesh: this,
  88361. simplificationType: simplificationType,
  88362. successCallback: successCallback
  88363. });
  88364. return this;
  88365. };
  88366. /**
  88367. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  88368. * created in a scene
  88369. */
  88370. var SimplicationQueueSceneComponent = /** @class */ (function () {
  88371. /**
  88372. * Creates a new instance of the component for the given scene
  88373. * @param scene Defines the scene to register the component in
  88374. */
  88375. function SimplicationQueueSceneComponent(scene) {
  88376. /**
  88377. * The component name helpfull to identify the component in the list of scene components.
  88378. */
  88379. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE;
  88380. this.scene = scene;
  88381. }
  88382. /**
  88383. * Registers the component in a given scene
  88384. */
  88385. SimplicationQueueSceneComponent.prototype.register = function () {
  88386. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate);
  88387. };
  88388. /**
  88389. * Rebuilds the elements related to this component in case of
  88390. * context lost for instance.
  88391. */
  88392. SimplicationQueueSceneComponent.prototype.rebuild = function () {
  88393. // Nothing to do for this component
  88394. };
  88395. /**
  88396. * Disposes the component and the associated ressources
  88397. */
  88398. SimplicationQueueSceneComponent.prototype.dispose = function () {
  88399. // Nothing to do for this component
  88400. };
  88401. SimplicationQueueSceneComponent.prototype._beforeCameraUpdate = function () {
  88402. if (this.scene._simplificationQueue && !this.scene._simplificationQueue.running) {
  88403. this.scene._simplificationQueue.executeNext();
  88404. }
  88405. };
  88406. return SimplicationQueueSceneComponent;
  88407. }());
  88408. /***/ }),
  88409. /***/ "./Meshes/polygonMesh.ts":
  88410. /*!*******************************!*\
  88411. !*** ./Meshes/polygonMesh.ts ***!
  88412. \*******************************/
  88413. /*! exports provided: Polygon, PolygonMeshBuilder */
  88414. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88415. "use strict";
  88416. __webpack_require__.r(__webpack_exports__);
  88417. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return Polygon; });
  88418. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return PolygonMeshBuilder; });
  88419. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  88420. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  88421. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  88422. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  88423. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  88424. /**
  88425. * Vector2 wth index property
  88426. */
  88427. var IndexedVector2 = /** @class */ (function (_super) {
  88428. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IndexedVector2, _super);
  88429. function IndexedVector2(original,
  88430. /** Index of the vector2 */
  88431. index) {
  88432. var _this = _super.call(this, original.x, original.y) || this;
  88433. _this.index = index;
  88434. return _this;
  88435. }
  88436. return IndexedVector2;
  88437. }(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"]));
  88438. /**
  88439. * Defines points to create a polygon
  88440. */
  88441. var PolygonPoints = /** @class */ (function () {
  88442. function PolygonPoints() {
  88443. this.elements = new Array();
  88444. }
  88445. PolygonPoints.prototype.add = function (originalPoints) {
  88446. var _this = this;
  88447. var result = new Array();
  88448. originalPoints.forEach(function (point) {
  88449. if (result.length === 0 || !point.equalsWithEpsilon(result[0])) {
  88450. var newPoint = new IndexedVector2(point, _this.elements.length);
  88451. result.push(newPoint);
  88452. _this.elements.push(newPoint);
  88453. }
  88454. });
  88455. return result;
  88456. };
  88457. PolygonPoints.prototype.computeBounds = function () {
  88458. var lmin = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  88459. var lmax = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  88460. this.elements.forEach(function (point) {
  88461. // x
  88462. if (point.x < lmin.x) {
  88463. lmin.x = point.x;
  88464. }
  88465. else if (point.x > lmax.x) {
  88466. lmax.x = point.x;
  88467. }
  88468. // y
  88469. if (point.y < lmin.y) {
  88470. lmin.y = point.y;
  88471. }
  88472. else if (point.y > lmax.y) {
  88473. lmax.y = point.y;
  88474. }
  88475. });
  88476. return {
  88477. min: lmin,
  88478. max: lmax,
  88479. width: lmax.x - lmin.x,
  88480. height: lmax.y - lmin.y
  88481. };
  88482. };
  88483. return PolygonPoints;
  88484. }());
  88485. /**
  88486. * Polygon
  88487. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  88488. */
  88489. var Polygon = /** @class */ (function () {
  88490. function Polygon() {
  88491. }
  88492. /**
  88493. * Creates a rectangle
  88494. * @param xmin bottom X coord
  88495. * @param ymin bottom Y coord
  88496. * @param xmax top X coord
  88497. * @param ymax top Y coord
  88498. * @returns points that make the resulting rectation
  88499. */
  88500. Polygon.Rectangle = function (xmin, ymin, xmax, ymax) {
  88501. return [
  88502. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymin),
  88503. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymin),
  88504. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymax),
  88505. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymax)
  88506. ];
  88507. };
  88508. /**
  88509. * Creates a circle
  88510. * @param radius radius of circle
  88511. * @param cx scale in x
  88512. * @param cy scale in y
  88513. * @param numberOfSides number of sides that make up the circle
  88514. * @returns points that make the resulting circle
  88515. */
  88516. Polygon.Circle = function (radius, cx, cy, numberOfSides) {
  88517. if (cx === void 0) { cx = 0; }
  88518. if (cy === void 0) { cy = 0; }
  88519. if (numberOfSides === void 0) { numberOfSides = 32; }
  88520. var result = new Array();
  88521. var angle = 0;
  88522. var increment = (Math.PI * 2) / numberOfSides;
  88523. for (var i = 0; i < numberOfSides; i++) {
  88524. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](cx + Math.cos(angle) * radius, cy + Math.sin(angle) * radius));
  88525. angle -= increment;
  88526. }
  88527. return result;
  88528. };
  88529. /**
  88530. * Creates a polygon from input string
  88531. * @param input Input polygon data
  88532. * @returns the parsed points
  88533. */
  88534. Polygon.Parse = function (input) {
  88535. var floats = input.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function (val) { return (!isNaN(val)); });
  88536. var i, result = [];
  88537. for (i = 0; i < (floats.length & 0x7FFFFFFE); i += 2) {
  88538. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](floats[i], floats[i + 1]));
  88539. }
  88540. return result;
  88541. };
  88542. /**
  88543. * Starts building a polygon from x and y coordinates
  88544. * @param x x coordinate
  88545. * @param y y coordinate
  88546. * @returns the started path2
  88547. */
  88548. Polygon.StartingAt = function (x, y) {
  88549. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"].StartingAt(x, y);
  88550. };
  88551. return Polygon;
  88552. }());
  88553. /**
  88554. * Builds a polygon
  88555. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  88556. */
  88557. var PolygonMeshBuilder = /** @class */ (function () {
  88558. /**
  88559. * Creates a PolygonMeshBuilder
  88560. * @param name name of the builder
  88561. * @param contours Path of the polygon
  88562. * @param scene scene to add to
  88563. */
  88564. function PolygonMeshBuilder(name, contours, scene, earcutInjection) {
  88565. if (earcutInjection === void 0) { earcutInjection = earcut; }
  88566. this._points = new PolygonPoints();
  88567. this._outlinepoints = new PolygonPoints();
  88568. this._holes = new Array();
  88569. this._epoints = new Array();
  88570. this._eholes = new Array();
  88571. this.bjsEarcut = earcutInjection;
  88572. this._name = name;
  88573. this._scene = scene;
  88574. var points;
  88575. if (contours instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"]) {
  88576. points = contours.getPoints();
  88577. }
  88578. else {
  88579. points = contours;
  88580. }
  88581. this._addToepoint(points);
  88582. this._points.add(points);
  88583. this._outlinepoints.add(points);
  88584. if (typeof this.bjsEarcut === 'undefined') {
  88585. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Earcut was not found, the polygon will not be built.");
  88586. }
  88587. }
  88588. PolygonMeshBuilder.prototype._addToepoint = function (points) {
  88589. for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
  88590. var p = points_1[_i];
  88591. this._epoints.push(p.x, p.y);
  88592. }
  88593. };
  88594. /**
  88595. * Adds a whole within the polygon
  88596. * @param hole Array of points defining the hole
  88597. * @returns this
  88598. */
  88599. PolygonMeshBuilder.prototype.addHole = function (hole) {
  88600. this._points.add(hole);
  88601. var holepoints = new PolygonPoints();
  88602. holepoints.add(hole);
  88603. this._holes.push(holepoints);
  88604. this._eholes.push(this._epoints.length / 2);
  88605. this._addToepoint(hole);
  88606. return this;
  88607. };
  88608. /**
  88609. * Creates the polygon
  88610. * @param updatable If the mesh should be updatable
  88611. * @param depth The depth of the mesh created
  88612. * @returns the created mesh
  88613. */
  88614. PolygonMeshBuilder.prototype.build = function (updatable, depth) {
  88615. var _this = this;
  88616. if (updatable === void 0) { updatable = false; }
  88617. if (depth === void 0) { depth = 0; }
  88618. var result = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this._name, this._scene);
  88619. var normals = new Array();
  88620. var positions = new Array();
  88621. var uvs = new Array();
  88622. var bounds = this._points.computeBounds();
  88623. this._points.elements.forEach(function (p) {
  88624. normals.push(0, 1.0, 0);
  88625. positions.push(p.x, 0, p.y);
  88626. uvs.push((p.x - bounds.min.x) / bounds.width, (p.y - bounds.min.y) / bounds.height);
  88627. });
  88628. var indices = new Array();
  88629. var res = this.bjsEarcut(this._epoints, this._eholes, 2);
  88630. for (var i = 0; i < res.length; i++) {
  88631. indices.push(res[i]);
  88632. }
  88633. if (depth > 0) {
  88634. var positionscount = (positions.length / 3); //get the current pointcount
  88635. this._points.elements.forEach(function (p) {
  88636. normals.push(0, -1.0, 0);
  88637. positions.push(p.x, -depth, p.y);
  88638. uvs.push(1 - (p.x - bounds.min.x) / bounds.width, 1 - (p.y - bounds.min.y) / bounds.height);
  88639. });
  88640. var totalCount = indices.length;
  88641. for (var i = 0; i < totalCount; i += 3) {
  88642. var i0 = indices[i + 0];
  88643. var i1 = indices[i + 1];
  88644. var i2 = indices[i + 2];
  88645. indices.push(i2 + positionscount);
  88646. indices.push(i1 + positionscount);
  88647. indices.push(i0 + positionscount);
  88648. }
  88649. //Add the sides
  88650. this.addSide(positions, normals, uvs, indices, bounds, this._outlinepoints, depth, false);
  88651. this._holes.forEach(function (hole) {
  88652. _this.addSide(positions, normals, uvs, indices, bounds, hole, depth, true);
  88653. });
  88654. }
  88655. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positions, updatable);
  88656. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normals, updatable);
  88657. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, uvs, updatable);
  88658. result.setIndices(indices);
  88659. return result;
  88660. };
  88661. /**
  88662. * Adds a side to the polygon
  88663. * @param positions points that make the polygon
  88664. * @param normals normals of the polygon
  88665. * @param uvs uvs of the polygon
  88666. * @param indices indices of the polygon
  88667. * @param bounds bounds of the polygon
  88668. * @param points points of the polygon
  88669. * @param depth depth of the polygon
  88670. * @param flip flip of the polygon
  88671. */
  88672. PolygonMeshBuilder.prototype.addSide = function (positions, normals, uvs, indices, bounds, points, depth, flip) {
  88673. var StartIndex = positions.length / 3;
  88674. var ulength = 0;
  88675. for (var i = 0; i < points.elements.length; i++) {
  88676. var p = points.elements[i];
  88677. var p1;
  88678. if ((i + 1) > points.elements.length - 1) {
  88679. p1 = points.elements[0];
  88680. }
  88681. else {
  88682. p1 = points.elements[i + 1];
  88683. }
  88684. positions.push(p.x, 0, p.y);
  88685. positions.push(p.x, -depth, p.y);
  88686. positions.push(p1.x, 0, p1.y);
  88687. positions.push(p1.x, -depth, p1.y);
  88688. var v1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p.x, 0, p.y);
  88689. var v2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p1.x, 0, p1.y);
  88690. var v3 = v2.subtract(v1);
  88691. var v4 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1, 0);
  88692. var vn = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(v3, v4);
  88693. vn = vn.normalize();
  88694. uvs.push(ulength / bounds.width, 0);
  88695. uvs.push(ulength / bounds.width, 1);
  88696. ulength += v3.length();
  88697. uvs.push((ulength / bounds.width), 0);
  88698. uvs.push((ulength / bounds.width), 1);
  88699. if (!flip) {
  88700. normals.push(-vn.x, -vn.y, -vn.z);
  88701. normals.push(-vn.x, -vn.y, -vn.z);
  88702. normals.push(-vn.x, -vn.y, -vn.z);
  88703. normals.push(-vn.x, -vn.y, -vn.z);
  88704. indices.push(StartIndex);
  88705. indices.push(StartIndex + 1);
  88706. indices.push(StartIndex + 2);
  88707. indices.push(StartIndex + 1);
  88708. indices.push(StartIndex + 3);
  88709. indices.push(StartIndex + 2);
  88710. }
  88711. else {
  88712. normals.push(vn.x, vn.y, vn.z);
  88713. normals.push(vn.x, vn.y, vn.z);
  88714. normals.push(vn.x, vn.y, vn.z);
  88715. normals.push(vn.x, vn.y, vn.z);
  88716. indices.push(StartIndex);
  88717. indices.push(StartIndex + 2);
  88718. indices.push(StartIndex + 1);
  88719. indices.push(StartIndex + 1);
  88720. indices.push(StartIndex + 2);
  88721. indices.push(StartIndex + 3);
  88722. }
  88723. StartIndex += 4;
  88724. }
  88725. };
  88726. return PolygonMeshBuilder;
  88727. }());
  88728. /***/ }),
  88729. /***/ "./Meshes/subMesh.ts":
  88730. /*!***************************!*\
  88731. !*** ./Meshes/subMesh.ts ***!
  88732. \***************************/
  88733. /*! exports provided: BaseSubMesh, SubMesh */
  88734. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88735. "use strict";
  88736. __webpack_require__.r(__webpack_exports__);
  88737. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return BaseSubMesh; });
  88738. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return SubMesh; });
  88739. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  88740. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  88741. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  88742. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  88743. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  88744. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  88745. /**
  88746. * Base class for submeshes
  88747. */
  88748. var BaseSubMesh = /** @class */ (function () {
  88749. function BaseSubMesh() {
  88750. }
  88751. Object.defineProperty(BaseSubMesh.prototype, "effect", {
  88752. /**
  88753. * Gets associated effect
  88754. */
  88755. get: function () {
  88756. return this._materialEffect;
  88757. },
  88758. enumerable: true,
  88759. configurable: true
  88760. });
  88761. /**
  88762. * Sets associated effect (effect used to render this submesh)
  88763. * @param effect defines the effect to associate with
  88764. * @param defines defines the set of defines used to compile this effect
  88765. */
  88766. BaseSubMesh.prototype.setEffect = function (effect, defines) {
  88767. if (defines === void 0) { defines = null; }
  88768. if (this._materialEffect === effect) {
  88769. if (!effect) {
  88770. this._materialDefines = null;
  88771. }
  88772. return;
  88773. }
  88774. this._materialDefines = defines;
  88775. this._materialEffect = effect;
  88776. };
  88777. return BaseSubMesh;
  88778. }());
  88779. /**
  88780. * Defines a subdivision inside a mesh
  88781. */
  88782. var SubMesh = /** @class */ (function (_super) {
  88783. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SubMesh, _super);
  88784. /**
  88785. * Creates a new submesh
  88786. * @param materialIndex defines the material index to use
  88787. * @param verticesStart defines vertex index start
  88788. * @param verticesCount defines vertices count
  88789. * @param indexStart defines index start
  88790. * @param indexCount defines indices count
  88791. * @param mesh defines the parent mesh
  88792. * @param renderingMesh defines an optional rendering mesh
  88793. * @param createBoundingBox defines if bounding box should be created for this submesh
  88794. */
  88795. function SubMesh(
  88796. /** the material index to use */
  88797. materialIndex,
  88798. /** vertex index start */
  88799. verticesStart,
  88800. /** vertices count */
  88801. verticesCount,
  88802. /** index start */
  88803. indexStart,
  88804. /** indices count */
  88805. indexCount, mesh, renderingMesh, createBoundingBox) {
  88806. if (createBoundingBox === void 0) { createBoundingBox = true; }
  88807. var _this = _super.call(this) || this;
  88808. _this.materialIndex = materialIndex;
  88809. _this.verticesStart = verticesStart;
  88810. _this.verticesCount = verticesCount;
  88811. _this.indexStart = indexStart;
  88812. _this.indexCount = indexCount;
  88813. /** @hidden */
  88814. _this._renderId = 0;
  88815. _this._mesh = mesh;
  88816. _this._renderingMesh = renderingMesh || mesh;
  88817. mesh.subMeshes.push(_this);
  88818. _this._trianglePlanes = [];
  88819. _this._id = mesh.subMeshes.length - 1;
  88820. if (createBoundingBox) {
  88821. _this.refreshBoundingInfo();
  88822. mesh.computeWorldMatrix(true);
  88823. }
  88824. return _this;
  88825. }
  88826. /**
  88827. * Add a new submesh to a mesh
  88828. * @param materialIndex defines the material index to use
  88829. * @param verticesStart defines vertex index start
  88830. * @param verticesCount defines vertices count
  88831. * @param indexStart defines index start
  88832. * @param indexCount defines indices count
  88833. * @param mesh defines the parent mesh
  88834. * @param renderingMesh defines an optional rendering mesh
  88835. * @param createBoundingBox defines if bounding box should be created for this submesh
  88836. * @returns the new submesh
  88837. */
  88838. SubMesh.AddToMesh = function (materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox) {
  88839. if (createBoundingBox === void 0) { createBoundingBox = true; }
  88840. return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);
  88841. };
  88842. Object.defineProperty(SubMesh.prototype, "IsGlobal", {
  88843. /**
  88844. * Returns true if this submesh covers the entire parent mesh
  88845. * @ignorenaming
  88846. */
  88847. get: function () {
  88848. return (this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices());
  88849. },
  88850. enumerable: true,
  88851. configurable: true
  88852. });
  88853. /**
  88854. * Returns the submesh BoudingInfo object
  88855. * @returns current bounding info (or mesh's one if the submesh is global)
  88856. */
  88857. SubMesh.prototype.getBoundingInfo = function () {
  88858. if (this.IsGlobal) {
  88859. return this._mesh.getBoundingInfo();
  88860. }
  88861. return this._boundingInfo;
  88862. };
  88863. /**
  88864. * Sets the submesh BoundingInfo
  88865. * @param boundingInfo defines the new bounding info to use
  88866. * @returns the SubMesh
  88867. */
  88868. SubMesh.prototype.setBoundingInfo = function (boundingInfo) {
  88869. this._boundingInfo = boundingInfo;
  88870. return this;
  88871. };
  88872. /**
  88873. * Returns the mesh of the current submesh
  88874. * @return the parent mesh
  88875. */
  88876. SubMesh.prototype.getMesh = function () {
  88877. return this._mesh;
  88878. };
  88879. /**
  88880. * Returns the rendering mesh of the submesh
  88881. * @returns the rendering mesh (could be different from parent mesh)
  88882. */
  88883. SubMesh.prototype.getRenderingMesh = function () {
  88884. return this._renderingMesh;
  88885. };
  88886. /**
  88887. * Returns the submesh material
  88888. * @returns null or the current material
  88889. */
  88890. SubMesh.prototype.getMaterial = function () {
  88891. var rootMaterial = this._renderingMesh.material;
  88892. if (rootMaterial === null || rootMaterial === undefined) {
  88893. return this._mesh.getScene().defaultMaterial;
  88894. }
  88895. else if (rootMaterial.getSubMaterial) {
  88896. var multiMaterial = rootMaterial;
  88897. var effectiveMaterial = multiMaterial.getSubMaterial(this.materialIndex);
  88898. if (this._currentMaterial !== effectiveMaterial) {
  88899. this._currentMaterial = effectiveMaterial;
  88900. this._materialDefines = null;
  88901. }
  88902. return effectiveMaterial;
  88903. }
  88904. return rootMaterial;
  88905. };
  88906. // Methods
  88907. /**
  88908. * Sets a new updated BoundingInfo object to the submesh
  88909. * @returns the SubMesh
  88910. */
  88911. SubMesh.prototype.refreshBoundingInfo = function () {
  88912. this._lastColliderWorldVertices = null;
  88913. if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {
  88914. return this;
  88915. }
  88916. var data = this._renderingMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  88917. if (!data) {
  88918. this._boundingInfo = this._mesh.getBoundingInfo();
  88919. return this;
  88920. }
  88921. var indices = this._renderingMesh.getIndices();
  88922. var extend;
  88923. //is this the only submesh?
  88924. if (this.indexStart === 0 && this.indexCount === indices.length) {
  88925. var boundingInfo = this._renderingMesh.getBoundingInfo();
  88926. //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.
  88927. extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };
  88928. }
  88929. else {
  88930. extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
  88931. }
  88932. if (this._boundingInfo) {
  88933. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  88934. }
  88935. else {
  88936. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](extend.minimum, extend.maximum);
  88937. }
  88938. return this;
  88939. };
  88940. /** @hidden */
  88941. SubMesh.prototype._checkCollision = function (collider) {
  88942. var boundingInfo = this.getBoundingInfo();
  88943. return boundingInfo._checkCollision(collider);
  88944. };
  88945. /**
  88946. * Updates the submesh BoundingInfo
  88947. * @param world defines the world matrix to use to update the bounding info
  88948. * @returns the submesh
  88949. */
  88950. SubMesh.prototype.updateBoundingInfo = function (world) {
  88951. var boundingInfo = this.getBoundingInfo();
  88952. if (!boundingInfo) {
  88953. this.refreshBoundingInfo();
  88954. boundingInfo = this.getBoundingInfo();
  88955. }
  88956. boundingInfo.update(world);
  88957. return this;
  88958. };
  88959. /**
  88960. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  88961. * @param frustumPlanes defines the frustum planes
  88962. * @returns true if the submesh is intersecting with the frustum
  88963. */
  88964. SubMesh.prototype.isInFrustum = function (frustumPlanes) {
  88965. var boundingInfo = this.getBoundingInfo();
  88966. if (!boundingInfo) {
  88967. return false;
  88968. }
  88969. return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);
  88970. };
  88971. /**
  88972. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  88973. * @param frustumPlanes defines the frustum planes
  88974. * @returns true if the submesh is inside the frustum
  88975. */
  88976. SubMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  88977. var boundingInfo = this.getBoundingInfo();
  88978. if (!boundingInfo) {
  88979. return false;
  88980. }
  88981. return boundingInfo.isCompletelyInFrustum(frustumPlanes);
  88982. };
  88983. /**
  88984. * Renders the submesh
  88985. * @param enableAlphaMode defines if alpha needs to be used
  88986. * @returns the submesh
  88987. */
  88988. SubMesh.prototype.render = function (enableAlphaMode) {
  88989. this._renderingMesh.render(this, enableAlphaMode);
  88990. return this;
  88991. };
  88992. /**
  88993. * @hidden
  88994. */
  88995. SubMesh.prototype._getLinesIndexBuffer = function (indices, engine) {
  88996. if (!this._linesIndexBuffer) {
  88997. var linesIndices = [];
  88998. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  88999. linesIndices.push(indices[index], indices[index + 1], indices[index + 1], indices[index + 2], indices[index + 2], indices[index]);
  89000. }
  89001. this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);
  89002. this._linesIndexCount = linesIndices.length;
  89003. }
  89004. return this._linesIndexBuffer;
  89005. };
  89006. /**
  89007. * Checks if the submesh intersects with a ray
  89008. * @param ray defines the ray to test
  89009. * @returns true is the passed ray intersects the submesh bounding box
  89010. */
  89011. SubMesh.prototype.canIntersects = function (ray) {
  89012. var boundingInfo = this.getBoundingInfo();
  89013. if (!boundingInfo) {
  89014. return false;
  89015. }
  89016. return ray.intersectsBox(boundingInfo.boundingBox);
  89017. };
  89018. /**
  89019. * Intersects current submesh with a ray
  89020. * @param ray defines the ray to test
  89021. * @param positions defines mesh's positions array
  89022. * @param indices defines mesh's indices array
  89023. * @param fastCheck defines if only bounding info should be used
  89024. * @returns intersection info or null if no intersection
  89025. */
  89026. SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck) {
  89027. var material = this.getMaterial();
  89028. if (!material) {
  89029. return null;
  89030. }
  89031. switch (material.fillMode) {
  89032. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_PointListDrawMode:
  89033. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineListDrawMode:
  89034. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineLoopDrawMode:
  89035. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineStripDrawMode:
  89036. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleFanDrawMode:
  89037. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleStripDrawMode:
  89038. return null;
  89039. }
  89040. // LineMesh first as it's also a Mesh...
  89041. if (this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh") {
  89042. return this._intersectLines(ray, positions, indices, this._mesh.intersectionThreshold, fastCheck);
  89043. }
  89044. return this._intersectTriangles(ray, positions, indices, fastCheck);
  89045. };
  89046. /** @hidden */
  89047. SubMesh.prototype._intersectLines = function (ray, positions, indices, intersectionThreshold, fastCheck) {
  89048. var intersectInfo = null;
  89049. // Line test
  89050. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {
  89051. var p0 = positions[indices[index]];
  89052. var p1 = positions[indices[index + 1]];
  89053. var length = ray.intersectionSegment(p0, p1, intersectionThreshold);
  89054. if (length < 0) {
  89055. continue;
  89056. }
  89057. if (fastCheck || !intersectInfo || length < intersectInfo.distance) {
  89058. intersectInfo = new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](null, null, length);
  89059. intersectInfo.faceId = index / 2;
  89060. if (fastCheck) {
  89061. break;
  89062. }
  89063. }
  89064. }
  89065. return intersectInfo;
  89066. };
  89067. /** @hidden */
  89068. SubMesh.prototype._intersectTriangles = function (ray, positions, indices, fastCheck) {
  89069. var intersectInfo = null;
  89070. // Triangles test
  89071. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  89072. var p0 = positions[indices[index]];
  89073. var p1 = positions[indices[index + 1]];
  89074. var p2 = positions[indices[index + 2]];
  89075. var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
  89076. if (currentIntersectInfo) {
  89077. if (currentIntersectInfo.distance < 0) {
  89078. continue;
  89079. }
  89080. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  89081. intersectInfo = currentIntersectInfo;
  89082. intersectInfo.faceId = index / 3;
  89083. if (fastCheck) {
  89084. break;
  89085. }
  89086. }
  89087. }
  89088. }
  89089. return intersectInfo;
  89090. };
  89091. /** @hidden */
  89092. SubMesh.prototype._rebuild = function () {
  89093. if (this._linesIndexBuffer) {
  89094. this._linesIndexBuffer = null;
  89095. }
  89096. };
  89097. // Clone
  89098. /**
  89099. * Creates a new submesh from the passed mesh
  89100. * @param newMesh defines the new hosting mesh
  89101. * @param newRenderingMesh defines an optional rendering mesh
  89102. * @returns the new submesh
  89103. */
  89104. SubMesh.prototype.clone = function (newMesh, newRenderingMesh) {
  89105. var result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);
  89106. if (!this.IsGlobal) {
  89107. var boundingInfo = this.getBoundingInfo();
  89108. if (!boundingInfo) {
  89109. return result;
  89110. }
  89111. result._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](boundingInfo.minimum, boundingInfo.maximum);
  89112. }
  89113. return result;
  89114. };
  89115. // Dispose
  89116. /**
  89117. * Release associated resources
  89118. */
  89119. SubMesh.prototype.dispose = function () {
  89120. if (this._linesIndexBuffer) {
  89121. this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);
  89122. this._linesIndexBuffer = null;
  89123. }
  89124. // Remove from mesh
  89125. var index = this._mesh.subMeshes.indexOf(this);
  89126. this._mesh.subMeshes.splice(index, 1);
  89127. };
  89128. /**
  89129. * Gets the class name
  89130. * @returns the string "SubMesh".
  89131. */
  89132. SubMesh.prototype.getClassName = function () {
  89133. return "SubMesh";
  89134. };
  89135. // Statics
  89136. /**
  89137. * Creates a new submesh from indices data
  89138. * @param materialIndex the index of the main mesh material
  89139. * @param startIndex the index where to start the copy in the mesh indices array
  89140. * @param indexCount the number of indices to copy then from the startIndex
  89141. * @param mesh the main mesh to create the submesh from
  89142. * @param renderingMesh the optional rendering mesh
  89143. * @returns a new submesh
  89144. */
  89145. SubMesh.CreateFromIndices = function (materialIndex, startIndex, indexCount, mesh, renderingMesh) {
  89146. var minVertexIndex = Number.MAX_VALUE;
  89147. var maxVertexIndex = -Number.MAX_VALUE;
  89148. var whatWillRender = (renderingMesh || mesh);
  89149. var indices = whatWillRender.getIndices();
  89150. for (var index = startIndex; index < startIndex + indexCount; index++) {
  89151. var vertexIndex = indices[index];
  89152. if (vertexIndex < minVertexIndex) {
  89153. minVertexIndex = vertexIndex;
  89154. }
  89155. if (vertexIndex > maxVertexIndex) {
  89156. maxVertexIndex = vertexIndex;
  89157. }
  89158. }
  89159. return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
  89160. };
  89161. return SubMesh;
  89162. }(BaseSubMesh));
  89163. /***/ }),
  89164. /***/ "./Meshes/transformNode.ts":
  89165. /*!*********************************!*\
  89166. !*** ./Meshes/transformNode.ts ***!
  89167. \*********************************/
  89168. /*! exports provided: TransformNode */
  89169. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89170. "use strict";
  89171. __webpack_require__.r(__webpack_exports__);
  89172. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return TransformNode; });
  89173. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  89174. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  89175. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  89176. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  89177. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  89178. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../node */ "./node.ts");
  89179. /**
  89180. * 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.
  89181. * @see https://doc.babylonjs.com/how_to/transformnode
  89182. */
  89183. var TransformNode = /** @class */ (function (_super) {
  89184. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TransformNode, _super);
  89185. function TransformNode(name, scene, isPure) {
  89186. if (scene === void 0) { scene = null; }
  89187. if (isPure === void 0) { isPure = true; }
  89188. var _this = _super.call(this, name, scene) || this;
  89189. _this._forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, 1);
  89190. _this._forwardInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, -1);
  89191. _this._up = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 1, 0);
  89192. _this._right = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](1, 0, 0);
  89193. _this._rightInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](-1, 0, 0);
  89194. // Properties
  89195. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89196. _this._rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89197. _this._scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].One();
  89198. _this._isDirty = false;
  89199. /**
  89200. * Set the billboard mode. Default is 0.
  89201. *
  89202. * | Value | Type | Description |
  89203. * | --- | --- | --- |
  89204. * | 0 | BILLBOARDMODE_NONE | |
  89205. * | 1 | BILLBOARDMODE_X | |
  89206. * | 2 | BILLBOARDMODE_Y | |
  89207. * | 4 | BILLBOARDMODE_Z | |
  89208. * | 7 | BILLBOARDMODE_ALL | |
  89209. *
  89210. */
  89211. _this.billboardMode = TransformNode.BILLBOARDMODE_NONE;
  89212. /**
  89213. * 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
  89214. */
  89215. _this.scalingDeterminant = 1;
  89216. /**
  89217. * Sets the distance of the object to max, often used by skybox
  89218. */
  89219. _this.infiniteDistance = false;
  89220. /**
  89221. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  89222. * By default the system will update normals to compensate
  89223. */
  89224. _this.ignoreNonUniformScaling = false;
  89225. /** @hidden */
  89226. _this._localMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  89227. _this._absolutePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89228. _this._pivotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  89229. _this._postMultiplyPivotMatrix = false;
  89230. _this._isWorldMatrixFrozen = false;
  89231. /** @hidden */
  89232. _this._indexInSceneTransformNodesArray = -1;
  89233. /**
  89234. * An event triggered after the world matrix is updated
  89235. */
  89236. _this.onAfterWorldMatrixUpdateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  89237. _this._nonUniformScaling = false;
  89238. if (isPure) {
  89239. _this.getScene().addTransformNode(_this);
  89240. }
  89241. return _this;
  89242. }
  89243. /**
  89244. * Gets a string identifying the name of the class
  89245. * @returns "TransformNode" string
  89246. */
  89247. TransformNode.prototype.getClassName = function () {
  89248. return "TransformNode";
  89249. };
  89250. Object.defineProperty(TransformNode.prototype, "position", {
  89251. /**
  89252. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  89253. */
  89254. get: function () {
  89255. return this._position;
  89256. },
  89257. set: function (newPosition) {
  89258. this._position = newPosition;
  89259. this._isDirty = true;
  89260. },
  89261. enumerable: true,
  89262. configurable: true
  89263. });
  89264. Object.defineProperty(TransformNode.prototype, "rotation", {
  89265. /**
  89266. * 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)).
  89267. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  89268. */
  89269. get: function () {
  89270. return this._rotation;
  89271. },
  89272. set: function (newRotation) {
  89273. this._rotation = newRotation;
  89274. this._isDirty = true;
  89275. },
  89276. enumerable: true,
  89277. configurable: true
  89278. });
  89279. Object.defineProperty(TransformNode.prototype, "scaling", {
  89280. /**
  89281. * 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)).
  89282. */
  89283. get: function () {
  89284. return this._scaling;
  89285. },
  89286. set: function (newScaling) {
  89287. this._scaling = newScaling;
  89288. this._isDirty = true;
  89289. },
  89290. enumerable: true,
  89291. configurable: true
  89292. });
  89293. Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
  89294. /**
  89295. * 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).
  89296. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  89297. */
  89298. get: function () {
  89299. return this._rotationQuaternion;
  89300. },
  89301. set: function (quaternion) {
  89302. this._rotationQuaternion = quaternion;
  89303. //reset the rotation vector.
  89304. if (quaternion) {
  89305. this.rotation.setAll(0.0);
  89306. }
  89307. },
  89308. enumerable: true,
  89309. configurable: true
  89310. });
  89311. Object.defineProperty(TransformNode.prototype, "forward", {
  89312. /**
  89313. * The forward direction of that transform in world space.
  89314. */
  89315. get: function () {
  89316. 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()));
  89317. },
  89318. enumerable: true,
  89319. configurable: true
  89320. });
  89321. Object.defineProperty(TransformNode.prototype, "up", {
  89322. /**
  89323. * The up direction of that transform in world space.
  89324. */
  89325. get: function () {
  89326. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormal(this._up, this.getWorldMatrix()));
  89327. },
  89328. enumerable: true,
  89329. configurable: true
  89330. });
  89331. Object.defineProperty(TransformNode.prototype, "right", {
  89332. /**
  89333. * The right direction of that transform in world space.
  89334. */
  89335. get: function () {
  89336. 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()));
  89337. },
  89338. enumerable: true,
  89339. configurable: true
  89340. });
  89341. /**
  89342. * Copies the parameter passed Matrix into the mesh Pose matrix.
  89343. * @param matrix the matrix to copy the pose from
  89344. * @returns this TransformNode.
  89345. */
  89346. TransformNode.prototype.updatePoseMatrix = function (matrix) {
  89347. this._poseMatrix.copyFrom(matrix);
  89348. return this;
  89349. };
  89350. /**
  89351. * Returns the mesh Pose matrix.
  89352. * @returns the pose matrix
  89353. */
  89354. TransformNode.prototype.getPoseMatrix = function () {
  89355. return this._poseMatrix;
  89356. };
  89357. /** @hidden */
  89358. TransformNode.prototype._isSynchronized = function () {
  89359. if (this._isDirty) {
  89360. return false;
  89361. }
  89362. if (this.billboardMode !== this._cache.billboardMode || this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  89363. return false;
  89364. }
  89365. if (this._cache.pivotMatrixUpdated) {
  89366. return false;
  89367. }
  89368. if (this.infiniteDistance) {
  89369. return false;
  89370. }
  89371. if (!this._cache.position.equals(this._position)) {
  89372. return false;
  89373. }
  89374. if (this._rotationQuaternion) {
  89375. if (!this._cache.rotationQuaternion.equals(this._rotationQuaternion)) {
  89376. return false;
  89377. }
  89378. }
  89379. if (!this._cache.rotation.equals(this._rotation)) {
  89380. return false;
  89381. }
  89382. if (!this._cache.scaling.equals(this._scaling)) {
  89383. return false;
  89384. }
  89385. return true;
  89386. };
  89387. /** @hidden */
  89388. TransformNode.prototype._initCache = function () {
  89389. _super.prototype._initCache.call(this);
  89390. this._cache.localMatrixUpdated = false;
  89391. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89392. this._cache.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89393. this._cache.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89394. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"](0, 0, 0, 0);
  89395. this._cache.billboardMode = -1;
  89396. this._cache.infiniteDistance = false;
  89397. };
  89398. /**
  89399. * Flag the transform node as dirty (Forcing it to update everything)
  89400. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  89401. * @returns this transform node
  89402. */
  89403. TransformNode.prototype.markAsDirty = function (property) {
  89404. if (property === "rotation") {
  89405. this.rotationQuaternion = null;
  89406. }
  89407. this._currentRenderId = Number.MAX_VALUE;
  89408. this._isDirty = true;
  89409. return this;
  89410. };
  89411. Object.defineProperty(TransformNode.prototype, "absolutePosition", {
  89412. /**
  89413. * Returns the current mesh absolute position.
  89414. * Returns a Vector3.
  89415. */
  89416. get: function () {
  89417. return this._absolutePosition;
  89418. },
  89419. enumerable: true,
  89420. configurable: true
  89421. });
  89422. /**
  89423. * Sets a new matrix to apply before all other transformation
  89424. * @param matrix defines the transform matrix
  89425. * @returns the current TransformNode
  89426. */
  89427. TransformNode.prototype.setPreTransformMatrix = function (matrix) {
  89428. return this.setPivotMatrix(matrix, false);
  89429. };
  89430. /**
  89431. * Sets a new pivot matrix to the current node
  89432. * @param matrix defines the new pivot matrix to use
  89433. * @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
  89434. * @returns the current TransformNode
  89435. */
  89436. TransformNode.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
  89437. if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = true; }
  89438. this._pivotMatrix.copyFrom(matrix);
  89439. this._cache.pivotMatrixUpdated = true;
  89440. this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
  89441. if (this._postMultiplyPivotMatrix) {
  89442. if (!this._pivotMatrixInverse) {
  89443. this._pivotMatrixInverse = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Invert(this._pivotMatrix);
  89444. }
  89445. else {
  89446. this._pivotMatrix.invertToRef(this._pivotMatrixInverse);
  89447. }
  89448. }
  89449. return this;
  89450. };
  89451. /**
  89452. * Returns the mesh pivot matrix.
  89453. * Default : Identity.
  89454. * @returns the matrix
  89455. */
  89456. TransformNode.prototype.getPivotMatrix = function () {
  89457. return this._pivotMatrix;
  89458. };
  89459. /**
  89460. * Prevents the World matrix to be computed any longer.
  89461. * @returns the TransformNode.
  89462. */
  89463. TransformNode.prototype.freezeWorldMatrix = function () {
  89464. this._isWorldMatrixFrozen = false; // no guarantee world is not already frozen, switch off temporarily
  89465. this.computeWorldMatrix(true);
  89466. this._isWorldMatrixFrozen = true;
  89467. return this;
  89468. };
  89469. /**
  89470. * Allows back the World matrix computation.
  89471. * @returns the TransformNode.
  89472. */
  89473. TransformNode.prototype.unfreezeWorldMatrix = function () {
  89474. this._isWorldMatrixFrozen = false;
  89475. this.computeWorldMatrix(true);
  89476. return this;
  89477. };
  89478. Object.defineProperty(TransformNode.prototype, "isWorldMatrixFrozen", {
  89479. /**
  89480. * True if the World matrix has been frozen.
  89481. */
  89482. get: function () {
  89483. return this._isWorldMatrixFrozen;
  89484. },
  89485. enumerable: true,
  89486. configurable: true
  89487. });
  89488. /**
  89489. * Retuns the mesh absolute position in the World.
  89490. * @returns a Vector3.
  89491. */
  89492. TransformNode.prototype.getAbsolutePosition = function () {
  89493. this.computeWorldMatrix();
  89494. return this._absolutePosition;
  89495. };
  89496. /**
  89497. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  89498. * @param absolutePosition the absolute position to set
  89499. * @returns the TransformNode.
  89500. */
  89501. TransformNode.prototype.setAbsolutePosition = function (absolutePosition) {
  89502. if (!absolutePosition) {
  89503. return this;
  89504. }
  89505. var absolutePositionX;
  89506. var absolutePositionY;
  89507. var absolutePositionZ;
  89508. if (absolutePosition.x === undefined) {
  89509. if (arguments.length < 3) {
  89510. return this;
  89511. }
  89512. absolutePositionX = arguments[0];
  89513. absolutePositionY = arguments[1];
  89514. absolutePositionZ = arguments[2];
  89515. }
  89516. else {
  89517. absolutePositionX = absolutePosition.x;
  89518. absolutePositionY = absolutePosition.y;
  89519. absolutePositionZ = absolutePosition.z;
  89520. }
  89521. if (this.parent) {
  89522. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  89523. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  89524. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesFromFloatsToRef(absolutePositionX, absolutePositionY, absolutePositionZ, invertParentWorldMatrix, this.position);
  89525. }
  89526. else {
  89527. this.position.x = absolutePositionX;
  89528. this.position.y = absolutePositionY;
  89529. this.position.z = absolutePositionZ;
  89530. }
  89531. return this;
  89532. };
  89533. /**
  89534. * Sets the mesh position in its local space.
  89535. * @param vector3 the position to set in localspace
  89536. * @returns the TransformNode.
  89537. */
  89538. TransformNode.prototype.setPositionWithLocalVector = function (vector3) {
  89539. this.computeWorldMatrix();
  89540. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormal(vector3, this._localMatrix);
  89541. return this;
  89542. };
  89543. /**
  89544. * Returns the mesh position in the local space from the current World matrix values.
  89545. * @returns a new Vector3.
  89546. */
  89547. TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
  89548. this.computeWorldMatrix();
  89549. var invLocalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  89550. this._localMatrix.invertToRef(invLocalWorldMatrix);
  89551. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormal(this.position, invLocalWorldMatrix);
  89552. };
  89553. /**
  89554. * Translates the mesh along the passed Vector3 in its local space.
  89555. * @param vector3 the distance to translate in localspace
  89556. * @returns the TransformNode.
  89557. */
  89558. TransformNode.prototype.locallyTranslate = function (vector3) {
  89559. this.computeWorldMatrix(true);
  89560. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(vector3, this._localMatrix);
  89561. return this;
  89562. };
  89563. /**
  89564. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  89565. * @param targetPoint the position (must be in same space as current mesh) to look at
  89566. * @param yawCor optional yaw (y-axis) correction in radians
  89567. * @param pitchCor optional pitch (x-axis) correction in radians
  89568. * @param rollCor optional roll (z-axis) correction in radians
  89569. * @param space the choosen space of the target
  89570. * @returns the TransformNode.
  89571. */
  89572. TransformNode.prototype.lookAt = function (targetPoint, yawCor, pitchCor, rollCor, space) {
  89573. if (yawCor === void 0) { yawCor = 0; }
  89574. if (pitchCor === void 0) { pitchCor = 0; }
  89575. if (rollCor === void 0) { rollCor = 0; }
  89576. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  89577. var dv = TransformNode._lookAtVectorCache;
  89578. var pos = space === _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL ? this.position : this.getAbsolutePosition();
  89579. targetPoint.subtractToRef(pos, dv);
  89580. this.setDirection(dv, yawCor, pitchCor, rollCor);
  89581. // Correct for parent's rotation offset
  89582. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].WORLD && this.parent) {
  89583. if (this.rotationQuaternion) {
  89584. // Get local rotation matrix of the looking object
  89585. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  89586. this.rotationQuaternion.toRotationMatrix(rotationMatrix);
  89587. // Offset rotation by parent's inverted rotation matrix to correct in world space
  89588. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1];
  89589. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  89590. parentRotationMatrix.invert();
  89591. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  89592. this.rotationQuaternion.fromRotationMatrix(rotationMatrix);
  89593. }
  89594. else {
  89595. // Get local rotation matrix of the looking object
  89596. var quaternionRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  89597. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].FromEulerVectorToRef(this.rotation, quaternionRotation);
  89598. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  89599. quaternionRotation.toRotationMatrix(rotationMatrix);
  89600. // Offset rotation by parent's inverted rotation matrix to correct in world space
  89601. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1];
  89602. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  89603. parentRotationMatrix.invert();
  89604. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  89605. quaternionRotation.fromRotationMatrix(rotationMatrix);
  89606. quaternionRotation.toEulerAnglesToRef(this.rotation);
  89607. }
  89608. }
  89609. return this;
  89610. };
  89611. /**
  89612. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  89613. * This Vector3 is expressed in the World space.
  89614. * @param localAxis axis to rotate
  89615. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  89616. */
  89617. TransformNode.prototype.getDirection = function (localAxis) {
  89618. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89619. this.getDirectionToRef(localAxis, result);
  89620. return result;
  89621. };
  89622. /**
  89623. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  89624. * localAxis is expressed in the mesh local space.
  89625. * result is computed in the Wordl space from the mesh World matrix.
  89626. * @param localAxis axis to rotate
  89627. * @param result the resulting transformnode
  89628. * @returns this TransformNode.
  89629. */
  89630. TransformNode.prototype.getDirectionToRef = function (localAxis, result) {
  89631. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  89632. return this;
  89633. };
  89634. /**
  89635. * Sets this transform node rotation to the given local axis.
  89636. * @param localAxis the axis in local space
  89637. * @param yawCor optional yaw (y-axis) correction in radians
  89638. * @param pitchCor optional pitch (x-axis) correction in radians
  89639. * @param rollCor optional roll (z-axis) correction in radians
  89640. * @returns this TransformNode
  89641. */
  89642. TransformNode.prototype.setDirection = function (localAxis, yawCor, pitchCor, rollCor) {
  89643. if (yawCor === void 0) { yawCor = 0; }
  89644. if (pitchCor === void 0) { pitchCor = 0; }
  89645. if (rollCor === void 0) { rollCor = 0; }
  89646. var yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;
  89647. var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
  89648. var pitch = -Math.atan2(localAxis.y, len);
  89649. if (this.rotationQuaternion) {
  89650. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
  89651. }
  89652. else {
  89653. this.rotation.x = pitch + pitchCor;
  89654. this.rotation.y = yaw + yawCor;
  89655. this.rotation.z = rollCor;
  89656. }
  89657. return this;
  89658. };
  89659. /**
  89660. * Sets a new pivot point to the current node
  89661. * @param point defines the new pivot point to use
  89662. * @param space defines if the point is in world or local space (local by default)
  89663. * @returns the current TransformNode
  89664. */
  89665. TransformNode.prototype.setPivotPoint = function (point, space) {
  89666. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  89667. if (this.getScene().getRenderId() == 0) {
  89668. this.computeWorldMatrix(true);
  89669. }
  89670. var wm = this.getWorldMatrix();
  89671. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].WORLD) {
  89672. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  89673. wm.invertToRef(tmat);
  89674. point = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(point, tmat);
  89675. }
  89676. return this.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(-point.x, -point.y, -point.z), true);
  89677. };
  89678. /**
  89679. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  89680. * @returns the pivot point
  89681. */
  89682. TransformNode.prototype.getPivotPoint = function () {
  89683. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89684. this.getPivotPointToRef(point);
  89685. return point;
  89686. };
  89687. /**
  89688. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  89689. * @param result the vector3 to store the result
  89690. * @returns this TransformNode.
  89691. */
  89692. TransformNode.prototype.getPivotPointToRef = function (result) {
  89693. result.x = -this._pivotMatrix.m[12];
  89694. result.y = -this._pivotMatrix.m[13];
  89695. result.z = -this._pivotMatrix.m[14];
  89696. return this;
  89697. };
  89698. /**
  89699. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  89700. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  89701. */
  89702. TransformNode.prototype.getAbsolutePivotPoint = function () {
  89703. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89704. this.getAbsolutePivotPointToRef(point);
  89705. return point;
  89706. };
  89707. /**
  89708. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  89709. * @param result vector3 to store the result
  89710. * @returns this TransformNode.
  89711. */
  89712. TransformNode.prototype.getAbsolutePivotPointToRef = function (result) {
  89713. result.x = this._pivotMatrix.m[12];
  89714. result.y = this._pivotMatrix.m[13];
  89715. result.z = this._pivotMatrix.m[14];
  89716. this.getPivotPointToRef(result);
  89717. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(result, this.getWorldMatrix(), result);
  89718. return this;
  89719. };
  89720. /**
  89721. * Defines the passed node as the parent of the current node.
  89722. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  89723. * @param node the node ot set as the parent
  89724. * @returns this TransformNode.
  89725. */
  89726. TransformNode.prototype.setParent = function (node) {
  89727. if (!node && !this.parent) {
  89728. return this;
  89729. }
  89730. var quatRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  89731. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  89732. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  89733. if (!node) {
  89734. if (this.parent && this.parent.computeWorldMatrix) {
  89735. this.parent.computeWorldMatrix(true);
  89736. }
  89737. this.computeWorldMatrix(true);
  89738. this.getWorldMatrix().decompose(scale, quatRotation, position);
  89739. }
  89740. else {
  89741. var diffMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  89742. var invParentMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1];
  89743. this.computeWorldMatrix(true);
  89744. node.computeWorldMatrix(true);
  89745. node.getWorldMatrix().invertToRef(invParentMatrix);
  89746. this.getWorldMatrix().multiplyToRef(invParentMatrix, diffMatrix);
  89747. diffMatrix.decompose(scale, quatRotation, position);
  89748. }
  89749. if (this.rotationQuaternion) {
  89750. this.rotationQuaternion.copyFrom(quatRotation);
  89751. }
  89752. else {
  89753. quatRotation.toEulerAnglesToRef(this.rotation);
  89754. }
  89755. this.scaling.copyFrom(scale);
  89756. this.position.copyFrom(position);
  89757. this.parent = node;
  89758. return this;
  89759. };
  89760. Object.defineProperty(TransformNode.prototype, "nonUniformScaling", {
  89761. /**
  89762. * True if the scaling property of this object is non uniform eg. (1,2,1)
  89763. */
  89764. get: function () {
  89765. return this._nonUniformScaling;
  89766. },
  89767. enumerable: true,
  89768. configurable: true
  89769. });
  89770. /** @hidden */
  89771. TransformNode.prototype._updateNonUniformScalingState = function (value) {
  89772. if (this._nonUniformScaling === value) {
  89773. return false;
  89774. }
  89775. this._nonUniformScaling = value;
  89776. return true;
  89777. };
  89778. /**
  89779. * Attach the current TransformNode to another TransformNode associated with a bone
  89780. * @param bone Bone affecting the TransformNode
  89781. * @param affectedTransformNode TransformNode associated with the bone
  89782. * @returns this object
  89783. */
  89784. TransformNode.prototype.attachToBone = function (bone, affectedTransformNode) {
  89785. this._transformToBoneReferal = affectedTransformNode;
  89786. this.parent = bone;
  89787. if (bone.getWorldMatrix().determinant() < 0) {
  89788. this.scalingDeterminant *= -1;
  89789. }
  89790. return this;
  89791. };
  89792. /**
  89793. * Detach the transform node if its associated with a bone
  89794. * @returns this object
  89795. */
  89796. TransformNode.prototype.detachFromBone = function () {
  89797. if (!this.parent) {
  89798. return this;
  89799. }
  89800. if (this.parent.getWorldMatrix().determinant() < 0) {
  89801. this.scalingDeterminant *= -1;
  89802. }
  89803. this._transformToBoneReferal = null;
  89804. this.parent = null;
  89805. return this;
  89806. };
  89807. /**
  89808. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  89809. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  89810. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  89811. * The passed axis is also normalized.
  89812. * @param axis the axis to rotate around
  89813. * @param amount the amount to rotate in radians
  89814. * @param space Space to rotate in (Default: local)
  89815. * @returns the TransformNode.
  89816. */
  89817. TransformNode.prototype.rotate = function (axis, amount, space) {
  89818. axis.normalize();
  89819. if (!this.rotationQuaternion) {
  89820. this.rotationQuaternion = this.rotation.toQuaternion();
  89821. this.rotation.setAll(0);
  89822. }
  89823. var rotationQuaternion;
  89824. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL) {
  89825. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  89826. this.rotationQuaternion.multiplyToRef(rotationQuaternion, this.rotationQuaternion);
  89827. }
  89828. else {
  89829. if (this.parent) {
  89830. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  89831. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  89832. axis = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormal(axis, invertParentWorldMatrix);
  89833. }
  89834. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  89835. rotationQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  89836. }
  89837. return this;
  89838. };
  89839. /**
  89840. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  89841. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  89842. * The passed axis is also normalized. .
  89843. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  89844. * @param point the point to rotate around
  89845. * @param axis the axis to rotate around
  89846. * @param amount the amount to rotate in radians
  89847. * @returns the TransformNode
  89848. */
  89849. TransformNode.prototype.rotateAround = function (point, axis, amount) {
  89850. axis.normalize();
  89851. if (!this.rotationQuaternion) {
  89852. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  89853. this.rotation.setAll(0);
  89854. }
  89855. var tmpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  89856. var finalScale = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  89857. var finalTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[2];
  89858. var finalRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  89859. var translationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]; // T
  89860. var translationMatrixInv = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1]; // T'
  89861. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[2]; // R
  89862. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[3]; // T' x R x T
  89863. point.subtractToRef(this.position, tmpVector);
  89864. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(tmpVector.x, tmpVector.y, tmpVector.z, translationMatrix); // T
  89865. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(-tmpVector.x, -tmpVector.y, -tmpVector.z, translationMatrixInv); // T'
  89866. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationAxisToRef(axis, amount, rotationMatrix); // R
  89867. translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R
  89868. finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x T
  89869. finalMatrix.decompose(finalScale, finalRotation, finalTranslation);
  89870. this.position.addInPlace(finalTranslation);
  89871. finalRotation.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  89872. return this;
  89873. };
  89874. /**
  89875. * Translates the mesh along the axis vector for the passed distance in the given space.
  89876. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  89877. * @param axis the axis to translate in
  89878. * @param distance the distance to translate
  89879. * @param space Space to rotate in (Default: local)
  89880. * @returns the TransformNode.
  89881. */
  89882. TransformNode.prototype.translate = function (axis, distance, space) {
  89883. var displacementVector = axis.scale(distance);
  89884. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL) {
  89885. var tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
  89886. this.setPositionWithLocalVector(tempV3);
  89887. }
  89888. else {
  89889. this.setAbsolutePosition(this.getAbsolutePosition().add(displacementVector));
  89890. }
  89891. return this;
  89892. };
  89893. /**
  89894. * Adds a rotation step to the mesh current rotation.
  89895. * x, y, z are Euler angles expressed in radians.
  89896. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  89897. * This means this rotation is made in the mesh local space only.
  89898. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  89899. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  89900. * ```javascript
  89901. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  89902. * ```
  89903. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  89904. * 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.
  89905. * @param x Rotation to add
  89906. * @param y Rotation to add
  89907. * @param z Rotation to add
  89908. * @returns the TransformNode.
  89909. */
  89910. TransformNode.prototype.addRotation = function (x, y, z) {
  89911. var rotationQuaternion;
  89912. if (this.rotationQuaternion) {
  89913. rotationQuaternion = this.rotationQuaternion;
  89914. }
  89915. else {
  89916. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[1];
  89917. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, rotationQuaternion);
  89918. }
  89919. var accumulation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  89920. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRollToRef(y, x, z, accumulation);
  89921. rotationQuaternion.multiplyInPlace(accumulation);
  89922. if (!this.rotationQuaternion) {
  89923. rotationQuaternion.toEulerAnglesToRef(this.rotation);
  89924. }
  89925. return this;
  89926. };
  89927. /**
  89928. * Computes the world matrix of the node
  89929. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89930. * @returns the world matrix
  89931. */
  89932. TransformNode.prototype.computeWorldMatrix = function (force) {
  89933. if (this._isWorldMatrixFrozen) {
  89934. return this._worldMatrix;
  89935. }
  89936. if (!force && this.isSynchronized()) {
  89937. this._currentRenderId = this.getScene().getRenderId();
  89938. return this._worldMatrix;
  89939. }
  89940. this._updateCache();
  89941. this._cache.position.copyFrom(this.position);
  89942. this._cache.scaling.copyFrom(this.scaling);
  89943. this._cache.pivotMatrixUpdated = false;
  89944. this._cache.billboardMode = this.billboardMode;
  89945. this._cache.infiniteDistance = this.infiniteDistance;
  89946. this._currentRenderId = this.getScene().getRenderId();
  89947. this._childRenderId = this.getScene().getRenderId();
  89948. this._isDirty = false;
  89949. // Scaling
  89950. _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]);
  89951. // Rotation
  89952. //rotate, if quaternion is set and rotation was used
  89953. if (this.rotationQuaternion) {
  89954. var len = this.rotation.length();
  89955. if (len) {
  89956. this.rotationQuaternion.multiplyInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z));
  89957. this.rotation.copyFromFloats(0, 0, 0);
  89958. }
  89959. }
  89960. if (this.rotationQuaternion) {
  89961. this.rotationQuaternion.toRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]);
  89962. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  89963. }
  89964. else {
  89965. _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]);
  89966. this._cache.rotation.copyFrom(this.rotation);
  89967. }
  89968. // Translation
  89969. var camera = this.getScene().activeCamera;
  89970. if (this.infiniteDistance && !this.parent && camera) {
  89971. var cameraWorldMatrix = camera.getWorldMatrix();
  89972. var cameraGlobalPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](cameraWorldMatrix.m[12], cameraWorldMatrix.m[13], cameraWorldMatrix.m[14]);
  89973. _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]);
  89974. }
  89975. else {
  89976. _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]);
  89977. }
  89978. // Composing transformations
  89979. this._pivotMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1], _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[4]);
  89980. _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]);
  89981. // Billboarding (testing PG:http://www.babylonjs-playground.com/#UJEIL#13)
  89982. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE && camera) {
  89983. if ((this.billboardMode & TransformNode.BILLBOARDMODE_ALL) !== TransformNode.BILLBOARDMODE_ALL) {
  89984. // Need to decompose each rotation here
  89985. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[3];
  89986. if (this.parent && this.parent.getWorldMatrix) {
  89987. if (this._transformToBoneReferal) {
  89988. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6]);
  89989. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this.position, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6], currentPosition);
  89990. }
  89991. else {
  89992. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), currentPosition);
  89993. }
  89994. }
  89995. else {
  89996. currentPosition.copyFrom(this.position);
  89997. }
  89998. currentPosition.subtractInPlace(camera.globalPosition);
  89999. var finalEuler = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[4].copyFromFloats(0, 0, 0);
  90000. if ((this.billboardMode & TransformNode.BILLBOARDMODE_X) === TransformNode.BILLBOARDMODE_X) {
  90001. finalEuler.x = Math.atan2(-currentPosition.y, currentPosition.z);
  90002. }
  90003. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Y) === TransformNode.BILLBOARDMODE_Y) {
  90004. finalEuler.y = Math.atan2(currentPosition.x, currentPosition.z);
  90005. }
  90006. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Z) === TransformNode.BILLBOARDMODE_Z) {
  90007. finalEuler.z = Math.atan2(currentPosition.y, currentPosition.x);
  90008. }
  90009. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(finalEuler.y, finalEuler.x, finalEuler.z, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]);
  90010. }
  90011. else {
  90012. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1].copyFrom(camera.getViewMatrix());
  90013. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1].setTranslationFromFloats(0, 0, 0);
  90014. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1].invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]);
  90015. }
  90016. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1].copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5]);
  90017. _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]);
  90018. }
  90019. // Post multiply inverse of pivotMatrix
  90020. if (this._postMultiplyPivotMatrix) {
  90021. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5].multiplyToRef(this._pivotMatrixInverse, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5]);
  90022. }
  90023. // Local world
  90024. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[2], this._localMatrix);
  90025. // Parent
  90026. if (this.parent && this.parent.getWorldMatrix) {
  90027. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  90028. if (this._transformToBoneReferal) {
  90029. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6]);
  90030. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5].copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6]);
  90031. }
  90032. else {
  90033. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5].copyFrom(this.parent.getWorldMatrix());
  90034. }
  90035. this._localMatrix.getTranslationToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[5]);
  90036. _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]);
  90037. this._worldMatrix.copyFrom(this._localMatrix);
  90038. this._worldMatrix.setTranslation(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[5]);
  90039. }
  90040. else {
  90041. if (this._transformToBoneReferal) {
  90042. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6]);
  90043. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix);
  90044. }
  90045. else {
  90046. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  90047. }
  90048. }
  90049. this._markSyncedWithParent();
  90050. }
  90051. else {
  90052. this._worldMatrix.copyFrom(this._localMatrix);
  90053. }
  90054. // Normal matrix
  90055. if (!this.ignoreNonUniformScaling) {
  90056. if (this.scaling.isNonUniform) {
  90057. this._updateNonUniformScalingState(true);
  90058. }
  90059. else if (this.parent && this.parent._nonUniformScaling) {
  90060. this._updateNonUniformScalingState(this.parent._nonUniformScaling);
  90061. }
  90062. else {
  90063. this._updateNonUniformScalingState(false);
  90064. }
  90065. }
  90066. else {
  90067. this._updateNonUniformScalingState(false);
  90068. }
  90069. this._afterComputeWorldMatrix();
  90070. // Absolute position
  90071. this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
  90072. // Callbacks
  90073. this.onAfterWorldMatrixUpdateObservable.notifyObservers(this);
  90074. if (!this._poseMatrix) {
  90075. this._poseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Invert(this._worldMatrix);
  90076. }
  90077. // Cache the determinant
  90078. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  90079. return this._worldMatrix;
  90080. };
  90081. TransformNode.prototype._afterComputeWorldMatrix = function () {
  90082. };
  90083. /**
  90084. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  90085. * @param func callback function to add
  90086. *
  90087. * @returns the TransformNode.
  90088. */
  90089. TransformNode.prototype.registerAfterWorldMatrixUpdate = function (func) {
  90090. this.onAfterWorldMatrixUpdateObservable.add(func);
  90091. return this;
  90092. };
  90093. /**
  90094. * Removes a registered callback function.
  90095. * @param func callback function to remove
  90096. * @returns the TransformNode.
  90097. */
  90098. TransformNode.prototype.unregisterAfterWorldMatrixUpdate = function (func) {
  90099. this.onAfterWorldMatrixUpdateObservable.removeCallback(func);
  90100. return this;
  90101. };
  90102. /**
  90103. * Gets the position of the current mesh in camera space
  90104. * @param camera defines the camera to use
  90105. * @returns a position
  90106. */
  90107. TransformNode.prototype.getPositionInCameraSpace = function (camera) {
  90108. if (camera === void 0) { camera = null; }
  90109. if (!camera) {
  90110. camera = this.getScene().activeCamera;
  90111. }
  90112. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(this.absolutePosition, camera.getViewMatrix());
  90113. };
  90114. /**
  90115. * Returns the distance from the mesh to the active camera
  90116. * @param camera defines the camera to use
  90117. * @returns the distance
  90118. */
  90119. TransformNode.prototype.getDistanceToCamera = function (camera) {
  90120. if (camera === void 0) { camera = null; }
  90121. if (!camera) {
  90122. camera = this.getScene().activeCamera;
  90123. }
  90124. return this.absolutePosition.subtract(camera.position).length();
  90125. };
  90126. /**
  90127. * Clone the current transform node
  90128. * @param name Name of the new clone
  90129. * @param newParent New parent for the clone
  90130. * @param doNotCloneChildren Do not clone children hierarchy
  90131. * @returns the new transform node
  90132. */
  90133. TransformNode.prototype.clone = function (name, newParent, doNotCloneChildren) {
  90134. var _this = this;
  90135. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new TransformNode(name, _this.getScene()); }, this);
  90136. result.name = name;
  90137. result.id = name;
  90138. if (newParent) {
  90139. result.parent = newParent;
  90140. }
  90141. if (!doNotCloneChildren) {
  90142. // Children
  90143. var directDescendants = this.getDescendants(true);
  90144. for (var index = 0; index < directDescendants.length; index++) {
  90145. var child = directDescendants[index];
  90146. if (child.clone) {
  90147. child.clone(name + "." + child.name, result);
  90148. }
  90149. }
  90150. }
  90151. return result;
  90152. };
  90153. /**
  90154. * Serializes the objects information.
  90155. * @param currentSerializationObject defines the object to serialize in
  90156. * @returns the serialized object
  90157. */
  90158. TransformNode.prototype.serialize = function (currentSerializationObject) {
  90159. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, currentSerializationObject);
  90160. serializationObject.type = this.getClassName();
  90161. // Parent
  90162. if (this.parent) {
  90163. serializationObject.parentId = this.parent.id;
  90164. }
  90165. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].HasTags(this)) {
  90166. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].GetTags(this);
  90167. }
  90168. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  90169. serializationObject.isEnabled = this.isEnabled();
  90170. // Parent
  90171. if (this.parent) {
  90172. serializationObject.parentId = this.parent.id;
  90173. }
  90174. return serializationObject;
  90175. };
  90176. // Statics
  90177. /**
  90178. * Returns a new TransformNode object parsed from the source provided.
  90179. * @param parsedTransformNode is the source.
  90180. * @param scene the scne the object belongs to
  90181. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  90182. * @returns a new TransformNode object parsed from the source provided.
  90183. */
  90184. TransformNode.Parse = function (parsedTransformNode, scene, rootUrl) {
  90185. var transformNode = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new TransformNode(parsedTransformNode.name, scene); }, parsedTransformNode, scene, rootUrl);
  90186. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  90187. _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].AddTagsTo(transformNode, parsedTransformNode.tags);
  90188. }
  90189. if (parsedTransformNode.localMatrix) {
  90190. transformNode.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArray(parsedTransformNode.localMatrix));
  90191. }
  90192. else if (parsedTransformNode.pivotMatrix) {
  90193. transformNode.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArray(parsedTransformNode.pivotMatrix));
  90194. }
  90195. transformNode.setEnabled(parsedTransformNode.isEnabled);
  90196. // Parent
  90197. if (parsedTransformNode.parentId) {
  90198. transformNode._waitingParentId = parsedTransformNode.parentId;
  90199. }
  90200. return transformNode;
  90201. };
  90202. /**
  90203. * Get all child-transformNodes of this node
  90204. * @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
  90205. * @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
  90206. * @returns an array of TransformNode
  90207. */
  90208. TransformNode.prototype.getChildTransformNodes = function (directDescendantsOnly, predicate) {
  90209. var results = [];
  90210. this._getDescendants(results, directDescendantsOnly, function (node) {
  90211. return ((!predicate || predicate(node)) && (node instanceof TransformNode));
  90212. });
  90213. return results;
  90214. };
  90215. /**
  90216. * Releases resources associated with this transform node.
  90217. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90218. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90219. */
  90220. TransformNode.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  90221. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  90222. // Animations
  90223. this.getScene().stopAnimation(this);
  90224. // Remove from scene
  90225. this.getScene().removeTransformNode(this);
  90226. this.onAfterWorldMatrixUpdateObservable.clear();
  90227. if (doNotRecurse) {
  90228. var transformNodes = this.getChildTransformNodes(true);
  90229. for (var _i = 0, transformNodes_1 = transformNodes; _i < transformNodes_1.length; _i++) {
  90230. var transformNode = transformNodes_1[_i];
  90231. transformNode.parent = null;
  90232. transformNode.computeWorldMatrix(true);
  90233. }
  90234. }
  90235. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  90236. };
  90237. // Statics
  90238. /**
  90239. * Object will not rotate to face the camera
  90240. */
  90241. TransformNode.BILLBOARDMODE_NONE = 0;
  90242. /**
  90243. * Object will rotate to face the camera but only on the x axis
  90244. */
  90245. TransformNode.BILLBOARDMODE_X = 1;
  90246. /**
  90247. * Object will rotate to face the camera but only on the y axis
  90248. */
  90249. TransformNode.BILLBOARDMODE_Y = 2;
  90250. /**
  90251. * Object will rotate to face the camera but only on the z axis
  90252. */
  90253. TransformNode.BILLBOARDMODE_Z = 4;
  90254. /**
  90255. * Object will rotate to face the camera
  90256. */
  90257. TransformNode.BILLBOARDMODE_ALL = 7;
  90258. TransformNode._lookAtVectorCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, 0);
  90259. TransformNode._rotationAxisCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]();
  90260. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90261. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  90262. ], TransformNode.prototype, "_position", void 0);
  90263. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90264. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("rotation")
  90265. ], TransformNode.prototype, "_rotation", void 0);
  90266. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90267. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsQuaternion"])("rotationQuaternion")
  90268. ], TransformNode.prototype, "_rotationQuaternion", void 0);
  90269. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90270. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("scaling")
  90271. ], TransformNode.prototype, "_scaling", void 0);
  90272. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90273. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  90274. ], TransformNode.prototype, "billboardMode", void 0);
  90275. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90276. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  90277. ], TransformNode.prototype, "scalingDeterminant", void 0);
  90278. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90279. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  90280. ], TransformNode.prototype, "infiniteDistance", void 0);
  90281. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90282. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  90283. ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
  90284. return TransformNode;
  90285. }(_node__WEBPACK_IMPORTED_MODULE_5__["Node"]));
  90286. /***/ }),
  90287. /***/ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts":
  90288. /*!***************************************************************!*\
  90289. !*** ./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts ***!
  90290. \***************************************************************/
  90291. /*! exports provided: CubeMapToSphericalPolynomialTools */
  90292. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90293. "use strict";
  90294. __webpack_require__.r(__webpack_exports__);
  90295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return CubeMapToSphericalPolynomialTools; });
  90296. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  90297. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  90298. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  90299. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  90300. var FileFaceOrientation = /** @class */ (function () {
  90301. function FileFaceOrientation(name, worldAxisForNormal, worldAxisForFileX, worldAxisForFileY) {
  90302. this.name = name;
  90303. this.worldAxisForNormal = worldAxisForNormal;
  90304. this.worldAxisForFileX = worldAxisForFileX;
  90305. this.worldAxisForFileY = worldAxisForFileY;
  90306. }
  90307. return FileFaceOrientation;
  90308. }());
  90309. /**
  90310. * Helper class dealing with the extraction of spherical polynomial dataArray
  90311. * from a cube map.
  90312. */
  90313. var CubeMapToSphericalPolynomialTools = /** @class */ (function () {
  90314. function CubeMapToSphericalPolynomialTools() {
  90315. }
  90316. /**
  90317. * Converts a texture to the according Spherical Polynomial data.
  90318. * This extracts the first 3 orders only as they are the only one used in the lighting.
  90319. *
  90320. * @param texture The texture to extract the information from.
  90321. * @return The Spherical Polynomial data.
  90322. */
  90323. CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial = function (texture) {
  90324. if (!texture.isCube) {
  90325. // Only supports cube Textures currently.
  90326. return null;
  90327. }
  90328. var size = texture.getSize().width;
  90329. var right = texture.readPixels(0);
  90330. var left = texture.readPixels(1);
  90331. var up;
  90332. var down;
  90333. if (texture.isRenderTarget) {
  90334. up = texture.readPixels(3);
  90335. down = texture.readPixels(2);
  90336. }
  90337. else {
  90338. up = texture.readPixels(2);
  90339. down = texture.readPixels(3);
  90340. }
  90341. var front = texture.readPixels(4);
  90342. var back = texture.readPixels(5);
  90343. var gammaSpace = texture.gammaSpace;
  90344. // Always read as RGBA.
  90345. var format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA;
  90346. var type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  90347. if (texture.textureType && texture.textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  90348. type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_FLOAT;
  90349. }
  90350. var cubeInfo = {
  90351. size: size,
  90352. right: right,
  90353. left: left,
  90354. up: up,
  90355. down: down,
  90356. front: front,
  90357. back: back,
  90358. format: format,
  90359. type: type,
  90360. gammaSpace: gammaSpace,
  90361. };
  90362. return this.ConvertCubeMapToSphericalPolynomial(cubeInfo);
  90363. };
  90364. /**
  90365. * Converts a cubemap to the according Spherical Polynomial data.
  90366. * This extracts the first 3 orders only as they are the only one used in the lighting.
  90367. *
  90368. * @param cubeInfo The Cube map to extract the information from.
  90369. * @return The Spherical Polynomial data.
  90370. */
  90371. CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial = function (cubeInfo) {
  90372. var sphericalHarmonics = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]();
  90373. var totalSolidAngle = 0.0;
  90374. // The (u,v) range is [-1,+1], so the distance between each texel is 2/Size.
  90375. var du = 2.0 / cubeInfo.size;
  90376. var dv = du;
  90377. // The (u,v) of the first texel is half a texel from the corner (-1,-1).
  90378. var minUV = du * 0.5 - 1.0;
  90379. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  90380. var fileFace = this.FileFaces[faceIndex];
  90381. var dataArray = cubeInfo[fileFace.name];
  90382. var v = minUV;
  90383. // TODO: we could perform the summation directly into a SphericalPolynomial (SP), which is more efficient than SphericalHarmonic (SH).
  90384. // This is possible because during the summation we do not need the SH-specific properties, e.g. orthogonality.
  90385. // Because SP is still linear, so summation is fine in that basis.
  90386. var stride = cubeInfo.format === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA ? 4 : 3;
  90387. for (var y = 0; y < cubeInfo.size; y++) {
  90388. var u = minUV;
  90389. for (var x = 0; x < cubeInfo.size; x++) {
  90390. // World direction (not normalised)
  90391. var worldDirection = fileFace.worldAxisForFileX.scale(u).add(fileFace.worldAxisForFileY.scale(v)).add(fileFace.worldAxisForNormal);
  90392. worldDirection.normalize();
  90393. var deltaSolidAngle = Math.pow(1.0 + u * u + v * v, -3.0 / 2.0);
  90394. var r = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 0];
  90395. var g = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 1];
  90396. var b = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 2];
  90397. // Handle Integer types.
  90398. if (cubeInfo.type === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  90399. r /= 255;
  90400. g /= 255;
  90401. b /= 255;
  90402. }
  90403. // Handle Gamma space textures.
  90404. if (cubeInfo.gammaSpace) {
  90405. r = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(r), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  90406. g = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(g), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  90407. b = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(b), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  90408. }
  90409. var color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](r, g, b);
  90410. sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);
  90411. totalSolidAngle += deltaSolidAngle;
  90412. u += du;
  90413. }
  90414. v += dv;
  90415. }
  90416. }
  90417. // Solid angle for entire sphere is 4*pi
  90418. var sphereSolidAngle = 4.0 * Math.PI;
  90419. // Adjust the solid angle to allow for how many faces we processed.
  90420. var facesProcessed = 6.0;
  90421. var expectedSolidAngle = sphereSolidAngle * facesProcessed / 6.0;
  90422. // Adjust the harmonics so that the accumulated solid angle matches the expected solid angle.
  90423. // This is needed because the numerical integration over the cube uses a
  90424. // small angle approximation of solid angle for each texel (see deltaSolidAngle),
  90425. // and also to compensate for accumulative error due to float precision in the summation.
  90426. var correctionFactor = expectedSolidAngle / totalSolidAngle;
  90427. sphericalHarmonics.scale(correctionFactor);
  90428. sphericalHarmonics.convertIncidentRadianceToIrradiance();
  90429. sphericalHarmonics.convertIrradianceToLambertianRadiance();
  90430. return _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"].FromHarmonics(sphericalHarmonics);
  90431. };
  90432. CubeMapToSphericalPolynomialTools.FileFaces = [
  90433. 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)),
  90434. 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)),
  90435. 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)),
  90436. 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)),
  90437. 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)),
  90438. 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
  90439. ];
  90440. return CubeMapToSphericalPolynomialTools;
  90441. }());
  90442. /***/ }),
  90443. /***/ "./Misc/HighDynamicRange/hdr.ts":
  90444. /*!**************************************!*\
  90445. !*** ./Misc/HighDynamicRange/hdr.ts ***!
  90446. \**************************************/
  90447. /*! exports provided: HDRTools */
  90448. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90449. "use strict";
  90450. __webpack_require__.r(__webpack_exports__);
  90451. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return HDRTools; });
  90452. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  90453. /**
  90454. * This groups tools to convert HDR texture to native colors array.
  90455. */
  90456. var HDRTools = /** @class */ (function () {
  90457. function HDRTools() {
  90458. }
  90459. HDRTools.Ldexp = function (mantissa, exponent) {
  90460. if (exponent > 1023) {
  90461. return mantissa * Math.pow(2, 1023) * Math.pow(2, exponent - 1023);
  90462. }
  90463. if (exponent < -1074) {
  90464. return mantissa * Math.pow(2, -1074) * Math.pow(2, exponent + 1074);
  90465. }
  90466. return mantissa * Math.pow(2, exponent);
  90467. };
  90468. HDRTools.Rgbe2float = function (float32array, red, green, blue, exponent, index) {
  90469. if (exponent > 0) { /*nonzero pixel*/
  90470. exponent = this.Ldexp(1.0, exponent - (128 + 8));
  90471. float32array[index + 0] = red * exponent;
  90472. float32array[index + 1] = green * exponent;
  90473. float32array[index + 2] = blue * exponent;
  90474. }
  90475. else {
  90476. float32array[index + 0] = 0;
  90477. float32array[index + 1] = 0;
  90478. float32array[index + 2] = 0;
  90479. }
  90480. };
  90481. HDRTools.readStringLine = function (uint8array, startIndex) {
  90482. var line = "";
  90483. var character = "";
  90484. for (var i = startIndex; i < uint8array.length - startIndex; i++) {
  90485. character = String.fromCharCode(uint8array[i]);
  90486. if (character == "\n") {
  90487. break;
  90488. }
  90489. line += character;
  90490. }
  90491. return line;
  90492. };
  90493. /**
  90494. * Reads header information from an RGBE texture stored in a native array.
  90495. * More information on this format are available here:
  90496. * https://en.wikipedia.org/wiki/RGBE_image_format
  90497. *
  90498. * @param uint8array The binary file stored in native array.
  90499. * @return The header information.
  90500. */
  90501. HDRTools.RGBE_ReadHeader = function (uint8array) {
  90502. var height = 0;
  90503. var width = 0;
  90504. var line = this.readStringLine(uint8array, 0);
  90505. if (line[0] != '#' || line[1] != '?') {
  90506. throw "Bad HDR Format.";
  90507. }
  90508. var endOfHeader = false;
  90509. var findFormat = false;
  90510. var lineIndex = 0;
  90511. do {
  90512. lineIndex += (line.length + 1);
  90513. line = this.readStringLine(uint8array, lineIndex);
  90514. if (line == "FORMAT=32-bit_rle_rgbe") {
  90515. findFormat = true;
  90516. }
  90517. else if (line.length == 0) {
  90518. endOfHeader = true;
  90519. }
  90520. } while (!endOfHeader);
  90521. if (!findFormat) {
  90522. throw "HDR Bad header format, unsupported FORMAT";
  90523. }
  90524. lineIndex += (line.length + 1);
  90525. line = this.readStringLine(uint8array, lineIndex);
  90526. var sizeRegexp = /^\-Y (.*) \+X (.*)$/g;
  90527. var match = sizeRegexp.exec(line);
  90528. // TODO. Support +Y and -X if needed.
  90529. if (!match || match.length < 3) {
  90530. throw "HDR Bad header format, no size";
  90531. }
  90532. width = parseInt(match[2]);
  90533. height = parseInt(match[1]);
  90534. if (width < 8 || width > 0x7fff) {
  90535. throw "HDR Bad header format, unsupported size";
  90536. }
  90537. lineIndex += (line.length + 1);
  90538. return {
  90539. height: height,
  90540. width: width,
  90541. dataPosition: lineIndex
  90542. };
  90543. };
  90544. /**
  90545. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  90546. * This RGBE texture needs to store the information as a panorama.
  90547. *
  90548. * More information on this format are available here:
  90549. * https://en.wikipedia.org/wiki/RGBE_image_format
  90550. *
  90551. * @param buffer The binary file stored in an array buffer.
  90552. * @param size The expected size of the extracted cubemap.
  90553. * @return The Cube Map information.
  90554. */
  90555. HDRTools.GetCubeMapTextureData = function (buffer, size) {
  90556. var uint8array = new Uint8Array(buffer);
  90557. var hdrInfo = this.RGBE_ReadHeader(uint8array);
  90558. var data = this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  90559. var cubeMapData = _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(data, hdrInfo.width, hdrInfo.height, size);
  90560. return cubeMapData;
  90561. };
  90562. /**
  90563. * Returns the pixels data extracted from an RGBE texture.
  90564. * This pixels will be stored left to right up to down in the R G B order in one array.
  90565. *
  90566. * More information on this format are available here:
  90567. * https://en.wikipedia.org/wiki/RGBE_image_format
  90568. *
  90569. * @param uint8array The binary file stored in an array buffer.
  90570. * @param hdrInfo The header information of the file.
  90571. * @return The pixels data in RGB right to left up to down order.
  90572. */
  90573. HDRTools.RGBE_ReadPixels = function (uint8array, hdrInfo) {
  90574. // Keep for multi format supports.
  90575. return this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  90576. };
  90577. HDRTools.RGBE_ReadPixels_RLE = function (uint8array, hdrInfo) {
  90578. var num_scanlines = hdrInfo.height;
  90579. var scanline_width = hdrInfo.width;
  90580. var a, b, c, d, count;
  90581. var dataIndex = hdrInfo.dataPosition;
  90582. var index = 0, endIndex = 0, i = 0;
  90583. var scanLineArrayBuffer = new ArrayBuffer(scanline_width * 4); // four channel R G B E
  90584. var scanLineArray = new Uint8Array(scanLineArrayBuffer);
  90585. // 3 channels of 4 bytes per pixel in float.
  90586. var resultBuffer = new ArrayBuffer(hdrInfo.width * hdrInfo.height * 4 * 3);
  90587. var resultArray = new Float32Array(resultBuffer);
  90588. // read in each successive scanline
  90589. while (num_scanlines > 0) {
  90590. a = uint8array[dataIndex++];
  90591. b = uint8array[dataIndex++];
  90592. c = uint8array[dataIndex++];
  90593. d = uint8array[dataIndex++];
  90594. if (a != 2 || b != 2 || (c & 0x80)) {
  90595. // this file is not run length encoded
  90596. throw "HDR Bad header format, not RLE";
  90597. }
  90598. if (((c << 8) | d) != scanline_width) {
  90599. throw "HDR Bad header format, wrong scan line width";
  90600. }
  90601. index = 0;
  90602. // read each of the four channels for the scanline into the buffer
  90603. for (i = 0; i < 4; i++) {
  90604. endIndex = (i + 1) * scanline_width;
  90605. while (index < endIndex) {
  90606. a = uint8array[dataIndex++];
  90607. b = uint8array[dataIndex++];
  90608. if (a > 128) {
  90609. // a run of the same value
  90610. count = a - 128;
  90611. if ((count == 0) || (count > endIndex - index)) {
  90612. throw "HDR Bad Format, bad scanline data (run)";
  90613. }
  90614. while (count-- > 0) {
  90615. scanLineArray[index++] = b;
  90616. }
  90617. }
  90618. else {
  90619. // a non-run
  90620. count = a;
  90621. if ((count == 0) || (count > endIndex - index)) {
  90622. throw "HDR Bad Format, bad scanline data (non-run)";
  90623. }
  90624. scanLineArray[index++] = b;
  90625. if (--count > 0) {
  90626. for (var j = 0; j < count; j++) {
  90627. scanLineArray[index++] = uint8array[dataIndex++];
  90628. }
  90629. }
  90630. }
  90631. }
  90632. }
  90633. // now convert data from buffer into floats
  90634. for (i = 0; i < scanline_width; i++) {
  90635. a = scanLineArray[i];
  90636. b = scanLineArray[i + scanline_width];
  90637. c = scanLineArray[i + 2 * scanline_width];
  90638. d = scanLineArray[i + 3 * scanline_width];
  90639. this.Rgbe2float(resultArray, a, b, c, d, (hdrInfo.height - num_scanlines) * scanline_width * 3 + i * 3);
  90640. }
  90641. num_scanlines--;
  90642. }
  90643. return resultArray;
  90644. };
  90645. return HDRTools;
  90646. }());
  90647. /***/ }),
  90648. /***/ "./Misc/HighDynamicRange/index.ts":
  90649. /*!****************************************!*\
  90650. !*** ./Misc/HighDynamicRange/index.ts ***!
  90651. \****************************************/
  90652. /*! exports provided: CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  90653. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90654. "use strict";
  90655. __webpack_require__.r(__webpack_exports__);
  90656. /* harmony import */ var _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  90657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  90658. /* harmony import */ var _hdr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hdr */ "./Misc/HighDynamicRange/hdr.ts");
  90659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _hdr__WEBPACK_IMPORTED_MODULE_1__["HDRTools"]; });
  90660. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  90661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__["PanoramaToCubeMapTools"]; });
  90662. /***/ }),
  90663. /***/ "./Misc/HighDynamicRange/panoramaToCubemap.ts":
  90664. /*!****************************************************!*\
  90665. !*** ./Misc/HighDynamicRange/panoramaToCubemap.ts ***!
  90666. \****************************************************/
  90667. /*! exports provided: PanoramaToCubeMapTools */
  90668. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90669. "use strict";
  90670. __webpack_require__.r(__webpack_exports__);
  90671. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return PanoramaToCubeMapTools; });
  90672. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  90673. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  90674. /**
  90675. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  90676. */
  90677. var PanoramaToCubeMapTools = /** @class */ (function () {
  90678. function PanoramaToCubeMapTools() {
  90679. }
  90680. /**
  90681. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  90682. *
  90683. * @param float32Array The source data.
  90684. * @param inputWidth The width of the input panorama.
  90685. * @param inputHeight The height of the input panorama.
  90686. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  90687. * @return The cubemap data
  90688. */
  90689. PanoramaToCubeMapTools.ConvertPanoramaToCubemap = function (float32Array, inputWidth, inputHeight, size) {
  90690. if (!float32Array) {
  90691. throw "ConvertPanoramaToCubemap: input cannot be null";
  90692. }
  90693. if (float32Array.length != inputWidth * inputHeight * 3) {
  90694. throw "ConvertPanoramaToCubemap: input size is wrong";
  90695. }
  90696. var textureFront = this.CreateCubemapTexture(size, this.FACE_FRONT, float32Array, inputWidth, inputHeight);
  90697. var textureBack = this.CreateCubemapTexture(size, this.FACE_BACK, float32Array, inputWidth, inputHeight);
  90698. var textureLeft = this.CreateCubemapTexture(size, this.FACE_LEFT, float32Array, inputWidth, inputHeight);
  90699. var textureRight = this.CreateCubemapTexture(size, this.FACE_RIGHT, float32Array, inputWidth, inputHeight);
  90700. var textureUp = this.CreateCubemapTexture(size, this.FACE_UP, float32Array, inputWidth, inputHeight);
  90701. var textureDown = this.CreateCubemapTexture(size, this.FACE_DOWN, float32Array, inputWidth, inputHeight);
  90702. return {
  90703. front: textureFront,
  90704. back: textureBack,
  90705. left: textureLeft,
  90706. right: textureRight,
  90707. up: textureUp,
  90708. down: textureDown,
  90709. size: size,
  90710. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT,
  90711. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGB,
  90712. gammaSpace: false,
  90713. };
  90714. };
  90715. PanoramaToCubeMapTools.CreateCubemapTexture = function (texSize, faceData, float32Array, inputWidth, inputHeight) {
  90716. var buffer = new ArrayBuffer(texSize * texSize * 4 * 3);
  90717. var textureArray = new Float32Array(buffer);
  90718. var rotDX1 = faceData[1].subtract(faceData[0]).scale(1 / texSize);
  90719. var rotDX2 = faceData[3].subtract(faceData[2]).scale(1 / texSize);
  90720. var dy = 1 / texSize;
  90721. var fy = 0;
  90722. for (var y = 0; y < texSize; y++) {
  90723. var xv1 = faceData[0];
  90724. var xv2 = faceData[2];
  90725. for (var x = 0; x < texSize; x++) {
  90726. var v = xv2.subtract(xv1).scale(fy).add(xv1);
  90727. v.normalize();
  90728. var color = this.CalcProjectionSpherical(v, float32Array, inputWidth, inputHeight);
  90729. // 3 channels per pixels
  90730. textureArray[y * texSize * 3 + (x * 3) + 0] = color.r;
  90731. textureArray[y * texSize * 3 + (x * 3) + 1] = color.g;
  90732. textureArray[y * texSize * 3 + (x * 3) + 2] = color.b;
  90733. xv1 = xv1.add(rotDX1);
  90734. xv2 = xv2.add(rotDX2);
  90735. }
  90736. fy += dy;
  90737. }
  90738. return textureArray;
  90739. };
  90740. PanoramaToCubeMapTools.CalcProjectionSpherical = function (vDir, float32Array, inputWidth, inputHeight) {
  90741. var theta = Math.atan2(vDir.z, vDir.x);
  90742. var phi = Math.acos(vDir.y);
  90743. while (theta < -Math.PI) {
  90744. theta += 2 * Math.PI;
  90745. }
  90746. while (theta > Math.PI) {
  90747. theta -= 2 * Math.PI;
  90748. }
  90749. var dx = theta / Math.PI;
  90750. var dy = phi / Math.PI;
  90751. // recenter.
  90752. dx = dx * 0.5 + 0.5;
  90753. var px = Math.round(dx * inputWidth);
  90754. if (px < 0) {
  90755. px = 0;
  90756. }
  90757. else if (px >= inputWidth) {
  90758. px = inputWidth - 1;
  90759. }
  90760. var py = Math.round(dy * inputHeight);
  90761. if (py < 0) {
  90762. py = 0;
  90763. }
  90764. else if (py >= inputHeight) {
  90765. py = inputHeight - 1;
  90766. }
  90767. var inputY = (inputHeight - py - 1);
  90768. var r = float32Array[inputY * inputWidth * 3 + (px * 3) + 0];
  90769. var g = float32Array[inputY * inputWidth * 3 + (px * 3) + 1];
  90770. var b = float32Array[inputY * inputWidth * 3 + (px * 3) + 2];
  90771. return {
  90772. r: r,
  90773. g: g,
  90774. b: b
  90775. };
  90776. };
  90777. PanoramaToCubeMapTools.FACE_FRONT = [
  90778. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  90779. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  90780. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  90781. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0)
  90782. ];
  90783. PanoramaToCubeMapTools.FACE_BACK = [
  90784. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  90785. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  90786. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0),
  90787. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0)
  90788. ];
  90789. PanoramaToCubeMapTools.FACE_RIGHT = [
  90790. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  90791. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  90792. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  90793. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  90794. ];
  90795. PanoramaToCubeMapTools.FACE_LEFT = [
  90796. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  90797. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  90798. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  90799. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0)
  90800. ];
  90801. PanoramaToCubeMapTools.FACE_DOWN = [
  90802. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  90803. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  90804. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  90805. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  90806. ];
  90807. PanoramaToCubeMapTools.FACE_UP = [
  90808. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  90809. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  90810. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  90811. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0)
  90812. ];
  90813. return PanoramaToCubeMapTools;
  90814. }());
  90815. /***/ }),
  90816. /***/ "./Misc/andOrNotEvaluator.ts":
  90817. /*!***********************************!*\
  90818. !*** ./Misc/andOrNotEvaluator.ts ***!
  90819. \***********************************/
  90820. /*! exports provided: AndOrNotEvaluator */
  90821. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90822. "use strict";
  90823. __webpack_require__.r(__webpack_exports__);
  90824. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return AndOrNotEvaluator; });
  90825. /**
  90826. * Class used to evalaute queries containing `and` and `or` operators
  90827. */
  90828. var AndOrNotEvaluator = /** @class */ (function () {
  90829. function AndOrNotEvaluator() {
  90830. }
  90831. /**
  90832. * Evaluate a query
  90833. * @param query defines the query to evaluate
  90834. * @param evaluateCallback defines the callback used to filter result
  90835. * @returns true if the query matches
  90836. */
  90837. AndOrNotEvaluator.Eval = function (query, evaluateCallback) {
  90838. if (!query.match(/\([^\(\)]*\)/g)) {
  90839. query = AndOrNotEvaluator._HandleParenthesisContent(query, evaluateCallback);
  90840. }
  90841. else {
  90842. query = query.replace(/\([^\(\)]*\)/g, function (r) {
  90843. // remove parenthesis
  90844. r = r.slice(1, r.length - 1);
  90845. return AndOrNotEvaluator._HandleParenthesisContent(r, evaluateCallback);
  90846. });
  90847. }
  90848. if (query === "true") {
  90849. return true;
  90850. }
  90851. if (query === "false") {
  90852. return false;
  90853. }
  90854. return AndOrNotEvaluator.Eval(query, evaluateCallback);
  90855. };
  90856. AndOrNotEvaluator._HandleParenthesisContent = function (parenthesisContent, evaluateCallback) {
  90857. evaluateCallback = evaluateCallback || (function (r) {
  90858. return r === "true" ? true : false;
  90859. });
  90860. var result;
  90861. var or = parenthesisContent.split("||");
  90862. for (var i in or) {
  90863. if (or.hasOwnProperty(i)) {
  90864. var ori = AndOrNotEvaluator._SimplifyNegation(or[i].trim());
  90865. var and = ori.split("&&");
  90866. if (and.length > 1) {
  90867. for (var j = 0; j < and.length; ++j) {
  90868. var andj = AndOrNotEvaluator._SimplifyNegation(and[j].trim());
  90869. if (andj !== "true" && andj !== "false") {
  90870. if (andj[0] === "!") {
  90871. result = !evaluateCallback(andj.substring(1));
  90872. }
  90873. else {
  90874. result = evaluateCallback(andj);
  90875. }
  90876. }
  90877. else {
  90878. result = andj === "true" ? true : false;
  90879. }
  90880. if (!result) { // no need to continue since 'false && ... && ...' will always return false
  90881. ori = "false";
  90882. break;
  90883. }
  90884. }
  90885. }
  90886. if (result || ori === "true") { // no need to continue since 'true || ... || ...' will always return true
  90887. result = true;
  90888. break;
  90889. }
  90890. // result equals false (or undefined)
  90891. if (ori !== "true" && ori !== "false") {
  90892. if (ori[0] === "!") {
  90893. result = !evaluateCallback(ori.substring(1));
  90894. }
  90895. else {
  90896. result = evaluateCallback(ori);
  90897. }
  90898. }
  90899. else {
  90900. result = ori === "true" ? true : false;
  90901. }
  90902. }
  90903. }
  90904. // the whole parenthesis scope is replaced by 'true' or 'false'
  90905. return result ? "true" : "false";
  90906. };
  90907. AndOrNotEvaluator._SimplifyNegation = function (booleanString) {
  90908. booleanString = booleanString.replace(/^[\s!]+/, function (r) {
  90909. // remove whitespaces
  90910. r = r.replace(/[\s]/g, function () { return ""; });
  90911. return r.length % 2 ? "!" : "";
  90912. });
  90913. booleanString = booleanString.trim();
  90914. if (booleanString === "!true") {
  90915. booleanString = "false";
  90916. }
  90917. else if (booleanString === "!false") {
  90918. booleanString = "true";
  90919. }
  90920. return booleanString;
  90921. };
  90922. return AndOrNotEvaluator;
  90923. }());
  90924. /***/ }),
  90925. /***/ "./Misc/arrayTools.ts":
  90926. /*!****************************!*\
  90927. !*** ./Misc/arrayTools.ts ***!
  90928. \****************************/
  90929. /*! exports provided: ArrayTools */
  90930. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90931. "use strict";
  90932. __webpack_require__.r(__webpack_exports__);
  90933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayTools", function() { return ArrayTools; });
  90934. /**
  90935. * Class containing a set of static utilities functions for arrays.
  90936. */
  90937. var ArrayTools = /** @class */ (function () {
  90938. function ArrayTools() {
  90939. }
  90940. /**
  90941. * Returns an array of the given size filled with element built from the given constructor and the paramters
  90942. * @param size the number of element to construct and put in the array
  90943. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  90944. * @returns a new array filled with new objects
  90945. */
  90946. ArrayTools.BuildArray = function (size, itemBuilder) {
  90947. var a = [];
  90948. for (var i = 0; i < size; ++i) {
  90949. a.push(itemBuilder());
  90950. }
  90951. return a;
  90952. };
  90953. return ArrayTools;
  90954. }());
  90955. /***/ }),
  90956. /***/ "./Misc/assetsManager.ts":
  90957. /*!*******************************!*\
  90958. !*** ./Misc/assetsManager.ts ***!
  90959. \*******************************/
  90960. /*! exports provided: AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager */
  90961. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90962. "use strict";
  90963. __webpack_require__.r(__webpack_exports__);
  90964. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return AssetTaskState; });
  90965. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return AbstractAssetTask; });
  90966. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return AssetsProgressEvent; });
  90967. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return MeshAssetTask; });
  90968. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return TextFileAssetTask; });
  90969. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return BinaryFileAssetTask; });
  90970. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return ImageAssetTask; });
  90971. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return TextureAssetTask; });
  90972. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return CubeTextureAssetTask; });
  90973. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return HDRCubeTextureAssetTask; });
  90974. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return AssetsManager; });
  90975. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  90976. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  90977. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  90978. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  90979. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  90980. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  90981. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  90982. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  90983. /**
  90984. * Defines the list of states available for a task inside a AssetsManager
  90985. */
  90986. var AssetTaskState;
  90987. (function (AssetTaskState) {
  90988. /**
  90989. * Initialization
  90990. */
  90991. AssetTaskState[AssetTaskState["INIT"] = 0] = "INIT";
  90992. /**
  90993. * Running
  90994. */
  90995. AssetTaskState[AssetTaskState["RUNNING"] = 1] = "RUNNING";
  90996. /**
  90997. * Done
  90998. */
  90999. AssetTaskState[AssetTaskState["DONE"] = 2] = "DONE";
  91000. /**
  91001. * Error
  91002. */
  91003. AssetTaskState[AssetTaskState["ERROR"] = 3] = "ERROR";
  91004. })(AssetTaskState || (AssetTaskState = {}));
  91005. /**
  91006. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  91007. */
  91008. var AbstractAssetTask = /** @class */ (function () {
  91009. /**
  91010. * Creates a new AssetsManager
  91011. * @param name defines the name of the task
  91012. */
  91013. function AbstractAssetTask(
  91014. /**
  91015. * Task name
  91016. */ name) {
  91017. this.name = name;
  91018. this._isCompleted = false;
  91019. this._taskState = AssetTaskState.INIT;
  91020. }
  91021. Object.defineProperty(AbstractAssetTask.prototype, "isCompleted", {
  91022. /**
  91023. * Get if the task is completed
  91024. */
  91025. get: function () {
  91026. return this._isCompleted;
  91027. },
  91028. enumerable: true,
  91029. configurable: true
  91030. });
  91031. Object.defineProperty(AbstractAssetTask.prototype, "taskState", {
  91032. /**
  91033. * Gets the current state of the task
  91034. */
  91035. get: function () {
  91036. return this._taskState;
  91037. },
  91038. enumerable: true,
  91039. configurable: true
  91040. });
  91041. Object.defineProperty(AbstractAssetTask.prototype, "errorObject", {
  91042. /**
  91043. * Gets the current error object (if task is in error)
  91044. */
  91045. get: function () {
  91046. return this._errorObject;
  91047. },
  91048. enumerable: true,
  91049. configurable: true
  91050. });
  91051. /**
  91052. * Internal only
  91053. * @hidden
  91054. */
  91055. AbstractAssetTask.prototype._setErrorObject = function (message, exception) {
  91056. if (this._errorObject) {
  91057. return;
  91058. }
  91059. this._errorObject = {
  91060. message: message,
  91061. exception: exception
  91062. };
  91063. };
  91064. /**
  91065. * Execute the current task
  91066. * @param scene defines the scene where you want your assets to be loaded
  91067. * @param onSuccess is a callback called when the task is successfully executed
  91068. * @param onError is a callback called if an error occurs
  91069. */
  91070. AbstractAssetTask.prototype.run = function (scene, onSuccess, onError) {
  91071. var _this = this;
  91072. this._taskState = AssetTaskState.RUNNING;
  91073. this.runTask(scene, function () {
  91074. _this.onDoneCallback(onSuccess, onError);
  91075. }, function (msg, exception) {
  91076. _this.onErrorCallback(onError, msg, exception);
  91077. });
  91078. };
  91079. /**
  91080. * Execute the current task
  91081. * @param scene defines the scene where you want your assets to be loaded
  91082. * @param onSuccess is a callback called when the task is successfully executed
  91083. * @param onError is a callback called if an error occurs
  91084. */
  91085. AbstractAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  91086. throw new Error("runTask is not implemented");
  91087. };
  91088. /**
  91089. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  91090. * This can be used with failed tasks that have the reason for failure fixed.
  91091. */
  91092. AbstractAssetTask.prototype.reset = function () {
  91093. this._taskState = AssetTaskState.INIT;
  91094. };
  91095. AbstractAssetTask.prototype.onErrorCallback = function (onError, message, exception) {
  91096. this._taskState = AssetTaskState.ERROR;
  91097. this._errorObject = {
  91098. message: message,
  91099. exception: exception
  91100. };
  91101. if (this.onError) {
  91102. this.onError(this, message, exception);
  91103. }
  91104. onError();
  91105. };
  91106. AbstractAssetTask.prototype.onDoneCallback = function (onSuccess, onError) {
  91107. try {
  91108. this._taskState = AssetTaskState.DONE;
  91109. this._isCompleted = true;
  91110. if (this.onSuccess) {
  91111. this.onSuccess(this);
  91112. }
  91113. onSuccess();
  91114. }
  91115. catch (e) {
  91116. this.onErrorCallback(onError, "Task is done, error executing success callback(s)", e);
  91117. }
  91118. };
  91119. return AbstractAssetTask;
  91120. }());
  91121. /**
  91122. * Class used to share progress information about assets loading
  91123. */
  91124. var AssetsProgressEvent = /** @class */ (function () {
  91125. /**
  91126. * Creates a AssetsProgressEvent
  91127. * @param remainingCount defines the number of remaining tasks to process
  91128. * @param totalCount defines the total number of tasks
  91129. * @param task defines the task that was just processed
  91130. */
  91131. function AssetsProgressEvent(remainingCount, totalCount, task) {
  91132. this.remainingCount = remainingCount;
  91133. this.totalCount = totalCount;
  91134. this.task = task;
  91135. }
  91136. return AssetsProgressEvent;
  91137. }());
  91138. /**
  91139. * Define a task used by AssetsManager to load meshes
  91140. */
  91141. var MeshAssetTask = /** @class */ (function (_super) {
  91142. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshAssetTask, _super);
  91143. /**
  91144. * Creates a new MeshAssetTask
  91145. * @param name defines the name of the task
  91146. * @param meshesNames defines the list of mesh's names you want to load
  91147. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  91148. * @param sceneFilename defines the filename of the scene to load from
  91149. */
  91150. function MeshAssetTask(
  91151. /**
  91152. * Defines the name of the task
  91153. */
  91154. name,
  91155. /**
  91156. * Defines the list of mesh's names you want to load
  91157. */
  91158. meshesNames,
  91159. /**
  91160. * Defines the root url to use as a base to load your meshes and associated resources
  91161. */
  91162. rootUrl,
  91163. /**
  91164. * Defines the filename of the scene to load from
  91165. */
  91166. sceneFilename) {
  91167. var _this = _super.call(this, name) || this;
  91168. _this.name = name;
  91169. _this.meshesNames = meshesNames;
  91170. _this.rootUrl = rootUrl;
  91171. _this.sceneFilename = sceneFilename;
  91172. return _this;
  91173. }
  91174. /**
  91175. * Execute the current task
  91176. * @param scene defines the scene where you want your assets to be loaded
  91177. * @param onSuccess is a callback called when the task is successfully executed
  91178. * @param onError is a callback called if an error occurs
  91179. */
  91180. MeshAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  91181. var _this = this;
  91182. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  91183. _this.loadedMeshes = meshes;
  91184. _this.loadedParticleSystems = particleSystems;
  91185. _this.loadedSkeletons = skeletons;
  91186. _this.loadedAnimationGroups = animationGroups;
  91187. onSuccess();
  91188. }, null, function (scene, message, exception) {
  91189. onError(message, exception);
  91190. });
  91191. };
  91192. return MeshAssetTask;
  91193. }(AbstractAssetTask));
  91194. /**
  91195. * Define a task used by AssetsManager to load text content
  91196. */
  91197. var TextFileAssetTask = /** @class */ (function (_super) {
  91198. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextFileAssetTask, _super);
  91199. /**
  91200. * Creates a new TextFileAssetTask object
  91201. * @param name defines the name of the task
  91202. * @param url defines the location of the file to load
  91203. */
  91204. function TextFileAssetTask(
  91205. /**
  91206. * Defines the name of the task
  91207. */
  91208. name,
  91209. /**
  91210. * Defines the location of the file to load
  91211. */
  91212. url) {
  91213. var _this = _super.call(this, name) || this;
  91214. _this.name = name;
  91215. _this.url = url;
  91216. return _this;
  91217. }
  91218. /**
  91219. * Execute the current task
  91220. * @param scene defines the scene where you want your assets to be loaded
  91221. * @param onSuccess is a callback called when the task is successfully executed
  91222. * @param onError is a callback called if an error occurs
  91223. */
  91224. TextFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  91225. var _this = this;
  91226. scene._loadFile(this.url, function (data) {
  91227. _this.text = data;
  91228. onSuccess();
  91229. }, undefined, false, false, function (request, exception) {
  91230. if (request) {
  91231. onError(request.status + " " + request.statusText, exception);
  91232. }
  91233. });
  91234. };
  91235. return TextFileAssetTask;
  91236. }(AbstractAssetTask));
  91237. /**
  91238. * Define a task used by AssetsManager to load binary data
  91239. */
  91240. var BinaryFileAssetTask = /** @class */ (function (_super) {
  91241. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BinaryFileAssetTask, _super);
  91242. /**
  91243. * Creates a new BinaryFileAssetTask object
  91244. * @param name defines the name of the new task
  91245. * @param url defines the location of the file to load
  91246. */
  91247. function BinaryFileAssetTask(
  91248. /**
  91249. * Defines the name of the task
  91250. */
  91251. name,
  91252. /**
  91253. * Defines the location of the file to load
  91254. */
  91255. url) {
  91256. var _this = _super.call(this, name) || this;
  91257. _this.name = name;
  91258. _this.url = url;
  91259. return _this;
  91260. }
  91261. /**
  91262. * Execute the current task
  91263. * @param scene defines the scene where you want your assets to be loaded
  91264. * @param onSuccess is a callback called when the task is successfully executed
  91265. * @param onError is a callback called if an error occurs
  91266. */
  91267. BinaryFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  91268. var _this = this;
  91269. scene._loadFile(this.url, function (data) {
  91270. _this.data = data;
  91271. onSuccess();
  91272. }, undefined, true, true, function (request, exception) {
  91273. if (request) {
  91274. onError(request.status + " " + request.statusText, exception);
  91275. }
  91276. });
  91277. };
  91278. return BinaryFileAssetTask;
  91279. }(AbstractAssetTask));
  91280. /**
  91281. * Define a task used by AssetsManager to load images
  91282. */
  91283. var ImageAssetTask = /** @class */ (function (_super) {
  91284. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageAssetTask, _super);
  91285. /**
  91286. * Creates a new ImageAssetTask
  91287. * @param name defines the name of the task
  91288. * @param url defines the location of the image to load
  91289. */
  91290. function ImageAssetTask(
  91291. /**
  91292. * Defines the name of the task
  91293. */
  91294. name,
  91295. /**
  91296. * Defines the location of the image to load
  91297. */
  91298. url) {
  91299. var _this = _super.call(this, name) || this;
  91300. _this.name = name;
  91301. _this.url = url;
  91302. return _this;
  91303. }
  91304. /**
  91305. * Execute the current task
  91306. * @param scene defines the scene where you want your assets to be loaded
  91307. * @param onSuccess is a callback called when the task is successfully executed
  91308. * @param onError is a callback called if an error occurs
  91309. */
  91310. ImageAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  91311. var _this = this;
  91312. var img = new Image();
  91313. _tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(this.url, img);
  91314. img.onload = function () {
  91315. _this.image = img;
  91316. onSuccess();
  91317. };
  91318. img.onerror = function (err) {
  91319. onError("Error loading image", err);
  91320. };
  91321. img.src = this.url;
  91322. };
  91323. return ImageAssetTask;
  91324. }(AbstractAssetTask));
  91325. /**
  91326. * Define a task used by AssetsManager to load 2D textures
  91327. */
  91328. var TextureAssetTask = /** @class */ (function (_super) {
  91329. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureAssetTask, _super);
  91330. /**
  91331. * Creates a new TextureAssetTask object
  91332. * @param name defines the name of the task
  91333. * @param url defines the location of the file to load
  91334. * @param noMipmap defines if mipmap should not be generated (default is false)
  91335. * @param invertY defines if texture must be inverted on Y axis (default is false)
  91336. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  91337. */
  91338. function TextureAssetTask(
  91339. /**
  91340. * Defines the name of the task
  91341. */
  91342. name,
  91343. /**
  91344. * Defines the location of the file to load
  91345. */
  91346. url,
  91347. /**
  91348. * Defines if mipmap should not be generated (default is false)
  91349. */
  91350. noMipmap,
  91351. /**
  91352. * Defines if texture must be inverted on Y axis (default is false)
  91353. */
  91354. invertY,
  91355. /**
  91356. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  91357. */
  91358. samplingMode) {
  91359. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  91360. var _this = _super.call(this, name) || this;
  91361. _this.name = name;
  91362. _this.url = url;
  91363. _this.noMipmap = noMipmap;
  91364. _this.invertY = invertY;
  91365. _this.samplingMode = samplingMode;
  91366. return _this;
  91367. }
  91368. /**
  91369. * Execute the current task
  91370. * @param scene defines the scene where you want your assets to be loaded
  91371. * @param onSuccess is a callback called when the task is successfully executed
  91372. * @param onError is a callback called if an error occurs
  91373. */
  91374. TextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  91375. var onload = function () {
  91376. onSuccess();
  91377. };
  91378. var onerror = function (message, exception) {
  91379. onError(message, exception);
  91380. };
  91381. this.texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](this.url, scene, this.noMipmap, this.invertY, this.samplingMode, onload, onerror);
  91382. };
  91383. return TextureAssetTask;
  91384. }(AbstractAssetTask));
  91385. /**
  91386. * Define a task used by AssetsManager to load cube textures
  91387. */
  91388. var CubeTextureAssetTask = /** @class */ (function (_super) {
  91389. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTextureAssetTask, _super);
  91390. /**
  91391. * Creates a new CubeTextureAssetTask
  91392. * @param name defines the name of the task
  91393. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  91394. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  91395. * @param noMipmap defines if mipmaps should not be generated (default is false)
  91396. * @param files defines the explicit list of files (undefined by default)
  91397. */
  91398. function CubeTextureAssetTask(
  91399. /**
  91400. * Defines the name of the task
  91401. */
  91402. name,
  91403. /**
  91404. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  91405. */
  91406. url,
  91407. /**
  91408. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  91409. */
  91410. extensions,
  91411. /**
  91412. * Defines if mipmaps should not be generated (default is false)
  91413. */
  91414. noMipmap,
  91415. /**
  91416. * Defines the explicit list of files (undefined by default)
  91417. */
  91418. files) {
  91419. var _this = _super.call(this, name) || this;
  91420. _this.name = name;
  91421. _this.url = url;
  91422. _this.extensions = extensions;
  91423. _this.noMipmap = noMipmap;
  91424. _this.files = files;
  91425. return _this;
  91426. }
  91427. /**
  91428. * Execute the current task
  91429. * @param scene defines the scene where you want your assets to be loaded
  91430. * @param onSuccess is a callback called when the task is successfully executed
  91431. * @param onError is a callback called if an error occurs
  91432. */
  91433. CubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  91434. var onload = function () {
  91435. onSuccess();
  91436. };
  91437. var onerror = function (message, exception) {
  91438. onError(message, exception);
  91439. };
  91440. this.texture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__["CubeTexture"](this.url, scene, this.extensions, this.noMipmap, this.files, onload, onerror);
  91441. };
  91442. return CubeTextureAssetTask;
  91443. }(AbstractAssetTask));
  91444. /**
  91445. * Define a task used by AssetsManager to load HDR cube textures
  91446. */
  91447. var HDRCubeTextureAssetTask = /** @class */ (function (_super) {
  91448. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTextureAssetTask, _super);
  91449. /**
  91450. * Creates a new HDRCubeTextureAssetTask object
  91451. * @param name defines the name of the task
  91452. * @param url defines the location of the file to load
  91453. * @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.
  91454. * @param noMipmap defines if mipmaps should not be generated (default is false)
  91455. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  91456. * @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)
  91457. * @param reserved Internal use only
  91458. */
  91459. function HDRCubeTextureAssetTask(
  91460. /**
  91461. * Defines the name of the task
  91462. */
  91463. name,
  91464. /**
  91465. * Defines the location of the file to load
  91466. */
  91467. url,
  91468. /**
  91469. * Defines the desired size (the more it increases the longer the generation will be)
  91470. */
  91471. size,
  91472. /**
  91473. * Defines if mipmaps should not be generated (default is false)
  91474. */
  91475. noMipmap,
  91476. /**
  91477. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  91478. */
  91479. generateHarmonics,
  91480. /**
  91481. * 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)
  91482. */
  91483. gammaSpace,
  91484. /**
  91485. * Internal Use Only
  91486. */
  91487. reserved) {
  91488. if (noMipmap === void 0) { noMipmap = false; }
  91489. if (generateHarmonics === void 0) { generateHarmonics = true; }
  91490. if (gammaSpace === void 0) { gammaSpace = false; }
  91491. if (reserved === void 0) { reserved = false; }
  91492. var _this = _super.call(this, name) || this;
  91493. _this.name = name;
  91494. _this.url = url;
  91495. _this.size = size;
  91496. _this.noMipmap = noMipmap;
  91497. _this.generateHarmonics = generateHarmonics;
  91498. _this.gammaSpace = gammaSpace;
  91499. _this.reserved = reserved;
  91500. return _this;
  91501. }
  91502. /**
  91503. * Execute the current task
  91504. * @param scene defines the scene where you want your assets to be loaded
  91505. * @param onSuccess is a callback called when the task is successfully executed
  91506. * @param onError is a callback called if an error occurs
  91507. */
  91508. HDRCubeTextureAssetTask.prototype.run = function (scene, onSuccess, onError) {
  91509. var onload = function () {
  91510. onSuccess();
  91511. };
  91512. var onerror = function (message, exception) {
  91513. onError(message, exception);
  91514. };
  91515. 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);
  91516. };
  91517. return HDRCubeTextureAssetTask;
  91518. }(AbstractAssetTask));
  91519. /**
  91520. * This class can be used to easily import assets into a scene
  91521. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  91522. */
  91523. var AssetsManager = /** @class */ (function () {
  91524. /**
  91525. * Creates a new AssetsManager
  91526. * @param scene defines the scene to work on
  91527. */
  91528. function AssetsManager(scene) {
  91529. this._isLoading = false;
  91530. this._tasks = new Array();
  91531. this._waitingTasksCount = 0;
  91532. this._totalTasksCount = 0;
  91533. /**
  91534. * Observable called when all tasks are processed
  91535. */
  91536. this.onTaskSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  91537. /**
  91538. * Observable called when a task had an error
  91539. */
  91540. this.onTaskErrorObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  91541. /**
  91542. * Observable called when a task is successful
  91543. */
  91544. this.onTasksDoneObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  91545. /**
  91546. * Observable called when a task is done (whatever the result is)
  91547. */
  91548. this.onProgressObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  91549. /**
  91550. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  91551. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91552. */
  91553. this.useDefaultLoadingScreen = true;
  91554. this._scene = scene;
  91555. }
  91556. /**
  91557. * Add a MeshAssetTask to the list of active tasks
  91558. * @param taskName defines the name of the new task
  91559. * @param meshesNames defines the name of meshes to load
  91560. * @param rootUrl defines the root url to use to locate files
  91561. * @param sceneFilename defines the filename of the scene file
  91562. * @returns a new MeshAssetTask object
  91563. */
  91564. AssetsManager.prototype.addMeshTask = function (taskName, meshesNames, rootUrl, sceneFilename) {
  91565. var task = new MeshAssetTask(taskName, meshesNames, rootUrl, sceneFilename);
  91566. this._tasks.push(task);
  91567. return task;
  91568. };
  91569. /**
  91570. * Add a TextFileAssetTask to the list of active tasks
  91571. * @param taskName defines the name of the new task
  91572. * @param url defines the url of the file to load
  91573. * @returns a new TextFileAssetTask object
  91574. */
  91575. AssetsManager.prototype.addTextFileTask = function (taskName, url) {
  91576. var task = new TextFileAssetTask(taskName, url);
  91577. this._tasks.push(task);
  91578. return task;
  91579. };
  91580. /**
  91581. * Add a BinaryFileAssetTask to the list of active tasks
  91582. * @param taskName defines the name of the new task
  91583. * @param url defines the url of the file to load
  91584. * @returns a new BinaryFileAssetTask object
  91585. */
  91586. AssetsManager.prototype.addBinaryFileTask = function (taskName, url) {
  91587. var task = new BinaryFileAssetTask(taskName, url);
  91588. this._tasks.push(task);
  91589. return task;
  91590. };
  91591. /**
  91592. * Add a ImageAssetTask to the list of active tasks
  91593. * @param taskName defines the name of the new task
  91594. * @param url defines the url of the file to load
  91595. * @returns a new ImageAssetTask object
  91596. */
  91597. AssetsManager.prototype.addImageTask = function (taskName, url) {
  91598. var task = new ImageAssetTask(taskName, url);
  91599. this._tasks.push(task);
  91600. return task;
  91601. };
  91602. /**
  91603. * Add a TextureAssetTask to the list of active tasks
  91604. * @param taskName defines the name of the new task
  91605. * @param url defines the url of the file to load
  91606. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  91607. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  91608. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  91609. * @returns a new TextureAssetTask object
  91610. */
  91611. AssetsManager.prototype.addTextureTask = function (taskName, url, noMipmap, invertY, samplingMode) {
  91612. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  91613. var task = new TextureAssetTask(taskName, url, noMipmap, invertY, samplingMode);
  91614. this._tasks.push(task);
  91615. return task;
  91616. };
  91617. /**
  91618. * Add a CubeTextureAssetTask to the list of active tasks
  91619. * @param taskName defines the name of the new task
  91620. * @param url defines the url of the file to load
  91621. * @param extensions defines the extension to use to load the cube map (can be null)
  91622. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  91623. * @param files defines the list of files to load (can be null)
  91624. * @returns a new CubeTextureAssetTask object
  91625. */
  91626. AssetsManager.prototype.addCubeTextureTask = function (taskName, url, extensions, noMipmap, files) {
  91627. var task = new CubeTextureAssetTask(taskName, url, extensions, noMipmap, files);
  91628. this._tasks.push(task);
  91629. return task;
  91630. };
  91631. /**
  91632. *
  91633. * Add a HDRCubeTextureAssetTask to the list of active tasks
  91634. * @param taskName defines the name of the new task
  91635. * @param url defines the url of the file to load
  91636. * @param size defines the size you want for the cubemap (can be null)
  91637. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  91638. * @param generateHarmonics defines if you want to automatically generate (true by default)
  91639. * @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)
  91640. * @param reserved Internal use only
  91641. * @returns a new HDRCubeTextureAssetTask object
  91642. */
  91643. AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved) {
  91644. if (noMipmap === void 0) { noMipmap = false; }
  91645. if (generateHarmonics === void 0) { generateHarmonics = true; }
  91646. if (gammaSpace === void 0) { gammaSpace = false; }
  91647. if (reserved === void 0) { reserved = false; }
  91648. var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved);
  91649. this._tasks.push(task);
  91650. return task;
  91651. };
  91652. /**
  91653. * Remove a task from the assets manager.
  91654. * @param task the task to remove
  91655. */
  91656. AssetsManager.prototype.removeTask = function (task) {
  91657. var index = this._tasks.indexOf(task);
  91658. if (index > -1) {
  91659. this._tasks.splice(index, 1);
  91660. }
  91661. };
  91662. AssetsManager.prototype._decreaseWaitingTasksCount = function (task) {
  91663. this._waitingTasksCount--;
  91664. try {
  91665. if (this.onProgress) {
  91666. this.onProgress(this._waitingTasksCount, this._totalTasksCount, task);
  91667. }
  91668. this.onProgressObservable.notifyObservers(new AssetsProgressEvent(this._waitingTasksCount, this._totalTasksCount, task));
  91669. }
  91670. catch (e) {
  91671. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running progress callbacks.");
  91672. console.log(e);
  91673. }
  91674. if (this._waitingTasksCount === 0) {
  91675. try {
  91676. if (this.onFinish) {
  91677. this.onFinish(this._tasks);
  91678. }
  91679. // Let's remove successfull tasks
  91680. var currentTasks = this._tasks.slice();
  91681. for (var _i = 0, currentTasks_1 = currentTasks; _i < currentTasks_1.length; _i++) {
  91682. var task = currentTasks_1[_i];
  91683. if (task.taskState === AssetTaskState.DONE) {
  91684. var index = this._tasks.indexOf(task);
  91685. if (index > -1) {
  91686. this._tasks.splice(index, 1);
  91687. }
  91688. }
  91689. }
  91690. this.onTasksDoneObservable.notifyObservers(this._tasks);
  91691. }
  91692. catch (e) {
  91693. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running tasks-done callbacks.");
  91694. console.log(e);
  91695. }
  91696. this._isLoading = false;
  91697. this._scene.getEngine().hideLoadingUI();
  91698. }
  91699. };
  91700. AssetsManager.prototype._runTask = function (task) {
  91701. var _this = this;
  91702. var done = function () {
  91703. try {
  91704. if (_this.onTaskSuccess) {
  91705. _this.onTaskSuccess(task);
  91706. }
  91707. _this.onTaskSuccessObservable.notifyObservers(task);
  91708. _this._decreaseWaitingTasksCount(task);
  91709. }
  91710. catch (e) {
  91711. error("Error executing task success callbacks", e);
  91712. }
  91713. };
  91714. var error = function (message, exception) {
  91715. task._setErrorObject(message, exception);
  91716. if (_this.onTaskError) {
  91717. _this.onTaskError(task);
  91718. }
  91719. _this.onTaskErrorObservable.notifyObservers(task);
  91720. _this._decreaseWaitingTasksCount(task);
  91721. };
  91722. task.run(this._scene, done, error);
  91723. };
  91724. /**
  91725. * Reset the AssetsManager and remove all tasks
  91726. * @return the current instance of the AssetsManager
  91727. */
  91728. AssetsManager.prototype.reset = function () {
  91729. this._isLoading = false;
  91730. this._tasks = new Array();
  91731. return this;
  91732. };
  91733. /**
  91734. * Start the loading process
  91735. * @return the current instance of the AssetsManager
  91736. */
  91737. AssetsManager.prototype.load = function () {
  91738. if (this._isLoading) {
  91739. return this;
  91740. }
  91741. this._isLoading = true;
  91742. this._waitingTasksCount = this._tasks.length;
  91743. this._totalTasksCount = this._tasks.length;
  91744. if (this._waitingTasksCount === 0) {
  91745. this._isLoading = false;
  91746. if (this.onFinish) {
  91747. this.onFinish(this._tasks);
  91748. }
  91749. this.onTasksDoneObservable.notifyObservers(this._tasks);
  91750. return this;
  91751. }
  91752. if (this.useDefaultLoadingScreen) {
  91753. this._scene.getEngine().displayLoadingUI();
  91754. }
  91755. for (var index = 0; index < this._tasks.length; index++) {
  91756. var task = this._tasks[index];
  91757. if (task.taskState === AssetTaskState.INIT) {
  91758. this._runTask(task);
  91759. }
  91760. }
  91761. return this;
  91762. };
  91763. return AssetsManager;
  91764. }());
  91765. /***/ }),
  91766. /***/ "./Misc/dds.ts":
  91767. /*!*********************!*\
  91768. !*** ./Misc/dds.ts ***!
  91769. \*********************/
  91770. /*! exports provided: DDSTools */
  91771. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91772. "use strict";
  91773. __webpack_require__.r(__webpack_exports__);
  91774. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return DDSTools; });
  91775. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  91776. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  91777. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  91778. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  91779. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  91780. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  91781. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  91782. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  91783. // Based on demo done by Brandon Jones - http://media.tojicode.com/webgl-samples/dds.html
  91784. // All values and structures referenced from:
  91785. // http://msdn.microsoft.com/en-us/library/bb943991.aspx/
  91786. var DDS_MAGIC = 0x20534444;
  91787. var
  91788. //DDSD_CAPS = 0x1,
  91789. //DDSD_HEIGHT = 0x2,
  91790. //DDSD_WIDTH = 0x4,
  91791. //DDSD_PITCH = 0x8,
  91792. //DDSD_PIXELFORMAT = 0x1000,
  91793. DDSD_MIPMAPCOUNT = 0x20000;
  91794. //DDSD_LINEARSIZE = 0x80000,
  91795. //DDSD_DEPTH = 0x800000;
  91796. // var DDSCAPS_COMPLEX = 0x8,
  91797. // DDSCAPS_MIPMAP = 0x400000,
  91798. // DDSCAPS_TEXTURE = 0x1000;
  91799. var DDSCAPS2_CUBEMAP = 0x200;
  91800. // DDSCAPS2_CUBEMAP_POSITIVEX = 0x400,
  91801. // DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800,
  91802. // DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000,
  91803. // DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000,
  91804. // DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000,
  91805. // DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000,
  91806. // DDSCAPS2_VOLUME = 0x200000;
  91807. var
  91808. //DDPF_ALPHAPIXELS = 0x1,
  91809. //DDPF_ALPHA = 0x2,
  91810. DDPF_FOURCC = 0x4, DDPF_RGB = 0x40,
  91811. //DDPF_YUV = 0x200,
  91812. DDPF_LUMINANCE = 0x20000;
  91813. function FourCCToInt32(value) {
  91814. return value.charCodeAt(0) +
  91815. (value.charCodeAt(1) << 8) +
  91816. (value.charCodeAt(2) << 16) +
  91817. (value.charCodeAt(3) << 24);
  91818. }
  91819. function Int32ToFourCC(value) {
  91820. return String.fromCharCode(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff);
  91821. }
  91822. var FOURCC_DXT1 = FourCCToInt32("DXT1");
  91823. var FOURCC_DXT3 = FourCCToInt32("DXT3");
  91824. var FOURCC_DXT5 = FourCCToInt32("DXT5");
  91825. var FOURCC_DX10 = FourCCToInt32("DX10");
  91826. var FOURCC_D3DFMT_R16G16B16A16F = 113;
  91827. var FOURCC_D3DFMT_R32G32B32A32F = 116;
  91828. var DXGI_FORMAT_R16G16B16A16_FLOAT = 10;
  91829. var DXGI_FORMAT_B8G8R8X8_UNORM = 88;
  91830. var headerLengthInt = 31; // The header length in 32 bit ints
  91831. // Offsets into the header array
  91832. var off_magic = 0;
  91833. var off_size = 1;
  91834. var off_flags = 2;
  91835. var off_height = 3;
  91836. var off_width = 4;
  91837. var off_mipmapCount = 7;
  91838. var off_pfFlags = 20;
  91839. var off_pfFourCC = 21;
  91840. var off_RGBbpp = 22;
  91841. var off_RMask = 23;
  91842. var off_GMask = 24;
  91843. var off_BMask = 25;
  91844. var off_AMask = 26;
  91845. // var off_caps1 = 27;
  91846. var off_caps2 = 28;
  91847. // var off_caps3 = 29;
  91848. // var off_caps4 = 30;
  91849. var off_dxgiFormat = 32;
  91850. /**
  91851. * Class used to provide DDS decompression tools
  91852. */
  91853. var DDSTools = /** @class */ (function () {
  91854. function DDSTools() {
  91855. }
  91856. /**
  91857. * Gets DDS information from an array buffer
  91858. * @param arrayBuffer defines the array buffer to read data from
  91859. * @returns the DDS information
  91860. */
  91861. DDSTools.GetDDSInfo = function (arrayBuffer) {
  91862. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  91863. var extendedHeader = new Int32Array(arrayBuffer, 0, headerLengthInt + 4);
  91864. var mipmapCount = 1;
  91865. if (header[off_flags] & DDSD_MIPMAPCOUNT) {
  91866. mipmapCount = Math.max(1, header[off_mipmapCount]);
  91867. }
  91868. var fourCC = header[off_pfFourCC];
  91869. var dxgiFormat = (fourCC === FOURCC_DX10) ? extendedHeader[off_dxgiFormat] : 0;
  91870. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  91871. switch (fourCC) {
  91872. case FOURCC_D3DFMT_R16G16B16A16F:
  91873. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  91874. break;
  91875. case FOURCC_D3DFMT_R32G32B32A32F:
  91876. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  91877. break;
  91878. case FOURCC_DX10:
  91879. if (dxgiFormat === DXGI_FORMAT_R16G16B16A16_FLOAT) {
  91880. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  91881. break;
  91882. }
  91883. }
  91884. return {
  91885. width: header[off_width],
  91886. height: header[off_height],
  91887. mipmapCount: mipmapCount,
  91888. isFourCC: (header[off_pfFlags] & DDPF_FOURCC) === DDPF_FOURCC,
  91889. isRGB: (header[off_pfFlags] & DDPF_RGB) === DDPF_RGB,
  91890. isLuminance: (header[off_pfFlags] & DDPF_LUMINANCE) === DDPF_LUMINANCE,
  91891. isCube: (header[off_caps2] & DDSCAPS2_CUBEMAP) === DDSCAPS2_CUBEMAP,
  91892. isCompressed: (fourCC === FOURCC_DXT1 || fourCC === FOURCC_DXT3 || fourCC === FOURCC_DXT5),
  91893. dxgiFormat: dxgiFormat,
  91894. textureType: textureType
  91895. };
  91896. };
  91897. DDSTools._ToHalfFloat = function (value) {
  91898. if (!DDSTools._FloatView) {
  91899. DDSTools._FloatView = new Float32Array(1);
  91900. DDSTools._Int32View = new Int32Array(DDSTools._FloatView.buffer);
  91901. }
  91902. DDSTools._FloatView[0] = value;
  91903. var x = DDSTools._Int32View[0];
  91904. var bits = (x >> 16) & 0x8000; /* Get the sign */
  91905. var m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */
  91906. var e = (x >> 23) & 0xff; /* Using int is faster here */
  91907. /* If zero, or denormal, or exponent underflows too much for a denormal
  91908. * half, return signed zero. */
  91909. if (e < 103) {
  91910. return bits;
  91911. }
  91912. /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */
  91913. if (e > 142) {
  91914. bits |= 0x7c00;
  91915. /* If exponent was 0xff and one mantissa bit was set, it means NaN,
  91916. * not Inf, so make sure we set one mantissa bit too. */
  91917. bits |= ((e == 255) ? 0 : 1) && (x & 0x007fffff);
  91918. return bits;
  91919. }
  91920. /* If exponent underflows but not too much, return a denormal */
  91921. if (e < 113) {
  91922. m |= 0x0800;
  91923. /* Extra rounding may overflow and set mantissa to 0 and exponent
  91924. * to 1, which is OK. */
  91925. bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);
  91926. return bits;
  91927. }
  91928. bits |= ((e - 112) << 10) | (m >> 1);
  91929. bits += m & 1;
  91930. return bits;
  91931. };
  91932. DDSTools._FromHalfFloat = function (value) {
  91933. var s = (value & 0x8000) >> 15;
  91934. var e = (value & 0x7C00) >> 10;
  91935. var f = value & 0x03FF;
  91936. if (e === 0) {
  91937. return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));
  91938. }
  91939. else if (e == 0x1F) {
  91940. return f ? NaN : ((s ? -1 : 1) * Infinity);
  91941. }
  91942. return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + (f / Math.pow(2, 10)));
  91943. };
  91944. DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  91945. var destArray = new Float32Array(dataLength);
  91946. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  91947. var index = 0;
  91948. for (var y = 0; y < height; y++) {
  91949. for (var x = 0; x < width; x++) {
  91950. var srcPos = (x + y * width) * 4;
  91951. destArray[index] = DDSTools._FromHalfFloat(srcData[srcPos]);
  91952. destArray[index + 1] = DDSTools._FromHalfFloat(srcData[srcPos + 1]);
  91953. destArray[index + 2] = DDSTools._FromHalfFloat(srcData[srcPos + 2]);
  91954. if (DDSTools.StoreLODInAlphaChannel) {
  91955. destArray[index + 3] = lod;
  91956. }
  91957. else {
  91958. destArray[index + 3] = DDSTools._FromHalfFloat(srcData[srcPos + 3]);
  91959. }
  91960. index += 4;
  91961. }
  91962. }
  91963. return destArray;
  91964. };
  91965. DDSTools._GetHalfFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  91966. if (DDSTools.StoreLODInAlphaChannel) {
  91967. var destArray = new Uint16Array(dataLength);
  91968. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  91969. var index = 0;
  91970. for (var y = 0; y < height; y++) {
  91971. for (var x = 0; x < width; x++) {
  91972. var srcPos = (x + y * width) * 4;
  91973. destArray[index] = srcData[srcPos];
  91974. destArray[index + 1] = srcData[srcPos + 1];
  91975. destArray[index + 2] = srcData[srcPos + 2];
  91976. destArray[index + 3] = DDSTools._ToHalfFloat(lod);
  91977. index += 4;
  91978. }
  91979. }
  91980. return destArray;
  91981. }
  91982. return new Uint16Array(arrayBuffer, dataOffset, dataLength);
  91983. };
  91984. DDSTools._GetFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  91985. if (DDSTools.StoreLODInAlphaChannel) {
  91986. var destArray = new Float32Array(dataLength);
  91987. var srcData = new Float32Array(arrayBuffer, dataOffset);
  91988. var index = 0;
  91989. for (var y = 0; y < height; y++) {
  91990. for (var x = 0; x < width; x++) {
  91991. var srcPos = (x + y * width) * 4;
  91992. destArray[index] = srcData[srcPos];
  91993. destArray[index + 1] = srcData[srcPos + 1];
  91994. destArray[index + 2] = srcData[srcPos + 2];
  91995. destArray[index + 3] = lod;
  91996. index += 4;
  91997. }
  91998. }
  91999. return destArray;
  92000. }
  92001. return new Float32Array(arrayBuffer, dataOffset, dataLength);
  92002. };
  92003. DDSTools._GetFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92004. var destArray = new Uint8Array(dataLength);
  92005. var srcData = new Float32Array(arrayBuffer, dataOffset);
  92006. var index = 0;
  92007. for (var y = 0; y < height; y++) {
  92008. for (var x = 0; x < width; x++) {
  92009. var srcPos = (x + y * width) * 4;
  92010. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos]) * 255;
  92011. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 1]) * 255;
  92012. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 2]) * 255;
  92013. if (DDSTools.StoreLODInAlphaChannel) {
  92014. destArray[index + 3] = lod;
  92015. }
  92016. else {
  92017. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 3]) * 255;
  92018. }
  92019. index += 4;
  92020. }
  92021. }
  92022. return destArray;
  92023. };
  92024. DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92025. var destArray = new Uint8Array(dataLength);
  92026. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  92027. var index = 0;
  92028. for (var y = 0; y < height; y++) {
  92029. for (var x = 0; x < width; x++) {
  92030. var srcPos = (x + y * width) * 4;
  92031. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos])) * 255;
  92032. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 1])) * 255;
  92033. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 2])) * 255;
  92034. if (DDSTools.StoreLODInAlphaChannel) {
  92035. destArray[index + 3] = lod;
  92036. }
  92037. else {
  92038. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 3])) * 255;
  92039. }
  92040. index += 4;
  92041. }
  92042. }
  92043. return destArray;
  92044. };
  92045. DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset) {
  92046. var byteArray = new Uint8Array(dataLength);
  92047. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  92048. var index = 0;
  92049. for (var y = 0; y < height; y++) {
  92050. for (var x = 0; x < width; x++) {
  92051. var srcPos = (x + y * width) * 4;
  92052. byteArray[index] = srcData[srcPos + rOffset];
  92053. byteArray[index + 1] = srcData[srcPos + gOffset];
  92054. byteArray[index + 2] = srcData[srcPos + bOffset];
  92055. byteArray[index + 3] = srcData[srcPos + aOffset];
  92056. index += 4;
  92057. }
  92058. }
  92059. return byteArray;
  92060. };
  92061. DDSTools._ExtractLongWordOrder = function (value) {
  92062. if (value === 0 || value === 255 || value === -16777216) {
  92063. return 0;
  92064. }
  92065. return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
  92066. };
  92067. DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset) {
  92068. var byteArray = new Uint8Array(dataLength);
  92069. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  92070. var index = 0;
  92071. for (var y = 0; y < height; y++) {
  92072. for (var x = 0; x < width; x++) {
  92073. var srcPos = (x + y * width) * 3;
  92074. byteArray[index] = srcData[srcPos + rOffset];
  92075. byteArray[index + 1] = srcData[srcPos + gOffset];
  92076. byteArray[index + 2] = srcData[srcPos + bOffset];
  92077. index += 3;
  92078. }
  92079. }
  92080. return byteArray;
  92081. };
  92082. DDSTools._GetLuminanceArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
  92083. var byteArray = new Uint8Array(dataLength);
  92084. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  92085. var index = 0;
  92086. for (var y = 0; y < height; y++) {
  92087. for (var x = 0; x < width; x++) {
  92088. var srcPos = (x + y * width);
  92089. byteArray[index] = srcData[srcPos];
  92090. index++;
  92091. }
  92092. }
  92093. return byteArray;
  92094. };
  92095. /**
  92096. * Uploads DDS Levels to a Babylon Texture
  92097. * @hidden
  92098. */
  92099. DDSTools.UploadDDSLevels = function (engine, texture, arrayBuffer, info, loadMipmaps, faces, lodIndex, currentFace) {
  92100. if (lodIndex === void 0) { lodIndex = -1; }
  92101. var sphericalPolynomialFaces = null;
  92102. if (info.sphericalPolynomial) {
  92103. sphericalPolynomialFaces = new Array();
  92104. }
  92105. var ext = engine.getCaps().s3tc;
  92106. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  92107. var fourCC, width, height, dataLength = 0, dataOffset;
  92108. var byteArray, mipmapCount, mip;
  92109. var internalCompressedFormat = 0;
  92110. var blockBytes = 1;
  92111. if (header[off_magic] !== DDS_MAGIC) {
  92112. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Invalid magic number in DDS header");
  92113. return;
  92114. }
  92115. if (!info.isFourCC && !info.isRGB && !info.isLuminance) {
  92116. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
  92117. return;
  92118. }
  92119. if (info.isCompressed && !ext) {
  92120. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Compressed textures are not supported on this platform.");
  92121. return;
  92122. }
  92123. var bpp = header[off_RGBbpp];
  92124. dataOffset = header[off_size] + 4;
  92125. var computeFormats = false;
  92126. if (info.isFourCC) {
  92127. fourCC = header[off_pfFourCC];
  92128. switch (fourCC) {
  92129. case FOURCC_DXT1:
  92130. blockBytes = 8;
  92131. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT1_EXT;
  92132. break;
  92133. case FOURCC_DXT3:
  92134. blockBytes = 16;
  92135. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT3_EXT;
  92136. break;
  92137. case FOURCC_DXT5:
  92138. blockBytes = 16;
  92139. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT5_EXT;
  92140. break;
  92141. case FOURCC_D3DFMT_R16G16B16A16F:
  92142. computeFormats = true;
  92143. break;
  92144. case FOURCC_D3DFMT_R32G32B32A32F:
  92145. computeFormats = true;
  92146. break;
  92147. case FOURCC_DX10:
  92148. // There is an additionnal header so dataOffset need to be changed
  92149. dataOffset += 5 * 4; // 5 uints
  92150. var supported = false;
  92151. switch (info.dxgiFormat) {
  92152. case DXGI_FORMAT_R16G16B16A16_FLOAT:
  92153. computeFormats = true;
  92154. supported = true;
  92155. break;
  92156. case DXGI_FORMAT_B8G8R8X8_UNORM:
  92157. info.isRGB = true;
  92158. info.isFourCC = false;
  92159. bpp = 32;
  92160. supported = true;
  92161. break;
  92162. }
  92163. if (supported) {
  92164. break;
  92165. }
  92166. default:
  92167. console.error("Unsupported FourCC code:", Int32ToFourCC(fourCC));
  92168. return;
  92169. }
  92170. }
  92171. var rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
  92172. var gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
  92173. var bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
  92174. var aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);
  92175. if (computeFormats) {
  92176. internalCompressedFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
  92177. }
  92178. mipmapCount = 1;
  92179. if (header[off_flags] & DDSD_MIPMAPCOUNT && loadMipmaps !== false) {
  92180. mipmapCount = Math.max(1, header[off_mipmapCount]);
  92181. }
  92182. for (var face = 0; face < faces; face++) {
  92183. width = header[off_width];
  92184. height = header[off_height];
  92185. for (mip = 0; mip < mipmapCount; ++mip) {
  92186. if (lodIndex === -1 || lodIndex === mip) {
  92187. // In case of fixed LOD, if the lod has just been uploaded, early exit.
  92188. var i = (lodIndex === -1) ? mip : 0;
  92189. if (!info.isCompressed && info.isFourCC) {
  92190. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  92191. dataLength = width * height * 4;
  92192. var floatArray = null;
  92193. if (engine._badOS || engine._badDesktopOS || (!engine.getCaps().textureHalfFloat && !engine.getCaps().textureFloat)) { // Required because iOS has many issues with float and half float generation
  92194. if (bpp === 128) {
  92195. floatArray = DDSTools._GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  92196. if (sphericalPolynomialFaces && i == 0) {
  92197. sphericalPolynomialFaces.push(DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  92198. }
  92199. }
  92200. else if (bpp === 64) {
  92201. floatArray = DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  92202. if (sphericalPolynomialFaces && i == 0) {
  92203. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  92204. }
  92205. }
  92206. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  92207. }
  92208. else {
  92209. if (bpp === 128) {
  92210. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  92211. floatArray = DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  92212. if (sphericalPolynomialFaces && i == 0) {
  92213. sphericalPolynomialFaces.push(floatArray);
  92214. }
  92215. }
  92216. else if (bpp === 64 && !engine.getCaps().textureHalfFloat) {
  92217. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  92218. floatArray = DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  92219. if (sphericalPolynomialFaces && i == 0) {
  92220. sphericalPolynomialFaces.push(floatArray);
  92221. }
  92222. }
  92223. else { // 64
  92224. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  92225. floatArray = DDSTools._GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  92226. if (sphericalPolynomialFaces && i == 0) {
  92227. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  92228. }
  92229. }
  92230. }
  92231. if (floatArray) {
  92232. engine._uploadDataToTextureDirectly(texture, floatArray, face, i);
  92233. }
  92234. }
  92235. else if (info.isRGB) {
  92236. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  92237. if (bpp === 24) {
  92238. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB;
  92239. dataLength = width * height * 3;
  92240. byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  92241. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  92242. }
  92243. else { // 32
  92244. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  92245. dataLength = width * height * 4;
  92246. byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  92247. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  92248. }
  92249. }
  92250. else if (info.isLuminance) {
  92251. var unpackAlignment = engine._getUnpackAlignement();
  92252. var unpaddedRowSize = width;
  92253. var paddedRowSize = Math.floor((width + unpackAlignment - 1) / unpackAlignment) * unpackAlignment;
  92254. dataLength = paddedRowSize * (height - 1) + unpaddedRowSize;
  92255. byteArray = DDSTools._GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  92256. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE;
  92257. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  92258. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  92259. }
  92260. else {
  92261. dataLength = Math.max(4, width) / 4 * Math.max(4, height) / 4 * blockBytes;
  92262. byteArray = new Uint8Array(arrayBuffer, dataOffset, dataLength);
  92263. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  92264. engine._uploadCompressedDataToTextureDirectly(texture, internalCompressedFormat, width, height, byteArray, face, i);
  92265. }
  92266. }
  92267. dataOffset += bpp ? (width * height * (bpp / 8)) : dataLength;
  92268. width *= 0.5;
  92269. height *= 0.5;
  92270. width = Math.max(1.0, width);
  92271. height = Math.max(1.0, height);
  92272. }
  92273. if (currentFace !== undefined) {
  92274. // Loading a single face
  92275. break;
  92276. }
  92277. }
  92278. if (sphericalPolynomialFaces && sphericalPolynomialFaces.length > 0) {
  92279. info.sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial({
  92280. size: header[off_width],
  92281. right: sphericalPolynomialFaces[0],
  92282. left: sphericalPolynomialFaces[1],
  92283. up: sphericalPolynomialFaces[2],
  92284. down: sphericalPolynomialFaces[3],
  92285. front: sphericalPolynomialFaces[4],
  92286. back: sphericalPolynomialFaces[5],
  92287. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA,
  92288. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT,
  92289. gammaSpace: false,
  92290. });
  92291. }
  92292. else {
  92293. info.sphericalPolynomial = undefined;
  92294. }
  92295. };
  92296. /**
  92297. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  92298. */
  92299. DDSTools.StoreLODInAlphaChannel = false;
  92300. return DDSTools;
  92301. }());
  92302. /**
  92303. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  92304. * @param rootUrl defines the url where the file to load is located
  92305. * @param scene defines the current scene
  92306. * @param lodScale defines scale to apply to the mip map selection
  92307. * @param lodOffset defines offset to apply to the mip map selection
  92308. * @param onLoad defines an optional callback raised when the texture is loaded
  92309. * @param onError defines an optional callback raised if there is an issue to load the texture
  92310. * @param format defines the format of the data
  92311. * @param forcedExtension defines the extension to use to pick the right loader
  92312. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  92313. * @returns the cube texture as an InternalTexture
  92314. */
  92315. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createPrefilteredCubeTexture = function (rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, createPolynomials) {
  92316. var _this = this;
  92317. if (onLoad === void 0) { onLoad = null; }
  92318. if (onError === void 0) { onError = null; }
  92319. if (forcedExtension === void 0) { forcedExtension = null; }
  92320. if (createPolynomials === void 0) { createPolynomials = true; }
  92321. var callback = function (loadData) {
  92322. if (!loadData) {
  92323. if (onLoad) {
  92324. onLoad(null);
  92325. }
  92326. return;
  92327. }
  92328. var texture = loadData.texture;
  92329. if (!createPolynomials) {
  92330. texture._sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__["SphericalPolynomial"]();
  92331. }
  92332. else if (loadData.info.sphericalPolynomial) {
  92333. texture._sphericalPolynomial = loadData.info.sphericalPolynomial;
  92334. }
  92335. texture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBEPREFILTERED;
  92336. if (_this.getCaps().textureLOD) {
  92337. // Do not add extra process if texture lod is supported.
  92338. if (onLoad) {
  92339. onLoad(texture);
  92340. }
  92341. return;
  92342. }
  92343. var mipSlices = 3;
  92344. var gl = _this._gl;
  92345. var width = loadData.width;
  92346. if (!width) {
  92347. return;
  92348. }
  92349. var textures = [];
  92350. for (var i = 0; i < mipSlices; i++) {
  92351. //compute LOD from even spacing in smoothness (matching shader calculation)
  92352. var smoothness = i / (mipSlices - 1);
  92353. var roughness = 1 - smoothness;
  92354. var minLODIndex = lodOffset; // roughness = 0
  92355. var maxLODIndex = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) * lodScale + lodOffset; // roughness = 1
  92356. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  92357. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  92358. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  92359. glTextureFromLod.type = texture.type;
  92360. glTextureFromLod.format = texture.format;
  92361. glTextureFromLod.width = Math.pow(2, Math.max(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) - mipmapIndex, 0));
  92362. glTextureFromLod.height = glTextureFromLod.width;
  92363. glTextureFromLod.isCube = true;
  92364. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, glTextureFromLod, true);
  92365. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  92366. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  92367. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  92368. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  92369. if (loadData.isDDS) {
  92370. var info = loadData.info;
  92371. var data = loadData.data;
  92372. _this._unpackFlipY(info.isCompressed);
  92373. DDSTools.UploadDDSLevels(_this, glTextureFromLod, data, info, true, 6, mipmapIndex);
  92374. }
  92375. else {
  92376. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("DDS is the only prefiltered cube map supported so far.");
  92377. }
  92378. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  92379. // Wrap in a base texture for easy binding.
  92380. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__["BaseTexture"](scene);
  92381. lodTexture.isCube = true;
  92382. lodTexture._texture = glTextureFromLod;
  92383. glTextureFromLod.isReady = true;
  92384. textures.push(lodTexture);
  92385. }
  92386. texture._lodTextureHigh = textures[2];
  92387. texture._lodTextureMid = textures[1];
  92388. texture._lodTextureLow = textures[0];
  92389. if (onLoad) {
  92390. onLoad(texture);
  92391. }
  92392. };
  92393. return this.createCubeTexture(rootUrl, scene, null, false, callback, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset);
  92394. };
  92395. /***/ }),
  92396. /***/ "./Misc/decorators.ts":
  92397. /*!****************************!*\
  92398. !*** ./Misc/decorators.ts ***!
  92399. \****************************/
  92400. /*! exports provided: expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper */
  92401. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92402. "use strict";
  92403. __webpack_require__.r(__webpack_exports__);
  92404. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return expandToProperty; });
  92405. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return serialize; });
  92406. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return serializeAsTexture; });
  92407. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return serializeAsColor3; });
  92408. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return serializeAsFresnelParameters; });
  92409. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return serializeAsVector2; });
  92410. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return serializeAsVector3; });
  92411. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return serializeAsMeshReference; });
  92412. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return serializeAsColorCurves; });
  92413. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return serializeAsColor4; });
  92414. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return serializeAsImageProcessingConfiguration; });
  92415. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return serializeAsQuaternion; });
  92416. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return serializeAsCameraReference; });
  92417. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return SerializationHelper; });
  92418. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  92419. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  92420. var __decoratorInitialStore = {};
  92421. var __mergedStore = {};
  92422. var _copySource = function (creationFunction, source, instanciate) {
  92423. var destination = creationFunction();
  92424. // Tags
  92425. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  92426. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  92427. }
  92428. var classStore = getMergedStore(destination);
  92429. // Properties
  92430. for (var property in classStore) {
  92431. var propertyDescriptor = classStore[property];
  92432. var sourceProperty = source[property];
  92433. var propertyType = propertyDescriptor.type;
  92434. if (sourceProperty !== undefined && sourceProperty !== null) {
  92435. switch (propertyType) {
  92436. case 0: // Value
  92437. case 6: // Mesh reference
  92438. case 11: // Camera reference
  92439. destination[property] = sourceProperty;
  92440. break;
  92441. case 1: // Texture
  92442. destination[property] = (instanciate || sourceProperty.isRenderTarget) ? sourceProperty : sourceProperty.clone();
  92443. break;
  92444. case 2: // Color3
  92445. case 3: // FresnelParameters
  92446. case 4: // Vector2
  92447. case 5: // Vector3
  92448. case 7: // Color Curves
  92449. case 10: // Quaternion
  92450. destination[property] = instanciate ? sourceProperty : sourceProperty.clone();
  92451. break;
  92452. }
  92453. }
  92454. }
  92455. return destination;
  92456. };
  92457. function getDirectStore(target) {
  92458. var classKey = target.getClassName();
  92459. if (!__decoratorInitialStore[classKey]) {
  92460. __decoratorInitialStore[classKey] = {};
  92461. }
  92462. return __decoratorInitialStore[classKey];
  92463. }
  92464. /**
  92465. * Return the list of properties flagged as serializable
  92466. * @param target: host object
  92467. */
  92468. function getMergedStore(target) {
  92469. var classKey = target.getClassName();
  92470. if (__mergedStore[classKey]) {
  92471. return __mergedStore[classKey];
  92472. }
  92473. __mergedStore[classKey] = {};
  92474. var store = __mergedStore[classKey];
  92475. var currentTarget = target;
  92476. var currentKey = classKey;
  92477. while (currentKey) {
  92478. var initialStore = __decoratorInitialStore[currentKey];
  92479. for (var property in initialStore) {
  92480. store[property] = initialStore[property];
  92481. }
  92482. var parent_1 = void 0;
  92483. var done = false;
  92484. do {
  92485. parent_1 = Object.getPrototypeOf(currentTarget);
  92486. if (!parent_1.getClassName) {
  92487. done = true;
  92488. break;
  92489. }
  92490. if (parent_1.getClassName() !== currentKey) {
  92491. break;
  92492. }
  92493. currentTarget = parent_1;
  92494. } while (parent_1);
  92495. if (done) {
  92496. break;
  92497. }
  92498. currentKey = parent_1.getClassName();
  92499. currentTarget = parent_1;
  92500. }
  92501. return store;
  92502. }
  92503. function generateSerializableMember(type, sourceName) {
  92504. return function (target, propertyKey) {
  92505. var classStore = getDirectStore(target);
  92506. if (!classStore[propertyKey]) {
  92507. classStore[propertyKey] = { type: type, sourceName: sourceName };
  92508. }
  92509. };
  92510. }
  92511. function generateExpandMember(setCallback, targetKey) {
  92512. if (targetKey === void 0) { targetKey = null; }
  92513. return function (target, propertyKey) {
  92514. var key = targetKey || ("_" + propertyKey);
  92515. Object.defineProperty(target, propertyKey, {
  92516. get: function () {
  92517. return this[key];
  92518. },
  92519. set: function (value) {
  92520. if (this[key] === value) {
  92521. return;
  92522. }
  92523. this[key] = value;
  92524. target[setCallback].apply(this);
  92525. },
  92526. enumerable: true,
  92527. configurable: true
  92528. });
  92529. };
  92530. }
  92531. function expandToProperty(callback, targetKey) {
  92532. if (targetKey === void 0) { targetKey = null; }
  92533. return generateExpandMember(callback, targetKey);
  92534. }
  92535. function serialize(sourceName) {
  92536. return generateSerializableMember(0, sourceName); // value member
  92537. }
  92538. function serializeAsTexture(sourceName) {
  92539. return generateSerializableMember(1, sourceName); // texture member
  92540. }
  92541. function serializeAsColor3(sourceName) {
  92542. return generateSerializableMember(2, sourceName); // color3 member
  92543. }
  92544. function serializeAsFresnelParameters(sourceName) {
  92545. return generateSerializableMember(3, sourceName); // fresnel parameters member
  92546. }
  92547. function serializeAsVector2(sourceName) {
  92548. return generateSerializableMember(4, sourceName); // vector2 member
  92549. }
  92550. function serializeAsVector3(sourceName) {
  92551. return generateSerializableMember(5, sourceName); // vector3 member
  92552. }
  92553. function serializeAsMeshReference(sourceName) {
  92554. return generateSerializableMember(6, sourceName); // mesh reference member
  92555. }
  92556. function serializeAsColorCurves(sourceName) {
  92557. return generateSerializableMember(7, sourceName); // color curves
  92558. }
  92559. function serializeAsColor4(sourceName) {
  92560. return generateSerializableMember(8, sourceName); // color 4
  92561. }
  92562. function serializeAsImageProcessingConfiguration(sourceName) {
  92563. return generateSerializableMember(9, sourceName); // image processing
  92564. }
  92565. function serializeAsQuaternion(sourceName) {
  92566. return generateSerializableMember(10, sourceName); // quaternion member
  92567. }
  92568. /**
  92569. * Decorator used to define property that can be serialized as reference to a camera
  92570. * @param sourceName defines the name of the property to decorate
  92571. */
  92572. function serializeAsCameraReference(sourceName) {
  92573. return generateSerializableMember(11, sourceName); // camera reference member
  92574. }
  92575. /**
  92576. * Class used to help serialization objects
  92577. */
  92578. var SerializationHelper = /** @class */ (function () {
  92579. function SerializationHelper() {
  92580. }
  92581. /**
  92582. * Appends the serialized animations from the source animations
  92583. * @param source Source containing the animations
  92584. * @param destination Target to store the animations
  92585. */
  92586. SerializationHelper.AppendSerializedAnimations = function (source, destination) {
  92587. if (source.animations) {
  92588. destination.animations = [];
  92589. for (var animationIndex = 0; animationIndex < source.animations.length; animationIndex++) {
  92590. var animation = source.animations[animationIndex];
  92591. destination.animations.push(animation.serialize());
  92592. }
  92593. }
  92594. };
  92595. /**
  92596. * Static function used to serialized a specific entity
  92597. * @param entity defines the entity to serialize
  92598. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  92599. * @returns a JSON compatible object representing the serialization of the entity
  92600. */
  92601. SerializationHelper.Serialize = function (entity, serializationObject) {
  92602. if (!serializationObject) {
  92603. serializationObject = {};
  92604. }
  92605. // Tags
  92606. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  92607. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].GetTags(entity);
  92608. }
  92609. var serializedProperties = getMergedStore(entity);
  92610. // Properties
  92611. for (var property in serializedProperties) {
  92612. var propertyDescriptor = serializedProperties[property];
  92613. var targetPropertyName = propertyDescriptor.sourceName || property;
  92614. var propertyType = propertyDescriptor.type;
  92615. var sourceProperty = entity[property];
  92616. if (sourceProperty !== undefined && sourceProperty !== null) {
  92617. switch (propertyType) {
  92618. case 0: // Value
  92619. serializationObject[targetPropertyName] = sourceProperty;
  92620. break;
  92621. case 1: // Texture
  92622. serializationObject[targetPropertyName] = sourceProperty.serialize();
  92623. break;
  92624. case 2: // Color3
  92625. serializationObject[targetPropertyName] = sourceProperty.asArray();
  92626. break;
  92627. case 3: // FresnelParameters
  92628. serializationObject[targetPropertyName] = sourceProperty.serialize();
  92629. break;
  92630. case 4: // Vector2
  92631. serializationObject[targetPropertyName] = sourceProperty.asArray();
  92632. break;
  92633. case 5: // Vector3
  92634. serializationObject[targetPropertyName] = sourceProperty.asArray();
  92635. break;
  92636. case 6: // Mesh reference
  92637. serializationObject[targetPropertyName] = sourceProperty.id;
  92638. break;
  92639. case 7: // Color Curves
  92640. serializationObject[targetPropertyName] = sourceProperty.serialize();
  92641. break;
  92642. case 8: // Color 4
  92643. serializationObject[targetPropertyName] = sourceProperty.asArray();
  92644. break;
  92645. case 9: // Image Processing
  92646. serializationObject[targetPropertyName] = sourceProperty.serialize();
  92647. break;
  92648. case 10: // Quaternion
  92649. serializationObject[targetPropertyName] = sourceProperty.asArray();
  92650. break;
  92651. case 11: // Camera reference
  92652. serializationObject[targetPropertyName] = sourceProperty.id;
  92653. break;
  92654. }
  92655. }
  92656. }
  92657. return serializationObject;
  92658. };
  92659. /**
  92660. * Creates a new entity from a serialization data object
  92661. * @param creationFunction defines a function used to instanciated the new entity
  92662. * @param source defines the source serialization data
  92663. * @param scene defines the hosting scene
  92664. * @param rootUrl defines the root url for resources
  92665. * @returns a new entity
  92666. */
  92667. SerializationHelper.Parse = function (creationFunction, source, scene, rootUrl) {
  92668. if (rootUrl === void 0) { rootUrl = null; }
  92669. var destination = creationFunction();
  92670. if (!rootUrl) {
  92671. rootUrl = "";
  92672. }
  92673. // Tags
  92674. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  92675. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  92676. }
  92677. var classStore = getMergedStore(destination);
  92678. // Properties
  92679. for (var property in classStore) {
  92680. var propertyDescriptor = classStore[property];
  92681. var sourceProperty = source[propertyDescriptor.sourceName || property];
  92682. var propertyType = propertyDescriptor.type;
  92683. if (sourceProperty !== undefined && sourceProperty !== null) {
  92684. var dest = destination;
  92685. switch (propertyType) {
  92686. case 0: // Value
  92687. dest[property] = sourceProperty;
  92688. break;
  92689. case 1: // Texture
  92690. if (scene) {
  92691. dest[property] = SerializationHelper._TextureParser(sourceProperty, scene, rootUrl);
  92692. }
  92693. break;
  92694. case 2: // Color3
  92695. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(sourceProperty);
  92696. break;
  92697. case 3: // FresnelParameters
  92698. dest[property] = SerializationHelper._FresnelParametersParser(sourceProperty);
  92699. break;
  92700. case 4: // Vector2
  92701. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"].FromArray(sourceProperty);
  92702. break;
  92703. case 5: // Vector3
  92704. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(sourceProperty);
  92705. break;
  92706. case 6: // Mesh reference
  92707. if (scene) {
  92708. dest[property] = scene.getLastMeshByID(sourceProperty);
  92709. }
  92710. break;
  92711. case 7: // Color Curves
  92712. dest[property] = SerializationHelper._ColorCurvesParser(sourceProperty);
  92713. break;
  92714. case 8: // Color 4
  92715. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(sourceProperty);
  92716. break;
  92717. case 9: // Image Processing
  92718. dest[property] = SerializationHelper._ImageProcessingConfigurationParser(sourceProperty);
  92719. break;
  92720. case 10: // Quaternion
  92721. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromArray(sourceProperty);
  92722. break;
  92723. case 11: // Camera reference
  92724. if (scene) {
  92725. dest[property] = scene.getCameraByID(sourceProperty);
  92726. }
  92727. break;
  92728. }
  92729. }
  92730. }
  92731. return destination;
  92732. };
  92733. /**
  92734. * Clones an object
  92735. * @param creationFunction defines the function used to instanciate the new object
  92736. * @param source defines the source object
  92737. * @returns the cloned object
  92738. */
  92739. SerializationHelper.Clone = function (creationFunction, source) {
  92740. return _copySource(creationFunction, source, false);
  92741. };
  92742. /**
  92743. * Instanciates a new object based on a source one (some data will be shared between both object)
  92744. * @param creationFunction defines the function used to instanciate the new object
  92745. * @param source defines the source object
  92746. * @returns the new object
  92747. */
  92748. SerializationHelper.Instanciate = function (creationFunction, source) {
  92749. return _copySource(creationFunction, source, true);
  92750. };
  92751. /** hidden */
  92752. SerializationHelper._ImageProcessingConfigurationParser = function (sourceProperty) {
  92753. throw "ImageProcessingConfiguration needs to be imported before being deserialized.";
  92754. };
  92755. /** hidden */
  92756. SerializationHelper._FresnelParametersParser = function (sourceProperty) {
  92757. throw "FresnelParameters needs to be imported before being deserialized.";
  92758. };
  92759. /** hidden */
  92760. SerializationHelper._ColorCurvesParser = function (sourceProperty) {
  92761. throw "ColorCurves needs to be imported before being deserialized.";
  92762. };
  92763. /** hidden */
  92764. SerializationHelper._TextureParser = function (sourceProperty, scene, rootUrl) {
  92765. throw "Texture needs to be imported before being deserialized.";
  92766. };
  92767. return SerializationHelper;
  92768. }());
  92769. /***/ }),
  92770. /***/ "./Misc/deepCopier.ts":
  92771. /*!****************************!*\
  92772. !*** ./Misc/deepCopier.ts ***!
  92773. \****************************/
  92774. /*! exports provided: DeepCopier */
  92775. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92776. "use strict";
  92777. __webpack_require__.r(__webpack_exports__);
  92778. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return DeepCopier; });
  92779. var cloneValue = function (source, destinationObject) {
  92780. if (!source) {
  92781. return null;
  92782. }
  92783. if (source.getClassName && source.getClassName() === "Mesh") {
  92784. return null;
  92785. }
  92786. if (source.getClassName && source.getClassName() === "SubMesh") {
  92787. return source.clone(destinationObject);
  92788. }
  92789. else if (source.clone) {
  92790. return source.clone();
  92791. }
  92792. return null;
  92793. };
  92794. /**
  92795. * Class containing a set of static utilities functions for deep copy.
  92796. */
  92797. var DeepCopier = /** @class */ (function () {
  92798. function DeepCopier() {
  92799. }
  92800. /**
  92801. * Tries to copy an object by duplicating every property
  92802. * @param source defines the source object
  92803. * @param destination defines the target object
  92804. * @param doNotCopyList defines a list of properties to avoid
  92805. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  92806. */
  92807. DeepCopier.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  92808. for (var prop in source) {
  92809. if (prop[0] === "_" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {
  92810. continue;
  92811. }
  92812. if (doNotCopyList && doNotCopyList.indexOf(prop) !== -1) {
  92813. continue;
  92814. }
  92815. var sourceValue = source[prop];
  92816. var typeOfSourceValue = typeof sourceValue;
  92817. if (typeOfSourceValue === "function") {
  92818. continue;
  92819. }
  92820. try {
  92821. if (typeOfSourceValue === "object") {
  92822. if (sourceValue instanceof Array) {
  92823. destination[prop] = [];
  92824. if (sourceValue.length > 0) {
  92825. if (typeof sourceValue[0] == "object") {
  92826. for (var index = 0; index < sourceValue.length; index++) {
  92827. var clonedValue = cloneValue(sourceValue[index], destination);
  92828. if (destination[prop].indexOf(clonedValue) === -1) { // Test if auto inject was not done
  92829. destination[prop].push(clonedValue);
  92830. }
  92831. }
  92832. }
  92833. else {
  92834. destination[prop] = sourceValue.slice(0);
  92835. }
  92836. }
  92837. }
  92838. else {
  92839. destination[prop] = cloneValue(sourceValue, destination);
  92840. }
  92841. }
  92842. else {
  92843. destination[prop] = sourceValue;
  92844. }
  92845. }
  92846. catch (e) {
  92847. // Just ignore error (it could be because of a read-only property)
  92848. }
  92849. }
  92850. };
  92851. return DeepCopier;
  92852. }());
  92853. /***/ }),
  92854. /***/ "./Misc/deferred.ts":
  92855. /*!**************************!*\
  92856. !*** ./Misc/deferred.ts ***!
  92857. \**************************/
  92858. /*! exports provided: Deferred */
  92859. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92860. "use strict";
  92861. __webpack_require__.r(__webpack_exports__);
  92862. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return Deferred; });
  92863. /**
  92864. * Wrapper class for promise with external resolve and reject.
  92865. */
  92866. var Deferred = /** @class */ (function () {
  92867. /**
  92868. * Constructor for this deferred object.
  92869. */
  92870. function Deferred() {
  92871. var _this = this;
  92872. this.promise = new Promise(function (resolve, reject) {
  92873. _this._resolve = resolve;
  92874. _this._reject = reject;
  92875. });
  92876. }
  92877. Object.defineProperty(Deferred.prototype, "resolve", {
  92878. /**
  92879. * The resolve method of the promise associated with this deferred object.
  92880. */
  92881. get: function () {
  92882. return this._resolve;
  92883. },
  92884. enumerable: true,
  92885. configurable: true
  92886. });
  92887. Object.defineProperty(Deferred.prototype, "reject", {
  92888. /**
  92889. * The reject method of the promise associated with this deferred object.
  92890. */
  92891. get: function () {
  92892. return this._reject;
  92893. },
  92894. enumerable: true,
  92895. configurable: true
  92896. });
  92897. return Deferred;
  92898. }());
  92899. /***/ }),
  92900. /***/ "./Misc/domManagement.ts":
  92901. /*!*******************************!*\
  92902. !*** ./Misc/domManagement.ts ***!
  92903. \*******************************/
  92904. /*! exports provided: DomManagement */
  92905. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92906. "use strict";
  92907. __webpack_require__.r(__webpack_exports__);
  92908. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DomManagement", function() { return DomManagement; });
  92909. /**
  92910. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  92911. * Babylon.js
  92912. */
  92913. var DomManagement = /** @class */ (function () {
  92914. function DomManagement() {
  92915. }
  92916. /**
  92917. * Checks if the window object exists
  92918. * @returns true if the window object exists
  92919. */
  92920. DomManagement.IsWindowObjectExist = function () {
  92921. return (typeof window) !== "undefined";
  92922. };
  92923. /**
  92924. * Extracts text content from a DOM element hierarchy
  92925. * @param element defines the root element
  92926. * @returns a string
  92927. */
  92928. DomManagement.GetDOMTextContent = function (element) {
  92929. var result = "";
  92930. var child = element.firstChild;
  92931. while (child) {
  92932. if (child.nodeType === 3) {
  92933. result += child.textContent;
  92934. }
  92935. child = (child.nextSibling);
  92936. }
  92937. return result;
  92938. };
  92939. return DomManagement;
  92940. }());
  92941. /***/ }),
  92942. /***/ "./Misc/environmentTextureTools.ts":
  92943. /*!*****************************************!*\
  92944. !*** ./Misc/environmentTextureTools.ts ***!
  92945. \*****************************************/
  92946. /*! exports provided: EnvironmentTextureTools */
  92947. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92948. "use strict";
  92949. __webpack_require__.r(__webpack_exports__);
  92950. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return EnvironmentTextureTools; });
  92951. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  92952. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  92953. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  92954. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  92955. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  92956. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  92957. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  92958. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  92959. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  92960. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  92961. /* harmony import */ var _Shaders_rgbdEncode_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/rgbdEncode.fragment */ "./Shaders/rgbdEncode.fragment.ts");
  92962. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  92963. /**
  92964. * Sets of helpers addressing the serialization and deserialization of environment texture
  92965. * stored in a BabylonJS env file.
  92966. * Those files are usually stored as .env files.
  92967. */
  92968. var EnvironmentTextureTools = /** @class */ (function () {
  92969. function EnvironmentTextureTools() {
  92970. }
  92971. /**
  92972. * Gets the environment info from an env file.
  92973. * @param data The array buffer containing the .env bytes.
  92974. * @returns the environment file info (the json header) if successfully parsed.
  92975. */
  92976. EnvironmentTextureTools.GetEnvInfo = function (data) {
  92977. var dataView = new DataView(data);
  92978. var pos = 0;
  92979. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  92980. if (dataView.getUint8(pos++) !== EnvironmentTextureTools._MagicBytes[i]) {
  92981. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Error('Not a babylon environment map');
  92982. return null;
  92983. }
  92984. }
  92985. // Read json manifest - collect characters up to null terminator
  92986. var manifestString = '';
  92987. var charCode = 0x00;
  92988. while ((charCode = dataView.getUint8(pos++))) {
  92989. manifestString += String.fromCharCode(charCode);
  92990. }
  92991. var manifest = JSON.parse(manifestString);
  92992. if (manifest.specular) {
  92993. // Extend the header with the position of the payload.
  92994. manifest.specular.specularDataPosition = pos;
  92995. // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.
  92996. manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;
  92997. }
  92998. return manifest;
  92999. };
  93000. /**
  93001. * Creates an environment texture from a loaded cube texture.
  93002. * @param texture defines the cube texture to convert in env file
  93003. * @return a promise containing the environment data if succesfull.
  93004. */
  93005. EnvironmentTextureTools.CreateEnvTextureAsync = function (texture) {
  93006. var _this = this;
  93007. var internalTexture = texture.getInternalTexture();
  93008. if (!internalTexture) {
  93009. return Promise.reject("The cube texture is invalid.");
  93010. }
  93011. if (!texture._prefiltered) {
  93012. return Promise.reject("The cube texture is invalid (not prefiltered).");
  93013. }
  93014. var engine = internalTexture.getEngine();
  93015. if (engine && engine.premultipliedAlpha) {
  93016. return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");
  93017. }
  93018. if (texture.textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  93019. return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");
  93020. }
  93021. var canvas = engine.getRenderingCanvas();
  93022. if (!canvas) {
  93023. return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");
  93024. }
  93025. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  93026. if (!engine.getCaps().textureFloatRender) {
  93027. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  93028. if (!engine.getCaps().textureHalfFloatRender) {
  93029. return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");
  93030. }
  93031. }
  93032. var cubeWidth = internalTexture.width;
  93033. var hostingScene = new _scene__WEBPACK_IMPORTED_MODULE_7__["Scene"](engine);
  93034. var specularTextures = {};
  93035. var promises = [];
  93036. // Read and collect all mipmaps data from the cube.
  93037. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(internalTexture.width);
  93038. mipmapsCount = Math.round(mipmapsCount);
  93039. var _loop_1 = function (i) {
  93040. var faceWidth = Math.pow(2, mipmapsCount - i);
  93041. var _loop_2 = function (face) {
  93042. var data = texture.readPixels(face, i);
  93043. // Creates a temp texture with the face data.
  93044. 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);
  93045. // And rgbdEncode them.
  93046. var promise = new Promise(function (resolve, reject) {
  93047. 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);
  93048. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  93049. rgbdPostProcess.onApply = function (effect) {
  93050. effect._bindTexture("textureSampler", tempTexture);
  93051. };
  93052. // As the process needs to happen on the main canvas, keep track of the current size
  93053. var currentW = engine.getRenderWidth();
  93054. var currentH = engine.getRenderHeight();
  93055. // Set the desired size for the texture
  93056. engine.setSize(faceWidth, faceWidth);
  93057. hostingScene.postProcessManager.directRender([rgbdPostProcess], null);
  93058. // Reading datas from WebGL
  93059. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ToBlob(canvas, function (blob) {
  93060. var fileReader = new FileReader();
  93061. fileReader.onload = function (event) {
  93062. var arrayBuffer = event.target.result;
  93063. specularTextures[i * 6 + face] = arrayBuffer;
  93064. resolve();
  93065. };
  93066. fileReader.readAsArrayBuffer(blob);
  93067. });
  93068. // Reapply the previous canvas size
  93069. engine.setSize(currentW, currentH);
  93070. });
  93071. });
  93072. promises.push(promise);
  93073. };
  93074. // All faces of the cube.
  93075. for (var face = 0; face < 6; face++) {
  93076. _loop_2(face);
  93077. }
  93078. };
  93079. for (var i = 0; i <= mipmapsCount; i++) {
  93080. _loop_1(i);
  93081. }
  93082. // Once all the textures haves been collected as RGBD stored in PNGs
  93083. return Promise.all(promises).then(function () {
  93084. // We can delete the hosting scene keeping track of all the creation objects
  93085. hostingScene.dispose();
  93086. // Creates the json header for the env texture
  93087. var info = {
  93088. version: 1,
  93089. width: cubeWidth,
  93090. irradiance: _this._CreateEnvTextureIrradiance(texture),
  93091. specular: {
  93092. mipmaps: [],
  93093. lodGenerationScale: texture.lodGenerationScale
  93094. }
  93095. };
  93096. // Sets the specular image data information
  93097. var position = 0;
  93098. for (var i = 0; i <= mipmapsCount; i++) {
  93099. for (var face = 0; face < 6; face++) {
  93100. var byteLength = specularTextures[i * 6 + face].byteLength;
  93101. info.specular.mipmaps.push({
  93102. length: byteLength,
  93103. position: position
  93104. });
  93105. position += byteLength;
  93106. }
  93107. }
  93108. // Encode the JSON as an array buffer
  93109. var infoString = JSON.stringify(info);
  93110. var infoBuffer = new ArrayBuffer(infoString.length + 1);
  93111. var infoView = new Uint8Array(infoBuffer); // Limited to ascii subset matching unicode.
  93112. for (var i = 0, strLen = infoString.length; i < strLen; i++) {
  93113. infoView[i] = infoString.charCodeAt(i);
  93114. }
  93115. // Ends up with a null terminator for easier parsing
  93116. infoView[infoString.length] = 0x00;
  93117. // Computes the final required size and creates the storage
  93118. var totalSize = EnvironmentTextureTools._MagicBytes.length + position + infoBuffer.byteLength;
  93119. var finalBuffer = new ArrayBuffer(totalSize);
  93120. var finalBufferView = new Uint8Array(finalBuffer);
  93121. var dataView = new DataView(finalBuffer);
  93122. // Copy the magic bytes identifying the file in
  93123. var pos = 0;
  93124. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  93125. dataView.setUint8(pos++, EnvironmentTextureTools._MagicBytes[i]);
  93126. }
  93127. // Add the json info
  93128. finalBufferView.set(new Uint8Array(infoBuffer), pos);
  93129. pos += infoBuffer.byteLength;
  93130. // Finally inserts the texture data
  93131. for (var i = 0; i <= mipmapsCount; i++) {
  93132. for (var face = 0; face < 6; face++) {
  93133. var dataBuffer = specularTextures[i * 6 + face];
  93134. finalBufferView.set(new Uint8Array(dataBuffer), pos);
  93135. pos += dataBuffer.byteLength;
  93136. }
  93137. }
  93138. // Voila
  93139. return finalBuffer;
  93140. });
  93141. };
  93142. /**
  93143. * Creates a JSON representation of the spherical data.
  93144. * @param texture defines the texture containing the polynomials
  93145. * @return the JSON representation of the spherical info
  93146. */
  93147. EnvironmentTextureTools._CreateEnvTextureIrradiance = function (texture) {
  93148. var polynmials = texture.sphericalPolynomial;
  93149. if (polynmials == null) {
  93150. return null;
  93151. }
  93152. return {
  93153. x: [polynmials.x.x, polynmials.x.y, polynmials.x.z],
  93154. y: [polynmials.y.x, polynmials.y.y, polynmials.y.z],
  93155. z: [polynmials.z.x, polynmials.z.y, polynmials.z.z],
  93156. xx: [polynmials.xx.x, polynmials.xx.y, polynmials.xx.z],
  93157. yy: [polynmials.yy.x, polynmials.yy.y, polynmials.yy.z],
  93158. zz: [polynmials.zz.x, polynmials.zz.y, polynmials.zz.z],
  93159. yz: [polynmials.yz.x, polynmials.yz.y, polynmials.yz.z],
  93160. zx: [polynmials.zx.x, polynmials.zx.y, polynmials.zx.z],
  93161. xy: [polynmials.xy.x, polynmials.xy.y, polynmials.xy.z]
  93162. };
  93163. };
  93164. /**
  93165. * Uploads the texture info contained in the env file to the GPU.
  93166. * @param texture defines the internal texture to upload to
  93167. * @param arrayBuffer defines the buffer cotaining the data to load
  93168. * @param info defines the texture info retrieved through the GetEnvInfo method
  93169. * @returns a promise
  93170. */
  93171. EnvironmentTextureTools.UploadEnvLevelsAsync = function (texture, arrayBuffer, info) {
  93172. if (info.version !== 1) {
  93173. throw new Error("Unsupported babylon environment map version \"" + info.version + "\"");
  93174. }
  93175. var specularInfo = info.specular;
  93176. if (!specularInfo) {
  93177. // Nothing else parsed so far
  93178. return Promise.resolve();
  93179. }
  93180. // Double checks the enclosed info
  93181. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(info.width);
  93182. mipmapsCount = Math.round(mipmapsCount) + 1;
  93183. if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {
  93184. throw new Error("Unsupported specular mipmaps number \"" + specularInfo.mipmaps.length + "\"");
  93185. }
  93186. texture._lodGenerationScale = specularInfo.lodGenerationScale;
  93187. var imageData = new Array(mipmapsCount);
  93188. for (var i = 0; i < mipmapsCount; i++) {
  93189. imageData[i] = new Array(6);
  93190. for (var face = 0; face < 6; face++) {
  93191. var imageInfo = specularInfo.mipmaps[i * 6 + face];
  93192. imageData[i][face] = new Uint8Array(arrayBuffer, specularInfo.specularDataPosition + imageInfo.position, imageInfo.length);
  93193. }
  93194. }
  93195. return EnvironmentTextureTools.UploadLevelsAsync(texture, imageData);
  93196. };
  93197. /**
  93198. * Uploads the levels of image data to the GPU.
  93199. * @param texture defines the internal texture to upload to
  93200. * @param imageData defines the array buffer views of image data [mipmap][face]
  93201. * @returns a promise
  93202. */
  93203. EnvironmentTextureTools.UploadLevelsAsync = function (texture, imageData) {
  93204. if (!_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsExponentOfTwo(texture.width)) {
  93205. throw new Error("Texture size must be a power of two");
  93206. }
  93207. var mipmapsCount = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(texture.width)) + 1;
  93208. // Gets everything ready.
  93209. var engine = texture.getEngine();
  93210. var expandTexture = false;
  93211. var generateNonLODTextures = false;
  93212. var rgbdPostProcess = null;
  93213. var cubeRtt = null;
  93214. var lodTextures = null;
  93215. var caps = engine.getCaps();
  93216. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA;
  93217. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93218. texture.generateMipMaps = true;
  93219. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, texture);
  93220. // Add extra process if texture lod is not supported
  93221. if (!caps.textureLOD) {
  93222. expandTexture = false;
  93223. generateNonLODTextures = true;
  93224. lodTextures = {};
  93225. }
  93226. // in webgl 1 there are no ways to either render or copy lod level information for float textures.
  93227. else if (engine.webGLVersion < 2) {
  93228. expandTexture = false;
  93229. }
  93230. // If half float available we can uncompress the texture
  93231. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  93232. expandTexture = true;
  93233. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  93234. }
  93235. // If full float available we can uncompress the texture
  93236. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  93237. expandTexture = true;
  93238. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  93239. }
  93240. // Expand the texture if possible
  93241. if (expandTexture) {
  93242. // Simply run through the decode PP
  93243. 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);
  93244. texture._isRGBD = false;
  93245. texture.invertY = false;
  93246. cubeRtt = engine.createRenderTargetCubeTexture(texture.width, {
  93247. generateDepthBuffer: false,
  93248. generateMipMaps: true,
  93249. generateStencilBuffer: false,
  93250. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE,
  93251. type: texture.type,
  93252. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA
  93253. });
  93254. }
  93255. else {
  93256. texture._isRGBD = true;
  93257. texture.invertY = true;
  93258. // In case of missing support, applies the same patch than DDS files.
  93259. if (generateNonLODTextures) {
  93260. var mipSlices = 3;
  93261. var scale = texture._lodGenerationScale;
  93262. var offset = texture._lodGenerationOffset;
  93263. for (var i = 0; i < mipSlices; i++) {
  93264. //compute LOD from even spacing in smoothness (matching shader calculation)
  93265. var smoothness = i / (mipSlices - 1);
  93266. var roughness = 1 - smoothness;
  93267. var minLODIndex = offset; // roughness = 0
  93268. var maxLODIndex = (mipmapsCount - 1) * scale + offset; // roughness = 1 (mipmaps start from 0)
  93269. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  93270. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  93271. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](engine, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  93272. glTextureFromLod.isCube = true;
  93273. glTextureFromLod.invertY = true;
  93274. glTextureFromLod.generateMipMaps = false;
  93275. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR, glTextureFromLod);
  93276. // Wrap in a base texture for easy binding.
  93277. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"](null);
  93278. lodTexture.isCube = true;
  93279. lodTexture._texture = glTextureFromLod;
  93280. lodTextures[mipmapIndex] = lodTexture;
  93281. switch (i) {
  93282. case 0:
  93283. texture._lodTextureLow = lodTexture;
  93284. break;
  93285. case 1:
  93286. texture._lodTextureMid = lodTexture;
  93287. break;
  93288. case 2:
  93289. texture._lodTextureHigh = lodTexture;
  93290. break;
  93291. }
  93292. }
  93293. }
  93294. }
  93295. var promises = [];
  93296. var _loop_3 = function (i) {
  93297. var _loop_4 = function (face) {
  93298. // Constructs an image element from image data
  93299. var bytes = imageData[i][face];
  93300. var blob = new Blob([bytes], { type: 'image/png' });
  93301. var url = URL.createObjectURL(blob);
  93302. var image = new Image();
  93303. image.src = url;
  93304. // Enqueue promise to upload to the texture.
  93305. var promise = new Promise(function (resolve, reject) {
  93306. image.onload = function () {
  93307. if (expandTexture) {
  93308. var tempTexture_1 = engine.createTexture(null, true, true, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, null, function (message) {
  93309. reject(message);
  93310. }, image);
  93311. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  93312. // Uncompress the data to a RTT
  93313. rgbdPostProcess.onApply = function (effect) {
  93314. effect._bindTexture("textureSampler", tempTexture_1);
  93315. effect.setFloat2("scale", 1, 1);
  93316. };
  93317. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess], cubeRtt, true, face, i);
  93318. // Cleanup
  93319. engine.restoreDefaultFramebuffer();
  93320. tempTexture_1.dispose();
  93321. window.URL.revokeObjectURL(url);
  93322. resolve();
  93323. });
  93324. }
  93325. else {
  93326. engine._uploadImageToTexture(texture, image, face, i);
  93327. // Upload the face to the non lod texture support
  93328. if (generateNonLODTextures) {
  93329. var lodTexture = lodTextures[i];
  93330. if (lodTexture) {
  93331. engine._uploadImageToTexture(lodTexture._texture, image, face, 0);
  93332. }
  93333. }
  93334. resolve();
  93335. }
  93336. };
  93337. image.onerror = function (error) {
  93338. reject(error);
  93339. };
  93340. });
  93341. promises.push(promise);
  93342. };
  93343. // All faces
  93344. for (var face = 0; face < 6; face++) {
  93345. _loop_4(face);
  93346. }
  93347. };
  93348. // All mipmaps up to provided number of images
  93349. for (var i = 0; i < imageData.length; i++) {
  93350. _loop_3(i);
  93351. }
  93352. // Fill remaining mipmaps with black textures.
  93353. if (imageData.length < mipmapsCount) {
  93354. var data = void 0;
  93355. var size = Math.pow(2, mipmapsCount - 1 - imageData.length);
  93356. var dataLength = size * size * 4;
  93357. switch (texture.type) {
  93358. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT: {
  93359. data = new Uint8Array(dataLength);
  93360. break;
  93361. }
  93362. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT: {
  93363. data = new Uint16Array(dataLength);
  93364. break;
  93365. }
  93366. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT: {
  93367. data = new Float32Array(dataLength);
  93368. break;
  93369. }
  93370. }
  93371. for (var i = imageData.length; i < mipmapsCount; i++) {
  93372. for (var face = 0; face < 6; face++) {
  93373. engine._uploadArrayBufferViewToTexture(texture, data, face, i);
  93374. }
  93375. }
  93376. }
  93377. // Once all done, finishes the cleanup and return
  93378. return Promise.all(promises).then(function () {
  93379. // Release temp RTT.
  93380. if (cubeRtt) {
  93381. engine._releaseFramebufferObjects(cubeRtt);
  93382. cubeRtt._swapAndDie(texture);
  93383. }
  93384. // Release temp Post Process.
  93385. if (rgbdPostProcess) {
  93386. rgbdPostProcess.dispose();
  93387. }
  93388. // Flag internal texture as ready in case they are in use.
  93389. if (generateNonLODTextures) {
  93390. if (texture._lodTextureHigh && texture._lodTextureHigh._texture) {
  93391. texture._lodTextureHigh._texture.isReady = true;
  93392. }
  93393. if (texture._lodTextureMid && texture._lodTextureMid._texture) {
  93394. texture._lodTextureMid._texture.isReady = true;
  93395. }
  93396. if (texture._lodTextureLow && texture._lodTextureLow._texture) {
  93397. texture._lodTextureLow._texture.isReady = true;
  93398. }
  93399. }
  93400. });
  93401. };
  93402. /**
  93403. * Uploads spherical polynomials information to the texture.
  93404. * @param texture defines the texture we are trying to upload the information to
  93405. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  93406. */
  93407. EnvironmentTextureTools.UploadEnvSpherical = function (texture, info) {
  93408. if (info.version !== 1) {
  93409. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn('Unsupported babylon environment map version "' + info.version + '"');
  93410. }
  93411. var irradianceInfo = info.irradiance;
  93412. if (!irradianceInfo) {
  93413. return;
  93414. }
  93415. var sp = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__["SphericalPolynomial"]();
  93416. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.x, 0, sp.x);
  93417. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.y, 0, sp.y);
  93418. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.z, 0, sp.z);
  93419. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xx, 0, sp.xx);
  93420. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yy, 0, sp.yy);
  93421. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zz, 0, sp.zz);
  93422. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yz, 0, sp.yz);
  93423. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zx, 0, sp.zx);
  93424. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xy, 0, sp.xy);
  93425. texture._sphericalPolynomial = sp;
  93426. };
  93427. /** @hidden */
  93428. EnvironmentTextureTools._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  93429. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  93430. internalTexture._bufferViewArrayArray = data;
  93431. internalTexture._lodGenerationScale = lodScale;
  93432. internalTexture._lodGenerationOffset = lodOffset;
  93433. internalTexture._sphericalPolynomial = sphericalPolynomial;
  93434. return EnvironmentTextureTools.UploadLevelsAsync(internalTexture, data).then(function () {
  93435. internalTexture.isReady = true;
  93436. });
  93437. };
  93438. /**
  93439. * Magic number identifying the env file.
  93440. */
  93441. EnvironmentTextureTools._MagicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];
  93442. return EnvironmentTextureTools;
  93443. }());
  93444. // References the dependencies.
  93445. _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"]._UpdateRGBDAsync = EnvironmentTextureTools._UpdateRGBDAsync;
  93446. /***/ }),
  93447. /***/ "./Misc/filesInput.ts":
  93448. /*!****************************!*\
  93449. !*** ./Misc/filesInput.ts ***!
  93450. \****************************/
  93451. /*! exports provided: FilesInput */
  93452. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93453. "use strict";
  93454. __webpack_require__.r(__webpack_exports__);
  93455. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return FilesInput; });
  93456. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  93457. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  93458. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  93459. /**
  93460. * Class used to help managing file picking and drag'n'drop
  93461. */
  93462. var FilesInput = /** @class */ (function () {
  93463. /**
  93464. * Creates a new FilesInput
  93465. * @param engine defines the rendering engine
  93466. * @param scene defines the hosting scene
  93467. * @param sceneLoadedCallback callback called when scene is loaded
  93468. * @param progressCallback callback called to track progress
  93469. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  93470. * @param textureLoadingCallback callback called when a texture is loading
  93471. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  93472. * @param onReloadCallback callback called when a reload is requested
  93473. * @param errorCallback callback call if an error occurs
  93474. */
  93475. function FilesInput(engine, scene, sceneLoadedCallback, progressCallback, additionalRenderLoopLogicCallback, textureLoadingCallback, startingProcessingFilesCallback, onReloadCallback, errorCallback) {
  93476. /**
  93477. * Callback called when a file is processed
  93478. */
  93479. this.onProcessFileCallback = function () { return true; };
  93480. this._engine = engine;
  93481. this._currentScene = scene;
  93482. this._sceneLoadedCallback = sceneLoadedCallback;
  93483. this._progressCallback = progressCallback;
  93484. this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;
  93485. this._textureLoadingCallback = textureLoadingCallback;
  93486. this._startingProcessingFilesCallback = startingProcessingFilesCallback;
  93487. this._onReloadCallback = onReloadCallback;
  93488. this._errorCallback = errorCallback;
  93489. }
  93490. Object.defineProperty(FilesInput, "FilesToLoad", {
  93491. /**
  93492. * List of files ready to be loaded
  93493. */
  93494. get: function () {
  93495. return _filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad;
  93496. },
  93497. enumerable: true,
  93498. configurable: true
  93499. });
  93500. /**
  93501. * Calls this function to listen to drag'n'drop events on a specific DOM element
  93502. * @param elementToMonitor defines the DOM element to track
  93503. */
  93504. FilesInput.prototype.monitorElementForDragNDrop = function (elementToMonitor) {
  93505. var _this = this;
  93506. if (elementToMonitor) {
  93507. this._elementToMonitor = elementToMonitor;
  93508. this._dragEnterHandler = function (e) { _this.drag(e); };
  93509. this._dragOverHandler = function (e) { _this.drag(e); };
  93510. this._dropHandler = function (e) { _this.drop(e); };
  93511. this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, false);
  93512. this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, false);
  93513. this._elementToMonitor.addEventListener("drop", this._dropHandler, false);
  93514. }
  93515. };
  93516. /**
  93517. * Release all associated resources
  93518. */
  93519. FilesInput.prototype.dispose = function () {
  93520. if (!this._elementToMonitor) {
  93521. return;
  93522. }
  93523. this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler);
  93524. this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler);
  93525. this._elementToMonitor.removeEventListener("drop", this._dropHandler);
  93526. };
  93527. FilesInput.prototype.renderFunction = function () {
  93528. if (this._additionalRenderLoopLogicCallback) {
  93529. this._additionalRenderLoopLogicCallback();
  93530. }
  93531. if (this._currentScene) {
  93532. if (this._textureLoadingCallback) {
  93533. var remaining = this._currentScene.getWaitingItemsCount();
  93534. if (remaining > 0) {
  93535. this._textureLoadingCallback(remaining);
  93536. }
  93537. }
  93538. this._currentScene.render();
  93539. }
  93540. };
  93541. FilesInput.prototype.drag = function (e) {
  93542. e.stopPropagation();
  93543. e.preventDefault();
  93544. };
  93545. FilesInput.prototype.drop = function (eventDrop) {
  93546. eventDrop.stopPropagation();
  93547. eventDrop.preventDefault();
  93548. this.loadFiles(eventDrop);
  93549. };
  93550. FilesInput.prototype._traverseFolder = function (folder, files, remaining, callback) {
  93551. var _this = this;
  93552. var reader = folder.createReader();
  93553. var relativePath = folder.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
  93554. reader.readEntries(function (entries) {
  93555. remaining.count += entries.length;
  93556. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  93557. var entry = entries_1[_i];
  93558. if (entry.isFile) {
  93559. entry.file(function (file) {
  93560. file.correctName = relativePath + file.name;
  93561. files.push(file);
  93562. if (--remaining.count === 0) {
  93563. callback();
  93564. }
  93565. });
  93566. }
  93567. else if (entry.isDirectory) {
  93568. _this._traverseFolder(entry, files, remaining, callback);
  93569. }
  93570. }
  93571. if (--remaining.count) {
  93572. callback();
  93573. }
  93574. });
  93575. };
  93576. FilesInput.prototype._processFiles = function (files) {
  93577. for (var i = 0; i < files.length; i++) {
  93578. var name = files[i].correctName.toLowerCase();
  93579. var extension = name.split('.').pop();
  93580. if (!this.onProcessFileCallback(files[i], name, extension)) {
  93581. continue;
  93582. }
  93583. if ((extension === "babylon" || extension === "stl" || extension === "obj" || extension === "gltf" || extension === "glb")
  93584. && name.indexOf(".binary.babylon") === -1 && name.indexOf(".incremental.babylon") === -1) {
  93585. this._sceneFileToLoad = files[i];
  93586. }
  93587. FilesInput.FilesToLoad[name] = files[i];
  93588. }
  93589. };
  93590. /**
  93591. * Load files from a drop event
  93592. * @param event defines the drop event to use as source
  93593. */
  93594. FilesInput.prototype.loadFiles = function (event) {
  93595. var _this = this;
  93596. // Handling data transfer via drag'n'drop
  93597. if (event && event.dataTransfer && event.dataTransfer.files) {
  93598. this._filesToLoad = event.dataTransfer.files;
  93599. }
  93600. // Handling files from input files
  93601. if (event && event.target && event.target.files) {
  93602. this._filesToLoad = event.target.files;
  93603. }
  93604. if (!this._filesToLoad || this._filesToLoad.length === 0) {
  93605. return;
  93606. }
  93607. if (this._startingProcessingFilesCallback) {
  93608. this._startingProcessingFilesCallback(this._filesToLoad);
  93609. }
  93610. if (this._filesToLoad && this._filesToLoad.length > 0) {
  93611. var files_1 = new Array();
  93612. var folders = [];
  93613. var items = event.dataTransfer ? event.dataTransfer.items : null;
  93614. for (var i = 0; i < this._filesToLoad.length; i++) {
  93615. var fileToLoad = this._filesToLoad[i];
  93616. var name_1 = fileToLoad.name.toLowerCase();
  93617. var entry = void 0;
  93618. fileToLoad.correctName = name_1;
  93619. if (items) {
  93620. var item = items[i];
  93621. if (item.getAsEntry) {
  93622. entry = item.getAsEntry();
  93623. }
  93624. else if (item.webkitGetAsEntry) {
  93625. entry = item.webkitGetAsEntry();
  93626. }
  93627. }
  93628. if (!entry) {
  93629. files_1.push(fileToLoad);
  93630. }
  93631. else {
  93632. if (entry.isDirectory) {
  93633. folders.push(entry);
  93634. }
  93635. else {
  93636. files_1.push(fileToLoad);
  93637. }
  93638. }
  93639. }
  93640. if (folders.length === 0) {
  93641. this._processFiles(files_1);
  93642. this._processReload();
  93643. }
  93644. else {
  93645. var remaining = { count: folders.length };
  93646. for (var _i = 0, folders_1 = folders; _i < folders_1.length; _i++) {
  93647. var folder = folders_1[_i];
  93648. this._traverseFolder(folder, files_1, remaining, function () {
  93649. _this._processFiles(files_1);
  93650. if (remaining.count === 0) {
  93651. _this._processReload();
  93652. }
  93653. });
  93654. }
  93655. }
  93656. }
  93657. };
  93658. FilesInput.prototype._processReload = function () {
  93659. if (this._onReloadCallback) {
  93660. this._onReloadCallback(this._sceneFileToLoad);
  93661. }
  93662. else {
  93663. this.reload();
  93664. }
  93665. };
  93666. /**
  93667. * Reload the current scene from the loaded files
  93668. */
  93669. FilesInput.prototype.reload = function () {
  93670. var _this = this;
  93671. // If a scene file has been provided
  93672. if (this._sceneFileToLoad) {
  93673. if (this._currentScene) {
  93674. if (_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].errorsCount > 0) {
  93675. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].ClearLogCache();
  93676. }
  93677. this._engine.stopRenderLoop();
  93678. }
  93679. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].LoadAsync("file:", this._sceneFileToLoad, this._engine, function (progress) {
  93680. if (_this._progressCallback) {
  93681. _this._progressCallback(progress);
  93682. }
  93683. }).then(function (scene) {
  93684. if (_this._currentScene) {
  93685. _this._currentScene.dispose();
  93686. }
  93687. _this._currentScene = scene;
  93688. if (_this._sceneLoadedCallback) {
  93689. _this._sceneLoadedCallback(_this._sceneFileToLoad, _this._currentScene);
  93690. }
  93691. // Wait for textures and shaders to be ready
  93692. _this._currentScene.executeWhenReady(function () {
  93693. _this._engine.runRenderLoop(function () {
  93694. _this.renderFunction();
  93695. });
  93696. });
  93697. }).catch(function (error) {
  93698. if (_this._errorCallback) {
  93699. _this._errorCallback(_this._sceneFileToLoad, _this._currentScene, error.message);
  93700. }
  93701. });
  93702. }
  93703. else {
  93704. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Please provide a valid .babylon file.");
  93705. }
  93706. };
  93707. return FilesInput;
  93708. }());
  93709. /***/ }),
  93710. /***/ "./Misc/filesInputStore.ts":
  93711. /*!*********************************!*\
  93712. !*** ./Misc/filesInputStore.ts ***!
  93713. \*********************************/
  93714. /*! exports provided: FilesInputStore */
  93715. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93716. "use strict";
  93717. __webpack_require__.r(__webpack_exports__);
  93718. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return FilesInputStore; });
  93719. /**
  93720. * Class used to help managing file picking and drag'n'drop
  93721. * File Storage
  93722. */
  93723. var FilesInputStore = /** @class */ (function () {
  93724. function FilesInputStore() {
  93725. }
  93726. /**
  93727. * List of files ready to be loaded
  93728. */
  93729. FilesInputStore.FilesToLoad = {};
  93730. return FilesInputStore;
  93731. }());
  93732. /***/ }),
  93733. /***/ "./Misc/index.ts":
  93734. /*!***********************!*\
  93735. !*** ./Misc/index.ts ***!
  93736. \***********************/
  93737. /*! 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 */
  93738. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93739. "use strict";
  93740. __webpack_require__.r(__webpack_exports__);
  93741. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  93742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  93743. /* harmony import */ var _assetsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assetsManager */ "./Misc/assetsManager.ts");
  93744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetTaskState"]; });
  93745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AbstractAssetTask"]; });
  93746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsProgressEvent"]; });
  93747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["MeshAssetTask"]; });
  93748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextFileAssetTask"]; });
  93749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["BinaryFileAssetTask"]; });
  93750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["ImageAssetTask"]; });
  93751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextureAssetTask"]; });
  93752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["CubeTextureAssetTask"]; });
  93753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["HDRCubeTextureAssetTask"]; });
  93754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsManager"]; });
  93755. /* harmony import */ var _dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dds */ "./Misc/dds.ts");
  93756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"]; });
  93757. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  93758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["expandToProperty"]; });
  93759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"]; });
  93760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsTexture"]; });
  93761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor3"]; });
  93762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsFresnelParameters"]; });
  93763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector2"]; });
  93764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector3"]; });
  93765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMeshReference"]; });
  93766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColorCurves"]; });
  93767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor4"]; });
  93768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsImageProcessingConfiguration"]; });
  93769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsQuaternion"]; });
  93770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsCameraReference"]; });
  93771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]; });
  93772. /* harmony import */ var _deferred__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./deferred */ "./Misc/deferred.ts");
  93773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _deferred__WEBPACK_IMPORTED_MODULE_4__["Deferred"]; });
  93774. /* harmony import */ var _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  93775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__["EnvironmentTextureTools"]; });
  93776. /* harmony import */ var _filesInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./filesInput */ "./Misc/filesInput.ts");
  93777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _filesInput__WEBPACK_IMPORTED_MODULE_6__["FilesInput"]; });
  93778. /* harmony import */ var _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./HighDynamicRange/index */ "./Misc/HighDynamicRange/index.ts");
  93779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"]; });
  93780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["HDRTools"]; });
  93781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["PanoramaToCubeMapTools"]; });
  93782. /* harmony import */ var _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  93783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_8__["KhronosTextureContainer"]; });
  93784. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  93785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["EventState"]; });
  93786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["Observer"]; });
  93787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["MultiObserver"]; });
  93788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["Observable"]; });
  93789. /* harmony import */ var _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./performanceMonitor */ "./Misc/performanceMonitor.ts");
  93790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__["PerformanceMonitor"]; });
  93791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__["RollingAverage"]; });
  93792. /* harmony import */ var _promise__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./promise */ "./Misc/promise.ts");
  93793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _promise__WEBPACK_IMPORTED_MODULE_11__["PromisePolyfill"]; });
  93794. /* harmony import */ var _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./sceneOptimizer */ "./Misc/sceneOptimizer.ts");
  93795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimization"]; });
  93796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["TextureOptimization"]; });
  93797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["HardwareScalingOptimization"]; });
  93798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["ShadowsOptimization"]; });
  93799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["PostProcessesOptimization"]; });
  93800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["LensFlaresOptimization"]; });
  93801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["CustomOptimization"]; });
  93802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["ParticlesOptimization"]; });
  93803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["RenderTargetsOptimization"]; });
  93804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["MergeMeshesOptimization"]; });
  93805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimizerOptions"]; });
  93806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimizer"]; });
  93807. /* harmony import */ var _sceneSerializer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./sceneSerializer */ "./Misc/sceneSerializer.ts");
  93808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _sceneSerializer__WEBPACK_IMPORTED_MODULE_13__["SceneSerializer"]; });
  93809. /* harmony import */ var _smartArray__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./smartArray */ "./Misc/smartArray.ts");
  93810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_14__["SmartArray"]; });
  93811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_14__["SmartArrayNoDuplicate"]; });
  93812. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  93813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _stringDictionary__WEBPACK_IMPORTED_MODULE_15__["StringDictionary"]; });
  93814. /* harmony import */ var _tags__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./tags */ "./Misc/tags.ts");
  93815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _tags__WEBPACK_IMPORTED_MODULE_16__["Tags"]; });
  93816. /* harmony import */ var _textureTools__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./textureTools */ "./Misc/textureTools.ts");
  93817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _textureTools__WEBPACK_IMPORTED_MODULE_17__["TextureTools"]; });
  93818. /* harmony import */ var _tga__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./tga */ "./Misc/tga.ts");
  93819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _tga__WEBPACK_IMPORTED_MODULE_18__["TGATools"]; });
  93820. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  93821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["ColorGradient"]; });
  93822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["Color3Gradient"]; });
  93823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["FactorGradient"]; });
  93824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["LoadFileError"]; });
  93825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["RetryStrategy"]; });
  93826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["Tools"]; });
  93827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["PerfCounter"]; });
  93828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["className"]; });
  93829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["AsyncLoop"]; });
  93830. /* harmony import */ var _videoRecorder__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./videoRecorder */ "./Misc/videoRecorder.ts");
  93831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _videoRecorder__WEBPACK_IMPORTED_MODULE_20__["VideoRecorder"]; });
  93832. /* harmony import */ var _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./virtualJoystick */ "./Misc/virtualJoystick.ts");
  93833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__["JoystickAxis"]; });
  93834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__["VirtualJoystick"]; });
  93835. /* harmony import */ var _workerPool__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./workerPool */ "./Misc/workerPool.ts");
  93836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _workerPool__WEBPACK_IMPORTED_MODULE_22__["WorkerPool"]; });
  93837. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  93838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _logger__WEBPACK_IMPORTED_MODULE_23__["Logger"]; });
  93839. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  93840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _typeStore__WEBPACK_IMPORTED_MODULE_24__["_TypeStore"]; });
  93841. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  93842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _filesInputStore__WEBPACK_IMPORTED_MODULE_25__["FilesInputStore"]; });
  93843. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  93844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _deepCopier__WEBPACK_IMPORTED_MODULE_26__["DeepCopier"]; });
  93845. /* harmony import */ var _pivotTools__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./pivotTools */ "./Misc/pivotTools.ts");
  93846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _pivotTools__WEBPACK_IMPORTED_MODULE_27__["PivotTools"]; });
  93847. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  93848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _precisionDate__WEBPACK_IMPORTED_MODULE_28__["PrecisionDate"]; });
  93849. /* harmony import */ var _screenshotTools__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./screenshotTools */ "./Misc/screenshotTools.ts");
  93850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _screenshotTools__WEBPACK_IMPORTED_MODULE_29__["ScreenshotTools"]; });
  93851. /* empty/unused harmony star reexport */
  93852. /***/ }),
  93853. /***/ "./Misc/khronosTextureContainer.ts":
  93854. /*!*****************************************!*\
  93855. !*** ./Misc/khronosTextureContainer.ts ***!
  93856. \*****************************************/
  93857. /*! exports provided: KhronosTextureContainer */
  93858. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93859. "use strict";
  93860. __webpack_require__.r(__webpack_exports__);
  93861. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return KhronosTextureContainer; });
  93862. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  93863. /**
  93864. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  93865. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  93866. */
  93867. var KhronosTextureContainer = /** @class */ (function () {
  93868. /**
  93869. * Creates a new KhronosTextureContainer
  93870. * @param arrayBuffer contents of the KTX container file
  93871. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  93872. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  93873. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  93874. */
  93875. function KhronosTextureContainer(
  93876. /** contents of the KTX container file */
  93877. arrayBuffer, facesExpected, threeDExpected, textureArrayExpected) {
  93878. this.arrayBuffer = arrayBuffer;
  93879. /**
  93880. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  93881. */
  93882. this.isInvalid = false;
  93883. // Test that it is a ktx formatted file, based on the first 12 bytes, character representation is:
  93884. // '�', 'K', 'T', 'X', ' ', '1', '1', '�', '\r', '\n', '\x1A', '\n'
  93885. // 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
  93886. var identifier = new Uint8Array(this.arrayBuffer, 0, 12);
  93887. if (identifier[0] !== 0xAB || identifier[1] !== 0x4B || identifier[2] !== 0x54 || identifier[3] !== 0x58 || identifier[4] !== 0x20 || identifier[5] !== 0x31 ||
  93888. identifier[6] !== 0x31 || identifier[7] !== 0xBB || identifier[8] !== 0x0D || identifier[9] !== 0x0A || identifier[10] !== 0x1A || identifier[11] !== 0x0A) {
  93889. this.isInvalid = true;
  93890. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture missing KTX identifier");
  93891. return;
  93892. }
  93893. // load the reset of the header in native 32 bit uint
  93894. var dataSize = Uint32Array.BYTES_PER_ELEMENT;
  93895. var headerDataView = new DataView(this.arrayBuffer, 12, 13 * dataSize);
  93896. var endianness = headerDataView.getUint32(0, true);
  93897. var littleEndian = endianness === 0x04030201;
  93898. this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures
  93899. this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures
  93900. this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures
  93901. this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)
  93902. this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)
  93903. this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)
  93904. this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)
  93905. this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)
  93906. this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays
  93907. this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6
  93908. this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures
  93909. this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data
  93910. // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing.
  93911. if (this.glType !== 0) {
  93912. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only compressed formats currently supported");
  93913. return;
  93914. }
  93915. else {
  93916. // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
  93917. this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
  93918. }
  93919. if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
  93920. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only 2D textures currently supported");
  93921. return;
  93922. }
  93923. if (this.numberOfArrayElements !== 0) {
  93924. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture arrays not currently supported");
  93925. return;
  93926. }
  93927. if (this.numberOfFaces !== facesExpected) {
  93928. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("number of faces expected" + facesExpected + ", but found " + this.numberOfFaces);
  93929. return;
  93930. }
  93931. // we now have a completely validated file, so could use existence of loadType as success
  93932. // would need to make this more elaborate & adjust checks above to support more than one load type
  93933. this.loadType = KhronosTextureContainer.COMPRESSED_2D;
  93934. }
  93935. /**
  93936. * Uploads KTX content to a Babylon Texture.
  93937. * It is assumed that the texture has already been created & is currently bound
  93938. * @hidden
  93939. */
  93940. KhronosTextureContainer.prototype.uploadLevels = function (texture, loadMipmaps) {
  93941. switch (this.loadType) {
  93942. case KhronosTextureContainer.COMPRESSED_2D:
  93943. this._upload2DCompressedLevels(texture, loadMipmaps);
  93944. break;
  93945. case KhronosTextureContainer.TEX_2D:
  93946. case KhronosTextureContainer.COMPRESSED_3D:
  93947. case KhronosTextureContainer.TEX_3D:
  93948. }
  93949. };
  93950. KhronosTextureContainer.prototype._upload2DCompressedLevels = function (texture, loadMipmaps) {
  93951. // initialize width & height for level 1
  93952. var dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData;
  93953. var width = this.pixelWidth;
  93954. var height = this.pixelHeight;
  93955. var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;
  93956. for (var level = 0; level < mipmapCount; level++) {
  93957. var imageSize = new Int32Array(this.arrayBuffer, dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
  93958. dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above.
  93959. for (var face = 0; face < this.numberOfFaces; face++) {
  93960. var byteArray = new Uint8Array(this.arrayBuffer, dataOffset, imageSize);
  93961. var engine = texture.getEngine();
  93962. engine._uploadCompressedDataToTextureDirectly(texture, this.glInternalFormat, width, height, byteArray, face, level);
  93963. dataOffset += imageSize; // add size of the image for the next face/mipmap
  93964. dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image
  93965. }
  93966. width = Math.max(1.0, width * 0.5);
  93967. height = Math.max(1.0, height * 0.5);
  93968. }
  93969. };
  93970. KhronosTextureContainer.HEADER_LEN = 12 + (13 * 4); // identifier + header elements (not including key value meta-data pairs)
  93971. // load types
  93972. KhronosTextureContainer.COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
  93973. KhronosTextureContainer.COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()
  93974. KhronosTextureContainer.TEX_2D = 2; // uses a gl.texImage2D()
  93975. KhronosTextureContainer.TEX_3D = 3; // uses a gl.texImage3D()
  93976. return KhronosTextureContainer;
  93977. }());
  93978. /***/ }),
  93979. /***/ "./Misc/logger.ts":
  93980. /*!************************!*\
  93981. !*** ./Misc/logger.ts ***!
  93982. \************************/
  93983. /*! exports provided: Logger */
  93984. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93985. "use strict";
  93986. __webpack_require__.r(__webpack_exports__);
  93987. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return Logger; });
  93988. /**
  93989. * Logger used througouht the application to allow configuration of
  93990. * the log level required for the messages.
  93991. */
  93992. var Logger = /** @class */ (function () {
  93993. function Logger() {
  93994. }
  93995. Logger._AddLogEntry = function (entry) {
  93996. Logger._LogCache = entry + Logger._LogCache;
  93997. if (Logger.OnNewCacheEntry) {
  93998. Logger.OnNewCacheEntry(entry);
  93999. }
  94000. };
  94001. Logger._FormatMessage = function (message) {
  94002. var padStr = function (i) { return (i < 10) ? "0" + i : "" + i; };
  94003. var date = new Date();
  94004. return "[" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
  94005. };
  94006. Logger._LogDisabled = function (message) {
  94007. // nothing to do
  94008. };
  94009. Logger._LogEnabled = function (message) {
  94010. var formattedMessage = Logger._FormatMessage(message);
  94011. console.log("BJS - " + formattedMessage);
  94012. var entry = "<div style='color:white'>" + formattedMessage + "</div><br>";
  94013. Logger._AddLogEntry(entry);
  94014. };
  94015. Logger._WarnDisabled = function (message) {
  94016. // nothing to do
  94017. };
  94018. Logger._WarnEnabled = function (message) {
  94019. var formattedMessage = Logger._FormatMessage(message);
  94020. console.warn("BJS - " + formattedMessage);
  94021. var entry = "<div style='color:orange'>" + formattedMessage + "</div><br>";
  94022. Logger._AddLogEntry(entry);
  94023. };
  94024. Logger._ErrorDisabled = function (message) {
  94025. // nothing to do
  94026. };
  94027. Logger._ErrorEnabled = function (message) {
  94028. Logger.errorsCount++;
  94029. var formattedMessage = Logger._FormatMessage(message);
  94030. console.error("BJS - " + formattedMessage);
  94031. var entry = "<div style='color:red'>" + formattedMessage + "</div><br>";
  94032. Logger._AddLogEntry(entry);
  94033. };
  94034. Object.defineProperty(Logger, "LogCache", {
  94035. /**
  94036. * Gets current log cache (list of logs)
  94037. */
  94038. get: function () {
  94039. return Logger._LogCache;
  94040. },
  94041. enumerable: true,
  94042. configurable: true
  94043. });
  94044. /**
  94045. * Clears the log cache
  94046. */
  94047. Logger.ClearLogCache = function () {
  94048. Logger._LogCache = "";
  94049. Logger.errorsCount = 0;
  94050. };
  94051. Object.defineProperty(Logger, "LogLevels", {
  94052. /**
  94053. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  94054. */
  94055. set: function (level) {
  94056. if ((level & Logger.MessageLogLevel) === Logger.MessageLogLevel) {
  94057. Logger.Log = Logger._LogEnabled;
  94058. }
  94059. else {
  94060. Logger.Log = Logger._LogDisabled;
  94061. }
  94062. if ((level & Logger.WarningLogLevel) === Logger.WarningLogLevel) {
  94063. Logger.Warn = Logger._WarnEnabled;
  94064. }
  94065. else {
  94066. Logger.Warn = Logger._WarnDisabled;
  94067. }
  94068. if ((level & Logger.ErrorLogLevel) === Logger.ErrorLogLevel) {
  94069. Logger.Error = Logger._ErrorEnabled;
  94070. }
  94071. else {
  94072. Logger.Error = Logger._ErrorDisabled;
  94073. }
  94074. },
  94075. enumerable: true,
  94076. configurable: true
  94077. });
  94078. /**
  94079. * No log
  94080. */
  94081. Logger.NoneLogLevel = 0;
  94082. /**
  94083. * Only message logs
  94084. */
  94085. Logger.MessageLogLevel = 1;
  94086. /**
  94087. * Only warning logs
  94088. */
  94089. Logger.WarningLogLevel = 2;
  94090. /**
  94091. * Only error logs
  94092. */
  94093. Logger.ErrorLogLevel = 4;
  94094. /**
  94095. * All logs
  94096. */
  94097. Logger.AllLogLevel = 7;
  94098. Logger._LogCache = "";
  94099. /**
  94100. * Gets a value indicating the number of loading errors
  94101. * @ignorenaming
  94102. */
  94103. Logger.errorsCount = 0;
  94104. /**
  94105. * Log a message to the console
  94106. */
  94107. Logger.Log = Logger._LogEnabled;
  94108. /**
  94109. * Write a warning message to the console
  94110. */
  94111. Logger.Warn = Logger._WarnEnabled;
  94112. /**
  94113. * Write an error message to the console
  94114. */
  94115. Logger.Error = Logger._ErrorEnabled;
  94116. return Logger;
  94117. }());
  94118. /***/ }),
  94119. /***/ "./Misc/observable.ts":
  94120. /*!****************************!*\
  94121. !*** ./Misc/observable.ts ***!
  94122. \****************************/
  94123. /*! exports provided: EventState, Observer, MultiObserver, Observable */
  94124. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94125. "use strict";
  94126. __webpack_require__.r(__webpack_exports__);
  94127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return EventState; });
  94128. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return Observer; });
  94129. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return MultiObserver; });
  94130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return Observable; });
  94131. /**
  94132. * A class serves as a medium between the observable and its observers
  94133. */
  94134. var EventState = /** @class */ (function () {
  94135. /**
  94136. * Create a new EventState
  94137. * @param mask defines the mask associated with this state
  94138. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  94139. * @param target defines the original target of the state
  94140. * @param currentTarget defines the current target of the state
  94141. */
  94142. function EventState(mask, skipNextObservers, target, currentTarget) {
  94143. if (skipNextObservers === void 0) { skipNextObservers = false; }
  94144. this.initalize(mask, skipNextObservers, target, currentTarget);
  94145. }
  94146. /**
  94147. * Initialize the current event state
  94148. * @param mask defines the mask associated with this state
  94149. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  94150. * @param target defines the original target of the state
  94151. * @param currentTarget defines the current target of the state
  94152. * @returns the current event state
  94153. */
  94154. EventState.prototype.initalize = function (mask, skipNextObservers, target, currentTarget) {
  94155. if (skipNextObservers === void 0) { skipNextObservers = false; }
  94156. this.mask = mask;
  94157. this.skipNextObservers = skipNextObservers;
  94158. this.target = target;
  94159. this.currentTarget = currentTarget;
  94160. return this;
  94161. };
  94162. return EventState;
  94163. }());
  94164. /**
  94165. * Represent an Observer registered to a given Observable object.
  94166. */
  94167. var Observer = /** @class */ (function () {
  94168. /**
  94169. * Creates a new observer
  94170. * @param callback defines the callback to call when the observer is notified
  94171. * @param mask defines the mask of the observer (used to filter notifications)
  94172. * @param scope defines the current scope used to restore the JS context
  94173. */
  94174. function Observer(
  94175. /**
  94176. * Defines the callback to call when the observer is notified
  94177. */
  94178. callback,
  94179. /**
  94180. * Defines the mask of the observer (used to filter notifications)
  94181. */
  94182. mask,
  94183. /**
  94184. * Defines the current scope used to restore the JS context
  94185. */
  94186. scope) {
  94187. if (scope === void 0) { scope = null; }
  94188. this.callback = callback;
  94189. this.mask = mask;
  94190. this.scope = scope;
  94191. /** @hidden */
  94192. this._willBeUnregistered = false;
  94193. /**
  94194. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  94195. */
  94196. this.unregisterOnNextCall = false;
  94197. }
  94198. return Observer;
  94199. }());
  94200. /**
  94201. * Represent a list of observers registered to multiple Observables object.
  94202. */
  94203. var MultiObserver = /** @class */ (function () {
  94204. function MultiObserver() {
  94205. }
  94206. /**
  94207. * Release associated resources
  94208. */
  94209. MultiObserver.prototype.dispose = function () {
  94210. if (this._observers && this._observables) {
  94211. for (var index = 0; index < this._observers.length; index++) {
  94212. this._observables[index].remove(this._observers[index]);
  94213. }
  94214. }
  94215. this._observers = null;
  94216. this._observables = null;
  94217. };
  94218. /**
  94219. * Raise a callback when one of the observable will notify
  94220. * @param observables defines a list of observables to watch
  94221. * @param callback defines the callback to call on notification
  94222. * @param mask defines the mask used to filter notifications
  94223. * @param scope defines the current scope used to restore the JS context
  94224. * @returns the new MultiObserver
  94225. */
  94226. MultiObserver.Watch = function (observables, callback, mask, scope) {
  94227. if (mask === void 0) { mask = -1; }
  94228. if (scope === void 0) { scope = null; }
  94229. var result = new MultiObserver();
  94230. result._observers = new Array();
  94231. result._observables = observables;
  94232. for (var _i = 0, observables_1 = observables; _i < observables_1.length; _i++) {
  94233. var observable = observables_1[_i];
  94234. var observer = observable.add(callback, mask, false, scope);
  94235. if (observer) {
  94236. result._observers.push(observer);
  94237. }
  94238. }
  94239. return result;
  94240. };
  94241. return MultiObserver;
  94242. }());
  94243. /**
  94244. * The Observable class is a simple implementation of the Observable pattern.
  94245. *
  94246. * 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.
  94247. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  94248. * 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).
  94249. * 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.
  94250. */
  94251. var Observable = /** @class */ (function () {
  94252. /**
  94253. * Creates a new observable
  94254. * @param onObserverAdded defines a callback to call when a new observer is added
  94255. */
  94256. function Observable(onObserverAdded) {
  94257. this._observers = new Array();
  94258. this._eventState = new EventState(0);
  94259. if (onObserverAdded) {
  94260. this._onObserverAdded = onObserverAdded;
  94261. }
  94262. }
  94263. /**
  94264. * Create a new Observer with the specified callback
  94265. * @param callback the callback that will be executed for that Observer
  94266. * @param mask the mask used to filter observers
  94267. * @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.
  94268. * @param scope optional scope for the callback to be called from
  94269. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  94270. * @returns the new observer created for the callback
  94271. */
  94272. Observable.prototype.add = function (callback, mask, insertFirst, scope, unregisterOnFirstCall) {
  94273. if (mask === void 0) { mask = -1; }
  94274. if (insertFirst === void 0) { insertFirst = false; }
  94275. if (scope === void 0) { scope = null; }
  94276. if (unregisterOnFirstCall === void 0) { unregisterOnFirstCall = false; }
  94277. if (!callback) {
  94278. return null;
  94279. }
  94280. var observer = new Observer(callback, mask, scope);
  94281. observer.unregisterOnNextCall = unregisterOnFirstCall;
  94282. if (insertFirst) {
  94283. this._observers.unshift(observer);
  94284. }
  94285. else {
  94286. this._observers.push(observer);
  94287. }
  94288. if (this._onObserverAdded) {
  94289. this._onObserverAdded(observer);
  94290. }
  94291. return observer;
  94292. };
  94293. /**
  94294. * Create a new Observer with the specified callback and unregisters after the next notification
  94295. * @param callback the callback that will be executed for that Observer
  94296. * @returns the new observer created for the callback
  94297. */
  94298. Observable.prototype.addOnce = function (callback) {
  94299. return this.add(callback, undefined, undefined, undefined, true);
  94300. };
  94301. /**
  94302. * Remove an Observer from the Observable object
  94303. * @param observer the instance of the Observer to remove
  94304. * @returns false if it doesn't belong to this Observable
  94305. */
  94306. Observable.prototype.remove = function (observer) {
  94307. if (!observer) {
  94308. return false;
  94309. }
  94310. var index = this._observers.indexOf(observer);
  94311. if (index !== -1) {
  94312. this._deferUnregister(observer);
  94313. return true;
  94314. }
  94315. return false;
  94316. };
  94317. /**
  94318. * Remove a callback from the Observable object
  94319. * @param callback the callback to remove
  94320. * @param scope optional scope. If used only the callbacks with this scope will be removed
  94321. * @returns false if it doesn't belong to this Observable
  94322. */
  94323. Observable.prototype.removeCallback = function (callback, scope) {
  94324. for (var index = 0; index < this._observers.length; index++) {
  94325. if (this._observers[index].callback === callback && (!scope || scope === this._observers[index].scope)) {
  94326. this._deferUnregister(this._observers[index]);
  94327. return true;
  94328. }
  94329. }
  94330. return false;
  94331. };
  94332. Observable.prototype._deferUnregister = function (observer) {
  94333. var _this = this;
  94334. observer.unregisterOnNextCall = false;
  94335. observer._willBeUnregistered = true;
  94336. setTimeout(function () {
  94337. _this._remove(observer);
  94338. }, 0);
  94339. };
  94340. // This should only be called when not iterating over _observers to avoid callback skipping.
  94341. // Removes an observer from the _observer Array.
  94342. Observable.prototype._remove = function (observer) {
  94343. if (!observer) {
  94344. return false;
  94345. }
  94346. var index = this._observers.indexOf(observer);
  94347. if (index !== -1) {
  94348. this._observers.splice(index, 1);
  94349. return true;
  94350. }
  94351. return false;
  94352. };
  94353. /**
  94354. * Notify all Observers by calling their respective callback with the given data
  94355. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  94356. * @param eventData defines the data to send to all observers
  94357. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  94358. * @param target defines the original target of the state
  94359. * @param currentTarget defines the current target of the state
  94360. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  94361. */
  94362. Observable.prototype.notifyObservers = function (eventData, mask, target, currentTarget) {
  94363. if (mask === void 0) { mask = -1; }
  94364. if (!this._observers.length) {
  94365. return true;
  94366. }
  94367. var state = this._eventState;
  94368. state.mask = mask;
  94369. state.target = target;
  94370. state.currentTarget = currentTarget;
  94371. state.skipNextObservers = false;
  94372. state.lastReturnValue = eventData;
  94373. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  94374. var obs = _a[_i];
  94375. if (obs._willBeUnregistered) {
  94376. continue;
  94377. }
  94378. if (obs.mask & mask) {
  94379. if (obs.scope) {
  94380. state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);
  94381. }
  94382. else {
  94383. state.lastReturnValue = obs.callback(eventData, state);
  94384. }
  94385. if (obs.unregisterOnNextCall) {
  94386. this._deferUnregister(obs);
  94387. }
  94388. }
  94389. if (state.skipNextObservers) {
  94390. return false;
  94391. }
  94392. }
  94393. return true;
  94394. };
  94395. /**
  94396. * Calling this will execute each callback, expecting it to be a promise or return a value.
  94397. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  94398. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  94399. * and it is crucial that all callbacks will be executed.
  94400. * The order of the callbacks is kept, callbacks are not executed parallel.
  94401. *
  94402. * @param eventData The data to be sent to each callback
  94403. * @param mask is used to filter observers defaults to -1
  94404. * @param target defines the callback target (see EventState)
  94405. * @param currentTarget defines he current object in the bubbling phase
  94406. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  94407. */
  94408. Observable.prototype.notifyObserversWithPromise = function (eventData, mask, target, currentTarget) {
  94409. var _this = this;
  94410. if (mask === void 0) { mask = -1; }
  94411. // create an empty promise
  94412. var p = Promise.resolve(eventData);
  94413. // no observers? return this promise.
  94414. if (!this._observers.length) {
  94415. return p;
  94416. }
  94417. var state = this._eventState;
  94418. state.mask = mask;
  94419. state.target = target;
  94420. state.currentTarget = currentTarget;
  94421. state.skipNextObservers = false;
  94422. // execute one callback after another (not using Promise.all, the order is important)
  94423. this._observers.forEach(function (obs) {
  94424. if (state.skipNextObservers) {
  94425. return;
  94426. }
  94427. if (obs._willBeUnregistered) {
  94428. return;
  94429. }
  94430. if (obs.mask & mask) {
  94431. if (obs.scope) {
  94432. p = p.then(function (lastReturnedValue) {
  94433. state.lastReturnValue = lastReturnedValue;
  94434. return obs.callback.apply(obs.scope, [eventData, state]);
  94435. });
  94436. }
  94437. else {
  94438. p = p.then(function (lastReturnedValue) {
  94439. state.lastReturnValue = lastReturnedValue;
  94440. return obs.callback(eventData, state);
  94441. });
  94442. }
  94443. if (obs.unregisterOnNextCall) {
  94444. _this._deferUnregister(obs);
  94445. }
  94446. }
  94447. });
  94448. // return the eventData
  94449. return p.then(function () { return eventData; });
  94450. };
  94451. /**
  94452. * Notify a specific observer
  94453. * @param observer defines the observer to notify
  94454. * @param eventData defines the data to be sent to each callback
  94455. * @param mask is used to filter observers defaults to -1
  94456. */
  94457. Observable.prototype.notifyObserver = function (observer, eventData, mask) {
  94458. if (mask === void 0) { mask = -1; }
  94459. var state = this._eventState;
  94460. state.mask = mask;
  94461. state.skipNextObservers = false;
  94462. observer.callback(eventData, state);
  94463. };
  94464. /**
  94465. * Gets a boolean indicating if the observable has at least one observer
  94466. * @returns true is the Observable has at least one Observer registered
  94467. */
  94468. Observable.prototype.hasObservers = function () {
  94469. return this._observers.length > 0;
  94470. };
  94471. /**
  94472. * Clear the list of observers
  94473. */
  94474. Observable.prototype.clear = function () {
  94475. this._observers = new Array();
  94476. this._onObserverAdded = null;
  94477. };
  94478. /**
  94479. * Clone the current observable
  94480. * @returns a new observable
  94481. */
  94482. Observable.prototype.clone = function () {
  94483. var result = new Observable();
  94484. result._observers = this._observers.slice(0);
  94485. return result;
  94486. };
  94487. /**
  94488. * Does this observable handles observer registered with a given mask
  94489. * @param mask defines the mask to be tested
  94490. * @return whether or not one observer registered with the given mask is handeled
  94491. **/
  94492. Observable.prototype.hasSpecificMask = function (mask) {
  94493. if (mask === void 0) { mask = -1; }
  94494. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  94495. var obs = _a[_i];
  94496. if (obs.mask & mask || obs.mask === mask) {
  94497. return true;
  94498. }
  94499. }
  94500. return false;
  94501. };
  94502. return Observable;
  94503. }());
  94504. /***/ }),
  94505. /***/ "./Misc/performanceMonitor.ts":
  94506. /*!************************************!*\
  94507. !*** ./Misc/performanceMonitor.ts ***!
  94508. \************************************/
  94509. /*! exports provided: PerformanceMonitor, RollingAverage */
  94510. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94511. "use strict";
  94512. __webpack_require__.r(__webpack_exports__);
  94513. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return PerformanceMonitor; });
  94514. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return RollingAverage; });
  94515. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  94516. /**
  94517. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  94518. */
  94519. var PerformanceMonitor = /** @class */ (function () {
  94520. /**
  94521. * constructor
  94522. * @param frameSampleSize The number of samples required to saturate the sliding window
  94523. */
  94524. function PerformanceMonitor(frameSampleSize) {
  94525. if (frameSampleSize === void 0) { frameSampleSize = 30; }
  94526. this._enabled = true;
  94527. this._rollingFrameTime = new RollingAverage(frameSampleSize);
  94528. }
  94529. /**
  94530. * Samples current frame
  94531. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  94532. */
  94533. PerformanceMonitor.prototype.sampleFrame = function (timeMs) {
  94534. if (timeMs === void 0) { timeMs = _precisionDate__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"].Now; }
  94535. if (!this._enabled) {
  94536. return;
  94537. }
  94538. if (this._lastFrameTimeMs != null) {
  94539. var dt = timeMs - this._lastFrameTimeMs;
  94540. this._rollingFrameTime.add(dt);
  94541. }
  94542. this._lastFrameTimeMs = timeMs;
  94543. };
  94544. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTime", {
  94545. /**
  94546. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  94547. */
  94548. get: function () {
  94549. return this._rollingFrameTime.average;
  94550. },
  94551. enumerable: true,
  94552. configurable: true
  94553. });
  94554. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTimeVariance", {
  94555. /**
  94556. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  94557. */
  94558. get: function () {
  94559. return this._rollingFrameTime.variance;
  94560. },
  94561. enumerable: true,
  94562. configurable: true
  94563. });
  94564. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFrameTime", {
  94565. /**
  94566. * Returns the frame time of the most recent frame
  94567. */
  94568. get: function () {
  94569. return this._rollingFrameTime.history(0);
  94570. },
  94571. enumerable: true,
  94572. configurable: true
  94573. });
  94574. Object.defineProperty(PerformanceMonitor.prototype, "averageFPS", {
  94575. /**
  94576. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  94577. */
  94578. get: function () {
  94579. return 1000.0 / this._rollingFrameTime.average;
  94580. },
  94581. enumerable: true,
  94582. configurable: true
  94583. });
  94584. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFPS", {
  94585. /**
  94586. * Returns the average framerate in frames per second using the most recent frame time
  94587. */
  94588. get: function () {
  94589. var history = this._rollingFrameTime.history(0);
  94590. if (history === 0) {
  94591. return 0;
  94592. }
  94593. return 1000.0 / history;
  94594. },
  94595. enumerable: true,
  94596. configurable: true
  94597. });
  94598. Object.defineProperty(PerformanceMonitor.prototype, "isSaturated", {
  94599. /**
  94600. * Returns true if enough samples have been taken to completely fill the sliding window
  94601. */
  94602. get: function () {
  94603. return this._rollingFrameTime.isSaturated();
  94604. },
  94605. enumerable: true,
  94606. configurable: true
  94607. });
  94608. /**
  94609. * Enables contributions to the sliding window sample set
  94610. */
  94611. PerformanceMonitor.prototype.enable = function () {
  94612. this._enabled = true;
  94613. };
  94614. /**
  94615. * Disables contributions to the sliding window sample set
  94616. * Samples will not be interpolated over the disabled period
  94617. */
  94618. PerformanceMonitor.prototype.disable = function () {
  94619. this._enabled = false;
  94620. //clear last sample to avoid interpolating over the disabled period when next enabled
  94621. this._lastFrameTimeMs = null;
  94622. };
  94623. Object.defineProperty(PerformanceMonitor.prototype, "isEnabled", {
  94624. /**
  94625. * Returns true if sampling is enabled
  94626. */
  94627. get: function () {
  94628. return this._enabled;
  94629. },
  94630. enumerable: true,
  94631. configurable: true
  94632. });
  94633. /**
  94634. * Resets performance monitor
  94635. */
  94636. PerformanceMonitor.prototype.reset = function () {
  94637. //clear last sample to avoid interpolating over the disabled period when next enabled
  94638. this._lastFrameTimeMs = null;
  94639. //wipe record
  94640. this._rollingFrameTime.reset();
  94641. };
  94642. return PerformanceMonitor;
  94643. }());
  94644. /**
  94645. * RollingAverage
  94646. *
  94647. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  94648. */
  94649. var RollingAverage = /** @class */ (function () {
  94650. /**
  94651. * constructor
  94652. * @param length The number of samples required to saturate the sliding window
  94653. */
  94654. function RollingAverage(length) {
  94655. this._samples = new Array(length);
  94656. this.reset();
  94657. }
  94658. /**
  94659. * Adds a sample to the sample set
  94660. * @param v The sample value
  94661. */
  94662. RollingAverage.prototype.add = function (v) {
  94663. //http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
  94664. var delta;
  94665. //we need to check if we've already wrapped round
  94666. if (this.isSaturated()) {
  94667. //remove bottom of stack from mean
  94668. var bottomValue = this._samples[this._pos];
  94669. delta = bottomValue - this.average;
  94670. this.average -= delta / (this._sampleCount - 1);
  94671. this._m2 -= delta * (bottomValue - this.average);
  94672. }
  94673. else {
  94674. this._sampleCount++;
  94675. }
  94676. //add new value to mean
  94677. delta = v - this.average;
  94678. this.average += delta / (this._sampleCount);
  94679. this._m2 += delta * (v - this.average);
  94680. //set the new variance
  94681. this.variance = this._m2 / (this._sampleCount - 1);
  94682. this._samples[this._pos] = v;
  94683. this._pos++;
  94684. this._pos %= this._samples.length; //positive wrap around
  94685. };
  94686. /**
  94687. * Returns previously added values or null if outside of history or outside the sliding window domain
  94688. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  94689. * @return Value previously recorded with add() or null if outside of range
  94690. */
  94691. RollingAverage.prototype.history = function (i) {
  94692. if ((i >= this._sampleCount) || (i >= this._samples.length)) {
  94693. return 0;
  94694. }
  94695. var i0 = this._wrapPosition(this._pos - 1.0);
  94696. return this._samples[this._wrapPosition(i0 - i)];
  94697. };
  94698. /**
  94699. * Returns true if enough samples have been taken to completely fill the sliding window
  94700. * @return true if sample-set saturated
  94701. */
  94702. RollingAverage.prototype.isSaturated = function () {
  94703. return this._sampleCount >= this._samples.length;
  94704. };
  94705. /**
  94706. * Resets the rolling average (equivalent to 0 samples taken so far)
  94707. */
  94708. RollingAverage.prototype.reset = function () {
  94709. this.average = 0;
  94710. this.variance = 0;
  94711. this._sampleCount = 0;
  94712. this._pos = 0;
  94713. this._m2 = 0;
  94714. };
  94715. /**
  94716. * Wraps a value around the sample range boundaries
  94717. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  94718. * @return Wrapped position in sample range
  94719. */
  94720. RollingAverage.prototype._wrapPosition = function (i) {
  94721. var max = this._samples.length;
  94722. return ((i % max) + max) % max;
  94723. };
  94724. return RollingAverage;
  94725. }());
  94726. /***/ }),
  94727. /***/ "./Misc/pivotTools.ts":
  94728. /*!****************************!*\
  94729. !*** ./Misc/pivotTools.ts ***!
  94730. \****************************/
  94731. /*! exports provided: PivotTools */
  94732. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94733. "use strict";
  94734. __webpack_require__.r(__webpack_exports__);
  94735. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return PivotTools; });
  94736. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  94737. /**
  94738. * Class containing a set of static utilities functions for managing Pivots
  94739. * @hidden
  94740. */
  94741. var PivotTools = /** @class */ (function () {
  94742. function PivotTools() {
  94743. }
  94744. /** @hidden */
  94745. PivotTools._RemoveAndStorePivotPoint = function (mesh) {
  94746. if (mesh && PivotTools._PivotCached === 0) {
  94747. // Save old pivot and set pivot to 0,0,0
  94748. mesh.getPivotPointToRef(PivotTools._OldPivotPoint);
  94749. if (!PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0)) {
  94750. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityReadOnly);
  94751. PivotTools._OldPivotPoint.subtractToRef(mesh.getPivotPoint(), PivotTools._PivotTranslation);
  94752. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  94753. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  94754. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  94755. mesh.position.addInPlace(PivotTools._PivotTmpVector);
  94756. }
  94757. }
  94758. PivotTools._PivotCached++;
  94759. };
  94760. /** @hidden */
  94761. PivotTools._RestorePivotPoint = function (mesh) {
  94762. if (mesh && !PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0) && PivotTools._PivotCached === 1) {
  94763. mesh.setPivotPoint(PivotTools._OldPivotPoint);
  94764. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  94765. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  94766. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  94767. mesh.position.subtractInPlace(PivotTools._PivotTmpVector);
  94768. }
  94769. this._PivotCached--;
  94770. };
  94771. // Stores the state of the pivot cache (_oldPivotPoint, _pivotTranslation)
  94772. // store/remove pivot point should only be applied during their outermost calls
  94773. PivotTools._PivotCached = 0;
  94774. PivotTools._OldPivotPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  94775. PivotTools._PivotTranslation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  94776. PivotTools._PivotTmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  94777. return PivotTools;
  94778. }());
  94779. /***/ }),
  94780. /***/ "./Misc/precisionDate.ts":
  94781. /*!*******************************!*\
  94782. !*** ./Misc/precisionDate.ts ***!
  94783. \*******************************/
  94784. /*! exports provided: PrecisionDate */
  94785. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94786. "use strict";
  94787. __webpack_require__.r(__webpack_exports__);
  94788. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return PrecisionDate; });
  94789. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  94790. /**
  94791. * Class containing a set of static utilities functions for precision date
  94792. */
  94793. var PrecisionDate = /** @class */ (function () {
  94794. function PrecisionDate() {
  94795. }
  94796. Object.defineProperty(PrecisionDate, "Now", {
  94797. /**
  94798. * Gets either window.performance.now() if supported or Date.now() else
  94799. */
  94800. get: function () {
  94801. if (_domManagement__WEBPACK_IMPORTED_MODULE_0__["DomManagement"].IsWindowObjectExist() && window.performance && window.performance.now) {
  94802. return window.performance.now();
  94803. }
  94804. return Date.now();
  94805. },
  94806. enumerable: true,
  94807. configurable: true
  94808. });
  94809. return PrecisionDate;
  94810. }());
  94811. /***/ }),
  94812. /***/ "./Misc/promise.ts":
  94813. /*!*************************!*\
  94814. !*** ./Misc/promise.ts ***!
  94815. \*************************/
  94816. /*! exports provided: PromisePolyfill */
  94817. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94818. "use strict";
  94819. __webpack_require__.r(__webpack_exports__);
  94820. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return PromisePolyfill; });
  94821. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  94822. var PromiseStates;
  94823. (function (PromiseStates) {
  94824. PromiseStates[PromiseStates["Pending"] = 0] = "Pending";
  94825. PromiseStates[PromiseStates["Fulfilled"] = 1] = "Fulfilled";
  94826. PromiseStates[PromiseStates["Rejected"] = 2] = "Rejected";
  94827. })(PromiseStates || (PromiseStates = {}));
  94828. var FulFillmentAgregator = /** @class */ (function () {
  94829. function FulFillmentAgregator() {
  94830. this.count = 0;
  94831. this.target = 0;
  94832. this.results = [];
  94833. }
  94834. return FulFillmentAgregator;
  94835. }());
  94836. var InternalPromise = /** @class */ (function () {
  94837. function InternalPromise(resolver) {
  94838. var _this = this;
  94839. this._state = PromiseStates.Pending;
  94840. this._children = new Array();
  94841. this._rejectWasConsumed = false;
  94842. if (!resolver) {
  94843. return;
  94844. }
  94845. try {
  94846. resolver(function (value) {
  94847. _this._resolve(value);
  94848. }, function (reason) {
  94849. _this._reject(reason);
  94850. });
  94851. }
  94852. catch (e) {
  94853. this._reject(e);
  94854. }
  94855. }
  94856. Object.defineProperty(InternalPromise.prototype, "_result", {
  94857. get: function () {
  94858. return this._resultValue;
  94859. },
  94860. set: function (value) {
  94861. this._resultValue = value;
  94862. if (this._parent && this._parent._result === undefined) {
  94863. this._parent._result = value;
  94864. }
  94865. },
  94866. enumerable: true,
  94867. configurable: true
  94868. });
  94869. InternalPromise.prototype.catch = function (onRejected) {
  94870. return this.then(undefined, onRejected);
  94871. };
  94872. InternalPromise.prototype.then = function (onFulfilled, onRejected) {
  94873. var _this = this;
  94874. var newPromise = new InternalPromise();
  94875. newPromise._onFulfilled = onFulfilled;
  94876. newPromise._onRejected = onRejected;
  94877. // Composition
  94878. this._children.push(newPromise);
  94879. newPromise._parent = this;
  94880. if (this._state !== PromiseStates.Pending) {
  94881. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  94882. if (_this._state === PromiseStates.Fulfilled || _this._rejectWasConsumed) {
  94883. var returnedValue = newPromise._resolve(_this._result);
  94884. if (returnedValue !== undefined && returnedValue !== null) {
  94885. if (returnedValue._state !== undefined) {
  94886. var returnedPromise = returnedValue;
  94887. newPromise._children.push(returnedPromise);
  94888. returnedPromise._parent = newPromise;
  94889. newPromise = returnedPromise;
  94890. }
  94891. else {
  94892. newPromise._result = returnedValue;
  94893. }
  94894. }
  94895. }
  94896. else {
  94897. newPromise._reject(_this._reason);
  94898. }
  94899. });
  94900. }
  94901. return newPromise;
  94902. };
  94903. InternalPromise.prototype._moveChildren = function (children) {
  94904. var _this = this;
  94905. var _a;
  94906. (_a = this._children).push.apply(_a, children.splice(0, children.length));
  94907. this._children.forEach(function (child) {
  94908. child._parent = _this;
  94909. });
  94910. if (this._state === PromiseStates.Fulfilled) {
  94911. for (var _i = 0, _b = this._children; _i < _b.length; _i++) {
  94912. var child = _b[_i];
  94913. child._resolve(this._result);
  94914. }
  94915. }
  94916. else if (this._state === PromiseStates.Rejected) {
  94917. for (var _c = 0, _d = this._children; _c < _d.length; _c++) {
  94918. var child = _d[_c];
  94919. child._reject(this._reason);
  94920. }
  94921. }
  94922. };
  94923. InternalPromise.prototype._resolve = function (value) {
  94924. try {
  94925. this._state = PromiseStates.Fulfilled;
  94926. var returnedValue = null;
  94927. if (this._onFulfilled) {
  94928. returnedValue = this._onFulfilled(value);
  94929. }
  94930. if (returnedValue !== undefined && returnedValue !== null) {
  94931. if (returnedValue._state !== undefined) {
  94932. // Transmit children
  94933. var returnedPromise = returnedValue;
  94934. returnedPromise._parent = this;
  94935. returnedPromise._moveChildren(this._children);
  94936. value = returnedPromise._result;
  94937. }
  94938. else {
  94939. value = returnedValue;
  94940. }
  94941. }
  94942. this._result = value;
  94943. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  94944. var child = _a[_i];
  94945. child._resolve(value);
  94946. }
  94947. this._children.length = 0;
  94948. delete this._onFulfilled;
  94949. delete this._onRejected;
  94950. }
  94951. catch (e) {
  94952. this._reject(e, true);
  94953. }
  94954. };
  94955. InternalPromise.prototype._reject = function (reason, onLocalThrow) {
  94956. if (onLocalThrow === void 0) { onLocalThrow = false; }
  94957. this._state = PromiseStates.Rejected;
  94958. this._reason = reason;
  94959. if (this._onRejected && !onLocalThrow) {
  94960. try {
  94961. this._onRejected(reason);
  94962. this._rejectWasConsumed = true;
  94963. }
  94964. catch (e) {
  94965. reason = e;
  94966. }
  94967. }
  94968. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  94969. var child = _a[_i];
  94970. if (this._rejectWasConsumed) {
  94971. child._resolve(null);
  94972. }
  94973. else {
  94974. child._reject(reason);
  94975. }
  94976. }
  94977. this._children.length = 0;
  94978. delete this._onFulfilled;
  94979. delete this._onRejected;
  94980. };
  94981. InternalPromise.resolve = function (value) {
  94982. var newPromise = new InternalPromise();
  94983. newPromise._resolve(value);
  94984. return newPromise;
  94985. };
  94986. InternalPromise._RegisterForFulfillment = function (promise, agregator, index) {
  94987. promise.then(function (value) {
  94988. agregator.results[index] = value;
  94989. agregator.count++;
  94990. if (agregator.count === agregator.target) {
  94991. agregator.rootPromise._resolve(agregator.results);
  94992. }
  94993. return null;
  94994. }, function (reason) {
  94995. if (agregator.rootPromise._state !== PromiseStates.Rejected) {
  94996. agregator.rootPromise._reject(reason);
  94997. }
  94998. });
  94999. };
  95000. InternalPromise.all = function (promises) {
  95001. var newPromise = new InternalPromise();
  95002. var agregator = new FulFillmentAgregator();
  95003. agregator.target = promises.length;
  95004. agregator.rootPromise = newPromise;
  95005. if (promises.length) {
  95006. for (var index = 0; index < promises.length; index++) {
  95007. InternalPromise._RegisterForFulfillment(promises[index], agregator, index);
  95008. }
  95009. }
  95010. else {
  95011. newPromise._resolve([]);
  95012. }
  95013. return newPromise;
  95014. };
  95015. InternalPromise.race = function (promises) {
  95016. var newPromise = new InternalPromise();
  95017. if (promises.length) {
  95018. for (var _i = 0, promises_1 = promises; _i < promises_1.length; _i++) {
  95019. var promise = promises_1[_i];
  95020. promise.then(function (value) {
  95021. if (newPromise) {
  95022. newPromise._resolve(value);
  95023. newPromise = null;
  95024. }
  95025. return null;
  95026. }, function (reason) {
  95027. if (newPromise) {
  95028. newPromise._reject(reason);
  95029. newPromise = null;
  95030. }
  95031. });
  95032. }
  95033. }
  95034. return newPromise;
  95035. };
  95036. return InternalPromise;
  95037. }());
  95038. /**
  95039. * Helper class that provides a small promise polyfill
  95040. */
  95041. var PromisePolyfill = /** @class */ (function () {
  95042. function PromisePolyfill() {
  95043. }
  95044. /**
  95045. * Static function used to check if the polyfill is required
  95046. * If this is the case then the function will inject the polyfill to window.Promise
  95047. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  95048. */
  95049. PromisePolyfill.Apply = function (force) {
  95050. if (force === void 0) { force = false; }
  95051. if (force || typeof Promise === 'undefined') {
  95052. var root = window;
  95053. root.Promise = InternalPromise;
  95054. }
  95055. };
  95056. return PromisePolyfill;
  95057. }());
  95058. /***/ }),
  95059. /***/ "./Misc/sceneOptimizer.ts":
  95060. /*!********************************!*\
  95061. !*** ./Misc/sceneOptimizer.ts ***!
  95062. \********************************/
  95063. /*! exports provided: SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer */
  95064. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95065. "use strict";
  95066. __webpack_require__.r(__webpack_exports__);
  95067. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return SceneOptimization; });
  95068. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return TextureOptimization; });
  95069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return HardwareScalingOptimization; });
  95070. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return ShadowsOptimization; });
  95071. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return PostProcessesOptimization; });
  95072. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return LensFlaresOptimization; });
  95073. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return CustomOptimization; });
  95074. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return ParticlesOptimization; });
  95075. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return RenderTargetsOptimization; });
  95076. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return MergeMeshesOptimization; });
  95077. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return SceneOptimizerOptions; });
  95078. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return SceneOptimizer; });
  95079. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  95080. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  95081. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  95082. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  95083. /**
  95084. * Defines the root class used to create scene optimization to use with SceneOptimizer
  95085. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95086. */
  95087. var SceneOptimization = /** @class */ (function () {
  95088. /**
  95089. * Creates the SceneOptimization object
  95090. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  95091. * @param desc defines the description associated with the optimization
  95092. */
  95093. function SceneOptimization(
  95094. /**
  95095. * Defines the priority of this optimization (0 by default which means first in the list)
  95096. */
  95097. priority) {
  95098. if (priority === void 0) { priority = 0; }
  95099. this.priority = priority;
  95100. }
  95101. /**
  95102. * Gets a string describing the action executed by the current optimization
  95103. * @returns description string
  95104. */
  95105. SceneOptimization.prototype.getDescription = function () {
  95106. return "";
  95107. };
  95108. /**
  95109. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95110. * @param scene defines the current scene where to apply this optimization
  95111. * @param optimizer defines the current optimizer
  95112. * @returns true if everything that can be done was applied
  95113. */
  95114. SceneOptimization.prototype.apply = function (scene, optimizer) {
  95115. return true;
  95116. };
  95117. return SceneOptimization;
  95118. }());
  95119. /**
  95120. * Defines an optimization used to reduce the size of render target textures
  95121. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95122. */
  95123. var TextureOptimization = /** @class */ (function (_super) {
  95124. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureOptimization, _super);
  95125. /**
  95126. * Creates the TextureOptimization object
  95127. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  95128. * @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
  95129. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  95130. */
  95131. function TextureOptimization(
  95132. /**
  95133. * Defines the priority of this optimization (0 by default which means first in the list)
  95134. */
  95135. priority,
  95136. /**
  95137. * 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
  95138. */
  95139. maximumSize,
  95140. /**
  95141. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  95142. */
  95143. step) {
  95144. if (priority === void 0) { priority = 0; }
  95145. if (maximumSize === void 0) { maximumSize = 1024; }
  95146. if (step === void 0) { step = 0.5; }
  95147. var _this = _super.call(this, priority) || this;
  95148. _this.priority = priority;
  95149. _this.maximumSize = maximumSize;
  95150. _this.step = step;
  95151. return _this;
  95152. }
  95153. /**
  95154. * Gets a string describing the action executed by the current optimization
  95155. * @returns description string
  95156. */
  95157. TextureOptimization.prototype.getDescription = function () {
  95158. return "Reducing render target texture size to " + this.maximumSize;
  95159. };
  95160. /**
  95161. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95162. * @param scene defines the current scene where to apply this optimization
  95163. * @param optimizer defines the current optimizer
  95164. * @returns true if everything that can be done was applied
  95165. */
  95166. TextureOptimization.prototype.apply = function (scene, optimizer) {
  95167. var allDone = true;
  95168. for (var index = 0; index < scene.textures.length; index++) {
  95169. var texture = scene.textures[index];
  95170. if (!texture.canRescale || texture.getContext) {
  95171. continue;
  95172. }
  95173. var currentSize = texture.getSize();
  95174. var maxDimension = Math.max(currentSize.width, currentSize.height);
  95175. if (maxDimension > this.maximumSize) {
  95176. texture.scale(this.step);
  95177. allDone = false;
  95178. }
  95179. }
  95180. return allDone;
  95181. };
  95182. return TextureOptimization;
  95183. }(SceneOptimization));
  95184. /**
  95185. * Defines an optimization used to increase or decrease the rendering resolution
  95186. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95187. */
  95188. var HardwareScalingOptimization = /** @class */ (function (_super) {
  95189. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HardwareScalingOptimization, _super);
  95190. /**
  95191. * Creates the HardwareScalingOptimization object
  95192. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  95193. * @param maximumScale defines the maximum scale to use (2 by default)
  95194. * @param step defines the step to use between two passes (0.5 by default)
  95195. */
  95196. function HardwareScalingOptimization(
  95197. /**
  95198. * Defines the priority of this optimization (0 by default which means first in the list)
  95199. */
  95200. priority,
  95201. /**
  95202. * Defines the maximum scale to use (2 by default)
  95203. */
  95204. maximumScale,
  95205. /**
  95206. * Defines the step to use between two passes (0.5 by default)
  95207. */
  95208. step) {
  95209. if (priority === void 0) { priority = 0; }
  95210. if (maximumScale === void 0) { maximumScale = 2; }
  95211. if (step === void 0) { step = 0.25; }
  95212. var _this = _super.call(this, priority) || this;
  95213. _this.priority = priority;
  95214. _this.maximumScale = maximumScale;
  95215. _this.step = step;
  95216. _this._currentScale = -1;
  95217. _this._directionOffset = 1;
  95218. return _this;
  95219. }
  95220. /**
  95221. * Gets a string describing the action executed by the current optimization
  95222. * @return description string
  95223. */
  95224. HardwareScalingOptimization.prototype.getDescription = function () {
  95225. return "Setting hardware scaling level to " + this._currentScale;
  95226. };
  95227. /**
  95228. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95229. * @param scene defines the current scene where to apply this optimization
  95230. * @param optimizer defines the current optimizer
  95231. * @returns true if everything that can be done was applied
  95232. */
  95233. HardwareScalingOptimization.prototype.apply = function (scene, optimizer) {
  95234. if (this._currentScale === -1) {
  95235. this._currentScale = scene.getEngine().getHardwareScalingLevel();
  95236. if (this._currentScale > this.maximumScale) {
  95237. this._directionOffset = -1;
  95238. }
  95239. }
  95240. this._currentScale += this._directionOffset * this.step;
  95241. scene.getEngine().setHardwareScalingLevel(this._currentScale);
  95242. return this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;
  95243. };
  95244. return HardwareScalingOptimization;
  95245. }(SceneOptimization));
  95246. /**
  95247. * Defines an optimization used to remove shadows
  95248. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95249. */
  95250. var ShadowsOptimization = /** @class */ (function (_super) {
  95251. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowsOptimization, _super);
  95252. function ShadowsOptimization() {
  95253. return _super !== null && _super.apply(this, arguments) || this;
  95254. }
  95255. /**
  95256. * Gets a string describing the action executed by the current optimization
  95257. * @return description string
  95258. */
  95259. ShadowsOptimization.prototype.getDescription = function () {
  95260. return "Turning shadows on/off";
  95261. };
  95262. /**
  95263. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95264. * @param scene defines the current scene where to apply this optimization
  95265. * @param optimizer defines the current optimizer
  95266. * @returns true if everything that can be done was applied
  95267. */
  95268. ShadowsOptimization.prototype.apply = function (scene, optimizer) {
  95269. scene.shadowsEnabled = optimizer.isInImprovementMode;
  95270. return true;
  95271. };
  95272. return ShadowsOptimization;
  95273. }(SceneOptimization));
  95274. /**
  95275. * Defines an optimization used to turn post-processes off
  95276. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95277. */
  95278. var PostProcessesOptimization = /** @class */ (function (_super) {
  95279. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PostProcessesOptimization, _super);
  95280. function PostProcessesOptimization() {
  95281. return _super !== null && _super.apply(this, arguments) || this;
  95282. }
  95283. /**
  95284. * Gets a string describing the action executed by the current optimization
  95285. * @return description string
  95286. */
  95287. PostProcessesOptimization.prototype.getDescription = function () {
  95288. return "Turning post-processes on/off";
  95289. };
  95290. /**
  95291. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95292. * @param scene defines the current scene where to apply this optimization
  95293. * @param optimizer defines the current optimizer
  95294. * @returns true if everything that can be done was applied
  95295. */
  95296. PostProcessesOptimization.prototype.apply = function (scene, optimizer) {
  95297. scene.postProcessesEnabled = optimizer.isInImprovementMode;
  95298. return true;
  95299. };
  95300. return PostProcessesOptimization;
  95301. }(SceneOptimization));
  95302. /**
  95303. * Defines an optimization used to turn lens flares off
  95304. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95305. */
  95306. var LensFlaresOptimization = /** @class */ (function (_super) {
  95307. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensFlaresOptimization, _super);
  95308. function LensFlaresOptimization() {
  95309. return _super !== null && _super.apply(this, arguments) || this;
  95310. }
  95311. /**
  95312. * Gets a string describing the action executed by the current optimization
  95313. * @return description string
  95314. */
  95315. LensFlaresOptimization.prototype.getDescription = function () {
  95316. return "Turning lens flares on/off";
  95317. };
  95318. /**
  95319. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95320. * @param scene defines the current scene where to apply this optimization
  95321. * @param optimizer defines the current optimizer
  95322. * @returns true if everything that can be done was applied
  95323. */
  95324. LensFlaresOptimization.prototype.apply = function (scene, optimizer) {
  95325. scene.lensFlaresEnabled = optimizer.isInImprovementMode;
  95326. return true;
  95327. };
  95328. return LensFlaresOptimization;
  95329. }(SceneOptimization));
  95330. /**
  95331. * Defines an optimization based on user defined callback.
  95332. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95333. */
  95334. var CustomOptimization = /** @class */ (function (_super) {
  95335. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomOptimization, _super);
  95336. function CustomOptimization() {
  95337. return _super !== null && _super.apply(this, arguments) || this;
  95338. }
  95339. /**
  95340. * Gets a string describing the action executed by the current optimization
  95341. * @returns description string
  95342. */
  95343. CustomOptimization.prototype.getDescription = function () {
  95344. if (this.onGetDescription) {
  95345. return this.onGetDescription();
  95346. }
  95347. return "Running user defined callback";
  95348. };
  95349. /**
  95350. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95351. * @param scene defines the current scene where to apply this optimization
  95352. * @param optimizer defines the current optimizer
  95353. * @returns true if everything that can be done was applied
  95354. */
  95355. CustomOptimization.prototype.apply = function (scene, optimizer) {
  95356. if (this.onApply) {
  95357. return this.onApply(scene, optimizer);
  95358. }
  95359. return true;
  95360. };
  95361. return CustomOptimization;
  95362. }(SceneOptimization));
  95363. /**
  95364. * Defines an optimization used to turn particles off
  95365. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95366. */
  95367. var ParticlesOptimization = /** @class */ (function (_super) {
  95368. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticlesOptimization, _super);
  95369. function ParticlesOptimization() {
  95370. return _super !== null && _super.apply(this, arguments) || this;
  95371. }
  95372. /**
  95373. * Gets a string describing the action executed by the current optimization
  95374. * @return description string
  95375. */
  95376. ParticlesOptimization.prototype.getDescription = function () {
  95377. return "Turning particles on/off";
  95378. };
  95379. /**
  95380. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95381. * @param scene defines the current scene where to apply this optimization
  95382. * @param optimizer defines the current optimizer
  95383. * @returns true if everything that can be done was applied
  95384. */
  95385. ParticlesOptimization.prototype.apply = function (scene, optimizer) {
  95386. scene.particlesEnabled = optimizer.isInImprovementMode;
  95387. return true;
  95388. };
  95389. return ParticlesOptimization;
  95390. }(SceneOptimization));
  95391. /**
  95392. * Defines an optimization used to turn render targets off
  95393. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95394. */
  95395. var RenderTargetsOptimization = /** @class */ (function (_super) {
  95396. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetsOptimization, _super);
  95397. function RenderTargetsOptimization() {
  95398. return _super !== null && _super.apply(this, arguments) || this;
  95399. }
  95400. /**
  95401. * Gets a string describing the action executed by the current optimization
  95402. * @return description string
  95403. */
  95404. RenderTargetsOptimization.prototype.getDescription = function () {
  95405. return "Turning render targets off";
  95406. };
  95407. /**
  95408. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95409. * @param scene defines the current scene where to apply this optimization
  95410. * @param optimizer defines the current optimizer
  95411. * @returns true if everything that can be done was applied
  95412. */
  95413. RenderTargetsOptimization.prototype.apply = function (scene, optimizer) {
  95414. scene.renderTargetsEnabled = optimizer.isInImprovementMode;
  95415. return true;
  95416. };
  95417. return RenderTargetsOptimization;
  95418. }(SceneOptimization));
  95419. /**
  95420. * Defines an optimization used to merge meshes with compatible materials
  95421. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95422. */
  95423. var MergeMeshesOptimization = /** @class */ (function (_super) {
  95424. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MergeMeshesOptimization, _super);
  95425. function MergeMeshesOptimization() {
  95426. var _this = _super !== null && _super.apply(this, arguments) || this;
  95427. _this._canBeMerged = function (abstractMesh) {
  95428. if (!(abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"])) {
  95429. return false;
  95430. }
  95431. var mesh = abstractMesh;
  95432. if (mesh.isDisposed()) {
  95433. return false;
  95434. }
  95435. if (!mesh.isVisible || !mesh.isEnabled()) {
  95436. return false;
  95437. }
  95438. if (mesh.instances.length > 0) {
  95439. return false;
  95440. }
  95441. if (mesh.skeleton || mesh.hasLODLevels) {
  95442. return false;
  95443. }
  95444. return true;
  95445. };
  95446. return _this;
  95447. }
  95448. Object.defineProperty(MergeMeshesOptimization, "UpdateSelectionTree", {
  95449. /**
  95450. * Gets or sets a boolean which defines if optimization octree has to be updated
  95451. */
  95452. get: function () {
  95453. return MergeMeshesOptimization._UpdateSelectionTree;
  95454. },
  95455. /**
  95456. * Gets or sets a boolean which defines if optimization octree has to be updated
  95457. */
  95458. set: function (value) {
  95459. MergeMeshesOptimization._UpdateSelectionTree = value;
  95460. },
  95461. enumerable: true,
  95462. configurable: true
  95463. });
  95464. /**
  95465. * Gets a string describing the action executed by the current optimization
  95466. * @return description string
  95467. */
  95468. MergeMeshesOptimization.prototype.getDescription = function () {
  95469. return "Merging similar meshes together";
  95470. };
  95471. /**
  95472. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95473. * @param scene defines the current scene where to apply this optimization
  95474. * @param optimizer defines the current optimizer
  95475. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  95476. * @returns true if everything that can be done was applied
  95477. */
  95478. MergeMeshesOptimization.prototype.apply = function (scene, optimizer, updateSelectionTree) {
  95479. var globalPool = scene.meshes.slice(0);
  95480. var globalLength = globalPool.length;
  95481. for (var index = 0; index < globalLength; index++) {
  95482. var currentPool = new Array();
  95483. var current = globalPool[index];
  95484. // Checks
  95485. if (!this._canBeMerged(current)) {
  95486. continue;
  95487. }
  95488. currentPool.push(current);
  95489. // Find compatible meshes
  95490. for (var subIndex = index + 1; subIndex < globalLength; subIndex++) {
  95491. var otherMesh = globalPool[subIndex];
  95492. if (!this._canBeMerged(otherMesh)) {
  95493. continue;
  95494. }
  95495. if (otherMesh.material !== current.material) {
  95496. continue;
  95497. }
  95498. if (otherMesh.checkCollisions !== current.checkCollisions) {
  95499. continue;
  95500. }
  95501. currentPool.push(otherMesh);
  95502. globalLength--;
  95503. globalPool.splice(subIndex, 1);
  95504. subIndex--;
  95505. }
  95506. if (currentPool.length < 2) {
  95507. continue;
  95508. }
  95509. // Merge meshes
  95510. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].MergeMeshes(currentPool, undefined, true);
  95511. }
  95512. // Call the octree system optimization if it is defined.
  95513. var sceneAsAny = scene;
  95514. if (sceneAsAny.createOrUpdateSelectionOctree) {
  95515. if (updateSelectionTree != undefined) {
  95516. if (updateSelectionTree) {
  95517. sceneAsAny.createOrUpdateSelectionOctree();
  95518. }
  95519. }
  95520. else if (MergeMeshesOptimization.UpdateSelectionTree) {
  95521. sceneAsAny.createOrUpdateSelectionOctree();
  95522. }
  95523. }
  95524. return true;
  95525. };
  95526. MergeMeshesOptimization._UpdateSelectionTree = false;
  95527. return MergeMeshesOptimization;
  95528. }(SceneOptimization));
  95529. /**
  95530. * Defines a list of options used by SceneOptimizer
  95531. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95532. */
  95533. var SceneOptimizerOptions = /** @class */ (function () {
  95534. /**
  95535. * Creates a new list of options used by SceneOptimizer
  95536. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  95537. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  95538. */
  95539. function SceneOptimizerOptions(
  95540. /**
  95541. * Defines the target frame rate to reach (60 by default)
  95542. */
  95543. targetFrameRate,
  95544. /**
  95545. * Defines the interval between two checkes (2000ms by default)
  95546. */
  95547. trackerDuration) {
  95548. if (targetFrameRate === void 0) { targetFrameRate = 60; }
  95549. if (trackerDuration === void 0) { trackerDuration = 2000; }
  95550. this.targetFrameRate = targetFrameRate;
  95551. this.trackerDuration = trackerDuration;
  95552. /**
  95553. * Gets the list of optimizations to apply
  95554. */
  95555. this.optimizations = new Array();
  95556. }
  95557. /**
  95558. * Add a new optimization
  95559. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  95560. * @returns the current SceneOptimizerOptions
  95561. */
  95562. SceneOptimizerOptions.prototype.addOptimization = function (optimization) {
  95563. this.optimizations.push(optimization);
  95564. return this;
  95565. };
  95566. /**
  95567. * Add a new custom optimization
  95568. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  95569. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  95570. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  95571. * @returns the current SceneOptimizerOptions
  95572. */
  95573. SceneOptimizerOptions.prototype.addCustomOptimization = function (onApply, onGetDescription, priority) {
  95574. if (priority === void 0) { priority = 0; }
  95575. var optimization = new CustomOptimization(priority);
  95576. optimization.onApply = onApply;
  95577. optimization.onGetDescription = onGetDescription;
  95578. this.optimizations.push(optimization);
  95579. return this;
  95580. };
  95581. /**
  95582. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  95583. * @param targetFrameRate defines the target frame rate (60 by default)
  95584. * @returns a SceneOptimizerOptions object
  95585. */
  95586. SceneOptimizerOptions.LowDegradationAllowed = function (targetFrameRate) {
  95587. var result = new SceneOptimizerOptions(targetFrameRate);
  95588. var priority = 0;
  95589. result.addOptimization(new MergeMeshesOptimization(priority));
  95590. result.addOptimization(new ShadowsOptimization(priority));
  95591. result.addOptimization(new LensFlaresOptimization(priority));
  95592. // Next priority
  95593. priority++;
  95594. result.addOptimization(new PostProcessesOptimization(priority));
  95595. result.addOptimization(new ParticlesOptimization(priority));
  95596. // Next priority
  95597. priority++;
  95598. result.addOptimization(new TextureOptimization(priority, 1024));
  95599. return result;
  95600. };
  95601. /**
  95602. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  95603. * @param targetFrameRate defines the target frame rate (60 by default)
  95604. * @returns a SceneOptimizerOptions object
  95605. */
  95606. SceneOptimizerOptions.ModerateDegradationAllowed = function (targetFrameRate) {
  95607. var result = new SceneOptimizerOptions(targetFrameRate);
  95608. var priority = 0;
  95609. result.addOptimization(new MergeMeshesOptimization(priority));
  95610. result.addOptimization(new ShadowsOptimization(priority));
  95611. result.addOptimization(new LensFlaresOptimization(priority));
  95612. // Next priority
  95613. priority++;
  95614. result.addOptimization(new PostProcessesOptimization(priority));
  95615. result.addOptimization(new ParticlesOptimization(priority));
  95616. // Next priority
  95617. priority++;
  95618. result.addOptimization(new TextureOptimization(priority, 512));
  95619. // Next priority
  95620. priority++;
  95621. result.addOptimization(new RenderTargetsOptimization(priority));
  95622. // Next priority
  95623. priority++;
  95624. result.addOptimization(new HardwareScalingOptimization(priority, 2));
  95625. return result;
  95626. };
  95627. /**
  95628. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  95629. * @param targetFrameRate defines the target frame rate (60 by default)
  95630. * @returns a SceneOptimizerOptions object
  95631. */
  95632. SceneOptimizerOptions.HighDegradationAllowed = function (targetFrameRate) {
  95633. var result = new SceneOptimizerOptions(targetFrameRate);
  95634. var priority = 0;
  95635. result.addOptimization(new MergeMeshesOptimization(priority));
  95636. result.addOptimization(new ShadowsOptimization(priority));
  95637. result.addOptimization(new LensFlaresOptimization(priority));
  95638. // Next priority
  95639. priority++;
  95640. result.addOptimization(new PostProcessesOptimization(priority));
  95641. result.addOptimization(new ParticlesOptimization(priority));
  95642. // Next priority
  95643. priority++;
  95644. result.addOptimization(new TextureOptimization(priority, 256));
  95645. // Next priority
  95646. priority++;
  95647. result.addOptimization(new RenderTargetsOptimization(priority));
  95648. // Next priority
  95649. priority++;
  95650. result.addOptimization(new HardwareScalingOptimization(priority, 4));
  95651. return result;
  95652. };
  95653. return SceneOptimizerOptions;
  95654. }());
  95655. /**
  95656. * Class used to run optimizations in order to reach a target frame rate
  95657. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95658. */
  95659. var SceneOptimizer = /** @class */ (function () {
  95660. /**
  95661. * Creates a new SceneOptimizer
  95662. * @param scene defines the scene to work on
  95663. * @param options defines the options to use with the SceneOptimizer
  95664. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  95665. * @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)
  95666. */
  95667. function SceneOptimizer(scene, options, autoGeneratePriorities, improvementMode) {
  95668. if (autoGeneratePriorities === void 0) { autoGeneratePriorities = true; }
  95669. if (improvementMode === void 0) { improvementMode = false; }
  95670. var _this = this;
  95671. this._isRunning = false;
  95672. this._currentPriorityLevel = 0;
  95673. this._targetFrameRate = 60;
  95674. this._trackerDuration = 2000;
  95675. this._currentFrameRate = 0;
  95676. this._improvementMode = false;
  95677. /**
  95678. * Defines an observable called when the optimizer reaches the target frame rate
  95679. */
  95680. this.onSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  95681. /**
  95682. * Defines an observable called when the optimizer enables an optimization
  95683. */
  95684. this.onNewOptimizationAppliedObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  95685. /**
  95686. * Defines an observable called when the optimizer is not able to reach the target frame rate
  95687. */
  95688. this.onFailureObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  95689. if (!options) {
  95690. this._options = new SceneOptimizerOptions();
  95691. }
  95692. else {
  95693. this._options = options;
  95694. }
  95695. if (this._options.targetFrameRate) {
  95696. this._targetFrameRate = this._options.targetFrameRate;
  95697. }
  95698. if (this._options.trackerDuration) {
  95699. this._trackerDuration = this._options.trackerDuration;
  95700. }
  95701. if (autoGeneratePriorities) {
  95702. var priority = 0;
  95703. for (var _i = 0, _a = this._options.optimizations; _i < _a.length; _i++) {
  95704. var optim = _a[_i];
  95705. optim.priority = priority++;
  95706. }
  95707. }
  95708. this._improvementMode = improvementMode;
  95709. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene;
  95710. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  95711. _this._sceneDisposeObserver = null;
  95712. _this.dispose();
  95713. });
  95714. }
  95715. Object.defineProperty(SceneOptimizer.prototype, "isInImprovementMode", {
  95716. /**
  95717. * Gets a boolean indicating if the optimizer is in improvement mode
  95718. */
  95719. get: function () {
  95720. return this._improvementMode;
  95721. },
  95722. enumerable: true,
  95723. configurable: true
  95724. });
  95725. Object.defineProperty(SceneOptimizer.prototype, "currentPriorityLevel", {
  95726. /**
  95727. * Gets the current priority level (0 at start)
  95728. */
  95729. get: function () {
  95730. return this._currentPriorityLevel;
  95731. },
  95732. enumerable: true,
  95733. configurable: true
  95734. });
  95735. Object.defineProperty(SceneOptimizer.prototype, "currentFrameRate", {
  95736. /**
  95737. * Gets the current frame rate checked by the SceneOptimizer
  95738. */
  95739. get: function () {
  95740. return this._currentFrameRate;
  95741. },
  95742. enumerable: true,
  95743. configurable: true
  95744. });
  95745. Object.defineProperty(SceneOptimizer.prototype, "targetFrameRate", {
  95746. /**
  95747. * Gets or sets the current target frame rate (60 by default)
  95748. */
  95749. get: function () {
  95750. return this._targetFrameRate;
  95751. },
  95752. /**
  95753. * Gets or sets the current target frame rate (60 by default)
  95754. */
  95755. set: function (value) {
  95756. this._targetFrameRate = value;
  95757. },
  95758. enumerable: true,
  95759. configurable: true
  95760. });
  95761. Object.defineProperty(SceneOptimizer.prototype, "trackerDuration", {
  95762. /**
  95763. * Gets or sets the current interval between two checks (every 2000ms by default)
  95764. */
  95765. get: function () {
  95766. return this._trackerDuration;
  95767. },
  95768. /**
  95769. * Gets or sets the current interval between two checks (every 2000ms by default)
  95770. */
  95771. set: function (value) {
  95772. this._trackerDuration = value;
  95773. },
  95774. enumerable: true,
  95775. configurable: true
  95776. });
  95777. Object.defineProperty(SceneOptimizer.prototype, "optimizations", {
  95778. /**
  95779. * Gets the list of active optimizations
  95780. */
  95781. get: function () {
  95782. return this._options.optimizations;
  95783. },
  95784. enumerable: true,
  95785. configurable: true
  95786. });
  95787. /**
  95788. * Stops the current optimizer
  95789. */
  95790. SceneOptimizer.prototype.stop = function () {
  95791. this._isRunning = false;
  95792. };
  95793. /**
  95794. * Reset the optimizer to initial step (current priority level = 0)
  95795. */
  95796. SceneOptimizer.prototype.reset = function () {
  95797. this._currentPriorityLevel = 0;
  95798. };
  95799. /**
  95800. * Start the optimizer. By default it will try to reach a specific framerate
  95801. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  95802. */
  95803. SceneOptimizer.prototype.start = function () {
  95804. var _this = this;
  95805. if (this._isRunning) {
  95806. return;
  95807. }
  95808. this._isRunning = true;
  95809. // Let's wait for the scene to be ready before running our check
  95810. this._scene.executeWhenReady(function () {
  95811. setTimeout(function () {
  95812. _this._checkCurrentState();
  95813. }, _this._trackerDuration);
  95814. });
  95815. };
  95816. SceneOptimizer.prototype._checkCurrentState = function () {
  95817. var _this = this;
  95818. if (!this._isRunning) {
  95819. return;
  95820. }
  95821. var scene = this._scene;
  95822. var options = this._options;
  95823. this._currentFrameRate = Math.round(scene.getEngine().getFps());
  95824. if (this._improvementMode && this._currentFrameRate <= this._targetFrameRate ||
  95825. !this._improvementMode && this._currentFrameRate >= this._targetFrameRate) {
  95826. this._isRunning = false;
  95827. this.onSuccessObservable.notifyObservers(this);
  95828. return;
  95829. }
  95830. // Apply current level of optimizations
  95831. var allDone = true;
  95832. var noOptimizationApplied = true;
  95833. for (var index = 0; index < options.optimizations.length; index++) {
  95834. var optimization = options.optimizations[index];
  95835. if (optimization.priority === this._currentPriorityLevel) {
  95836. noOptimizationApplied = false;
  95837. allDone = allDone && optimization.apply(scene, this);
  95838. this.onNewOptimizationAppliedObservable.notifyObservers(optimization);
  95839. }
  95840. }
  95841. // If no optimization was applied, this is a failure :(
  95842. if (noOptimizationApplied) {
  95843. this._isRunning = false;
  95844. this.onFailureObservable.notifyObservers(this);
  95845. return;
  95846. }
  95847. // If all optimizations were done, move to next level
  95848. if (allDone) {
  95849. this._currentPriorityLevel++;
  95850. }
  95851. // Let's the system running for a specific amount of time before checking FPS
  95852. scene.executeWhenReady(function () {
  95853. setTimeout(function () {
  95854. _this._checkCurrentState();
  95855. }, _this._trackerDuration);
  95856. });
  95857. };
  95858. /**
  95859. * Release all resources
  95860. */
  95861. SceneOptimizer.prototype.dispose = function () {
  95862. this.stop();
  95863. this.onSuccessObservable.clear();
  95864. this.onFailureObservable.clear();
  95865. this.onNewOptimizationAppliedObservable.clear();
  95866. if (this._sceneDisposeObserver) {
  95867. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  95868. }
  95869. };
  95870. /**
  95871. * Helper function to create a SceneOptimizer with one single line of code
  95872. * @param scene defines the scene to work on
  95873. * @param options defines the options to use with the SceneOptimizer
  95874. * @param onSuccess defines a callback to call on success
  95875. * @param onFailure defines a callback to call on failure
  95876. * @returns the new SceneOptimizer object
  95877. */
  95878. SceneOptimizer.OptimizeAsync = function (scene, options, onSuccess, onFailure) {
  95879. var optimizer = new SceneOptimizer(scene, options || SceneOptimizerOptions.ModerateDegradationAllowed(), false);
  95880. if (onSuccess) {
  95881. optimizer.onSuccessObservable.add(function () {
  95882. onSuccess();
  95883. });
  95884. }
  95885. if (onFailure) {
  95886. optimizer.onFailureObservable.add(function () {
  95887. onFailure();
  95888. });
  95889. }
  95890. optimizer.start();
  95891. return optimizer;
  95892. };
  95893. return SceneOptimizer;
  95894. }());
  95895. /***/ }),
  95896. /***/ "./Misc/sceneSerializer.ts":
  95897. /*!*********************************!*\
  95898. !*** ./Misc/sceneSerializer.ts ***!
  95899. \*********************************/
  95900. /*! exports provided: SceneSerializer */
  95901. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95902. "use strict";
  95903. __webpack_require__.r(__webpack_exports__);
  95904. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return SceneSerializer; });
  95905. /* harmony import */ var _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/geometry */ "./Meshes/geometry.ts");
  95906. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  95907. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  95908. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  95909. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  95910. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  95911. var serializedGeometries = [];
  95912. var serializeGeometry = function (geometry, serializationGeometries) {
  95913. if (serializedGeometries[geometry.id]) {
  95914. return;
  95915. }
  95916. if (geometry.doNotSerialize) {
  95917. return;
  95918. }
  95919. if (geometry instanceof _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__["BoxGeometry"]) {
  95920. serializationGeometries.boxes.push(geometry.serialize());
  95921. }
  95922. else if (geometry instanceof _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__["SphereGeometry"]) {
  95923. serializationGeometries.spheres.push(geometry.serialize());
  95924. }
  95925. else if (geometry instanceof _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__["CylinderGeometry"]) {
  95926. serializationGeometries.cylinders.push(geometry.serialize());
  95927. }
  95928. else if (geometry instanceof _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__["TorusGeometry"]) {
  95929. serializationGeometries.toruses.push(geometry.serialize());
  95930. }
  95931. else if (geometry instanceof _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__["GroundGeometry"]) {
  95932. serializationGeometries.grounds.push(geometry.serialize());
  95933. }
  95934. else if (geometry instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Plane"]) {
  95935. serializationGeometries.planes.push(geometry.serialize());
  95936. }
  95937. else if (geometry instanceof _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__["TorusKnotGeometry"]) {
  95938. serializationGeometries.torusKnots.push(geometry.serialize());
  95939. }
  95940. else if (geometry instanceof _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__["_PrimitiveGeometry"]) {
  95941. throw new Error("Unknown primitive type");
  95942. }
  95943. else {
  95944. serializationGeometries.vertexData.push(geometry.serializeVerticeData());
  95945. }
  95946. serializedGeometries[geometry.id] = true;
  95947. };
  95948. var serializeMesh = function (mesh, serializationScene) {
  95949. var serializationObject = {};
  95950. // Geometry
  95951. var geometry = mesh._geometry;
  95952. if (geometry) {
  95953. if (!mesh.getScene().getGeometryByID(geometry.id)) {
  95954. // 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
  95955. serializeGeometry(geometry, serializationScene.geometries);
  95956. }
  95957. }
  95958. // Custom
  95959. if (mesh.serialize) {
  95960. mesh.serialize(serializationObject);
  95961. }
  95962. return serializationObject;
  95963. };
  95964. var finalizeSingleMesh = function (mesh, serializationObject) {
  95965. //only works if the mesh is already loaded
  95966. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NONE) {
  95967. //serialize material
  95968. if (mesh.material) {
  95969. if (mesh.material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_4__["MultiMaterial"]) {
  95970. serializationObject.multiMaterials = serializationObject.multiMaterials || [];
  95971. serializationObject.materials = serializationObject.materials || [];
  95972. if (!serializationObject.multiMaterials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  95973. serializationObject.multiMaterials.push(mesh.material.serialize());
  95974. var _loop_1 = function (submaterial) {
  95975. if (submaterial) {
  95976. if (!serializationObject.materials.some(function (mat) { return (mat.id === submaterial.id); })) {
  95977. serializationObject.materials.push(submaterial.serialize());
  95978. }
  95979. }
  95980. };
  95981. for (var _i = 0, _a = mesh.material.subMaterials; _i < _a.length; _i++) {
  95982. var submaterial = _a[_i];
  95983. _loop_1(submaterial);
  95984. }
  95985. }
  95986. }
  95987. else {
  95988. serializationObject.materials = serializationObject.materials || [];
  95989. if (!serializationObject.materials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  95990. serializationObject.materials.push(mesh.material.serialize());
  95991. }
  95992. }
  95993. }
  95994. //serialize geometry
  95995. var geometry = mesh._geometry;
  95996. if (geometry) {
  95997. if (!serializationObject.geometries) {
  95998. serializationObject.geometries = {};
  95999. serializationObject.geometries.boxes = [];
  96000. serializationObject.geometries.spheres = [];
  96001. serializationObject.geometries.cylinders = [];
  96002. serializationObject.geometries.toruses = [];
  96003. serializationObject.geometries.grounds = [];
  96004. serializationObject.geometries.planes = [];
  96005. serializationObject.geometries.torusKnots = [];
  96006. serializationObject.geometries.vertexData = [];
  96007. }
  96008. serializeGeometry(geometry, serializationObject.geometries);
  96009. }
  96010. // Skeletons
  96011. if (mesh.skeleton) {
  96012. serializationObject.skeletons = serializationObject.skeletons || [];
  96013. serializationObject.skeletons.push(mesh.skeleton.serialize());
  96014. }
  96015. //serialize the actual mesh
  96016. serializationObject.meshes = serializationObject.meshes || [];
  96017. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  96018. }
  96019. };
  96020. /**
  96021. * Class used to serialize a scene into a string
  96022. */
  96023. var SceneSerializer = /** @class */ (function () {
  96024. function SceneSerializer() {
  96025. }
  96026. /**
  96027. * Clear cache used by a previous serialization
  96028. */
  96029. SceneSerializer.ClearCache = function () {
  96030. serializedGeometries = [];
  96031. };
  96032. /**
  96033. * Serialize a scene into a JSON compatible object
  96034. * @param scene defines the scene to serialize
  96035. * @returns a JSON compatible object
  96036. */
  96037. SceneSerializer.Serialize = function (scene) {
  96038. var serializationObject = {};
  96039. SceneSerializer.ClearCache();
  96040. // Scene
  96041. serializationObject.useDelayedTextureLoading = scene.useDelayedTextureLoading;
  96042. serializationObject.autoClear = scene.autoClear;
  96043. serializationObject.clearColor = scene.clearColor.asArray();
  96044. serializationObject.ambientColor = scene.ambientColor.asArray();
  96045. serializationObject.gravity = scene.gravity.asArray();
  96046. serializationObject.collisionsEnabled = scene.collisionsEnabled;
  96047. // Fog
  96048. if (scene.fogMode && scene.fogMode !== 0) {
  96049. serializationObject.fogMode = scene.fogMode;
  96050. serializationObject.fogColor = scene.fogColor.asArray();
  96051. serializationObject.fogStart = scene.fogStart;
  96052. serializationObject.fogEnd = scene.fogEnd;
  96053. serializationObject.fogDensity = scene.fogDensity;
  96054. }
  96055. //Physics
  96056. if (scene.isPhysicsEnabled()) {
  96057. var physicEngine = scene.getPhysicsEngine();
  96058. if (physicEngine) {
  96059. serializationObject.physicsEnabled = true;
  96060. serializationObject.physicsGravity = physicEngine.gravity.asArray();
  96061. serializationObject.physicsEngine = physicEngine.getPhysicsPluginName();
  96062. }
  96063. }
  96064. // Metadata
  96065. if (scene.metadata) {
  96066. serializationObject.metadata = scene.metadata;
  96067. }
  96068. // Morph targets
  96069. serializationObject.morphTargetManagers = [];
  96070. for (var _i = 0, _a = scene.meshes; _i < _a.length; _i++) {
  96071. var abstractMesh = _a[_i];
  96072. var manager = abstractMesh.morphTargetManager;
  96073. if (manager) {
  96074. serializationObject.morphTargetManagers.push(manager.serialize());
  96075. }
  96076. }
  96077. // Lights
  96078. serializationObject.lights = [];
  96079. var index;
  96080. var light;
  96081. for (index = 0; index < scene.lights.length; index++) {
  96082. light = scene.lights[index];
  96083. if (!light.doNotSerialize) {
  96084. serializationObject.lights.push(light.serialize());
  96085. }
  96086. }
  96087. // Cameras
  96088. serializationObject.cameras = [];
  96089. for (index = 0; index < scene.cameras.length; index++) {
  96090. var camera = scene.cameras[index];
  96091. if (!camera.doNotSerialize) {
  96092. serializationObject.cameras.push(camera.serialize());
  96093. }
  96094. }
  96095. if (scene.activeCamera) {
  96096. serializationObject.activeCameraID = scene.activeCamera.id;
  96097. }
  96098. // Animations
  96099. _decorators__WEBPACK_IMPORTED_MODULE_5__["SerializationHelper"].AppendSerializedAnimations(scene, serializationObject);
  96100. // Reflection probes
  96101. if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
  96102. serializationObject.reflectionProbes = [];
  96103. for (index = 0; index < scene.reflectionProbes.length; index++) {
  96104. var reflectionProbe = scene.reflectionProbes[index];
  96105. serializationObject.reflectionProbes.push(reflectionProbe.serialize());
  96106. }
  96107. }
  96108. // Materials
  96109. serializationObject.materials = [];
  96110. serializationObject.multiMaterials = [];
  96111. var material;
  96112. for (index = 0; index < scene.materials.length; index++) {
  96113. material = scene.materials[index];
  96114. if (!material.doNotSerialize) {
  96115. serializationObject.materials.push(material.serialize());
  96116. }
  96117. }
  96118. // MultiMaterials
  96119. serializationObject.multiMaterials = [];
  96120. for (index = 0; index < scene.multiMaterials.length; index++) {
  96121. var multiMaterial = scene.multiMaterials[index];
  96122. serializationObject.multiMaterials.push(multiMaterial.serialize());
  96123. }
  96124. // Environment texture
  96125. if (scene.environmentTexture) {
  96126. serializationObject.environmentTexture = scene.environmentTexture.name;
  96127. }
  96128. // Skeletons
  96129. serializationObject.skeletons = [];
  96130. for (index = 0; index < scene.skeletons.length; index++) {
  96131. var skeleton = scene.skeletons[index];
  96132. if (!skeleton.doNotSerialize) {
  96133. serializationObject.skeletons.push(skeleton.serialize());
  96134. }
  96135. }
  96136. // Transform nodes
  96137. serializationObject.transformNodes = [];
  96138. for (index = 0; index < scene.transformNodes.length; index++) {
  96139. serializationObject.transformNodes.push(scene.transformNodes[index].serialize());
  96140. }
  96141. // Geometries
  96142. serializationObject.geometries = {};
  96143. serializationObject.geometries.boxes = [];
  96144. serializationObject.geometries.spheres = [];
  96145. serializationObject.geometries.cylinders = [];
  96146. serializationObject.geometries.toruses = [];
  96147. serializationObject.geometries.grounds = [];
  96148. serializationObject.geometries.planes = [];
  96149. serializationObject.geometries.torusKnots = [];
  96150. serializationObject.geometries.vertexData = [];
  96151. serializedGeometries = [];
  96152. var geometries = scene.getGeometries();
  96153. for (index = 0; index < geometries.length; index++) {
  96154. var geometry = geometries[index];
  96155. if (geometry.isReady()) {
  96156. serializeGeometry(geometry, serializationObject.geometries);
  96157. }
  96158. }
  96159. // Meshes
  96160. serializationObject.meshes = [];
  96161. for (index = 0; index < scene.meshes.length; index++) {
  96162. var abstractMesh = scene.meshes[index];
  96163. if (abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]) {
  96164. var mesh = abstractMesh;
  96165. if (!mesh.doNotSerialize) {
  96166. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NONE) {
  96167. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  96168. }
  96169. }
  96170. }
  96171. }
  96172. // Particles Systems
  96173. serializationObject.particleSystems = [];
  96174. for (index = 0; index < scene.particleSystems.length; index++) {
  96175. serializationObject.particleSystems.push(scene.particleSystems[index].serialize());
  96176. }
  96177. // Action Manager
  96178. if (scene.actionManager) {
  96179. serializationObject.actions = scene.actionManager.serialize("scene");
  96180. }
  96181. // Components
  96182. for (var _b = 0, _c = scene._serializableComponents; _b < _c.length; _b++) {
  96183. var component = _c[_b];
  96184. component.serialize(serializationObject);
  96185. }
  96186. return serializationObject;
  96187. };
  96188. /**
  96189. * Serialize a mesh into a JSON compatible object
  96190. * @param toSerialize defines the mesh to serialize
  96191. * @param withParents defines if parents must be serialized as well
  96192. * @param withChildren defines if children must be serialized as well
  96193. * @returns a JSON compatible object
  96194. */
  96195. SceneSerializer.SerializeMesh = function (toSerialize /* Mesh || Mesh[] */, withParents, withChildren) {
  96196. if (withParents === void 0) { withParents = false; }
  96197. if (withChildren === void 0) { withChildren = false; }
  96198. var serializationObject = {};
  96199. SceneSerializer.ClearCache();
  96200. toSerialize = (toSerialize instanceof Array) ? toSerialize : [toSerialize];
  96201. if (withParents || withChildren) {
  96202. //deliberate for loop! not for each, appended should be processed as well.
  96203. for (var i = 0; i < toSerialize.length; ++i) {
  96204. if (withChildren) {
  96205. toSerialize[i].getDescendants().forEach(function (node) {
  96206. if (node instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"] && (toSerialize.indexOf(node) < 0)) {
  96207. toSerialize.push(node);
  96208. }
  96209. });
  96210. }
  96211. //make sure the array doesn't contain the object already
  96212. if (withParents && toSerialize[i].parent && (toSerialize.indexOf(toSerialize[i].parent) < 0)) {
  96213. toSerialize.push(toSerialize[i].parent);
  96214. }
  96215. }
  96216. }
  96217. toSerialize.forEach(function (mesh) {
  96218. finalizeSingleMesh(mesh, serializationObject);
  96219. });
  96220. return serializationObject;
  96221. };
  96222. return SceneSerializer;
  96223. }());
  96224. /***/ }),
  96225. /***/ "./Misc/screenshotTools.ts":
  96226. /*!*********************************!*\
  96227. !*** ./Misc/screenshotTools.ts ***!
  96228. \*********************************/
  96229. /*! exports provided: ScreenshotTools */
  96230. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96231. "use strict";
  96232. __webpack_require__.r(__webpack_exports__);
  96233. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return ScreenshotTools; });
  96234. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  96235. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  96236. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  96237. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  96238. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  96239. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  96240. // Screenshots
  96241. var screenshotCanvas;
  96242. /**
  96243. * Class containing a set of static utilities functions for screenshots
  96244. */
  96245. var ScreenshotTools = /** @class */ (function () {
  96246. function ScreenshotTools() {
  96247. }
  96248. /**
  96249. * Captures a screenshot of the current rendering
  96250. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96251. * @param engine defines the rendering engine
  96252. * @param camera defines the source camera
  96253. * @param size This parameter can be set to a single number or to an object with the
  96254. * following (optional) properties: precision, width, height. If a single number is passed,
  96255. * it will be used for both width and height. If an object is passed, the screenshot size
  96256. * will be derived from the parameters. The precision property is a multiplier allowing
  96257. * rendering at a higher or lower resolution
  96258. * @param successCallback defines the callback receives a single parameter which contains the
  96259. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  96260. * src parameter of an <img> to display it
  96261. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  96262. * Check your browser for supported MIME types
  96263. */
  96264. ScreenshotTools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  96265. if (mimeType === void 0) { mimeType = "image/png"; }
  96266. var width;
  96267. var height;
  96268. // If a precision value is specified
  96269. if (size.precision) {
  96270. width = Math.round(engine.getRenderWidth() * size.precision);
  96271. height = Math.round(width / engine.getAspectRatio(camera));
  96272. }
  96273. else if (size.width && size.height) {
  96274. width = size.width;
  96275. height = size.height;
  96276. }
  96277. //If passing only width, computing height to keep display canvas ratio.
  96278. else if (size.width && !size.height) {
  96279. width = size.width;
  96280. height = Math.round(width / engine.getAspectRatio(camera));
  96281. }
  96282. //If passing only height, computing width to keep display canvas ratio.
  96283. else if (size.height && !size.width) {
  96284. height = size.height;
  96285. width = Math.round(height * engine.getAspectRatio(camera));
  96286. }
  96287. //Assuming here that "size" parameter is a number
  96288. else if (!isNaN(size)) {
  96289. height = size;
  96290. width = size;
  96291. }
  96292. else {
  96293. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  96294. return;
  96295. }
  96296. if (!screenshotCanvas) {
  96297. screenshotCanvas = document.createElement('canvas');
  96298. }
  96299. screenshotCanvas.width = width;
  96300. screenshotCanvas.height = height;
  96301. var renderContext = screenshotCanvas.getContext("2d");
  96302. var ratio = engine.getRenderWidth() / engine.getRenderHeight();
  96303. var newWidth = width;
  96304. var newHeight = newWidth / ratio;
  96305. if (newHeight > height) {
  96306. newHeight = height;
  96307. newWidth = newHeight * ratio;
  96308. }
  96309. var offsetX = Math.max(0, width - newWidth) / 2;
  96310. var offsetY = Math.max(0, height - newHeight) / 2;
  96311. var renderingCanvas = engine.getRenderingCanvas();
  96312. if (renderContext && renderingCanvas) {
  96313. renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);
  96314. }
  96315. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].EncodeScreenshotCanvasData(successCallback, mimeType);
  96316. };
  96317. /**
  96318. * Generates an image screenshot from the specified camera.
  96319. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96320. * @param engine The engine to use for rendering
  96321. * @param camera The camera to use for rendering
  96322. * @param size This parameter can be set to a single number or to an object with the
  96323. * following (optional) properties: precision, width, height. If a single number is passed,
  96324. * it will be used for both width and height. If an object is passed, the screenshot size
  96325. * will be derived from the parameters. The precision property is a multiplier allowing
  96326. * rendering at a higher or lower resolution
  96327. * @param successCallback The callback receives a single parameter which contains the
  96328. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  96329. * src parameter of an <img> to display it
  96330. * @param mimeType The MIME type of the screenshot image (default: image/png).
  96331. * Check your browser for supported MIME types
  96332. * @param samples Texture samples (default: 1)
  96333. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  96334. * @param fileName A name for for the downloaded file.
  96335. */
  96336. ScreenshotTools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  96337. if (mimeType === void 0) { mimeType = "image/png"; }
  96338. if (samples === void 0) { samples = 1; }
  96339. if (antialiasing === void 0) { antialiasing = false; }
  96340. var width;
  96341. var height;
  96342. //If a precision value is specified
  96343. if (size.precision) {
  96344. width = Math.round(engine.getRenderWidth() * size.precision);
  96345. height = Math.round(width / engine.getAspectRatio(camera));
  96346. size = { width: width, height: height };
  96347. }
  96348. else if (size.width && size.height) {
  96349. width = size.width;
  96350. height = size.height;
  96351. }
  96352. //If passing only width, computing height to keep display canvas ratio.
  96353. else if (size.width && !size.height) {
  96354. width = size.width;
  96355. height = Math.round(width / engine.getAspectRatio(camera));
  96356. size = { width: width, height: height };
  96357. }
  96358. //If passing only height, computing width to keep display canvas ratio.
  96359. else if (size.height && !size.width) {
  96360. height = size.height;
  96361. width = Math.round(height * engine.getAspectRatio(camera));
  96362. size = { width: width, height: height };
  96363. }
  96364. //Assuming here that "size" parameter is a number
  96365. else if (!isNaN(size)) {
  96366. height = size;
  96367. width = size;
  96368. }
  96369. else {
  96370. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  96371. return;
  96372. }
  96373. var scene = camera.getScene();
  96374. var previousCamera = null;
  96375. if (scene.activeCamera !== camera) {
  96376. previousCamera = scene.activeCamera;
  96377. scene.activeCamera = camera;
  96378. }
  96379. var renderCanvas = engine.getRenderingCanvas();
  96380. if (!renderCanvas) {
  96381. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("No rendering canvas found !");
  96382. return;
  96383. }
  96384. var originalSize = { width: renderCanvas.width, height: renderCanvas.height };
  96385. engine.setSize(width, height);
  96386. scene.render();
  96387. // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)
  96388. 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);
  96389. texture.renderList = null;
  96390. texture.samples = samples;
  96391. if (antialiasing) {
  96392. texture.addPostProcess(new _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__["FxaaPostProcess"]('antialiasing', 1.0, scene.activeCamera));
  96393. }
  96394. texture.onAfterRenderObservable.add(function () {
  96395. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].DumpFramebuffer(width, height, engine, successCallback, mimeType, fileName);
  96396. });
  96397. scene.incrementRenderId();
  96398. scene.resetCachedMaterial();
  96399. texture.render(true);
  96400. texture.dispose();
  96401. if (previousCamera) {
  96402. scene.activeCamera = previousCamera;
  96403. }
  96404. engine.setSize(originalSize.width, originalSize.height);
  96405. camera.getProjectionMatrix(true); // Force cache refresh;
  96406. };
  96407. return ScreenshotTools;
  96408. }());
  96409. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshot = ScreenshotTools.CreateScreenshot;
  96410. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshotUsingRenderTarget = ScreenshotTools.CreateScreenshotUsingRenderTarget;
  96411. /***/ }),
  96412. /***/ "./Misc/smartArray.ts":
  96413. /*!****************************!*\
  96414. !*** ./Misc/smartArray.ts ***!
  96415. \****************************/
  96416. /*! exports provided: SmartArray, SmartArrayNoDuplicate */
  96417. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96418. "use strict";
  96419. __webpack_require__.r(__webpack_exports__);
  96420. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return SmartArray; });
  96421. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return SmartArrayNoDuplicate; });
  96422. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  96423. /**
  96424. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  96425. */
  96426. var SmartArray = /** @class */ (function () {
  96427. /**
  96428. * Instantiates a Smart Array.
  96429. * @param capacity defines the default capacity of the array.
  96430. */
  96431. function SmartArray(capacity) {
  96432. /**
  96433. * The active length of the array.
  96434. */
  96435. this.length = 0;
  96436. this.data = new Array(capacity);
  96437. this._id = SmartArray._GlobalId++;
  96438. }
  96439. /**
  96440. * Pushes a value at the end of the active data.
  96441. * @param value defines the object to push in the array.
  96442. */
  96443. SmartArray.prototype.push = function (value) {
  96444. this.data[this.length++] = value;
  96445. if (this.length > this.data.length) {
  96446. this.data.length *= 2;
  96447. }
  96448. };
  96449. /**
  96450. * Iterates over the active data and apply the lambda to them.
  96451. * @param func defines the action to apply on each value.
  96452. */
  96453. SmartArray.prototype.forEach = function (func) {
  96454. for (var index = 0; index < this.length; index++) {
  96455. func(this.data[index]);
  96456. }
  96457. };
  96458. /**
  96459. * Sorts the full sets of data.
  96460. * @param compareFn defines the comparison function to apply.
  96461. */
  96462. SmartArray.prototype.sort = function (compareFn) {
  96463. this.data.sort(compareFn);
  96464. };
  96465. /**
  96466. * Resets the active data to an empty array.
  96467. */
  96468. SmartArray.prototype.reset = function () {
  96469. this.length = 0;
  96470. };
  96471. /**
  96472. * Releases all the data from the array as well as the array.
  96473. */
  96474. SmartArray.prototype.dispose = function () {
  96475. this.reset();
  96476. if (this.data) {
  96477. this.data.length = 0;
  96478. this.data = [];
  96479. }
  96480. };
  96481. /**
  96482. * Concats the active data with a given array.
  96483. * @param array defines the data to concatenate with.
  96484. */
  96485. SmartArray.prototype.concat = function (array) {
  96486. if (array.length === 0) {
  96487. return;
  96488. }
  96489. if (this.length + array.length > this.data.length) {
  96490. this.data.length = (this.length + array.length) * 2;
  96491. }
  96492. for (var index = 0; index < array.length; index++) {
  96493. this.data[this.length++] = (array.data || array)[index];
  96494. }
  96495. };
  96496. /**
  96497. * Returns the position of a value in the active data.
  96498. * @param value defines the value to find the index for
  96499. * @returns the index if found in the active data otherwise -1
  96500. */
  96501. SmartArray.prototype.indexOf = function (value) {
  96502. var position = this.data.indexOf(value);
  96503. if (position >= this.length) {
  96504. return -1;
  96505. }
  96506. return position;
  96507. };
  96508. /**
  96509. * Returns whether an element is part of the active data.
  96510. * @param value defines the value to look for
  96511. * @returns true if found in the active data otherwise false
  96512. */
  96513. SmartArray.prototype.contains = function (value) {
  96514. return this.indexOf(value) !== -1;
  96515. };
  96516. // Statics
  96517. SmartArray._GlobalId = 0;
  96518. return SmartArray;
  96519. }());
  96520. /**
  96521. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  96522. * The data in this array can only be present once
  96523. */
  96524. var SmartArrayNoDuplicate = /** @class */ (function (_super) {
  96525. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SmartArrayNoDuplicate, _super);
  96526. function SmartArrayNoDuplicate() {
  96527. var _this = _super !== null && _super.apply(this, arguments) || this;
  96528. _this._duplicateId = 0;
  96529. return _this;
  96530. }
  96531. /**
  96532. * Pushes a value at the end of the active data.
  96533. * THIS DOES NOT PREVENT DUPPLICATE DATA
  96534. * @param value defines the object to push in the array.
  96535. */
  96536. SmartArrayNoDuplicate.prototype.push = function (value) {
  96537. _super.prototype.push.call(this, value);
  96538. if (!value.__smartArrayFlags) {
  96539. value.__smartArrayFlags = {};
  96540. }
  96541. value.__smartArrayFlags[this._id] = this._duplicateId;
  96542. };
  96543. /**
  96544. * Pushes a value at the end of the active data.
  96545. * If the data is already present, it won t be added again
  96546. * @param value defines the object to push in the array.
  96547. * @returns true if added false if it was already present
  96548. */
  96549. SmartArrayNoDuplicate.prototype.pushNoDuplicate = function (value) {
  96550. if (value.__smartArrayFlags && value.__smartArrayFlags[this._id] === this._duplicateId) {
  96551. return false;
  96552. }
  96553. this.push(value);
  96554. return true;
  96555. };
  96556. /**
  96557. * Resets the active data to an empty array.
  96558. */
  96559. SmartArrayNoDuplicate.prototype.reset = function () {
  96560. _super.prototype.reset.call(this);
  96561. this._duplicateId++;
  96562. };
  96563. /**
  96564. * Concats the active data with a given array.
  96565. * This ensures no dupplicate will be present in the result.
  96566. * @param array defines the data to concatenate with.
  96567. */
  96568. SmartArrayNoDuplicate.prototype.concatWithNoDuplicate = function (array) {
  96569. if (array.length === 0) {
  96570. return;
  96571. }
  96572. if (this.length + array.length > this.data.length) {
  96573. this.data.length = (this.length + array.length) * 2;
  96574. }
  96575. for (var index = 0; index < array.length; index++) {
  96576. var item = (array.data || array)[index];
  96577. this.pushNoDuplicate(item);
  96578. }
  96579. };
  96580. return SmartArrayNoDuplicate;
  96581. }(SmartArray));
  96582. /***/ }),
  96583. /***/ "./Misc/stringDictionary.ts":
  96584. /*!**********************************!*\
  96585. !*** ./Misc/stringDictionary.ts ***!
  96586. \**********************************/
  96587. /*! exports provided: StringDictionary */
  96588. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96589. "use strict";
  96590. __webpack_require__.r(__webpack_exports__);
  96591. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return StringDictionary; });
  96592. /**
  96593. * This class implement a typical dictionary using a string as key and the generic type T as value.
  96594. * The underlying implementation relies on an associative array to ensure the best performances.
  96595. * The value can be anything including 'null' but except 'undefined'
  96596. */
  96597. var StringDictionary = /** @class */ (function () {
  96598. function StringDictionary() {
  96599. this._count = 0;
  96600. this._data = {};
  96601. }
  96602. /**
  96603. * This will clear this dictionary and copy the content from the 'source' one.
  96604. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  96605. * @param source the dictionary to take the content from and copy to this dictionary
  96606. */
  96607. StringDictionary.prototype.copyFrom = function (source) {
  96608. var _this = this;
  96609. this.clear();
  96610. source.forEach(function (t, v) { return _this.add(t, v); });
  96611. };
  96612. /**
  96613. * Get a value based from its key
  96614. * @param key the given key to get the matching value from
  96615. * @return the value if found, otherwise undefined is returned
  96616. */
  96617. StringDictionary.prototype.get = function (key) {
  96618. var val = this._data[key];
  96619. if (val !== undefined) {
  96620. return val;
  96621. }
  96622. return undefined;
  96623. };
  96624. /**
  96625. * Get a value from its key or add it if it doesn't exist.
  96626. * This method will ensure you that a given key/data will be present in the dictionary.
  96627. * @param key the given key to get the matching value from
  96628. * @param factory the factory that will create the value if the key is not present in the dictionary.
  96629. * The factory will only be invoked if there's no data for the given key.
  96630. * @return the value corresponding to the key.
  96631. */
  96632. StringDictionary.prototype.getOrAddWithFactory = function (key, factory) {
  96633. var val = this.get(key);
  96634. if (val !== undefined) {
  96635. return val;
  96636. }
  96637. val = factory(key);
  96638. if (val) {
  96639. this.add(key, val);
  96640. }
  96641. return val;
  96642. };
  96643. /**
  96644. * Get a value from its key if present in the dictionary otherwise add it
  96645. * @param key the key to get the value from
  96646. * @param val if there's no such key/value pair in the dictionary add it with this value
  96647. * @return the value corresponding to the key
  96648. */
  96649. StringDictionary.prototype.getOrAdd = function (key, val) {
  96650. var curVal = this.get(key);
  96651. if (curVal !== undefined) {
  96652. return curVal;
  96653. }
  96654. this.add(key, val);
  96655. return val;
  96656. };
  96657. /**
  96658. * Check if there's a given key in the dictionary
  96659. * @param key the key to check for
  96660. * @return true if the key is present, false otherwise
  96661. */
  96662. StringDictionary.prototype.contains = function (key) {
  96663. return this._data[key] !== undefined;
  96664. };
  96665. /**
  96666. * Add a new key and its corresponding value
  96667. * @param key the key to add
  96668. * @param value the value corresponding to the key
  96669. * @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
  96670. */
  96671. StringDictionary.prototype.add = function (key, value) {
  96672. if (this._data[key] !== undefined) {
  96673. return false;
  96674. }
  96675. this._data[key] = value;
  96676. ++this._count;
  96677. return true;
  96678. };
  96679. /**
  96680. * Update a specific value associated to a key
  96681. * @param key defines the key to use
  96682. * @param value defines the value to store
  96683. * @returns true if the value was updated (or false if the key was not found)
  96684. */
  96685. StringDictionary.prototype.set = function (key, value) {
  96686. if (this._data[key] === undefined) {
  96687. return false;
  96688. }
  96689. this._data[key] = value;
  96690. return true;
  96691. };
  96692. /**
  96693. * Get the element of the given key and remove it from the dictionary
  96694. * @param key defines the key to search
  96695. * @returns the value associated with the key or null if not found
  96696. */
  96697. StringDictionary.prototype.getAndRemove = function (key) {
  96698. var val = this.get(key);
  96699. if (val !== undefined) {
  96700. delete this._data[key];
  96701. --this._count;
  96702. return val;
  96703. }
  96704. return null;
  96705. };
  96706. /**
  96707. * Remove a key/value from the dictionary.
  96708. * @param key the key to remove
  96709. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  96710. */
  96711. StringDictionary.prototype.remove = function (key) {
  96712. if (this.contains(key)) {
  96713. delete this._data[key];
  96714. --this._count;
  96715. return true;
  96716. }
  96717. return false;
  96718. };
  96719. /**
  96720. * Clear the whole content of the dictionary
  96721. */
  96722. StringDictionary.prototype.clear = function () {
  96723. this._data = {};
  96724. this._count = 0;
  96725. };
  96726. Object.defineProperty(StringDictionary.prototype, "count", {
  96727. /**
  96728. * Gets the current count
  96729. */
  96730. get: function () {
  96731. return this._count;
  96732. },
  96733. enumerable: true,
  96734. configurable: true
  96735. });
  96736. /**
  96737. * Execute a callback on each key/val of the dictionary.
  96738. * Note that you can remove any element in this dictionary in the callback implementation
  96739. * @param callback the callback to execute on a given key/value pair
  96740. */
  96741. StringDictionary.prototype.forEach = function (callback) {
  96742. for (var cur in this._data) {
  96743. var val = this._data[cur];
  96744. callback(cur, val);
  96745. }
  96746. };
  96747. /**
  96748. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  96749. * If the callback returns null or undefined the method will iterate to the next key/value pair
  96750. * Note that you can remove any element in this dictionary in the callback implementation
  96751. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  96752. * @returns the first item
  96753. */
  96754. StringDictionary.prototype.first = function (callback) {
  96755. for (var cur in this._data) {
  96756. var val = this._data[cur];
  96757. var res = callback(cur, val);
  96758. if (res) {
  96759. return res;
  96760. }
  96761. }
  96762. return null;
  96763. };
  96764. return StringDictionary;
  96765. }());
  96766. /***/ }),
  96767. /***/ "./Misc/tags.ts":
  96768. /*!**********************!*\
  96769. !*** ./Misc/tags.ts ***!
  96770. \**********************/
  96771. /*! exports provided: Tags */
  96772. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96773. "use strict";
  96774. __webpack_require__.r(__webpack_exports__);
  96775. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return Tags; });
  96776. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  96777. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  96778. /**
  96779. * Class used to store custom tags
  96780. */
  96781. var Tags = /** @class */ (function () {
  96782. function Tags() {
  96783. }
  96784. /**
  96785. * Adds support for tags on the given object
  96786. * @param obj defines the object to use
  96787. */
  96788. Tags.EnableFor = function (obj) {
  96789. obj._tags = obj._tags || {};
  96790. obj.hasTags = function () {
  96791. return Tags.HasTags(obj);
  96792. };
  96793. obj.addTags = function (tagsString) {
  96794. return Tags.AddTagsTo(obj, tagsString);
  96795. };
  96796. obj.removeTags = function (tagsString) {
  96797. return Tags.RemoveTagsFrom(obj, tagsString);
  96798. };
  96799. obj.matchesTagsQuery = function (tagsQuery) {
  96800. return Tags.MatchesQuery(obj, tagsQuery);
  96801. };
  96802. };
  96803. /**
  96804. * Removes tags support
  96805. * @param obj defines the object to use
  96806. */
  96807. Tags.DisableFor = function (obj) {
  96808. delete obj._tags;
  96809. delete obj.hasTags;
  96810. delete obj.addTags;
  96811. delete obj.removeTags;
  96812. delete obj.matchesTagsQuery;
  96813. };
  96814. /**
  96815. * Gets a boolean indicating if the given object has tags
  96816. * @param obj defines the object to use
  96817. * @returns a boolean
  96818. */
  96819. Tags.HasTags = function (obj) {
  96820. if (!obj._tags) {
  96821. return false;
  96822. }
  96823. return !_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsEmpty(obj._tags);
  96824. };
  96825. /**
  96826. * Gets the tags available on a given object
  96827. * @param obj defines the object to use
  96828. * @param asString defines if the tags must be returned as a string instead of an array of strings
  96829. * @returns the tags
  96830. */
  96831. Tags.GetTags = function (obj, asString) {
  96832. if (asString === void 0) { asString = true; }
  96833. if (!obj._tags) {
  96834. return null;
  96835. }
  96836. if (asString) {
  96837. var tagsArray = [];
  96838. for (var tag in obj._tags) {
  96839. if (obj._tags.hasOwnProperty(tag) && obj._tags[tag] === true) {
  96840. tagsArray.push(tag);
  96841. }
  96842. }
  96843. return tagsArray.join(" ");
  96844. }
  96845. else {
  96846. return obj._tags;
  96847. }
  96848. };
  96849. /**
  96850. * Adds tags to an object
  96851. * @param obj defines the object to use
  96852. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  96853. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  96854. */
  96855. Tags.AddTagsTo = function (obj, tagsString) {
  96856. if (!tagsString) {
  96857. return;
  96858. }
  96859. if (typeof tagsString !== "string") {
  96860. return;
  96861. }
  96862. var tags = tagsString.split(" ");
  96863. tags.forEach(function (tag, index, array) {
  96864. Tags._AddTagTo(obj, tag);
  96865. });
  96866. };
  96867. /**
  96868. * @hidden
  96869. */
  96870. Tags._AddTagTo = function (obj, tag) {
  96871. tag = tag.trim();
  96872. if (tag === "" || tag === "true" || tag === "false") {
  96873. return;
  96874. }
  96875. if (tag.match(/[\s]/) || tag.match(/^([!]|([|]|[&]){2})/)) {
  96876. return;
  96877. }
  96878. Tags.EnableFor(obj);
  96879. obj._tags[tag] = true;
  96880. };
  96881. /**
  96882. * Removes specific tags from a specific object
  96883. * @param obj defines the object to use
  96884. * @param tagsString defines the tags to remove
  96885. */
  96886. Tags.RemoveTagsFrom = function (obj, tagsString) {
  96887. if (!Tags.HasTags(obj)) {
  96888. return;
  96889. }
  96890. var tags = tagsString.split(" ");
  96891. for (var t in tags) {
  96892. Tags._RemoveTagFrom(obj, tags[t]);
  96893. }
  96894. };
  96895. /**
  96896. * @hidden
  96897. */
  96898. Tags._RemoveTagFrom = function (obj, tag) {
  96899. delete obj._tags[tag];
  96900. };
  96901. /**
  96902. * Defines if tags hosted on an object match a given query
  96903. * @param obj defines the object to use
  96904. * @param tagsQuery defines the tag query
  96905. * @returns a boolean
  96906. */
  96907. Tags.MatchesQuery = function (obj, tagsQuery) {
  96908. if (tagsQuery === undefined) {
  96909. return true;
  96910. }
  96911. if (tagsQuery === "") {
  96912. return Tags.HasTags(obj);
  96913. }
  96914. return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__["AndOrNotEvaluator"].Eval(tagsQuery, function (r) { return Tags.HasTags(obj) && obj._tags[r]; });
  96915. };
  96916. return Tags;
  96917. }());
  96918. /***/ }),
  96919. /***/ "./Misc/textureTools.ts":
  96920. /*!******************************!*\
  96921. !*** ./Misc/textureTools.ts ***!
  96922. \******************************/
  96923. /*! exports provided: TextureTools */
  96924. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96925. "use strict";
  96926. __webpack_require__.r(__webpack_exports__);
  96927. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return TextureTools; });
  96928. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  96929. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  96930. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  96931. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  96932. /**
  96933. * Class used to host texture specific utilities
  96934. */
  96935. var TextureTools = /** @class */ (function () {
  96936. function TextureTools() {
  96937. }
  96938. /**
  96939. * Uses the GPU to create a copy texture rescaled at a given size
  96940. * @param texture Texture to copy from
  96941. * @param width defines the desired width
  96942. * @param height defines the desired height
  96943. * @param useBilinearMode defines if bilinear mode has to be used
  96944. * @return the generated texture
  96945. */
  96946. TextureTools.CreateResizedCopy = function (texture, width, height, useBilinearMode) {
  96947. if (useBilinearMode === void 0) { useBilinearMode = true; }
  96948. var scene = texture.getScene();
  96949. var engine = scene.getEngine();
  96950. 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);
  96951. rtt.wrapU = texture.wrapU;
  96952. rtt.wrapV = texture.wrapV;
  96953. rtt.uOffset = texture.uOffset;
  96954. rtt.vOffset = texture.vOffset;
  96955. rtt.uScale = texture.uScale;
  96956. rtt.vScale = texture.vScale;
  96957. rtt.uAng = texture.uAng;
  96958. rtt.vAng = texture.vAng;
  96959. rtt.wAng = texture.wAng;
  96960. rtt.coordinatesIndex = texture.coordinatesIndex;
  96961. rtt.level = texture.level;
  96962. rtt.anisotropicFilteringLevel = texture.anisotropicFilteringLevel;
  96963. rtt._texture.isReady = false;
  96964. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  96965. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  96966. 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);
  96967. passPostProcess.getEffect().executeWhenCompiled(function () {
  96968. passPostProcess.onApply = function (effect) {
  96969. effect.setTexture("textureSampler", texture);
  96970. };
  96971. var internalTexture = rtt.getInternalTexture();
  96972. if (internalTexture) {
  96973. scene.postProcessManager.directRender([passPostProcess], internalTexture);
  96974. engine.unBindFramebuffer(internalTexture);
  96975. rtt.disposeFramebufferObjects();
  96976. passPostProcess.dispose();
  96977. internalTexture.isReady = true;
  96978. }
  96979. });
  96980. return rtt;
  96981. };
  96982. /**
  96983. * Gets an environment BRDF texture for a given scene
  96984. * @param scene defines the hosting scene
  96985. * @returns the environment BRDF texture
  96986. */
  96987. TextureTools.GetEnvironmentBRDFTexture = function (scene) {
  96988. if (!scene._environmentBRDFTexture) {
  96989. 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);
  96990. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  96991. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  96992. scene._environmentBRDFTexture = texture;
  96993. }
  96994. return scene._environmentBRDFTexture;
  96995. };
  96996. 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=";
  96997. return TextureTools;
  96998. }());
  96999. /***/ }),
  97000. /***/ "./Misc/tga.ts":
  97001. /*!*********************!*\
  97002. !*** ./Misc/tga.ts ***!
  97003. \*********************/
  97004. /*! exports provided: TGATools */
  97005. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97006. "use strict";
  97007. __webpack_require__.r(__webpack_exports__);
  97008. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return TGATools; });
  97009. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  97010. /**
  97011. * Based on jsTGALoader - Javascript loader for TGA file
  97012. * By Vincent Thibault
  97013. * @see http://blog.robrowser.com/javascript-tga-loader.html
  97014. */
  97015. var TGATools = /** @class */ (function () {
  97016. function TGATools() {
  97017. }
  97018. /**
  97019. * Gets the header of a TGA file
  97020. * @param data defines the TGA data
  97021. * @returns the header
  97022. */
  97023. TGATools.GetTGAHeader = function (data) {
  97024. var offset = 0;
  97025. var header = {
  97026. id_length: data[offset++],
  97027. colormap_type: data[offset++],
  97028. image_type: data[offset++],
  97029. colormap_index: data[offset++] | data[offset++] << 8,
  97030. colormap_length: data[offset++] | data[offset++] << 8,
  97031. colormap_size: data[offset++],
  97032. origin: [
  97033. data[offset++] | data[offset++] << 8,
  97034. data[offset++] | data[offset++] << 8
  97035. ],
  97036. width: data[offset++] | data[offset++] << 8,
  97037. height: data[offset++] | data[offset++] << 8,
  97038. pixel_size: data[offset++],
  97039. flags: data[offset++]
  97040. };
  97041. return header;
  97042. };
  97043. /**
  97044. * Uploads TGA content to a Babylon Texture
  97045. * @hidden
  97046. */
  97047. TGATools.UploadContent = function (texture, data) {
  97048. // Not enough data to contain header ?
  97049. if (data.length < 19) {
  97050. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data to contain header");
  97051. return;
  97052. }
  97053. // Read Header
  97054. var offset = 18;
  97055. var header = TGATools.GetTGAHeader(data);
  97056. // Assume it's a valid Targa file.
  97057. if (header.id_length + offset > data.length) {
  97058. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data");
  97059. return;
  97060. }
  97061. // Skip not needed data
  97062. offset += header.id_length;
  97063. var use_rle = false;
  97064. var use_pal = false;
  97065. var use_grey = false;
  97066. // Get some informations.
  97067. switch (header.image_type) {
  97068. case TGATools._TYPE_RLE_INDEXED:
  97069. use_rle = true;
  97070. case TGATools._TYPE_INDEXED:
  97071. use_pal = true;
  97072. break;
  97073. case TGATools._TYPE_RLE_RGB:
  97074. use_rle = true;
  97075. case TGATools._TYPE_RGB:
  97076. // use_rgb = true;
  97077. break;
  97078. case TGATools._TYPE_RLE_GREY:
  97079. use_rle = true;
  97080. case TGATools._TYPE_GREY:
  97081. use_grey = true;
  97082. break;
  97083. }
  97084. var pixel_data;
  97085. // var numAlphaBits = header.flags & 0xf;
  97086. var pixel_size = header.pixel_size >> 3;
  97087. var pixel_total = header.width * header.height * pixel_size;
  97088. // Read palettes
  97089. var palettes;
  97090. if (use_pal) {
  97091. palettes = data.subarray(offset, offset += header.colormap_length * (header.colormap_size >> 3));
  97092. }
  97093. // Read LRE
  97094. if (use_rle) {
  97095. pixel_data = new Uint8Array(pixel_total);
  97096. var c, count, i;
  97097. var localOffset = 0;
  97098. var pixels = new Uint8Array(pixel_size);
  97099. while (offset < pixel_total && localOffset < pixel_total) {
  97100. c = data[offset++];
  97101. count = (c & 0x7f) + 1;
  97102. // RLE pixels
  97103. if (c & 0x80) {
  97104. // Bind pixel tmp array
  97105. for (i = 0; i < pixel_size; ++i) {
  97106. pixels[i] = data[offset++];
  97107. }
  97108. // Copy pixel array
  97109. for (i = 0; i < count; ++i) {
  97110. pixel_data.set(pixels, localOffset + i * pixel_size);
  97111. }
  97112. localOffset += pixel_size * count;
  97113. }
  97114. // Raw pixels
  97115. else {
  97116. count *= pixel_size;
  97117. for (i = 0; i < count; ++i) {
  97118. pixel_data[localOffset + i] = data[offset++];
  97119. }
  97120. localOffset += count;
  97121. }
  97122. }
  97123. }
  97124. // RAW Pixels
  97125. else {
  97126. pixel_data = data.subarray(offset, offset += (use_pal ? header.width * header.height : pixel_total));
  97127. }
  97128. // Load to texture
  97129. var x_start, y_start, x_step, y_step, y_end, x_end;
  97130. switch ((header.flags & TGATools._ORIGIN_MASK) >> TGATools._ORIGIN_SHIFT) {
  97131. default:
  97132. case TGATools._ORIGIN_UL:
  97133. x_start = 0;
  97134. x_step = 1;
  97135. x_end = header.width;
  97136. y_start = 0;
  97137. y_step = 1;
  97138. y_end = header.height;
  97139. break;
  97140. case TGATools._ORIGIN_BL:
  97141. x_start = 0;
  97142. x_step = 1;
  97143. x_end = header.width;
  97144. y_start = header.height - 1;
  97145. y_step = -1;
  97146. y_end = -1;
  97147. break;
  97148. case TGATools._ORIGIN_UR:
  97149. x_start = header.width - 1;
  97150. x_step = -1;
  97151. x_end = -1;
  97152. y_start = 0;
  97153. y_step = 1;
  97154. y_end = header.height;
  97155. break;
  97156. case TGATools._ORIGIN_BR:
  97157. x_start = header.width - 1;
  97158. x_step = -1;
  97159. x_end = -1;
  97160. y_start = header.height - 1;
  97161. y_step = -1;
  97162. y_end = -1;
  97163. break;
  97164. }
  97165. // Load the specify method
  97166. var func = '_getImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
  97167. var imageData = TGATools[func](header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end);
  97168. var engine = texture.getEngine();
  97169. engine._uploadDataToTextureDirectly(texture, imageData);
  97170. };
  97171. /** @hidden */
  97172. TGATools._getImageData8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  97173. var image = pixel_data, colormap = palettes;
  97174. var width = header.width, height = header.height;
  97175. var color, i = 0, x, y;
  97176. var imageData = new Uint8Array(width * height * 4);
  97177. for (y = y_start; y !== y_end; y += y_step) {
  97178. for (x = x_start; x !== x_end; x += x_step, i++) {
  97179. color = image[i];
  97180. imageData[(x + width * y) * 4 + 3] = 255;
  97181. imageData[(x + width * y) * 4 + 2] = colormap[(color * 3) + 0];
  97182. imageData[(x + width * y) * 4 + 1] = colormap[(color * 3) + 1];
  97183. imageData[(x + width * y) * 4 + 0] = colormap[(color * 3) + 2];
  97184. }
  97185. }
  97186. return imageData;
  97187. };
  97188. /** @hidden */
  97189. TGATools._getImageData16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  97190. var image = pixel_data;
  97191. var width = header.width, height = header.height;
  97192. var color, i = 0, x, y;
  97193. var imageData = new Uint8Array(width * height * 4);
  97194. for (y = y_start; y !== y_end; y += y_step) {
  97195. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  97196. color = image[i + 0] + (image[i + 1] << 8); // Inversed ?
  97197. var r = (((color & 0x7C00) >> 10) * 255) / 0x1F | 0;
  97198. var g = (((color & 0x03E0) >> 5) * 255) / 0x1F | 0;
  97199. var b = ((color & 0x001F) * 255) / 0x1F | 0;
  97200. imageData[(x + width * y) * 4 + 0] = r;
  97201. imageData[(x + width * y) * 4 + 1] = g;
  97202. imageData[(x + width * y) * 4 + 2] = b;
  97203. imageData[(x + width * y) * 4 + 3] = (color & 0x8000) ? 0 : 255;
  97204. }
  97205. }
  97206. return imageData;
  97207. };
  97208. /** @hidden */
  97209. TGATools._getImageData24bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  97210. var image = pixel_data;
  97211. var width = header.width, height = header.height;
  97212. var i = 0, x, y;
  97213. var imageData = new Uint8Array(width * height * 4);
  97214. for (y = y_start; y !== y_end; y += y_step) {
  97215. for (x = x_start; x !== x_end; x += x_step, i += 3) {
  97216. imageData[(x + width * y) * 4 + 3] = 255;
  97217. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  97218. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  97219. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  97220. }
  97221. }
  97222. return imageData;
  97223. };
  97224. /** @hidden */
  97225. TGATools._getImageData32bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  97226. var image = pixel_data;
  97227. var width = header.width, height = header.height;
  97228. var i = 0, x, y;
  97229. var imageData = new Uint8Array(width * height * 4);
  97230. for (y = y_start; y !== y_end; y += y_step) {
  97231. for (x = x_start; x !== x_end; x += x_step, i += 4) {
  97232. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  97233. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  97234. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  97235. imageData[(x + width * y) * 4 + 3] = image[i + 3];
  97236. }
  97237. }
  97238. return imageData;
  97239. };
  97240. /** @hidden */
  97241. TGATools._getImageDataGrey8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  97242. var image = pixel_data;
  97243. var width = header.width, height = header.height;
  97244. var color, i = 0, x, y;
  97245. var imageData = new Uint8Array(width * height * 4);
  97246. for (y = y_start; y !== y_end; y += y_step) {
  97247. for (x = x_start; x !== x_end; x += x_step, i++) {
  97248. color = image[i];
  97249. imageData[(x + width * y) * 4 + 0] = color;
  97250. imageData[(x + width * y) * 4 + 1] = color;
  97251. imageData[(x + width * y) * 4 + 2] = color;
  97252. imageData[(x + width * y) * 4 + 3] = 255;
  97253. }
  97254. }
  97255. return imageData;
  97256. };
  97257. /** @hidden */
  97258. TGATools._getImageDataGrey16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  97259. var image = pixel_data;
  97260. var width = header.width, height = header.height;
  97261. var i = 0, x, y;
  97262. var imageData = new Uint8Array(width * height * 4);
  97263. for (y = y_start; y !== y_end; y += y_step) {
  97264. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  97265. imageData[(x + width * y) * 4 + 0] = image[i + 0];
  97266. imageData[(x + width * y) * 4 + 1] = image[i + 0];
  97267. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  97268. imageData[(x + width * y) * 4 + 3] = image[i + 1];
  97269. }
  97270. }
  97271. return imageData;
  97272. };
  97273. //private static _TYPE_NO_DATA = 0;
  97274. TGATools._TYPE_INDEXED = 1;
  97275. TGATools._TYPE_RGB = 2;
  97276. TGATools._TYPE_GREY = 3;
  97277. TGATools._TYPE_RLE_INDEXED = 9;
  97278. TGATools._TYPE_RLE_RGB = 10;
  97279. TGATools._TYPE_RLE_GREY = 11;
  97280. TGATools._ORIGIN_MASK = 0x30;
  97281. TGATools._ORIGIN_SHIFT = 0x04;
  97282. TGATools._ORIGIN_BL = 0x00;
  97283. TGATools._ORIGIN_BR = 0x01;
  97284. TGATools._ORIGIN_UL = 0x02;
  97285. TGATools._ORIGIN_UR = 0x03;
  97286. return TGATools;
  97287. }());
  97288. /***/ }),
  97289. /***/ "./Misc/tools.ts":
  97290. /*!***********************!*\
  97291. !*** ./Misc/tools.ts ***!
  97292. \***********************/
  97293. /*! exports provided: ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop */
  97294. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97295. "use strict";
  97296. __webpack_require__.r(__webpack_exports__);
  97297. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return ColorGradient; });
  97298. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return Color3Gradient; });
  97299. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return FactorGradient; });
  97300. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return LoadFileError; });
  97301. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return RetryStrategy; });
  97302. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return Tools; });
  97303. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return PerfCounter; });
  97304. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "className", function() { return className; });
  97305. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return AsyncLoop; });
  97306. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  97307. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  97308. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  97309. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  97310. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  97311. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  97312. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  97313. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  97314. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  97315. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  97316. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  97317. /** Class used to store color4 gradient */
  97318. var ColorGradient = /** @class */ (function () {
  97319. function ColorGradient() {
  97320. }
  97321. /**
  97322. * Will get a color picked randomly between color1 and color2.
  97323. * If color2 is undefined then color1 will be used
  97324. * @param result defines the target Color4 to store the result in
  97325. */
  97326. ColorGradient.prototype.getColorToRef = function (result) {
  97327. if (!this.color2) {
  97328. result.copyFrom(this.color1);
  97329. return;
  97330. }
  97331. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].LerpToRef(this.color1, this.color2, Math.random(), result);
  97332. };
  97333. return ColorGradient;
  97334. }());
  97335. /** Class used to store color 3 gradient */
  97336. var Color3Gradient = /** @class */ (function () {
  97337. function Color3Gradient() {
  97338. }
  97339. return Color3Gradient;
  97340. }());
  97341. /** Class used to store factor gradient */
  97342. var FactorGradient = /** @class */ (function () {
  97343. function FactorGradient() {
  97344. }
  97345. /**
  97346. * Will get a number picked randomly between factor1 and factor2.
  97347. * If factor2 is undefined then factor1 will be used
  97348. * @returns the picked number
  97349. */
  97350. FactorGradient.prototype.getFactor = function () {
  97351. if (this.factor2 === undefined) {
  97352. return this.factor1;
  97353. }
  97354. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Lerp(this.factor1, this.factor2, Math.random());
  97355. };
  97356. return FactorGradient;
  97357. }());
  97358. /**
  97359. * @ignore
  97360. * Application error to support additional information when loading a file
  97361. */
  97362. var LoadFileError = /** @class */ (function (_super) {
  97363. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LoadFileError, _super);
  97364. /**
  97365. * Creates a new LoadFileError
  97366. * @param message defines the message of the error
  97367. * @param request defines the optional XHR request
  97368. */
  97369. function LoadFileError(message,
  97370. /** defines the optional XHR request */
  97371. request) {
  97372. var _this = _super.call(this, message) || this;
  97373. _this.request = request;
  97374. _this.name = "LoadFileError";
  97375. LoadFileError._setPrototypeOf(_this, LoadFileError.prototype);
  97376. return _this;
  97377. }
  97378. // See https://stackoverflow.com/questions/12915412/how-do-i-extend-a-host-object-e-g-error-in-typescript
  97379. // and https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  97380. // Polyfill for Object.setPrototypeOf if necessary.
  97381. LoadFileError._setPrototypeOf = Object.setPrototypeOf || (function (o, proto) { o.__proto__ = proto; return o; });
  97382. return LoadFileError;
  97383. }(Error));
  97384. /**
  97385. * Class used to define a retry strategy when error happens while loading assets
  97386. */
  97387. var RetryStrategy = /** @class */ (function () {
  97388. function RetryStrategy() {
  97389. }
  97390. /**
  97391. * Function used to defines an exponential back off strategy
  97392. * @param maxRetries defines the maximum number of retries (3 by default)
  97393. * @param baseInterval defines the interval between retries
  97394. * @returns the strategy function to use
  97395. */
  97396. RetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) {
  97397. if (maxRetries === void 0) { maxRetries = 3; }
  97398. if (baseInterval === void 0) { baseInterval = 500; }
  97399. return function (url, request, retryIndex) {
  97400. if (request.status !== 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) {
  97401. return -1;
  97402. }
  97403. return Math.pow(2, retryIndex) * baseInterval;
  97404. };
  97405. };
  97406. return RetryStrategy;
  97407. }());
  97408. // Screenshots
  97409. var screenshotCanvas;
  97410. /**
  97411. * Class containing a set of static utilities functions
  97412. */
  97413. var Tools = /** @class */ (function () {
  97414. function Tools() {
  97415. }
  97416. /**
  97417. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  97418. * @param u defines the coordinate on X axis
  97419. * @param v defines the coordinate on Y axis
  97420. * @param width defines the width of the source data
  97421. * @param height defines the height of the source data
  97422. * @param pixels defines the source byte array
  97423. * @param color defines the output color
  97424. */
  97425. Tools.FetchToRef = function (u, v, width, height, pixels, color) {
  97426. var wrappedU = ((Math.abs(u) * width) % width) | 0;
  97427. var wrappedV = ((Math.abs(v) * height) % height) | 0;
  97428. var position = (wrappedU + wrappedV * width) * 4;
  97429. color.r = pixels[position] / 255;
  97430. color.g = pixels[position + 1] / 255;
  97431. color.b = pixels[position + 2] / 255;
  97432. color.a = pixels[position + 3] / 255;
  97433. };
  97434. /**
  97435. * Interpolates between a and b via alpha
  97436. * @param a The lower value (returned when alpha = 0)
  97437. * @param b The upper value (returned when alpha = 1)
  97438. * @param alpha The interpolation-factor
  97439. * @return The mixed value
  97440. */
  97441. Tools.Mix = function (a, b, alpha) {
  97442. return a * (1 - alpha) + b * alpha;
  97443. };
  97444. /**
  97445. * Tries to instantiate a new object from a given class name
  97446. * @param className defines the class name to instantiate
  97447. * @returns the new object or null if the system was not able to do the instantiation
  97448. */
  97449. Tools.Instantiate = function (className) {
  97450. if (Tools.RegisteredExternalClasses && Tools.RegisteredExternalClasses[className]) {
  97451. return Tools.RegisteredExternalClasses[className];
  97452. }
  97453. var internalClass = _typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass(className);
  97454. if (internalClass) {
  97455. return internalClass;
  97456. }
  97457. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(className + " not found, you may have missed an import.");
  97458. var arr = className.split(".");
  97459. var fn = (window || this);
  97460. for (var i = 0, len = arr.length; i < len; i++) {
  97461. fn = fn[arr[i]];
  97462. }
  97463. if (typeof fn !== "function") {
  97464. return null;
  97465. }
  97466. return fn;
  97467. };
  97468. /**
  97469. * Provides a slice function that will work even on IE
  97470. * @param data defines the array to slice
  97471. * @param start defines the start of the data (optional)
  97472. * @param end defines the end of the data (optional)
  97473. * @returns the new sliced array
  97474. */
  97475. Tools.Slice = function (data, start, end) {
  97476. if (data.slice) {
  97477. return data.slice(start, end);
  97478. }
  97479. return Array.prototype.slice.call(data, start, end);
  97480. };
  97481. /**
  97482. * Polyfill for setImmediate
  97483. * @param action defines the action to execute after the current execution block
  97484. */
  97485. Tools.SetImmediate = function (action) {
  97486. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && window.setImmediate) {
  97487. window.setImmediate(action);
  97488. }
  97489. else {
  97490. setTimeout(action, 1);
  97491. }
  97492. };
  97493. /**
  97494. * Function indicating if a number is an exponent of 2
  97495. * @param value defines the value to test
  97496. * @returns true if the value is an exponent of 2
  97497. */
  97498. Tools.IsExponentOfTwo = function (value) {
  97499. var count = 1;
  97500. do {
  97501. count *= 2;
  97502. } while (count < value);
  97503. return count === value;
  97504. };
  97505. /**
  97506. * Returns the nearest 32-bit single precision float representation of a Number
  97507. * @param value A Number. If the parameter is of a different type, it will get converted
  97508. * to a number or to NaN if it cannot be converted
  97509. * @returns number
  97510. */
  97511. Tools.FloatRound = function (value) {
  97512. if (Math.fround) {
  97513. return Math.fround(value);
  97514. }
  97515. return (Tools._tmpFloatArray[0] = value);
  97516. };
  97517. /**
  97518. * Find the next highest power of two.
  97519. * @param x Number to start search from.
  97520. * @return Next highest power of two.
  97521. */
  97522. Tools.CeilingPOT = function (x) {
  97523. x--;
  97524. x |= x >> 1;
  97525. x |= x >> 2;
  97526. x |= x >> 4;
  97527. x |= x >> 8;
  97528. x |= x >> 16;
  97529. x++;
  97530. return x;
  97531. };
  97532. /**
  97533. * Find the next lowest power of two.
  97534. * @param x Number to start search from.
  97535. * @return Next lowest power of two.
  97536. */
  97537. Tools.FloorPOT = function (x) {
  97538. x = x | (x >> 1);
  97539. x = x | (x >> 2);
  97540. x = x | (x >> 4);
  97541. x = x | (x >> 8);
  97542. x = x | (x >> 16);
  97543. return x - (x >> 1);
  97544. };
  97545. /**
  97546. * Find the nearest power of two.
  97547. * @param x Number to start search from.
  97548. * @return Next nearest power of two.
  97549. */
  97550. Tools.NearestPOT = function (x) {
  97551. var c = Tools.CeilingPOT(x);
  97552. var f = Tools.FloorPOT(x);
  97553. return (c - x) > (x - f) ? f : c;
  97554. };
  97555. /**
  97556. * Get the closest exponent of two
  97557. * @param value defines the value to approximate
  97558. * @param max defines the maximum value to return
  97559. * @param mode defines how to define the closest value
  97560. * @returns closest exponent of two of the given value
  97561. */
  97562. Tools.GetExponentOfTwo = function (value, max, mode) {
  97563. if (mode === void 0) { mode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST; }
  97564. var pot;
  97565. switch (mode) {
  97566. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_FLOOR:
  97567. pot = Tools.FloorPOT(value);
  97568. break;
  97569. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST:
  97570. pot = Tools.NearestPOT(value);
  97571. break;
  97572. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_CEILING:
  97573. default:
  97574. pot = Tools.CeilingPOT(value);
  97575. break;
  97576. }
  97577. return Math.min(pot, max);
  97578. };
  97579. /**
  97580. * Extracts the filename from a path
  97581. * @param path defines the path to use
  97582. * @returns the filename
  97583. */
  97584. Tools.GetFilename = function (path) {
  97585. var index = path.lastIndexOf("/");
  97586. if (index < 0) {
  97587. return path;
  97588. }
  97589. return path.substring(index + 1);
  97590. };
  97591. /**
  97592. * Extracts the "folder" part of a path (everything before the filename).
  97593. * @param uri The URI to extract the info from
  97594. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  97595. * @returns The "folder" part of the path
  97596. */
  97597. Tools.GetFolderPath = function (uri, returnUnchangedIfNoSlash) {
  97598. if (returnUnchangedIfNoSlash === void 0) { returnUnchangedIfNoSlash = false; }
  97599. var index = uri.lastIndexOf("/");
  97600. if (index < 0) {
  97601. if (returnUnchangedIfNoSlash) {
  97602. return uri;
  97603. }
  97604. return "";
  97605. }
  97606. return uri.substring(0, index + 1);
  97607. };
  97608. /**
  97609. * Convert an angle in radians to degrees
  97610. * @param angle defines the angle to convert
  97611. * @returns the angle in degrees
  97612. */
  97613. Tools.ToDegrees = function (angle) {
  97614. return angle * 180 / Math.PI;
  97615. };
  97616. /**
  97617. * Convert an angle in degrees to radians
  97618. * @param angle defines the angle to convert
  97619. * @returns the angle in radians
  97620. */
  97621. Tools.ToRadians = function (angle) {
  97622. return angle * Math.PI / 180;
  97623. };
  97624. /**
  97625. * Encode a buffer to a base64 string
  97626. * @param buffer defines the buffer to encode
  97627. * @returns the encoded string
  97628. */
  97629. Tools.EncodeArrayBufferTobase64 = function (buffer) {
  97630. var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  97631. var output = "";
  97632. var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
  97633. var i = 0;
  97634. var bytes = new Uint8Array(buffer);
  97635. while (i < bytes.length) {
  97636. chr1 = bytes[i++];
  97637. chr2 = i < bytes.length ? bytes[i++] : Number.NaN; // Not sure if the index
  97638. chr3 = i < bytes.length ? bytes[i++] : Number.NaN; // checks are needed here
  97639. enc1 = chr1 >> 2;
  97640. enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  97641. enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  97642. enc4 = chr3 & 63;
  97643. if (isNaN(chr2)) {
  97644. enc3 = enc4 = 64;
  97645. }
  97646. else if (isNaN(chr3)) {
  97647. enc4 = 64;
  97648. }
  97649. output += keyStr.charAt(enc1) + keyStr.charAt(enc2) +
  97650. keyStr.charAt(enc3) + keyStr.charAt(enc4);
  97651. }
  97652. return "data:image/png;base64," + output;
  97653. };
  97654. /**
  97655. * Extracts minimum and maximum values from a list of indexed positions
  97656. * @param positions defines the positions to use
  97657. * @param indices defines the indices to the positions
  97658. * @param indexStart defines the start index
  97659. * @param indexCount defines the end index
  97660. * @param bias defines bias value to add to the result
  97661. * @return minimum and maximum values
  97662. */
  97663. Tools.ExtractMinAndMaxIndexed = function (positions, indices, indexStart, indexCount, bias) {
  97664. if (bias === void 0) { bias = null; }
  97665. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  97666. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  97667. for (var index = indexStart; index < indexStart + indexCount; index++) {
  97668. var offset = indices[index] * 3;
  97669. var x = positions[offset];
  97670. var y = positions[offset + 1];
  97671. var z = positions[offset + 2];
  97672. minimum.minimizeInPlaceFromFloats(x, y, z);
  97673. maximum.maximizeInPlaceFromFloats(x, y, z);
  97674. }
  97675. if (bias) {
  97676. minimum.x -= minimum.x * bias.x + bias.y;
  97677. minimum.y -= minimum.y * bias.x + bias.y;
  97678. minimum.z -= minimum.z * bias.x + bias.y;
  97679. maximum.x += maximum.x * bias.x + bias.y;
  97680. maximum.y += maximum.y * bias.x + bias.y;
  97681. maximum.z += maximum.z * bias.x + bias.y;
  97682. }
  97683. return {
  97684. minimum: minimum,
  97685. maximum: maximum
  97686. };
  97687. };
  97688. /**
  97689. * Extracts minimum and maximum values from a list of positions
  97690. * @param positions defines the positions to use
  97691. * @param start defines the start index in the positions array
  97692. * @param count defines the number of positions to handle
  97693. * @param bias defines bias value to add to the result
  97694. * @param stride defines the stride size to use (distance between two positions in the positions array)
  97695. * @return minimum and maximum values
  97696. */
  97697. Tools.ExtractMinAndMax = function (positions, start, count, bias, stride) {
  97698. if (bias === void 0) { bias = null; }
  97699. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  97700. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  97701. if (!stride) {
  97702. stride = 3;
  97703. }
  97704. for (var index = start, offset = start * stride; index < start + count; index++, offset += stride) {
  97705. var x = positions[offset];
  97706. var y = positions[offset + 1];
  97707. var z = positions[offset + 2];
  97708. minimum.minimizeInPlaceFromFloats(x, y, z);
  97709. maximum.maximizeInPlaceFromFloats(x, y, z);
  97710. }
  97711. if (bias) {
  97712. minimum.x -= minimum.x * bias.x + bias.y;
  97713. minimum.y -= minimum.y * bias.x + bias.y;
  97714. minimum.z -= minimum.z * bias.x + bias.y;
  97715. maximum.x += maximum.x * bias.x + bias.y;
  97716. maximum.y += maximum.y * bias.x + bias.y;
  97717. maximum.z += maximum.z * bias.x + bias.y;
  97718. }
  97719. return {
  97720. minimum: minimum,
  97721. maximum: maximum
  97722. };
  97723. };
  97724. /**
  97725. * Returns an array if obj is not an array
  97726. * @param obj defines the object to evaluate as an array
  97727. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  97728. * @returns either obj directly if obj is an array or a new array containing obj
  97729. */
  97730. Tools.MakeArray = function (obj, allowsNullUndefined) {
  97731. if (allowsNullUndefined !== true && (obj === undefined || obj == null)) {
  97732. return null;
  97733. }
  97734. return Array.isArray(obj) ? obj : [obj];
  97735. };
  97736. /**
  97737. * Gets the pointer prefix to use
  97738. * @returns "pointer" if touch is enabled. Else returns "mouse"
  97739. */
  97740. Tools.GetPointerPrefix = function () {
  97741. var eventPrefix = "pointer";
  97742. // Check if pointer events are supported
  97743. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && !window.PointerEvent && !navigator.pointerEnabled) {
  97744. eventPrefix = "mouse";
  97745. }
  97746. return eventPrefix;
  97747. };
  97748. /**
  97749. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97750. * @param func - the function to be called
  97751. * @param requester - the object that will request the next frame. Falls back to window.
  97752. * @returns frame number
  97753. */
  97754. Tools.QueueNewFrame = function (func, requester) {
  97755. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  97756. return setTimeout(func, 16);
  97757. }
  97758. if (!requester) {
  97759. requester = window;
  97760. }
  97761. if (requester.requestAnimationFrame) {
  97762. return requester.requestAnimationFrame(func);
  97763. }
  97764. else if (requester.msRequestAnimationFrame) {
  97765. return requester.msRequestAnimationFrame(func);
  97766. }
  97767. else if (requester.webkitRequestAnimationFrame) {
  97768. return requester.webkitRequestAnimationFrame(func);
  97769. }
  97770. else if (requester.mozRequestAnimationFrame) {
  97771. return requester.mozRequestAnimationFrame(func);
  97772. }
  97773. else if (requester.oRequestAnimationFrame) {
  97774. return requester.oRequestAnimationFrame(func);
  97775. }
  97776. else {
  97777. return window.setTimeout(func, 16);
  97778. }
  97779. };
  97780. /**
  97781. * Ask the browser to promote the current element to fullscreen rendering mode
  97782. * @param element defines the DOM element to promote
  97783. */
  97784. Tools.RequestFullscreen = function (element) {
  97785. var requestFunction = element.requestFullscreen || element.msRequestFullscreen || element.webkitRequestFullscreen || element.mozRequestFullScreen;
  97786. if (!requestFunction) {
  97787. return;
  97788. }
  97789. requestFunction.call(element);
  97790. };
  97791. /**
  97792. * Asks the browser to exit fullscreen mode
  97793. */
  97794. Tools.ExitFullscreen = function () {
  97795. if (document.exitFullscreen) {
  97796. document.exitFullscreen();
  97797. }
  97798. else if (document.mozCancelFullScreen) {
  97799. document.mozCancelFullScreen();
  97800. }
  97801. else if (document.webkitCancelFullScreen) {
  97802. document.webkitCancelFullScreen();
  97803. }
  97804. else if (document.msCancelFullScreen) {
  97805. document.msCancelFullScreen();
  97806. }
  97807. };
  97808. /**
  97809. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  97810. * @param url define the url we are trying
  97811. * @param element define the dom element where to configure the cors policy
  97812. */
  97813. Tools.SetCorsBehavior = function (url, element) {
  97814. if (url && url.indexOf("data:") === 0) {
  97815. return;
  97816. }
  97817. if (Tools.CorsBehavior) {
  97818. if (typeof (Tools.CorsBehavior) === 'string' || Tools.CorsBehavior instanceof String) {
  97819. element.crossOrigin = Tools.CorsBehavior;
  97820. }
  97821. else {
  97822. var result = Tools.CorsBehavior(url);
  97823. if (result) {
  97824. element.crossOrigin = result;
  97825. }
  97826. }
  97827. }
  97828. };
  97829. // External files
  97830. /**
  97831. * Removes unwanted characters from an url
  97832. * @param url defines the url to clean
  97833. * @returns the cleaned url
  97834. */
  97835. Tools.CleanUrl = function (url) {
  97836. url = url.replace(/#/mg, "%23");
  97837. return url;
  97838. };
  97839. /**
  97840. * Loads an image as an HTMLImageElement.
  97841. * @param input url string, ArrayBuffer, or Blob to load
  97842. * @param onLoad callback called when the image successfully loads
  97843. * @param onError callback called when the image fails to load
  97844. * @param offlineProvider offline provider for caching
  97845. * @returns the HTMLImageElement of the loaded image
  97846. */
  97847. Tools.LoadImage = function (input, onLoad, onError, offlineProvider) {
  97848. var url;
  97849. var usingObjectURL = false;
  97850. if (input instanceof ArrayBuffer) {
  97851. url = URL.createObjectURL(new Blob([input]));
  97852. usingObjectURL = true;
  97853. }
  97854. else if (input instanceof Blob) {
  97855. url = URL.createObjectURL(input);
  97856. usingObjectURL = true;
  97857. }
  97858. else {
  97859. url = Tools.CleanUrl(input);
  97860. url = Tools.PreprocessUrl(input);
  97861. }
  97862. var img = new Image();
  97863. Tools.SetCorsBehavior(url, img);
  97864. var loadHandler = function () {
  97865. if (usingObjectURL && img.src) {
  97866. URL.revokeObjectURL(img.src);
  97867. }
  97868. img.removeEventListener("load", loadHandler);
  97869. img.removeEventListener("error", errorHandler);
  97870. onLoad(img);
  97871. };
  97872. var errorHandler = function (err) {
  97873. if (usingObjectURL && img.src) {
  97874. URL.revokeObjectURL(img.src);
  97875. }
  97876. img.removeEventListener("load", loadHandler);
  97877. img.removeEventListener("error", errorHandler);
  97878. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error while trying to load image: " + input);
  97879. if (onError) {
  97880. onError("Error while trying to load image: " + input, err);
  97881. }
  97882. };
  97883. img.addEventListener("load", loadHandler);
  97884. img.addEventListener("error", errorHandler);
  97885. var noOfflineSupport = function () {
  97886. img.src = url;
  97887. };
  97888. var loadFromOfflineSupport = function () {
  97889. if (offlineProvider) {
  97890. offlineProvider.loadImage(url, img);
  97891. }
  97892. };
  97893. if (url.substr(0, 5) !== "data:" && offlineProvider && offlineProvider.enableTexturesOffline) {
  97894. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport);
  97895. }
  97896. else {
  97897. if (url.indexOf("file:") !== -1) {
  97898. var textureName = decodeURIComponent(url.substring(5).toLowerCase());
  97899. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]) {
  97900. try {
  97901. var blobURL;
  97902. try {
  97903. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  97904. }
  97905. catch (ex) {
  97906. // Chrome doesn't support oneTimeOnly parameter
  97907. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  97908. }
  97909. img.src = blobURL;
  97910. usingObjectURL = true;
  97911. }
  97912. catch (e) {
  97913. img.src = "";
  97914. }
  97915. return img;
  97916. }
  97917. }
  97918. noOfflineSupport();
  97919. }
  97920. return img;
  97921. };
  97922. /**
  97923. * Loads a file
  97924. * @param url url string, ArrayBuffer, or Blob to load
  97925. * @param onSuccess callback called when the file successfully loads
  97926. * @param onProgress callback called while file is loading (if the server supports this mode)
  97927. * @param offlineProvider defines the offline provider for caching
  97928. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  97929. * @param onError callback called when the file fails to load
  97930. * @returns a file request object
  97931. */
  97932. Tools.LoadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  97933. url = Tools.CleanUrl(url);
  97934. url = Tools.PreprocessUrl(url);
  97935. // If file and file input are set
  97936. if (url.indexOf("file:") !== -1) {
  97937. var fileName = decodeURIComponent(url.substring(5).toLowerCase());
  97938. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName]) {
  97939. return Tools.ReadFile(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName], onSuccess, onProgress, useArrayBuffer);
  97940. }
  97941. }
  97942. var loadUrl = Tools.BaseUrl + url;
  97943. var aborted = false;
  97944. var fileRequest = {
  97945. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  97946. abort: function () { return aborted = true; },
  97947. };
  97948. var requestFile = function () {
  97949. var request = new XMLHttpRequest();
  97950. var retryHandle = null;
  97951. fileRequest.abort = function () {
  97952. aborted = true;
  97953. if (request.readyState !== (XMLHttpRequest.DONE || 4)) {
  97954. request.abort();
  97955. }
  97956. if (retryHandle !== null) {
  97957. clearTimeout(retryHandle);
  97958. retryHandle = null;
  97959. }
  97960. };
  97961. var retryLoop = function (retryIndex) {
  97962. request.open('GET', loadUrl, true);
  97963. if (useArrayBuffer) {
  97964. request.responseType = "arraybuffer";
  97965. }
  97966. if (onProgress) {
  97967. request.addEventListener("progress", onProgress);
  97968. }
  97969. var onLoadEnd = function () {
  97970. request.removeEventListener("loadend", onLoadEnd);
  97971. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  97972. fileRequest.onCompleteObservable.clear();
  97973. };
  97974. request.addEventListener("loadend", onLoadEnd);
  97975. var onReadyStateChange = function () {
  97976. if (aborted) {
  97977. return;
  97978. }
  97979. // In case of undefined state in some browsers.
  97980. if (request.readyState === (XMLHttpRequest.DONE || 4)) {
  97981. // Some browsers have issues where onreadystatechange can be called multiple times with the same value.
  97982. request.removeEventListener("readystatechange", onReadyStateChange);
  97983. if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() || Tools.IsFileURL()))) {
  97984. onSuccess(!useArrayBuffer ? request.responseText : request.response, request.responseURL);
  97985. return;
  97986. }
  97987. var retryStrategy = Tools.DefaultRetryStrategy;
  97988. if (retryStrategy) {
  97989. var waitTime = retryStrategy(loadUrl, request, retryIndex);
  97990. if (waitTime !== -1) {
  97991. // Prevent the request from completing for retry.
  97992. request.removeEventListener("loadend", onLoadEnd);
  97993. request = new XMLHttpRequest();
  97994. retryHandle = setTimeout(function () { return retryLoop(retryIndex + 1); }, waitTime);
  97995. return;
  97996. }
  97997. }
  97998. var e = new LoadFileError("Error status: " + request.status + " " + request.statusText + " - Unable to load " + loadUrl, request);
  97999. if (onError) {
  98000. onError(request, e);
  98001. }
  98002. else {
  98003. throw e;
  98004. }
  98005. }
  98006. };
  98007. request.addEventListener("readystatechange", onReadyStateChange);
  98008. if (Tools.UseCustomRequestHeaders) {
  98009. Tools.InjectCustomRequestHeaders(request);
  98010. }
  98011. request.send();
  98012. };
  98013. retryLoop(0);
  98014. };
  98015. // Caching all files
  98016. if (offlineProvider && offlineProvider.enableSceneOffline) {
  98017. var noOfflineSupport_1 = function (request) {
  98018. if (request && request.status > 400) {
  98019. if (onError) {
  98020. onError(request);
  98021. }
  98022. }
  98023. else {
  98024. if (!aborted) {
  98025. requestFile();
  98026. }
  98027. }
  98028. };
  98029. var loadFromOfflineSupport = function () {
  98030. // TODO: database needs to support aborting and should return a IFileRequest
  98031. if (aborted) {
  98032. return;
  98033. }
  98034. if (offlineProvider) {
  98035. offlineProvider.loadFile(url, function (data) {
  98036. if (!aborted) {
  98037. onSuccess(data);
  98038. }
  98039. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  98040. }, onProgress ? function (event) {
  98041. if (!aborted) {
  98042. onProgress(event);
  98043. }
  98044. } : undefined, noOfflineSupport_1, useArrayBuffer);
  98045. }
  98046. };
  98047. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport_1);
  98048. }
  98049. else {
  98050. requestFile();
  98051. }
  98052. return fileRequest;
  98053. };
  98054. /**
  98055. * Load a script (identified by an url). When the url returns, the
  98056. * content of this file is added into a new script element, attached to the DOM (body element)
  98057. * @param scriptUrl defines the url of the script to laod
  98058. * @param onSuccess defines the callback called when the script is loaded
  98059. * @param onError defines the callback to call if an error occurs
  98060. */
  98061. Tools.LoadScript = function (scriptUrl, onSuccess, onError) {
  98062. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  98063. return;
  98064. }
  98065. var head = document.getElementsByTagName('head')[0];
  98066. var script = document.createElement('script');
  98067. script.type = 'text/javascript';
  98068. script.src = scriptUrl;
  98069. script.onload = function () {
  98070. if (onSuccess) {
  98071. onSuccess();
  98072. }
  98073. };
  98074. script.onerror = function (e) {
  98075. if (onError) {
  98076. onError("Unable to load script '" + scriptUrl + "'", e);
  98077. }
  98078. };
  98079. head.appendChild(script);
  98080. };
  98081. /**
  98082. * Loads a file from a blob
  98083. * @param fileToLoad defines the blob to use
  98084. * @param callback defines the callback to call when data is loaded
  98085. * @param progressCallback defines the callback to call during loading process
  98086. * @returns a file request object
  98087. */
  98088. Tools.ReadFileAsDataURL = function (fileToLoad, callback, progressCallback) {
  98089. var reader = new FileReader();
  98090. var request = {
  98091. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  98092. abort: function () { return reader.abort(); },
  98093. };
  98094. reader.onloadend = function (e) {
  98095. request.onCompleteObservable.notifyObservers(request);
  98096. };
  98097. reader.onload = function (e) {
  98098. //target doesn't have result from ts 1.3
  98099. callback(e.target['result']);
  98100. };
  98101. reader.onprogress = progressCallback;
  98102. reader.readAsDataURL(fileToLoad);
  98103. return request;
  98104. };
  98105. /**
  98106. * Loads a file
  98107. * @param fileToLoad defines the file to load
  98108. * @param callback defines the callback to call when data is loaded
  98109. * @param progressCallBack defines the callback to call during loading process
  98110. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  98111. * @returns a file request object
  98112. */
  98113. Tools.ReadFile = function (fileToLoad, callback, progressCallBack, useArrayBuffer) {
  98114. var reader = new FileReader();
  98115. var request = {
  98116. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  98117. abort: function () { return reader.abort(); },
  98118. };
  98119. reader.onloadend = function (e) { return request.onCompleteObservable.notifyObservers(request); };
  98120. reader.onerror = function (e) {
  98121. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log("Error while reading file: " + fileToLoad.name);
  98122. callback(JSON.stringify({ autoClear: true, clearColor: [1, 0, 0], ambientColor: [0, 0, 0], gravity: [0, -9.807, 0], meshes: [], cameras: [], lights: [] }));
  98123. };
  98124. reader.onload = function (e) {
  98125. //target doesn't have result from ts 1.3
  98126. callback(e.target['result']);
  98127. };
  98128. if (progressCallBack) {
  98129. reader.onprogress = progressCallBack;
  98130. }
  98131. if (!useArrayBuffer) {
  98132. // Asynchronous read
  98133. reader.readAsText(fileToLoad);
  98134. }
  98135. else {
  98136. reader.readAsArrayBuffer(fileToLoad);
  98137. }
  98138. return request;
  98139. };
  98140. /**
  98141. * Creates a data url from a given string content
  98142. * @param content defines the content to convert
  98143. * @returns the new data url link
  98144. */
  98145. Tools.FileAsURL = function (content) {
  98146. var fileBlob = new Blob([content]);
  98147. var url = window.URL || window.webkitURL;
  98148. var link = url.createObjectURL(fileBlob);
  98149. return link;
  98150. };
  98151. /**
  98152. * Format the given number to a specific decimal format
  98153. * @param value defines the number to format
  98154. * @param decimals defines the number of decimals to use
  98155. * @returns the formatted string
  98156. */
  98157. Tools.Format = function (value, decimals) {
  98158. if (decimals === void 0) { decimals = 2; }
  98159. return value.toFixed(decimals);
  98160. };
  98161. /**
  98162. * Checks if a given vector is inside a specific range
  98163. * @param v defines the vector to test
  98164. * @param min defines the minimum range
  98165. * @param max defines the maximum range
  98166. */
  98167. Tools.CheckExtends = function (v, min, max) {
  98168. min.minimizeInPlace(v);
  98169. max.maximizeInPlace(v);
  98170. };
  98171. /**
  98172. * Tries to copy an object by duplicating every property
  98173. * @param source defines the source object
  98174. * @param destination defines the target object
  98175. * @param doNotCopyList defines a list of properties to avoid
  98176. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98177. */
  98178. Tools.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  98179. _deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source, destination, doNotCopyList, mustCopyList);
  98180. };
  98181. /**
  98182. * Gets a boolean indicating if the given object has no own property
  98183. * @param obj defines the object to test
  98184. * @returns true if object has no own property
  98185. */
  98186. Tools.IsEmpty = function (obj) {
  98187. for (var i in obj) {
  98188. if (obj.hasOwnProperty(i)) {
  98189. return false;
  98190. }
  98191. }
  98192. return true;
  98193. };
  98194. /**
  98195. * Function used to register events at window level
  98196. * @param events defines the events to register
  98197. */
  98198. Tools.RegisterTopRootEvents = function (events) {
  98199. for (var index = 0; index < events.length; index++) {
  98200. var event = events[index];
  98201. window.addEventListener(event.name, event.handler, false);
  98202. try {
  98203. if (window.parent) {
  98204. window.parent.addEventListener(event.name, event.handler, false);
  98205. }
  98206. }
  98207. catch (e) {
  98208. // Silently fails...
  98209. }
  98210. }
  98211. };
  98212. /**
  98213. * Function used to unregister events from window level
  98214. * @param events defines the events to unregister
  98215. */
  98216. Tools.UnregisterTopRootEvents = function (events) {
  98217. for (var index = 0; index < events.length; index++) {
  98218. var event = events[index];
  98219. window.removeEventListener(event.name, event.handler);
  98220. try {
  98221. if (window.parent) {
  98222. window.parent.removeEventListener(event.name, event.handler);
  98223. }
  98224. }
  98225. catch (e) {
  98226. // Silently fails...
  98227. }
  98228. }
  98229. };
  98230. /**
  98231. * Dumps the current bound framebuffer
  98232. * @param width defines the rendering width
  98233. * @param height defines the rendering height
  98234. * @param engine defines the hosting engine
  98235. * @param successCallback defines the callback triggered once the data are available
  98236. * @param mimeType defines the mime type of the result
  98237. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  98238. */
  98239. Tools.DumpFramebuffer = function (width, height, engine, successCallback, mimeType, fileName) {
  98240. if (mimeType === void 0) { mimeType = "image/png"; }
  98241. // Read the contents of the framebuffer
  98242. var numberOfChannelsByLine = width * 4;
  98243. var halfHeight = height / 2;
  98244. //Reading datas from WebGL
  98245. var data = engine.readPixels(0, 0, width, height);
  98246. //To flip image on Y axis.
  98247. for (var i = 0; i < halfHeight; i++) {
  98248. for (var j = 0; j < numberOfChannelsByLine; j++) {
  98249. var currentCell = j + i * numberOfChannelsByLine;
  98250. var targetLine = height - i - 1;
  98251. var targetCell = j + targetLine * numberOfChannelsByLine;
  98252. var temp = data[currentCell];
  98253. data[currentCell] = data[targetCell];
  98254. data[targetCell] = temp;
  98255. }
  98256. }
  98257. // Create a 2D canvas to store the result
  98258. if (!screenshotCanvas) {
  98259. screenshotCanvas = document.createElement('canvas');
  98260. }
  98261. screenshotCanvas.width = width;
  98262. screenshotCanvas.height = height;
  98263. var context = screenshotCanvas.getContext('2d');
  98264. if (context) {
  98265. // Copy the pixels to a 2D canvas
  98266. var imageData = context.createImageData(width, height);
  98267. var castData = (imageData.data);
  98268. castData.set(data);
  98269. context.putImageData(imageData, 0, 0);
  98270. Tools.EncodeScreenshotCanvasData(successCallback, mimeType, fileName);
  98271. }
  98272. };
  98273. /**
  98274. * Converts the canvas data to blob.
  98275. * This acts as a polyfill for browsers not supporting the to blob function.
  98276. * @param canvas Defines the canvas to extract the data from
  98277. * @param successCallback Defines the callback triggered once the data are available
  98278. * @param mimeType Defines the mime type of the result
  98279. */
  98280. Tools.ToBlob = function (canvas, successCallback, mimeType) {
  98281. if (mimeType === void 0) { mimeType = "image/png"; }
  98282. // We need HTMLCanvasElement.toBlob for HD screenshots
  98283. if (!canvas.toBlob) {
  98284. // low performance polyfill based on toDataURL (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)
  98285. canvas.toBlob = function (callback, type, quality) {
  98286. var _this = this;
  98287. setTimeout(function () {
  98288. var binStr = atob(_this.toDataURL(type, quality).split(',')[1]), len = binStr.length, arr = new Uint8Array(len);
  98289. for (var i = 0; i < len; i++) {
  98290. arr[i] = binStr.charCodeAt(i);
  98291. }
  98292. callback(new Blob([arr]));
  98293. });
  98294. };
  98295. }
  98296. canvas.toBlob(function (blob) {
  98297. successCallback(blob);
  98298. }, mimeType);
  98299. };
  98300. /**
  98301. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  98302. * @param successCallback defines the callback triggered once the data are available
  98303. * @param mimeType defines the mime type of the result
  98304. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  98305. */
  98306. Tools.EncodeScreenshotCanvasData = function (successCallback, mimeType, fileName) {
  98307. if (mimeType === void 0) { mimeType = "image/png"; }
  98308. if (successCallback) {
  98309. var base64Image = screenshotCanvas.toDataURL(mimeType);
  98310. successCallback(base64Image);
  98311. }
  98312. else {
  98313. this.ToBlob(screenshotCanvas, function (blob) {
  98314. //Creating a link if the browser have the download attribute on the a tag, to automatically start download generated image.
  98315. if (("download" in document.createElement("a"))) {
  98316. if (!fileName) {
  98317. var date = new Date();
  98318. var stringDate = (date.getFullYear() + "-" + (date.getMonth() + 1)).slice(2) + "-" + date.getDate() + "_" + date.getHours() + "-" + ('0' + date.getMinutes()).slice(-2);
  98319. fileName = "screenshot_" + stringDate + ".png";
  98320. }
  98321. Tools.Download(blob, fileName);
  98322. }
  98323. else {
  98324. var url = URL.createObjectURL(blob);
  98325. var newWindow = window.open("");
  98326. if (!newWindow) {
  98327. return;
  98328. }
  98329. var img = newWindow.document.createElement("img");
  98330. img.onload = function () {
  98331. // no longer need to read the blob so it's revoked
  98332. URL.revokeObjectURL(url);
  98333. };
  98334. img.src = url;
  98335. newWindow.document.body.appendChild(img);
  98336. }
  98337. }, mimeType);
  98338. }
  98339. };
  98340. /**
  98341. * Downloads a blob in the browser
  98342. * @param blob defines the blob to download
  98343. * @param fileName defines the name of the downloaded file
  98344. */
  98345. Tools.Download = function (blob, fileName) {
  98346. if (navigator && navigator.msSaveBlob) {
  98347. navigator.msSaveBlob(blob, fileName);
  98348. return;
  98349. }
  98350. var url = window.URL.createObjectURL(blob);
  98351. var a = document.createElement("a");
  98352. document.body.appendChild(a);
  98353. a.style.display = "none";
  98354. a.href = url;
  98355. a.download = fileName;
  98356. a.addEventListener("click", function () {
  98357. if (a.parentElement) {
  98358. a.parentElement.removeChild(a);
  98359. }
  98360. });
  98361. a.click();
  98362. window.URL.revokeObjectURL(url);
  98363. };
  98364. /**
  98365. * Captures a screenshot of the current rendering
  98366. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98367. * @param engine defines the rendering engine
  98368. * @param camera defines the source camera
  98369. * @param size This parameter can be set to a single number or to an object with the
  98370. * following (optional) properties: precision, width, height. If a single number is passed,
  98371. * it will be used for both width and height. If an object is passed, the screenshot size
  98372. * will be derived from the parameters. The precision property is a multiplier allowing
  98373. * rendering at a higher or lower resolution
  98374. * @param successCallback defines the callback receives a single parameter which contains the
  98375. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98376. * src parameter of an <img> to display it
  98377. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98378. * Check your browser for supported MIME types
  98379. */
  98380. Tools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  98381. if (mimeType === void 0) { mimeType = "image/png"; }
  98382. throw "Import ScreenshotTools before creating screenshot.";
  98383. };
  98384. /**
  98385. * Generates an image screenshot from the specified camera.
  98386. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98387. * @param engine The engine to use for rendering
  98388. * @param camera The camera to use for rendering
  98389. * @param size This parameter can be set to a single number or to an object with the
  98390. * following (optional) properties: precision, width, height. If a single number is passed,
  98391. * it will be used for both width and height. If an object is passed, the screenshot size
  98392. * will be derived from the parameters. The precision property is a multiplier allowing
  98393. * rendering at a higher or lower resolution
  98394. * @param successCallback The callback receives a single parameter which contains the
  98395. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98396. * src parameter of an <img> to display it
  98397. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98398. * Check your browser for supported MIME types
  98399. * @param samples Texture samples (default: 1)
  98400. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98401. * @param fileName A name for for the downloaded file.
  98402. */
  98403. Tools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  98404. if (mimeType === void 0) { mimeType = "image/png"; }
  98405. if (samples === void 0) { samples = 1; }
  98406. if (antialiasing === void 0) { antialiasing = false; }
  98407. throw "Import ScreenshotTools before creating screenshot.";
  98408. };
  98409. /**
  98410. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98411. * Be aware Math.random() could cause collisions, but:
  98412. * "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"
  98413. * @returns a pseudo random id
  98414. */
  98415. Tools.RandomId = function () {
  98416. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  98417. var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
  98418. return v.toString(16);
  98419. });
  98420. };
  98421. /**
  98422. * Test if the given uri is a base64 string
  98423. * @param uri The uri to test
  98424. * @return True if the uri is a base64 string or false otherwise
  98425. */
  98426. Tools.IsBase64 = function (uri) {
  98427. return uri.length < 5 ? false : uri.substr(0, 5) === "data:";
  98428. };
  98429. /**
  98430. * Decode the given base64 uri.
  98431. * @param uri The uri to decode
  98432. * @return The decoded base64 data.
  98433. */
  98434. Tools.DecodeBase64 = function (uri) {
  98435. var decodedString = atob(uri.split(",")[1]);
  98436. var bufferLength = decodedString.length;
  98437. var bufferView = new Uint8Array(new ArrayBuffer(bufferLength));
  98438. for (var i = 0; i < bufferLength; i++) {
  98439. bufferView[i] = decodedString.charCodeAt(i);
  98440. }
  98441. return bufferView.buffer;
  98442. };
  98443. Object.defineProperty(Tools, "errorsCount", {
  98444. /**
  98445. * Gets a value indicating the number of loading errors
  98446. * @ignorenaming
  98447. */
  98448. get: function () {
  98449. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].errorsCount;
  98450. },
  98451. enumerable: true,
  98452. configurable: true
  98453. });
  98454. /**
  98455. * Log a message to the console
  98456. * @param message defines the message to log
  98457. */
  98458. Tools.Log = function (message) {
  98459. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log(message);
  98460. };
  98461. /**
  98462. * Write a warning message to the console
  98463. * @param message defines the message to log
  98464. */
  98465. Tools.Warn = function (message) {
  98466. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(message);
  98467. };
  98468. /**
  98469. * Write an error message to the console
  98470. * @param message defines the message to log
  98471. */
  98472. Tools.Error = function (message) {
  98473. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error(message);
  98474. };
  98475. Object.defineProperty(Tools, "LogCache", {
  98476. /**
  98477. * Gets current log cache (list of logs)
  98478. */
  98479. get: function () {
  98480. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogCache;
  98481. },
  98482. enumerable: true,
  98483. configurable: true
  98484. });
  98485. /**
  98486. * Clears the log cache
  98487. */
  98488. Tools.ClearLogCache = function () {
  98489. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ClearLogCache();
  98490. };
  98491. Object.defineProperty(Tools, "LogLevels", {
  98492. /**
  98493. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  98494. */
  98495. set: function (level) {
  98496. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogLevels = level;
  98497. },
  98498. enumerable: true,
  98499. configurable: true
  98500. });
  98501. /**
  98502. * Checks if the loaded document was accessed via `file:`-Protocol.
  98503. * @returns boolean
  98504. */
  98505. Tools.IsFileURL = function () {
  98506. return location.protocol === "file:";
  98507. };
  98508. Object.defineProperty(Tools, "PerformanceLogLevel", {
  98509. /**
  98510. * Sets the current performance log level
  98511. */
  98512. set: function (level) {
  98513. if ((level & Tools.PerformanceUserMarkLogLevel) === Tools.PerformanceUserMarkLogLevel) {
  98514. Tools.StartPerformanceCounter = Tools._StartUserMark;
  98515. Tools.EndPerformanceCounter = Tools._EndUserMark;
  98516. return;
  98517. }
  98518. if ((level & Tools.PerformanceConsoleLogLevel) === Tools.PerformanceConsoleLogLevel) {
  98519. Tools.StartPerformanceCounter = Tools._StartPerformanceConsole;
  98520. Tools.EndPerformanceCounter = Tools._EndPerformanceConsole;
  98521. return;
  98522. }
  98523. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  98524. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  98525. },
  98526. enumerable: true,
  98527. configurable: true
  98528. });
  98529. Tools._StartPerformanceCounterDisabled = function (counterName, condition) {
  98530. };
  98531. Tools._EndPerformanceCounterDisabled = function (counterName, condition) {
  98532. };
  98533. Tools._StartUserMark = function (counterName, condition) {
  98534. if (condition === void 0) { condition = true; }
  98535. if (!Tools._performance) {
  98536. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  98537. return;
  98538. }
  98539. Tools._performance = window.performance;
  98540. }
  98541. if (!condition || !Tools._performance.mark) {
  98542. return;
  98543. }
  98544. Tools._performance.mark(counterName + "-Begin");
  98545. };
  98546. Tools._EndUserMark = function (counterName, condition) {
  98547. if (condition === void 0) { condition = true; }
  98548. if (!condition || !Tools._performance.mark) {
  98549. return;
  98550. }
  98551. Tools._performance.mark(counterName + "-End");
  98552. Tools._performance.measure(counterName, counterName + "-Begin", counterName + "-End");
  98553. };
  98554. Tools._StartPerformanceConsole = function (counterName, condition) {
  98555. if (condition === void 0) { condition = true; }
  98556. if (!condition) {
  98557. return;
  98558. }
  98559. Tools._StartUserMark(counterName, condition);
  98560. if (console.time) {
  98561. console.time(counterName);
  98562. }
  98563. };
  98564. Tools._EndPerformanceConsole = function (counterName, condition) {
  98565. if (condition === void 0) { condition = true; }
  98566. if (!condition) {
  98567. return;
  98568. }
  98569. Tools._EndUserMark(counterName, condition);
  98570. if (console.time) {
  98571. console.timeEnd(counterName);
  98572. }
  98573. };
  98574. /**
  98575. * Injects the @see CustomRequestHeaders into the given request
  98576. * @param request the request that should be used for injection
  98577. */
  98578. Tools.InjectCustomRequestHeaders = function (request) {
  98579. for (var key in Tools.CustomRequestHeaders) {
  98580. var val = Tools.CustomRequestHeaders[key];
  98581. if (val) {
  98582. request.setRequestHeader(key, val);
  98583. }
  98584. }
  98585. };
  98586. Object.defineProperty(Tools, "Now", {
  98587. /**
  98588. * Gets either window.performance.now() if supported or Date.now() else
  98589. */
  98590. get: function () {
  98591. return _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  98592. },
  98593. enumerable: true,
  98594. configurable: true
  98595. });
  98596. /**
  98597. * This method will return the name of the class used to create the instance of the given object.
  98598. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  98599. * @param object the object to get the class name from
  98600. * @param isType defines if the object is actually a type
  98601. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  98602. */
  98603. Tools.GetClassName = function (object, isType) {
  98604. if (isType === void 0) { isType = false; }
  98605. var name = null;
  98606. if (!isType && object.getClassName) {
  98607. name = object.getClassName();
  98608. }
  98609. else {
  98610. if (object instanceof Object) {
  98611. var classObj = isType ? object : Object.getPrototypeOf(object);
  98612. name = classObj.constructor["__bjsclassName__"];
  98613. }
  98614. if (!name) {
  98615. name = typeof object;
  98616. }
  98617. }
  98618. return name;
  98619. };
  98620. /**
  98621. * Gets the first element of an array satisfying a given predicate
  98622. * @param array defines the array to browse
  98623. * @param predicate defines the predicate to use
  98624. * @returns null if not found or the element
  98625. */
  98626. Tools.First = function (array, predicate) {
  98627. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  98628. var el = array_1[_i];
  98629. if (predicate(el)) {
  98630. return el;
  98631. }
  98632. }
  98633. return null;
  98634. };
  98635. /**
  98636. * This method will return the name of the full name of the class, including its owning module (if any).
  98637. * 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).
  98638. * @param object the object to get the class name from
  98639. * @param isType defines if the object is actually a type
  98640. * @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.
  98641. * @ignorenaming
  98642. */
  98643. Tools.getFullClassName = function (object, isType) {
  98644. if (isType === void 0) { isType = false; }
  98645. var className = null;
  98646. var moduleName = null;
  98647. if (!isType && object.getClassName) {
  98648. className = object.getClassName();
  98649. }
  98650. else {
  98651. if (object instanceof Object) {
  98652. var classObj = isType ? object : Object.getPrototypeOf(object);
  98653. className = classObj.constructor["__bjsclassName__"];
  98654. moduleName = classObj.constructor["__bjsmoduleName__"];
  98655. }
  98656. if (!className) {
  98657. className = typeof object;
  98658. }
  98659. }
  98660. if (!className) {
  98661. return null;
  98662. }
  98663. return ((moduleName != null) ? (moduleName + ".") : "") + className;
  98664. };
  98665. /**
  98666. * Returns a promise that resolves after the given amount of time.
  98667. * @param delay Number of milliseconds to delay
  98668. * @returns Promise that resolves after the given amount of time
  98669. */
  98670. Tools.DelayAsync = function (delay) {
  98671. return new Promise(function (resolve) {
  98672. setTimeout(function () {
  98673. resolve();
  98674. }, delay);
  98675. });
  98676. };
  98677. /**
  98678. * Gets the current gradient from an array of IValueGradient
  98679. * @param ratio defines the current ratio to get
  98680. * @param gradients defines the array of IValueGradient
  98681. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  98682. */
  98683. Tools.GetCurrentGradient = function (ratio, gradients, updateFunc) {
  98684. for (var gradientIndex = 0; gradientIndex < gradients.length - 1; gradientIndex++) {
  98685. var currentGradient = gradients[gradientIndex];
  98686. var nextGradient = gradients[gradientIndex + 1];
  98687. if (ratio >= currentGradient.gradient && ratio <= nextGradient.gradient) {
  98688. var scale = (ratio - currentGradient.gradient) / (nextGradient.gradient - currentGradient.gradient);
  98689. updateFunc(currentGradient, nextGradient, scale);
  98690. return;
  98691. }
  98692. }
  98693. // Use last index if over
  98694. var lastIndex = gradients.length - 1;
  98695. updateFunc(gradients[lastIndex], gradients[lastIndex], 1.0);
  98696. };
  98697. /**
  98698. * Gets or sets the base URL to use to load assets
  98699. */
  98700. Tools.BaseUrl = "";
  98701. /**
  98702. * Enable/Disable Custom HTTP Request Headers globally.
  98703. * default = false
  98704. * @see CustomRequestHeaders
  98705. */
  98706. Tools.UseCustomRequestHeaders = false;
  98707. /**
  98708. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  98709. * i.e. when loading files, where the server/service expects an Authorization header.
  98710. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  98711. */
  98712. Tools.CustomRequestHeaders = {};
  98713. /**
  98714. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  98715. */
  98716. Tools.DefaultRetryStrategy = RetryStrategy.ExponentialBackoff();
  98717. /**
  98718. * Default behaviour for cors in the application.
  98719. * It can be a string if the expected behavior is identical in the entire app.
  98720. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  98721. */
  98722. Tools.CorsBehavior = "anonymous";
  98723. /**
  98724. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98725. * @ignorenaming
  98726. */
  98727. Tools.UseFallbackTexture = true;
  98728. /**
  98729. * Use this object to register external classes like custom textures or material
  98730. * to allow the laoders to instantiate them
  98731. */
  98732. Tools.RegisteredExternalClasses = {};
  98733. /**
  98734. * Texture content used if a texture cannot loaded
  98735. * @ignorenaming
  98736. */
  98737. 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";
  98738. Tools._tmpFloatArray = new Float32Array(1);
  98739. /**
  98740. * Extracts text content from a DOM element hierarchy
  98741. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  98742. */
  98743. Tools.GetDOMTextContent = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].GetDOMTextContent;
  98744. /**
  98745. * Gets or sets a function used to pre-process url before using them to load assets
  98746. */
  98747. Tools.PreprocessUrl = function (url) {
  98748. return url;
  98749. };
  98750. // Logs
  98751. /**
  98752. * No log
  98753. */
  98754. Tools.NoneLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].NoneLogLevel;
  98755. /**
  98756. * Only message logs
  98757. */
  98758. Tools.MessageLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].MessageLogLevel;
  98759. /**
  98760. * Only warning logs
  98761. */
  98762. Tools.WarningLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].WarningLogLevel;
  98763. /**
  98764. * Only error logs
  98765. */
  98766. Tools.ErrorLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ErrorLogLevel;
  98767. /**
  98768. * All logs
  98769. */
  98770. Tools.AllLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].AllLogLevel;
  98771. /**
  98772. * Checks if the window object exists
  98773. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  98774. */
  98775. Tools.IsWindowObjectExist = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist;
  98776. // Performances
  98777. /**
  98778. * No performance log
  98779. */
  98780. Tools.PerformanceNoneLogLevel = 0;
  98781. /**
  98782. * Use user marks to log performance
  98783. */
  98784. Tools.PerformanceUserMarkLogLevel = 1;
  98785. /**
  98786. * Log performance to the console
  98787. */
  98788. Tools.PerformanceConsoleLogLevel = 2;
  98789. /**
  98790. * Starts a performance counter
  98791. */
  98792. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  98793. /**
  98794. * Ends a specific performance coutner
  98795. */
  98796. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  98797. return Tools;
  98798. }());
  98799. /**
  98800. * This class is used to track a performance counter which is number based.
  98801. * The user has access to many properties which give statistics of different nature.
  98802. *
  98803. * The implementer can track two kinds of Performance Counter: time and count.
  98804. * 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.
  98805. * 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.
  98806. */
  98807. var PerfCounter = /** @class */ (function () {
  98808. /**
  98809. * Creates a new counter
  98810. */
  98811. function PerfCounter() {
  98812. this._startMonitoringTime = 0;
  98813. this._min = 0;
  98814. this._max = 0;
  98815. this._average = 0;
  98816. this._lastSecAverage = 0;
  98817. this._current = 0;
  98818. this._totalValueCount = 0;
  98819. this._totalAccumulated = 0;
  98820. this._lastSecAccumulated = 0;
  98821. this._lastSecTime = 0;
  98822. this._lastSecValueCount = 0;
  98823. }
  98824. Object.defineProperty(PerfCounter.prototype, "min", {
  98825. /**
  98826. * Returns the smallest value ever
  98827. */
  98828. get: function () {
  98829. return this._min;
  98830. },
  98831. enumerable: true,
  98832. configurable: true
  98833. });
  98834. Object.defineProperty(PerfCounter.prototype, "max", {
  98835. /**
  98836. * Returns the biggest value ever
  98837. */
  98838. get: function () {
  98839. return this._max;
  98840. },
  98841. enumerable: true,
  98842. configurable: true
  98843. });
  98844. Object.defineProperty(PerfCounter.prototype, "average", {
  98845. /**
  98846. * Returns the average value since the performance counter is running
  98847. */
  98848. get: function () {
  98849. return this._average;
  98850. },
  98851. enumerable: true,
  98852. configurable: true
  98853. });
  98854. Object.defineProperty(PerfCounter.prototype, "lastSecAverage", {
  98855. /**
  98856. * Returns the average value of the last second the counter was monitored
  98857. */
  98858. get: function () {
  98859. return this._lastSecAverage;
  98860. },
  98861. enumerable: true,
  98862. configurable: true
  98863. });
  98864. Object.defineProperty(PerfCounter.prototype, "current", {
  98865. /**
  98866. * Returns the current value
  98867. */
  98868. get: function () {
  98869. return this._current;
  98870. },
  98871. enumerable: true,
  98872. configurable: true
  98873. });
  98874. Object.defineProperty(PerfCounter.prototype, "total", {
  98875. /**
  98876. * Gets the accumulated total
  98877. */
  98878. get: function () {
  98879. return this._totalAccumulated;
  98880. },
  98881. enumerable: true,
  98882. configurable: true
  98883. });
  98884. Object.defineProperty(PerfCounter.prototype, "count", {
  98885. /**
  98886. * Gets the total value count
  98887. */
  98888. get: function () {
  98889. return this._totalValueCount;
  98890. },
  98891. enumerable: true,
  98892. configurable: true
  98893. });
  98894. /**
  98895. * Call this method to start monitoring a new frame.
  98896. * 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.
  98897. */
  98898. PerfCounter.prototype.fetchNewFrame = function () {
  98899. this._totalValueCount++;
  98900. this._current = 0;
  98901. this._lastSecValueCount++;
  98902. };
  98903. /**
  98904. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  98905. * @param newCount the count value to add to the monitored count
  98906. * @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.
  98907. */
  98908. PerfCounter.prototype.addCount = function (newCount, fetchResult) {
  98909. if (!PerfCounter.Enabled) {
  98910. return;
  98911. }
  98912. this._current += newCount;
  98913. if (fetchResult) {
  98914. this._fetchResult();
  98915. }
  98916. };
  98917. /**
  98918. * Start monitoring this performance counter
  98919. */
  98920. PerfCounter.prototype.beginMonitoring = function () {
  98921. if (!PerfCounter.Enabled) {
  98922. return;
  98923. }
  98924. this._startMonitoringTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  98925. };
  98926. /**
  98927. * Compute the time lapsed since the previous beginMonitoring() call.
  98928. * @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
  98929. */
  98930. PerfCounter.prototype.endMonitoring = function (newFrame) {
  98931. if (newFrame === void 0) { newFrame = true; }
  98932. if (!PerfCounter.Enabled) {
  98933. return;
  98934. }
  98935. if (newFrame) {
  98936. this.fetchNewFrame();
  98937. }
  98938. var currentTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  98939. this._current = currentTime - this._startMonitoringTime;
  98940. if (newFrame) {
  98941. this._fetchResult();
  98942. }
  98943. };
  98944. PerfCounter.prototype._fetchResult = function () {
  98945. this._totalAccumulated += this._current;
  98946. this._lastSecAccumulated += this._current;
  98947. // Min/Max update
  98948. this._min = Math.min(this._min, this._current);
  98949. this._max = Math.max(this._max, this._current);
  98950. this._average = this._totalAccumulated / this._totalValueCount;
  98951. // Reset last sec?
  98952. var now = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  98953. if ((now - this._lastSecTime) > 1000) {
  98954. this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount;
  98955. this._lastSecTime = now;
  98956. this._lastSecAccumulated = 0;
  98957. this._lastSecValueCount = 0;
  98958. }
  98959. };
  98960. /**
  98961. * Gets or sets a global boolean to turn on and off all the counters
  98962. */
  98963. PerfCounter.Enabled = true;
  98964. return PerfCounter;
  98965. }());
  98966. /**
  98967. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  98968. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  98969. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  98970. * @param name The name of the class, case should be preserved
  98971. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  98972. */
  98973. function className(name, module) {
  98974. return function (target) {
  98975. target["__bjsclassName__"] = name;
  98976. target["__bjsmoduleName__"] = (module != null) ? module : null;
  98977. };
  98978. }
  98979. /**
  98980. * An implementation of a loop for asynchronous functions.
  98981. */
  98982. var AsyncLoop = /** @class */ (function () {
  98983. /**
  98984. * Constructor.
  98985. * @param iterations the number of iterations.
  98986. * @param func the function to run each iteration
  98987. * @param successCallback the callback that will be called upon succesful execution
  98988. * @param offset starting offset.
  98989. */
  98990. function AsyncLoop(
  98991. /**
  98992. * Defines the number of iterations for the loop
  98993. */
  98994. iterations, func, successCallback, offset) {
  98995. if (offset === void 0) { offset = 0; }
  98996. this.iterations = iterations;
  98997. this.index = offset - 1;
  98998. this._done = false;
  98999. this._fn = func;
  99000. this._successCallback = successCallback;
  99001. }
  99002. /**
  99003. * Execute the next iteration. Must be called after the last iteration was finished.
  99004. */
  99005. AsyncLoop.prototype.executeNext = function () {
  99006. if (!this._done) {
  99007. if (this.index + 1 < this.iterations) {
  99008. ++this.index;
  99009. this._fn(this);
  99010. }
  99011. else {
  99012. this.breakLoop();
  99013. }
  99014. }
  99015. };
  99016. /**
  99017. * Break the loop and run the success callback.
  99018. */
  99019. AsyncLoop.prototype.breakLoop = function () {
  99020. this._done = true;
  99021. this._successCallback();
  99022. };
  99023. /**
  99024. * Create and run an async loop.
  99025. * @param iterations the number of iterations.
  99026. * @param fn the function to run each iteration
  99027. * @param successCallback the callback that will be called upon succesful execution
  99028. * @param offset starting offset.
  99029. * @returns the created async loop object
  99030. */
  99031. AsyncLoop.Run = function (iterations, fn, successCallback, offset) {
  99032. if (offset === void 0) { offset = 0; }
  99033. var loop = new AsyncLoop(iterations, fn, successCallback, offset);
  99034. loop.executeNext();
  99035. return loop;
  99036. };
  99037. /**
  99038. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99039. * @param iterations total number of iterations
  99040. * @param syncedIterations number of synchronous iterations in each async iteration.
  99041. * @param fn the function to call each iteration.
  99042. * @param callback a success call back that will be called when iterating stops.
  99043. * @param breakFunction a break condition (optional)
  99044. * @param timeout timeout settings for the setTimeout function. default - 0.
  99045. * @returns the created async loop object
  99046. */
  99047. AsyncLoop.SyncAsyncForLoop = function (iterations, syncedIterations, fn, callback, breakFunction, timeout) {
  99048. if (timeout === void 0) { timeout = 0; }
  99049. return AsyncLoop.Run(Math.ceil(iterations / syncedIterations), function (loop) {
  99050. if (breakFunction && breakFunction()) {
  99051. loop.breakLoop();
  99052. }
  99053. else {
  99054. setTimeout(function () {
  99055. for (var i = 0; i < syncedIterations; ++i) {
  99056. var iteration = (loop.index * syncedIterations) + i;
  99057. if (iteration >= iterations) {
  99058. break;
  99059. }
  99060. fn(iteration);
  99061. if (breakFunction && breakFunction()) {
  99062. loop.breakLoop();
  99063. break;
  99064. }
  99065. }
  99066. loop.executeNext();
  99067. }, timeout);
  99068. }
  99069. }, callback);
  99070. };
  99071. return AsyncLoop;
  99072. }());
  99073. /***/ }),
  99074. /***/ "./Misc/typeStore.ts":
  99075. /*!***************************!*\
  99076. !*** ./Misc/typeStore.ts ***!
  99077. \***************************/
  99078. /*! exports provided: _TypeStore */
  99079. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99080. "use strict";
  99081. __webpack_require__.r(__webpack_exports__);
  99082. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _TypeStore; });
  99083. /** @hidden */
  99084. var _TypeStore = /** @class */ (function () {
  99085. function _TypeStore() {
  99086. }
  99087. /** @hidden */
  99088. _TypeStore.GetClass = function (fqdn) {
  99089. if (this.RegisteredTypes && this.RegisteredTypes[fqdn]) {
  99090. return this.RegisteredTypes[fqdn];
  99091. }
  99092. return null;
  99093. };
  99094. /** @hidden */
  99095. _TypeStore.RegisteredTypes = {};
  99096. return _TypeStore;
  99097. }());
  99098. /***/ }),
  99099. /***/ "./Misc/videoRecorder.ts":
  99100. /*!*******************************!*\
  99101. !*** ./Misc/videoRecorder.ts ***!
  99102. \*******************************/
  99103. /*! exports provided: VideoRecorder */
  99104. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99105. "use strict";
  99106. __webpack_require__.r(__webpack_exports__);
  99107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return VideoRecorder; });
  99108. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  99109. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  99110. /**
  99111. * This can helps recording videos from BabylonJS.
  99112. * This is based on the available WebRTC functionalities of the browser.
  99113. *
  99114. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  99115. */
  99116. var VideoRecorder = /** @class */ (function () {
  99117. /**
  99118. * Create a new VideoCapture object which can help converting what you see in Babylon to
  99119. * a video file.
  99120. * @param engine Defines the BabylonJS Engine you wish to record
  99121. * @param options Defines options that can be used to customized the capture
  99122. */
  99123. function VideoRecorder(engine, options) {
  99124. if (options === void 0) { options = null; }
  99125. if (!VideoRecorder.IsSupported(engine)) {
  99126. throw "Your browser does not support recording so far.";
  99127. }
  99128. var canvas = engine.getRenderingCanvas();
  99129. if (!canvas) {
  99130. throw "The babylon engine must have a canvas to be recorded";
  99131. }
  99132. this._canvas = canvas;
  99133. this._canvas.isRecording = false;
  99134. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, VideoRecorder._defaultOptions, options);
  99135. var stream = this._canvas.captureStream(this._options.fps);
  99136. this._mediaRecorder = new MediaRecorder(stream, { mimeType: this._options.mimeType });
  99137. this._mediaRecorder.ondataavailable = this._handleDataAvailable.bind(this);
  99138. this._mediaRecorder.onerror = this._handleError.bind(this);
  99139. this._mediaRecorder.onstop = this._handleStop.bind(this);
  99140. }
  99141. /**
  99142. * Returns wehther or not the VideoRecorder is available in your browser.
  99143. * @param engine Defines the Babylon Engine to check the support for
  99144. * @returns true if supported otherwise false
  99145. */
  99146. VideoRecorder.IsSupported = function (engine) {
  99147. var canvas = engine.getRenderingCanvas();
  99148. return (!!canvas && typeof canvas.captureStream === "function");
  99149. };
  99150. Object.defineProperty(VideoRecorder.prototype, "isRecording", {
  99151. /**
  99152. * True wether a recording is already in progress.
  99153. */
  99154. get: function () {
  99155. return !!this._canvas && this._canvas.isRecording;
  99156. },
  99157. enumerable: true,
  99158. configurable: true
  99159. });
  99160. /**
  99161. * Stops the current recording before the default capture timeout passed in the startRecording
  99162. * functions.
  99163. */
  99164. VideoRecorder.prototype.stopRecording = function () {
  99165. if (!this._canvas || !this._mediaRecorder) {
  99166. return;
  99167. }
  99168. if (!this.isRecording) {
  99169. return;
  99170. }
  99171. this._canvas.isRecording = false;
  99172. this._mediaRecorder.stop();
  99173. };
  99174. /**
  99175. * Starts recording the canvas for a max duration specified in parameters.
  99176. * @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.
  99177. * @param maxDuration Defines the maximum recording time in seconds.
  99178. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  99179. * @return a promise callback at the end of the recording with the video data in Blob.
  99180. */
  99181. VideoRecorder.prototype.startRecording = function (fileName, maxDuration) {
  99182. var _this = this;
  99183. if (fileName === void 0) { fileName = "babylonjs.webm"; }
  99184. if (maxDuration === void 0) { maxDuration = 7; }
  99185. if (!this._canvas || !this._mediaRecorder) {
  99186. throw "Recorder has already been disposed";
  99187. }
  99188. if (this.isRecording) {
  99189. throw "Recording already in progress";
  99190. }
  99191. if (maxDuration > 0) {
  99192. setTimeout(function () {
  99193. _this.stopRecording();
  99194. }, maxDuration * 1000);
  99195. }
  99196. this._fileName = fileName;
  99197. this._recordedChunks = [];
  99198. this._resolve = null;
  99199. this._reject = null;
  99200. this._canvas.isRecording = true;
  99201. this._mediaRecorder.start(this._options.recordChunckSize);
  99202. return new Promise(function (resolve, reject) {
  99203. _this._resolve = resolve;
  99204. _this._reject = reject;
  99205. });
  99206. };
  99207. /**
  99208. * Releases internal resources used during the recording.
  99209. */
  99210. VideoRecorder.prototype.dispose = function () {
  99211. this._canvas = null;
  99212. this._mediaRecorder = null;
  99213. this._recordedChunks = [];
  99214. this._fileName = null;
  99215. this._resolve = null;
  99216. this._reject = null;
  99217. };
  99218. VideoRecorder.prototype._handleDataAvailable = function (event) {
  99219. if (event.data.size > 0) {
  99220. this._recordedChunks.push(event.data);
  99221. }
  99222. };
  99223. VideoRecorder.prototype._handleError = function (event) {
  99224. this.stopRecording();
  99225. if (this._reject) {
  99226. this._reject(event.error);
  99227. }
  99228. else {
  99229. throw new event.error();
  99230. }
  99231. };
  99232. VideoRecorder.prototype._handleStop = function () {
  99233. this.stopRecording();
  99234. var superBuffer = new Blob(this._recordedChunks);
  99235. if (this._resolve) {
  99236. this._resolve(superBuffer);
  99237. }
  99238. window.URL.createObjectURL(superBuffer);
  99239. if (this._fileName) {
  99240. _tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Download(superBuffer, this._fileName);
  99241. }
  99242. };
  99243. VideoRecorder._defaultOptions = {
  99244. mimeType: "video/webm",
  99245. fps: 25,
  99246. recordChunckSize: 3000
  99247. };
  99248. return VideoRecorder;
  99249. }());
  99250. /***/ }),
  99251. /***/ "./Misc/virtualJoystick.ts":
  99252. /*!*********************************!*\
  99253. !*** ./Misc/virtualJoystick.ts ***!
  99254. \*********************************/
  99255. /*! exports provided: JoystickAxis, VirtualJoystick */
  99256. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99257. "use strict";
  99258. __webpack_require__.r(__webpack_exports__);
  99259. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return JoystickAxis; });
  99260. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return VirtualJoystick; });
  99261. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  99262. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  99263. // Mainly based on these 2 articles :
  99264. // 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
  99265. // & on Seb Lee-Delisle original work: http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/
  99266. /**
  99267. * Defines the potential axis of a Joystick
  99268. */
  99269. var JoystickAxis;
  99270. (function (JoystickAxis) {
  99271. /** X axis */
  99272. JoystickAxis[JoystickAxis["X"] = 0] = "X";
  99273. /** Y axis */
  99274. JoystickAxis[JoystickAxis["Y"] = 1] = "Y";
  99275. /** Z axis */
  99276. JoystickAxis[JoystickAxis["Z"] = 2] = "Z";
  99277. })(JoystickAxis || (JoystickAxis = {}));
  99278. /**
  99279. * Class used to define virtual joystick (used in touch mode)
  99280. */
  99281. var VirtualJoystick = /** @class */ (function () {
  99282. /**
  99283. * Creates a new virtual joystick
  99284. * @param leftJoystick defines that the joystick is for left hand (false by default)
  99285. */
  99286. function VirtualJoystick(leftJoystick) {
  99287. var _this = this;
  99288. if (leftJoystick) {
  99289. this._leftJoystick = true;
  99290. }
  99291. else {
  99292. this._leftJoystick = false;
  99293. }
  99294. VirtualJoystick._globalJoystickIndex++;
  99295. // By default left & right arrow keys are moving the X
  99296. // and up & down keys are moving the Y
  99297. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  99298. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  99299. this.reverseLeftRight = false;
  99300. this.reverseUpDown = false;
  99301. // collections of pointers
  99302. this._touches = new _stringDictionary__WEBPACK_IMPORTED_MODULE_1__["StringDictionary"]();
  99303. this.deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  99304. this._joystickSensibility = 25;
  99305. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  99306. this._onResize = function (evt) {
  99307. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  99308. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  99309. if (VirtualJoystick.Canvas) {
  99310. VirtualJoystick.Canvas.width = VirtualJoystick.vjCanvasWidth;
  99311. VirtualJoystick.Canvas.height = VirtualJoystick.vjCanvasHeight;
  99312. }
  99313. VirtualJoystick.halfWidth = VirtualJoystick.vjCanvasWidth / 2;
  99314. };
  99315. // injecting a canvas element on top of the canvas 3D game
  99316. if (!VirtualJoystick.Canvas) {
  99317. window.addEventListener("resize", this._onResize, false);
  99318. VirtualJoystick.Canvas = document.createElement("canvas");
  99319. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  99320. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  99321. VirtualJoystick.Canvas.width = window.innerWidth;
  99322. VirtualJoystick.Canvas.height = window.innerHeight;
  99323. VirtualJoystick.Canvas.style.width = "100%";
  99324. VirtualJoystick.Canvas.style.height = "100%";
  99325. VirtualJoystick.Canvas.style.position = "absolute";
  99326. VirtualJoystick.Canvas.style.backgroundColor = "transparent";
  99327. VirtualJoystick.Canvas.style.top = "0px";
  99328. VirtualJoystick.Canvas.style.left = "0px";
  99329. VirtualJoystick.Canvas.style.zIndex = "5";
  99330. VirtualJoystick.Canvas.style.msTouchAction = "none";
  99331. // Support for jQuery PEP polyfill
  99332. VirtualJoystick.Canvas.setAttribute("touch-action", "none");
  99333. var context = VirtualJoystick.Canvas.getContext('2d');
  99334. if (!context) {
  99335. throw new Error("Unable to create canvas for virtual joystick");
  99336. }
  99337. VirtualJoystick.vjCanvasContext = context;
  99338. VirtualJoystick.vjCanvasContext.strokeStyle = "#ffffff";
  99339. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  99340. document.body.appendChild(VirtualJoystick.Canvas);
  99341. }
  99342. VirtualJoystick.halfWidth = VirtualJoystick.Canvas.width / 2;
  99343. this.pressed = false;
  99344. // default joystick color
  99345. this._joystickColor = "cyan";
  99346. this._joystickPointerID = -1;
  99347. // current joystick position
  99348. this._joystickPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  99349. this._joystickPreviousPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  99350. // origin joystick position
  99351. this._joystickPointerStartPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  99352. this._deltaJoystickVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  99353. this._onPointerDownHandlerRef = function (evt) {
  99354. _this._onPointerDown(evt);
  99355. };
  99356. this._onPointerMoveHandlerRef = function (evt) {
  99357. _this._onPointerMove(evt);
  99358. };
  99359. this._onPointerUpHandlerRef = function (evt) {
  99360. _this._onPointerUp(evt);
  99361. };
  99362. VirtualJoystick.Canvas.addEventListener('pointerdown', this._onPointerDownHandlerRef, false);
  99363. VirtualJoystick.Canvas.addEventListener('pointermove', this._onPointerMoveHandlerRef, false);
  99364. VirtualJoystick.Canvas.addEventListener('pointerup', this._onPointerUpHandlerRef, false);
  99365. VirtualJoystick.Canvas.addEventListener('pointerout', this._onPointerUpHandlerRef, false);
  99366. VirtualJoystick.Canvas.addEventListener("contextmenu", function (evt) {
  99367. evt.preventDefault(); // Disables system menu
  99368. }, false);
  99369. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  99370. }
  99371. /**
  99372. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  99373. * @param newJoystickSensibility defines the new sensibility
  99374. */
  99375. VirtualJoystick.prototype.setJoystickSensibility = function (newJoystickSensibility) {
  99376. this._joystickSensibility = newJoystickSensibility;
  99377. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  99378. };
  99379. VirtualJoystick.prototype._onPointerDown = function (e) {
  99380. var positionOnScreenCondition;
  99381. e.preventDefault();
  99382. if (this._leftJoystick === true) {
  99383. positionOnScreenCondition = (e.clientX < VirtualJoystick.halfWidth);
  99384. }
  99385. else {
  99386. positionOnScreenCondition = (e.clientX > VirtualJoystick.halfWidth);
  99387. }
  99388. if (positionOnScreenCondition && this._joystickPointerID < 0) {
  99389. // First contact will be dedicated to the virtual joystick
  99390. this._joystickPointerID = e.pointerId;
  99391. this._joystickPointerStartPos.x = e.clientX;
  99392. this._joystickPointerStartPos.y = e.clientY;
  99393. this._joystickPointerPos = this._joystickPointerStartPos.clone();
  99394. this._joystickPreviousPointerPos = this._joystickPointerStartPos.clone();
  99395. this._deltaJoystickVector.x = 0;
  99396. this._deltaJoystickVector.y = 0;
  99397. this.pressed = true;
  99398. this._touches.add(e.pointerId.toString(), e);
  99399. }
  99400. else {
  99401. // You can only trigger the action buttons with a joystick declared
  99402. if (VirtualJoystick._globalJoystickIndex < 2 && this._action) {
  99403. this._action();
  99404. this._touches.add(e.pointerId.toString(), { x: e.clientX, y: e.clientY, prevX: e.clientX, prevY: e.clientY });
  99405. }
  99406. }
  99407. };
  99408. VirtualJoystick.prototype._onPointerMove = function (e) {
  99409. // If the current pointer is the one associated to the joystick (first touch contact)
  99410. if (this._joystickPointerID == e.pointerId) {
  99411. this._joystickPointerPos.x = e.clientX;
  99412. this._joystickPointerPos.y = e.clientY;
  99413. this._deltaJoystickVector = this._joystickPointerPos.clone();
  99414. this._deltaJoystickVector = this._deltaJoystickVector.subtract(this._joystickPointerStartPos);
  99415. var directionLeftRight = this.reverseLeftRight ? -1 : 1;
  99416. var deltaJoystickX = directionLeftRight * this._deltaJoystickVector.x / this._inversedSensibility;
  99417. switch (this._axisTargetedByLeftAndRight) {
  99418. case JoystickAxis.X:
  99419. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickX));
  99420. break;
  99421. case JoystickAxis.Y:
  99422. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickX));
  99423. break;
  99424. case JoystickAxis.Z:
  99425. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickX));
  99426. break;
  99427. }
  99428. var directionUpDown = this.reverseUpDown ? 1 : -1;
  99429. var deltaJoystickY = directionUpDown * this._deltaJoystickVector.y / this._inversedSensibility;
  99430. switch (this._axisTargetedByUpAndDown) {
  99431. case JoystickAxis.X:
  99432. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickY));
  99433. break;
  99434. case JoystickAxis.Y:
  99435. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickY));
  99436. break;
  99437. case JoystickAxis.Z:
  99438. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickY));
  99439. break;
  99440. }
  99441. }
  99442. else {
  99443. var data = this._touches.get(e.pointerId.toString());
  99444. if (data) {
  99445. data.x = e.clientX;
  99446. data.y = e.clientY;
  99447. }
  99448. }
  99449. };
  99450. VirtualJoystick.prototype._onPointerUp = function (e) {
  99451. if (this._joystickPointerID == e.pointerId) {
  99452. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPointerStartPos.x - 64, this._joystickPointerStartPos.y - 64, 128, 128);
  99453. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x - 42, this._joystickPreviousPointerPos.y - 42, 84, 84);
  99454. this._joystickPointerID = -1;
  99455. this.pressed = false;
  99456. }
  99457. else {
  99458. var touch = this._touches.get(e.pointerId.toString());
  99459. if (touch) {
  99460. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  99461. }
  99462. }
  99463. this._deltaJoystickVector.x = 0;
  99464. this._deltaJoystickVector.y = 0;
  99465. this._touches.remove(e.pointerId.toString());
  99466. };
  99467. /**
  99468. * Change the color of the virtual joystick
  99469. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  99470. */
  99471. VirtualJoystick.prototype.setJoystickColor = function (newColor) {
  99472. this._joystickColor = newColor;
  99473. };
  99474. /**
  99475. * Defines a callback to call when the joystick is touched
  99476. * @param action defines the callback
  99477. */
  99478. VirtualJoystick.prototype.setActionOnTouch = function (action) {
  99479. this._action = action;
  99480. };
  99481. /**
  99482. * Defines which axis you'd like to control for left & right
  99483. * @param axis defines the axis to use
  99484. */
  99485. VirtualJoystick.prototype.setAxisForLeftRight = function (axis) {
  99486. switch (axis) {
  99487. case JoystickAxis.X:
  99488. case JoystickAxis.Y:
  99489. case JoystickAxis.Z:
  99490. this._axisTargetedByLeftAndRight = axis;
  99491. break;
  99492. default:
  99493. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  99494. break;
  99495. }
  99496. };
  99497. /**
  99498. * Defines which axis you'd like to control for up & down
  99499. * @param axis defines the axis to use
  99500. */
  99501. VirtualJoystick.prototype.setAxisForUpDown = function (axis) {
  99502. switch (axis) {
  99503. case JoystickAxis.X:
  99504. case JoystickAxis.Y:
  99505. case JoystickAxis.Z:
  99506. this._axisTargetedByUpAndDown = axis;
  99507. break;
  99508. default:
  99509. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  99510. break;
  99511. }
  99512. };
  99513. VirtualJoystick.prototype._drawVirtualJoystick = function () {
  99514. var _this = this;
  99515. if (this.pressed) {
  99516. this._touches.forEach(function (key, touch) {
  99517. if (touch.pointerId === _this._joystickPointerID) {
  99518. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPointerStartPos.x - 64, _this._joystickPointerStartPos.y - 64, 128, 128);
  99519. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPreviousPointerPos.x - 42, _this._joystickPreviousPointerPos.y - 42, 84, 84);
  99520. VirtualJoystick.vjCanvasContext.beginPath();
  99521. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  99522. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  99523. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 40, 0, Math.PI * 2, true);
  99524. VirtualJoystick.vjCanvasContext.stroke();
  99525. VirtualJoystick.vjCanvasContext.closePath();
  99526. VirtualJoystick.vjCanvasContext.beginPath();
  99527. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  99528. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  99529. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 60, 0, Math.PI * 2, true);
  99530. VirtualJoystick.vjCanvasContext.stroke();
  99531. VirtualJoystick.vjCanvasContext.closePath();
  99532. VirtualJoystick.vjCanvasContext.beginPath();
  99533. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  99534. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerPos.x, _this._joystickPointerPos.y, 40, 0, Math.PI * 2, true);
  99535. VirtualJoystick.vjCanvasContext.stroke();
  99536. VirtualJoystick.vjCanvasContext.closePath();
  99537. _this._joystickPreviousPointerPos = _this._joystickPointerPos.clone();
  99538. }
  99539. else {
  99540. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  99541. VirtualJoystick.vjCanvasContext.beginPath();
  99542. VirtualJoystick.vjCanvasContext.fillStyle = "white";
  99543. VirtualJoystick.vjCanvasContext.beginPath();
  99544. VirtualJoystick.vjCanvasContext.strokeStyle = "red";
  99545. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  99546. VirtualJoystick.vjCanvasContext.arc(touch.x, touch.y, 40, 0, Math.PI * 2, true);
  99547. VirtualJoystick.vjCanvasContext.stroke();
  99548. VirtualJoystick.vjCanvasContext.closePath();
  99549. touch.prevX = touch.x;
  99550. touch.prevY = touch.y;
  99551. }
  99552. });
  99553. }
  99554. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  99555. };
  99556. /**
  99557. * Release internal HTML canvas
  99558. */
  99559. VirtualJoystick.prototype.releaseCanvas = function () {
  99560. if (VirtualJoystick.Canvas) {
  99561. VirtualJoystick.Canvas.removeEventListener('pointerdown', this._onPointerDownHandlerRef);
  99562. VirtualJoystick.Canvas.removeEventListener('pointermove', this._onPointerMoveHandlerRef);
  99563. VirtualJoystick.Canvas.removeEventListener('pointerup', this._onPointerUpHandlerRef);
  99564. VirtualJoystick.Canvas.removeEventListener('pointerout', this._onPointerUpHandlerRef);
  99565. window.removeEventListener("resize", this._onResize);
  99566. document.body.removeChild(VirtualJoystick.Canvas);
  99567. VirtualJoystick.Canvas = null;
  99568. }
  99569. };
  99570. // Used to draw the virtual joystick inside a 2D canvas on top of the WebGL rendering canvas
  99571. VirtualJoystick._globalJoystickIndex = 0;
  99572. return VirtualJoystick;
  99573. }());
  99574. /***/ }),
  99575. /***/ "./Misc/workerPool.ts":
  99576. /*!****************************!*\
  99577. !*** ./Misc/workerPool.ts ***!
  99578. \****************************/
  99579. /*! exports provided: WorkerPool */
  99580. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99581. "use strict";
  99582. __webpack_require__.r(__webpack_exports__);
  99583. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return WorkerPool; });
  99584. /**
  99585. * Helper class to push actions to a pool of workers.
  99586. */
  99587. var WorkerPool = /** @class */ (function () {
  99588. /**
  99589. * Constructor
  99590. * @param workers Array of workers to use for actions
  99591. */
  99592. function WorkerPool(workers) {
  99593. this._pendingActions = new Array();
  99594. this._workerInfos = workers.map(function (worker) { return ({
  99595. worker: worker,
  99596. active: false
  99597. }); });
  99598. }
  99599. /**
  99600. * Terminates all workers and clears any pending actions.
  99601. */
  99602. WorkerPool.prototype.dispose = function () {
  99603. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  99604. var workerInfo = _a[_i];
  99605. workerInfo.worker.terminate();
  99606. }
  99607. delete this._workerInfos;
  99608. delete this._pendingActions;
  99609. };
  99610. /**
  99611. * Pushes an action to the worker pool. If all the workers are active, the action will be
  99612. * pended until a worker has completed its action.
  99613. * @param action The action to perform. Call onComplete when the action is complete.
  99614. */
  99615. WorkerPool.prototype.push = function (action) {
  99616. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  99617. var workerInfo = _a[_i];
  99618. if (!workerInfo.active) {
  99619. this._execute(workerInfo, action);
  99620. return;
  99621. }
  99622. }
  99623. this._pendingActions.push(action);
  99624. };
  99625. WorkerPool.prototype._execute = function (workerInfo, action) {
  99626. var _this = this;
  99627. workerInfo.active = true;
  99628. action(workerInfo.worker, function () {
  99629. workerInfo.active = false;
  99630. var nextAction = _this._pendingActions.shift();
  99631. if (nextAction) {
  99632. _this._execute(workerInfo, nextAction);
  99633. }
  99634. });
  99635. };
  99636. return WorkerPool;
  99637. }());
  99638. /***/ }),
  99639. /***/ "./Morph/index.ts":
  99640. /*!************************!*\
  99641. !*** ./Morph/index.ts ***!
  99642. \************************/
  99643. /*! exports provided: MorphTarget, MorphTargetManager */
  99644. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99645. "use strict";
  99646. __webpack_require__.r(__webpack_exports__);
  99647. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  99648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _morphTarget__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  99649. /* harmony import */ var _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./morphTargetManager */ "./Morph/morphTargetManager.ts");
  99650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__["MorphTargetManager"]; });
  99651. /***/ }),
  99652. /***/ "./Morph/morphTarget.ts":
  99653. /*!******************************!*\
  99654. !*** ./Morph/morphTarget.ts ***!
  99655. \******************************/
  99656. /*! exports provided: MorphTarget */
  99657. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99658. "use strict";
  99659. __webpack_require__.r(__webpack_exports__);
  99660. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return MorphTarget; });
  99661. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  99662. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  99663. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  99664. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  99665. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  99666. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  99667. /**
  99668. * Defines a target to use with MorphTargetManager
  99669. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  99670. */
  99671. var MorphTarget = /** @class */ (function () {
  99672. /**
  99673. * Creates a new MorphTarget
  99674. * @param name defines the name of the target
  99675. * @param influence defines the influence to use
  99676. */
  99677. function MorphTarget(
  99678. /** defines the name of the target */
  99679. name, influence, scene) {
  99680. if (influence === void 0) { influence = 0; }
  99681. if (scene === void 0) { scene = null; }
  99682. this.name = name;
  99683. /**
  99684. * Gets or sets the list of animations
  99685. */
  99686. this.animations = new Array();
  99687. this._positions = null;
  99688. this._normals = null;
  99689. this._tangents = null;
  99690. /**
  99691. * Observable raised when the influence changes
  99692. */
  99693. this.onInfluenceChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  99694. /** @hidden */
  99695. this._onDataLayoutChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  99696. this._animationPropertiesOverride = null;
  99697. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  99698. this.influence = influence;
  99699. }
  99700. Object.defineProperty(MorphTarget.prototype, "influence", {
  99701. /**
  99702. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  99703. */
  99704. get: function () {
  99705. return this._influence;
  99706. },
  99707. set: function (influence) {
  99708. if (this._influence === influence) {
  99709. return;
  99710. }
  99711. var previous = this._influence;
  99712. this._influence = influence;
  99713. if (this.onInfluenceChanged.hasObservers) {
  99714. this.onInfluenceChanged.notifyObservers(previous === 0 || influence === 0);
  99715. }
  99716. },
  99717. enumerable: true,
  99718. configurable: true
  99719. });
  99720. Object.defineProperty(MorphTarget.prototype, "animationPropertiesOverride", {
  99721. /**
  99722. * Gets or sets the animation properties override
  99723. */
  99724. get: function () {
  99725. if (!this._animationPropertiesOverride && this._scene) {
  99726. return this._scene.animationPropertiesOverride;
  99727. }
  99728. return this._animationPropertiesOverride;
  99729. },
  99730. set: function (value) {
  99731. this._animationPropertiesOverride = value;
  99732. },
  99733. enumerable: true,
  99734. configurable: true
  99735. });
  99736. Object.defineProperty(MorphTarget.prototype, "hasPositions", {
  99737. /**
  99738. * Gets a boolean defining if the target contains position data
  99739. */
  99740. get: function () {
  99741. return !!this._positions;
  99742. },
  99743. enumerable: true,
  99744. configurable: true
  99745. });
  99746. Object.defineProperty(MorphTarget.prototype, "hasNormals", {
  99747. /**
  99748. * Gets a boolean defining if the target contains normal data
  99749. */
  99750. get: function () {
  99751. return !!this._normals;
  99752. },
  99753. enumerable: true,
  99754. configurable: true
  99755. });
  99756. Object.defineProperty(MorphTarget.prototype, "hasTangents", {
  99757. /**
  99758. * Gets a boolean defining if the target contains tangent data
  99759. */
  99760. get: function () {
  99761. return !!this._tangents;
  99762. },
  99763. enumerable: true,
  99764. configurable: true
  99765. });
  99766. /**
  99767. * Affects position data to this target
  99768. * @param data defines the position data to use
  99769. */
  99770. MorphTarget.prototype.setPositions = function (data) {
  99771. var hadPositions = this.hasPositions;
  99772. this._positions = data;
  99773. if (hadPositions !== this.hasPositions) {
  99774. this._onDataLayoutChanged.notifyObservers(undefined);
  99775. }
  99776. };
  99777. /**
  99778. * Gets the position data stored in this target
  99779. * @returns a FloatArray containing the position data (or null if not present)
  99780. */
  99781. MorphTarget.prototype.getPositions = function () {
  99782. return this._positions;
  99783. };
  99784. /**
  99785. * Affects normal data to this target
  99786. * @param data defines the normal data to use
  99787. */
  99788. MorphTarget.prototype.setNormals = function (data) {
  99789. var hadNormals = this.hasNormals;
  99790. this._normals = data;
  99791. if (hadNormals !== this.hasNormals) {
  99792. this._onDataLayoutChanged.notifyObservers(undefined);
  99793. }
  99794. };
  99795. /**
  99796. * Gets the normal data stored in this target
  99797. * @returns a FloatArray containing the normal data (or null if not present)
  99798. */
  99799. MorphTarget.prototype.getNormals = function () {
  99800. return this._normals;
  99801. };
  99802. /**
  99803. * Affects tangent data to this target
  99804. * @param data defines the tangent data to use
  99805. */
  99806. MorphTarget.prototype.setTangents = function (data) {
  99807. var hadTangents = this.hasTangents;
  99808. this._tangents = data;
  99809. if (hadTangents !== this.hasTangents) {
  99810. this._onDataLayoutChanged.notifyObservers(undefined);
  99811. }
  99812. };
  99813. /**
  99814. * Gets the tangent data stored in this target
  99815. * @returns a FloatArray containing the tangent data (or null if not present)
  99816. */
  99817. MorphTarget.prototype.getTangents = function () {
  99818. return this._tangents;
  99819. };
  99820. /**
  99821. * Serializes the current target into a Serialization object
  99822. * @returns the serialized object
  99823. */
  99824. MorphTarget.prototype.serialize = function () {
  99825. var serializationObject = {};
  99826. serializationObject.name = this.name;
  99827. serializationObject.influence = this.influence;
  99828. serializationObject.positions = Array.prototype.slice.call(this.getPositions());
  99829. if (this.id != null) {
  99830. serializationObject.id = this.id;
  99831. }
  99832. if (this.hasNormals) {
  99833. serializationObject.normals = Array.prototype.slice.call(this.getNormals());
  99834. }
  99835. if (this.hasTangents) {
  99836. serializationObject.tangents = Array.prototype.slice.call(this.getTangents());
  99837. }
  99838. // Animations
  99839. _Misc_decorators__WEBPACK_IMPORTED_MODULE_5__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  99840. return serializationObject;
  99841. };
  99842. /**
  99843. * Returns the string "MorphTarget"
  99844. * @returns "MorphTarget"
  99845. */
  99846. MorphTarget.prototype.getClassName = function () {
  99847. return "MorphTarget";
  99848. };
  99849. // Statics
  99850. /**
  99851. * Creates a new target from serialized data
  99852. * @param serializationObject defines the serialized data to use
  99853. * @returns a new MorphTarget
  99854. */
  99855. MorphTarget.Parse = function (serializationObject) {
  99856. var result = new MorphTarget(serializationObject.name, serializationObject.influence);
  99857. result.setPositions(serializationObject.positions);
  99858. if (serializationObject.id != null) {
  99859. result.id = serializationObject.id;
  99860. }
  99861. if (serializationObject.normals) {
  99862. result.setNormals(serializationObject.normals);
  99863. }
  99864. if (serializationObject.tangents) {
  99865. result.setTangents(serializationObject.tangents);
  99866. }
  99867. // Animations
  99868. if (serializationObject.animations) {
  99869. for (var animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {
  99870. var parsedAnimation = serializationObject.animations[animationIndex];
  99871. result.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].Parse(parsedAnimation));
  99872. }
  99873. }
  99874. return result;
  99875. };
  99876. /**
  99877. * Creates a MorphTarget from mesh data
  99878. * @param mesh defines the source mesh
  99879. * @param name defines the name to use for the new target
  99880. * @param influence defines the influence to attach to the target
  99881. * @returns a new MorphTarget
  99882. */
  99883. MorphTarget.FromMesh = function (mesh, name, influence) {
  99884. if (!name) {
  99885. name = mesh.name;
  99886. }
  99887. var result = new MorphTarget(name, influence, mesh.getScene());
  99888. result.setPositions(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind));
  99889. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  99890. result.setNormals(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  99891. }
  99892. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  99893. result.setTangents(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind));
  99894. }
  99895. return result;
  99896. };
  99897. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  99898. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_5__["serialize"])()
  99899. ], MorphTarget.prototype, "id", void 0);
  99900. return MorphTarget;
  99901. }());
  99902. /***/ }),
  99903. /***/ "./Morph/morphTargetManager.ts":
  99904. /*!*************************************!*\
  99905. !*** ./Morph/morphTargetManager.ts ***!
  99906. \*************************************/
  99907. /*! exports provided: MorphTargetManager */
  99908. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99909. "use strict";
  99910. __webpack_require__.r(__webpack_exports__);
  99911. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return MorphTargetManager; });
  99912. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  99913. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  99914. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  99915. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  99916. /**
  99917. * This class is used to deform meshes using morphing between different targets
  99918. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  99919. */
  99920. var MorphTargetManager = /** @class */ (function () {
  99921. /**
  99922. * Creates a new MorphTargetManager
  99923. * @param scene defines the current scene
  99924. */
  99925. function MorphTargetManager(scene) {
  99926. if (scene === void 0) { scene = null; }
  99927. this._targets = new Array();
  99928. this._targetInfluenceChangedObservers = new Array();
  99929. this._targetDataLayoutChangedObservers = new Array();
  99930. this._activeTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  99931. this._supportsNormals = false;
  99932. this._supportsTangents = false;
  99933. this._vertexCount = 0;
  99934. this._uniqueId = 0;
  99935. this._tempInfluences = new Array();
  99936. if (!scene) {
  99937. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  99938. }
  99939. this._scene = scene;
  99940. if (this._scene) {
  99941. this._scene.morphTargetManagers.push(this);
  99942. this._uniqueId = this._scene.getUniqueId();
  99943. }
  99944. }
  99945. Object.defineProperty(MorphTargetManager.prototype, "uniqueId", {
  99946. /**
  99947. * Gets the unique ID of this manager
  99948. */
  99949. get: function () {
  99950. return this._uniqueId;
  99951. },
  99952. enumerable: true,
  99953. configurable: true
  99954. });
  99955. Object.defineProperty(MorphTargetManager.prototype, "vertexCount", {
  99956. /**
  99957. * Gets the number of vertices handled by this manager
  99958. */
  99959. get: function () {
  99960. return this._vertexCount;
  99961. },
  99962. enumerable: true,
  99963. configurable: true
  99964. });
  99965. Object.defineProperty(MorphTargetManager.prototype, "supportsNormals", {
  99966. /**
  99967. * Gets a boolean indicating if this manager supports morphing of normals
  99968. */
  99969. get: function () {
  99970. return this._supportsNormals;
  99971. },
  99972. enumerable: true,
  99973. configurable: true
  99974. });
  99975. Object.defineProperty(MorphTargetManager.prototype, "supportsTangents", {
  99976. /**
  99977. * Gets a boolean indicating if this manager supports morphing of tangents
  99978. */
  99979. get: function () {
  99980. return this._supportsTangents;
  99981. },
  99982. enumerable: true,
  99983. configurable: true
  99984. });
  99985. Object.defineProperty(MorphTargetManager.prototype, "numTargets", {
  99986. /**
  99987. * Gets the number of targets stored in this manager
  99988. */
  99989. get: function () {
  99990. return this._targets.length;
  99991. },
  99992. enumerable: true,
  99993. configurable: true
  99994. });
  99995. Object.defineProperty(MorphTargetManager.prototype, "numInfluencers", {
  99996. /**
  99997. * Gets the number of influencers (ie. the number of targets with influences > 0)
  99998. */
  99999. get: function () {
  100000. return this._activeTargets.length;
  100001. },
  100002. enumerable: true,
  100003. configurable: true
  100004. });
  100005. Object.defineProperty(MorphTargetManager.prototype, "influences", {
  100006. /**
  100007. * Gets the list of influences (one per target)
  100008. */
  100009. get: function () {
  100010. return this._influences;
  100011. },
  100012. enumerable: true,
  100013. configurable: true
  100014. });
  100015. /**
  100016. * Gets the active target at specified index. An active target is a target with an influence > 0
  100017. * @param index defines the index to check
  100018. * @returns the requested target
  100019. */
  100020. MorphTargetManager.prototype.getActiveTarget = function (index) {
  100021. return this._activeTargets.data[index];
  100022. };
  100023. /**
  100024. * Gets the target at specified index
  100025. * @param index defines the index to check
  100026. * @returns the requested target
  100027. */
  100028. MorphTargetManager.prototype.getTarget = function (index) {
  100029. return this._targets[index];
  100030. };
  100031. /**
  100032. * Add a new target to this manager
  100033. * @param target defines the target to add
  100034. */
  100035. MorphTargetManager.prototype.addTarget = function (target) {
  100036. var _this = this;
  100037. this._targets.push(target);
  100038. this._targetInfluenceChangedObservers.push(target.onInfluenceChanged.add(function (needUpdate) {
  100039. _this._syncActiveTargets(needUpdate);
  100040. }));
  100041. this._targetDataLayoutChangedObservers.push(target._onDataLayoutChanged.add(function () {
  100042. _this._syncActiveTargets(true);
  100043. }));
  100044. this._syncActiveTargets(true);
  100045. };
  100046. /**
  100047. * Removes a target from the manager
  100048. * @param target defines the target to remove
  100049. */
  100050. MorphTargetManager.prototype.removeTarget = function (target) {
  100051. var index = this._targets.indexOf(target);
  100052. if (index >= 0) {
  100053. this._targets.splice(index, 1);
  100054. target.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(index, 1)[0]);
  100055. target._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(index, 1)[0]);
  100056. this._syncActiveTargets(true);
  100057. }
  100058. };
  100059. /**
  100060. * Serializes the current manager into a Serialization object
  100061. * @returns the serialized object
  100062. */
  100063. MorphTargetManager.prototype.serialize = function () {
  100064. var serializationObject = {};
  100065. serializationObject.id = this.uniqueId;
  100066. serializationObject.targets = [];
  100067. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  100068. var target = _a[_i];
  100069. serializationObject.targets.push(target.serialize());
  100070. }
  100071. return serializationObject;
  100072. };
  100073. MorphTargetManager.prototype._syncActiveTargets = function (needUpdate) {
  100074. var influenceCount = 0;
  100075. this._activeTargets.reset();
  100076. this._supportsNormals = true;
  100077. this._supportsTangents = true;
  100078. this._vertexCount = 0;
  100079. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  100080. var target = _a[_i];
  100081. if (target.influence === 0) {
  100082. continue;
  100083. }
  100084. this._activeTargets.push(target);
  100085. this._tempInfluences[influenceCount++] = target.influence;
  100086. this._supportsNormals = this._supportsNormals && target.hasNormals;
  100087. this._supportsTangents = this._supportsTangents && target.hasTangents;
  100088. var positions = target.getPositions();
  100089. if (positions) {
  100090. var vertexCount = positions.length / 3;
  100091. if (this._vertexCount === 0) {
  100092. this._vertexCount = vertexCount;
  100093. }
  100094. else if (this._vertexCount !== vertexCount) {
  100095. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Incompatible target. Targets must all have the same vertices count.");
  100096. return;
  100097. }
  100098. }
  100099. }
  100100. if (!this._influences || this._influences.length !== influenceCount) {
  100101. this._influences = new Float32Array(influenceCount);
  100102. }
  100103. for (var index = 0; index < influenceCount; index++) {
  100104. this._influences[index] = this._tempInfluences[index];
  100105. }
  100106. if (needUpdate) {
  100107. this.synchronize();
  100108. }
  100109. };
  100110. /**
  100111. * Syncrhonize the targets with all the meshes using this morph target manager
  100112. */
  100113. MorphTargetManager.prototype.synchronize = function () {
  100114. if (!this._scene) {
  100115. return;
  100116. }
  100117. // Flag meshes as dirty to resync with the active targets
  100118. for (var _i = 0, _a = this._scene.meshes; _i < _a.length; _i++) {
  100119. var mesh = _a[_i];
  100120. if (mesh.morphTargetManager === this) {
  100121. mesh._syncGeometryWithMorphTargetManager();
  100122. }
  100123. }
  100124. };
  100125. // Statics
  100126. /**
  100127. * Creates a new MorphTargetManager from serialized data
  100128. * @param serializationObject defines the serialized data
  100129. * @param scene defines the hosting scene
  100130. * @returns the new MorphTargetManager
  100131. */
  100132. MorphTargetManager.Parse = function (serializationObject, scene) {
  100133. var result = new MorphTargetManager(scene);
  100134. result._uniqueId = serializationObject.id;
  100135. for (var _i = 0, _a = serializationObject.targets; _i < _a.length; _i++) {
  100136. var targetData = _a[_i];
  100137. result.addTarget(_morphTarget__WEBPACK_IMPORTED_MODULE_3__["MorphTarget"].Parse(targetData));
  100138. }
  100139. return result;
  100140. };
  100141. return MorphTargetManager;
  100142. }());
  100143. /***/ }),
  100144. /***/ "./Offline/database.ts":
  100145. /*!*****************************!*\
  100146. !*** ./Offline/database.ts ***!
  100147. \*****************************/
  100148. /*! exports provided: Database */
  100149. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100150. "use strict";
  100151. __webpack_require__.r(__webpack_exports__);
  100152. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return Database; });
  100153. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  100154. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  100155. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tga */ "./Misc/tga.ts");
  100156. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  100157. // Sets the default offline provider to Babylon.js
  100158. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].OfflineProviderFactory = function (urlToScene, callbackManifestChecked, disableManifestCheck) {
  100159. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  100160. return new Database(urlToScene, callbackManifestChecked, disableManifestCheck);
  100161. };
  100162. /**
  100163. * Class used to enable access to IndexedDB
  100164. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  100165. */
  100166. var Database = /** @class */ (function () {
  100167. /**
  100168. * Creates a new Database
  100169. * @param urlToScene defines the url to load the scene
  100170. * @param callbackManifestChecked defines the callback to use when manifest is checked
  100171. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  100172. */
  100173. function Database(urlToScene, callbackManifestChecked, disableManifestCheck) {
  100174. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  100175. var _this = this;
  100176. // Handling various flavors of prefixed version of IndexedDB
  100177. this._idbFactory = (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB);
  100178. this._callbackManifestChecked = callbackManifestChecked;
  100179. this._currentSceneUrl = Database._ReturnFullUrlLocation(urlToScene);
  100180. this._db = null;
  100181. this._enableSceneOffline = false;
  100182. this._enableTexturesOffline = false;
  100183. this._manifestVersionFound = 0;
  100184. this._mustUpdateRessources = false;
  100185. this._hasReachedQuota = false;
  100186. if (!Database.IDBStorageEnabled) {
  100187. this._callbackManifestChecked(true);
  100188. }
  100189. else {
  100190. if (disableManifestCheck) {
  100191. this._enableSceneOffline = true;
  100192. this._enableTexturesOffline = true;
  100193. this._manifestVersionFound = 1;
  100194. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  100195. _this._callbackManifestChecked(true);
  100196. });
  100197. }
  100198. else {
  100199. this._checkManifestFile();
  100200. }
  100201. }
  100202. }
  100203. Object.defineProperty(Database.prototype, "enableSceneOffline", {
  100204. /**
  100205. * Gets a boolean indicating if scene must be saved in the database
  100206. */
  100207. get: function () {
  100208. return this._enableSceneOffline;
  100209. },
  100210. enumerable: true,
  100211. configurable: true
  100212. });
  100213. Object.defineProperty(Database.prototype, "enableTexturesOffline", {
  100214. /**
  100215. * Gets a boolean indicating if textures must be saved in the database
  100216. */
  100217. get: function () {
  100218. return this._enableTexturesOffline;
  100219. },
  100220. enumerable: true,
  100221. configurable: true
  100222. });
  100223. Database.prototype._checkManifestFile = function () {
  100224. var _this = this;
  100225. var noManifestFile = function () {
  100226. _this._enableSceneOffline = false;
  100227. _this._enableTexturesOffline = false;
  100228. _this._callbackManifestChecked(false);
  100229. };
  100230. var timeStampUsed = false;
  100231. var manifestURL = this._currentSceneUrl + ".manifest";
  100232. var xhr = new XMLHttpRequest();
  100233. if (navigator.onLine) {
  100234. // Adding a timestamp to by-pass browsers' cache
  100235. timeStampUsed = true;
  100236. manifestURL = manifestURL + (manifestURL.match(/\?/) == null ? "?" : "&") + Date.now();
  100237. }
  100238. xhr.open("GET", manifestURL, true);
  100239. xhr.addEventListener("load", function () {
  100240. if (xhr.status === 200 || Database._ValidateXHRData(xhr, 1)) {
  100241. try {
  100242. var manifestFile = JSON.parse(xhr.response);
  100243. _this._enableSceneOffline = manifestFile.enableSceneOffline;
  100244. _this._enableTexturesOffline = manifestFile.enableTexturesOffline && Database.IsUASupportingBlobStorage;
  100245. if (manifestFile.version && !isNaN(parseInt(manifestFile.version))) {
  100246. _this._manifestVersionFound = manifestFile.version;
  100247. }
  100248. if (_this._callbackManifestChecked) {
  100249. _this._callbackManifestChecked(true);
  100250. }
  100251. }
  100252. catch (ex) {
  100253. noManifestFile();
  100254. }
  100255. }
  100256. else {
  100257. noManifestFile();
  100258. }
  100259. }, false);
  100260. xhr.addEventListener("error", function () {
  100261. if (timeStampUsed) {
  100262. timeStampUsed = false;
  100263. // Let's retry without the timeStamp
  100264. // It could fail when coupled with HTML5 Offline API
  100265. var retryManifestURL = _this._currentSceneUrl + ".manifest";
  100266. xhr.open("GET", retryManifestURL, true);
  100267. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  100268. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  100269. }
  100270. xhr.send();
  100271. }
  100272. else {
  100273. noManifestFile();
  100274. }
  100275. }, false);
  100276. try {
  100277. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  100278. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  100279. }
  100280. xhr.send();
  100281. }
  100282. catch (ex) {
  100283. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error on XHR send request.");
  100284. this._callbackManifestChecked(false);
  100285. }
  100286. };
  100287. /**
  100288. * Open the database and make it available
  100289. * @param successCallback defines the callback to call on success
  100290. * @param errorCallback defines the callback to call on error
  100291. */
  100292. Database.prototype.open = function (successCallback, errorCallback) {
  100293. var _this = this;
  100294. var handleError = function () {
  100295. _this._isSupported = false;
  100296. if (errorCallback) {
  100297. errorCallback();
  100298. }
  100299. };
  100300. if (!this._idbFactory || !(this._enableSceneOffline || this._enableTexturesOffline)) {
  100301. // Your browser doesn't support IndexedDB
  100302. this._isSupported = false;
  100303. if (errorCallback) {
  100304. errorCallback();
  100305. }
  100306. }
  100307. else {
  100308. // If the DB hasn't been opened or created yet
  100309. if (!this._db) {
  100310. this._hasReachedQuota = false;
  100311. this._isSupported = true;
  100312. var request = this._idbFactory.open("babylonjs", 1);
  100313. // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB
  100314. request.onerror = function () {
  100315. handleError();
  100316. };
  100317. // executes when a version change transaction cannot complete due to other active transactions
  100318. request.onblocked = function () {
  100319. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("IDB request blocked. Please reload the page.");
  100320. handleError();
  100321. };
  100322. // DB has been opened successfully
  100323. request.onsuccess = function () {
  100324. _this._db = request.result;
  100325. successCallback();
  100326. };
  100327. // Initialization of the DB. Creating Scenes & Textures stores
  100328. request.onupgradeneeded = function (event) {
  100329. _this._db = (event.target).result;
  100330. if (_this._db) {
  100331. try {
  100332. _this._db.createObjectStore("scenes", { keyPath: "sceneUrl" });
  100333. _this._db.createObjectStore("versions", { keyPath: "sceneUrl" });
  100334. _this._db.createObjectStore("textures", { keyPath: "textureUrl" });
  100335. }
  100336. catch (ex) {
  100337. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while creating object stores. Exception: " + ex.message);
  100338. handleError();
  100339. }
  100340. }
  100341. };
  100342. }
  100343. // DB has already been created and opened
  100344. else {
  100345. if (successCallback) {
  100346. successCallback();
  100347. }
  100348. }
  100349. }
  100350. };
  100351. /**
  100352. * Loads an image from the database
  100353. * @param url defines the url to load from
  100354. * @param image defines the target DOM image
  100355. */
  100356. Database.prototype.loadImage = function (url, image) {
  100357. var _this = this;
  100358. var completeURL = Database._ReturnFullUrlLocation(url);
  100359. var saveAndLoadImage = function () {
  100360. if (!_this._hasReachedQuota && _this._db !== null) {
  100361. // the texture is not yet in the DB, let's try to save it
  100362. _this._saveImageIntoDBAsync(completeURL, image);
  100363. }
  100364. // If the texture is not in the DB and we've reached the DB quota limit
  100365. // let's load it directly from the web
  100366. else {
  100367. image.src = url;
  100368. }
  100369. };
  100370. if (!this._mustUpdateRessources) {
  100371. this._loadImageFromDBAsync(completeURL, image, saveAndLoadImage);
  100372. }
  100373. // First time we're download the images or update requested in the manifest file by a version change
  100374. else {
  100375. saveAndLoadImage();
  100376. }
  100377. };
  100378. Database.prototype._loadImageFromDBAsync = function (url, image, notInDBCallback) {
  100379. if (this._isSupported && this._db !== null) {
  100380. var texture;
  100381. var transaction = this._db.transaction(["textures"]);
  100382. transaction.onabort = function () {
  100383. image.src = url;
  100384. };
  100385. transaction.oncomplete = function () {
  100386. var blobTextureURL;
  100387. if (texture) {
  100388. var URL = window.URL || window.webkitURL;
  100389. blobTextureURL = URL.createObjectURL(texture.data);
  100390. image.onerror = function () {
  100391. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading image from blob URL: " + blobTextureURL + " switching back to web url: " + url);
  100392. image.src = url;
  100393. };
  100394. image.src = blobTextureURL;
  100395. }
  100396. else {
  100397. notInDBCallback();
  100398. }
  100399. };
  100400. var getRequest = transaction.objectStore("textures").get(url);
  100401. getRequest.onsuccess = function (event) {
  100402. texture = (event.target).result;
  100403. };
  100404. getRequest.onerror = function () {
  100405. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading texture " + url + " from DB.");
  100406. image.src = url;
  100407. };
  100408. }
  100409. else {
  100410. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  100411. image.src = url;
  100412. }
  100413. };
  100414. Database.prototype._saveImageIntoDBAsync = function (url, image) {
  100415. var _this = this;
  100416. if (this._isSupported) {
  100417. // In case of error (type not supported or quota exceeded), we're at least sending back XHR data to allow texture loading later on
  100418. var generateBlobUrl = function () {
  100419. var blobTextureURL;
  100420. if (blob) {
  100421. var URL = window.URL || window.webkitURL;
  100422. try {
  100423. blobTextureURL = URL.createObjectURL(blob);
  100424. }
  100425. // Chrome is raising a type error if we're setting the oneTimeOnly parameter
  100426. catch (ex) {
  100427. blobTextureURL = URL.createObjectURL(blob);
  100428. }
  100429. }
  100430. if (blobTextureURL) {
  100431. image.src = blobTextureURL;
  100432. }
  100433. };
  100434. if (Database.IsUASupportingBlobStorage) { // Create XHR
  100435. var xhr = new XMLHttpRequest(), blob;
  100436. xhr.open("GET", url, true);
  100437. xhr.responseType = "blob";
  100438. xhr.addEventListener("load", function () {
  100439. if (xhr.status === 200 && _this._db) {
  100440. // Blob as response (XHR2)
  100441. blob = xhr.response;
  100442. var transaction = _this._db.transaction(["textures"], "readwrite");
  100443. // the transaction could abort because of a QuotaExceededError error
  100444. transaction.onabort = function (event) {
  100445. try {
  100446. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  100447. var srcElement = (event.srcElement || event.target);
  100448. var error = srcElement.error;
  100449. if (error && error.name === "QuotaExceededError") {
  100450. _this._hasReachedQuota = true;
  100451. }
  100452. }
  100453. catch (ex) { }
  100454. generateBlobUrl();
  100455. };
  100456. transaction.oncomplete = function () {
  100457. generateBlobUrl();
  100458. };
  100459. var newTexture = { textureUrl: url, data: blob };
  100460. try {
  100461. // Put the blob into the dabase
  100462. var addRequest = transaction.objectStore("textures").put(newTexture);
  100463. addRequest.onsuccess = function () {
  100464. };
  100465. addRequest.onerror = function () {
  100466. generateBlobUrl();
  100467. };
  100468. }
  100469. catch (ex) {
  100470. // "DataCloneError" generated by Chrome when you try to inject blob into IndexedDB
  100471. if (ex.code === 25) {
  100472. Database.IsUASupportingBlobStorage = false;
  100473. _this._enableTexturesOffline = false;
  100474. }
  100475. image.src = url;
  100476. }
  100477. }
  100478. else {
  100479. image.src = url;
  100480. }
  100481. }, false);
  100482. xhr.addEventListener("error", function () {
  100483. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in XHR request in BABYLON.Database.");
  100484. image.src = url;
  100485. }, false);
  100486. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].CustomRequestHeaders) {
  100487. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  100488. }
  100489. xhr.send();
  100490. }
  100491. else {
  100492. image.src = url;
  100493. }
  100494. }
  100495. else {
  100496. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  100497. image.src = url;
  100498. }
  100499. };
  100500. Database.prototype._checkVersionFromDB = function (url, versionLoaded) {
  100501. var _this = this;
  100502. var updateVersion = function () {
  100503. // the version is not yet in the DB or we need to update it
  100504. _this._saveVersionIntoDBAsync(url, versionLoaded);
  100505. };
  100506. this._loadVersionFromDBAsync(url, versionLoaded, updateVersion);
  100507. };
  100508. Database.prototype._loadVersionFromDBAsync = function (url, callback, updateInDBCallback) {
  100509. var _this = this;
  100510. if (this._isSupported && this._db) {
  100511. var version;
  100512. try {
  100513. var transaction = this._db.transaction(["versions"]);
  100514. transaction.oncomplete = function () {
  100515. if (version) {
  100516. // If the version in the JSON file is different from the version in DB
  100517. if (_this._manifestVersionFound !== version.data) {
  100518. _this._mustUpdateRessources = true;
  100519. updateInDBCallback();
  100520. }
  100521. else {
  100522. callback(version.data);
  100523. }
  100524. }
  100525. // version was not found in DB
  100526. else {
  100527. _this._mustUpdateRessources = true;
  100528. updateInDBCallback();
  100529. }
  100530. };
  100531. transaction.onabort = function () {
  100532. callback(-1);
  100533. };
  100534. var getRequest = transaction.objectStore("versions").get(url);
  100535. getRequest.onsuccess = function (event) {
  100536. version = (event.target).result;
  100537. };
  100538. getRequest.onerror = function () {
  100539. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading version for scene " + url + " from DB.");
  100540. callback(-1);
  100541. };
  100542. }
  100543. catch (ex) {
  100544. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (READ OP). Exception: " + ex.message);
  100545. callback(-1);
  100546. }
  100547. }
  100548. else {
  100549. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  100550. callback(-1);
  100551. }
  100552. };
  100553. Database.prototype._saveVersionIntoDBAsync = function (url, callback) {
  100554. var _this = this;
  100555. if (this._isSupported && !this._hasReachedQuota && this._db) {
  100556. try {
  100557. // Open a transaction to the database
  100558. var transaction = this._db.transaction(["versions"], "readwrite");
  100559. // the transaction could abort because of a QuotaExceededError error
  100560. transaction.onabort = function (event) {
  100561. try { //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  100562. var error = event.srcElement['error'];
  100563. if (error && error.name === "QuotaExceededError") {
  100564. _this._hasReachedQuota = true;
  100565. }
  100566. }
  100567. catch (ex) { }
  100568. callback(-1);
  100569. };
  100570. transaction.oncomplete = function () {
  100571. callback(_this._manifestVersionFound);
  100572. };
  100573. var newVersion = { sceneUrl: url, data: this._manifestVersionFound };
  100574. // Put the scene into the database
  100575. var addRequest = transaction.objectStore("versions").put(newVersion);
  100576. addRequest.onsuccess = function () {
  100577. };
  100578. addRequest.onerror = function () {
  100579. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add version request in BABYLON.Database.");
  100580. };
  100581. }
  100582. catch (ex) {
  100583. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + ex.message);
  100584. callback(-1);
  100585. }
  100586. }
  100587. else {
  100588. callback(-1);
  100589. }
  100590. };
  100591. /**
  100592. * Loads a file from database
  100593. * @param url defines the URL to load from
  100594. * @param sceneLoaded defines a callback to call on success
  100595. * @param progressCallBack defines a callback to call when progress changed
  100596. * @param errorCallback defines a callback to call on error
  100597. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  100598. */
  100599. Database.prototype.loadFile = function (url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer) {
  100600. var _this = this;
  100601. var completeUrl = Database._ReturnFullUrlLocation(url);
  100602. var saveAndLoadFile = function () {
  100603. // the scene is not yet in the DB, let's try to save it
  100604. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  100605. };
  100606. this._checkVersionFromDB(completeUrl, function (version) {
  100607. if (version !== -1) {
  100608. if (!_this._mustUpdateRessources) {
  100609. _this._loadFileAsync(completeUrl, sceneLoaded, saveAndLoadFile);
  100610. }
  100611. else {
  100612. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  100613. }
  100614. }
  100615. else {
  100616. if (errorCallback) {
  100617. errorCallback();
  100618. }
  100619. }
  100620. });
  100621. };
  100622. Database.prototype._loadFileAsync = function (url, callback, notInDBCallback) {
  100623. if (this._isSupported && this._db) {
  100624. var targetStore;
  100625. if (url.indexOf(".babylon") !== -1) {
  100626. targetStore = "scenes";
  100627. }
  100628. else {
  100629. targetStore = "textures";
  100630. }
  100631. var file;
  100632. var transaction = this._db.transaction([targetStore]);
  100633. transaction.oncomplete = function () {
  100634. if (file) {
  100635. callback(file.data);
  100636. }
  100637. // file was not found in DB
  100638. else {
  100639. notInDBCallback();
  100640. }
  100641. };
  100642. transaction.onabort = function () {
  100643. notInDBCallback();
  100644. };
  100645. var getRequest = transaction.objectStore(targetStore).get(url);
  100646. getRequest.onsuccess = function (event) {
  100647. file = (event.target).result;
  100648. };
  100649. getRequest.onerror = function () {
  100650. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading file " + url + " from DB.");
  100651. notInDBCallback();
  100652. };
  100653. }
  100654. else {
  100655. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  100656. callback();
  100657. }
  100658. };
  100659. Database.prototype._saveFileAsync = function (url, callback, progressCallback, useArrayBuffer, errorCallback) {
  100660. var _this = this;
  100661. if (this._isSupported) {
  100662. var targetStore;
  100663. if (url.indexOf(".babylon") !== -1) {
  100664. targetStore = "scenes";
  100665. }
  100666. else {
  100667. targetStore = "textures";
  100668. }
  100669. // Create XHR
  100670. var xhr = new XMLHttpRequest();
  100671. var fileData;
  100672. xhr.open("GET", url + "?" + Date.now(), true);
  100673. if (useArrayBuffer) {
  100674. xhr.responseType = "arraybuffer";
  100675. }
  100676. if (progressCallback) {
  100677. xhr.onprogress = progressCallback;
  100678. }
  100679. xhr.addEventListener("load", function () {
  100680. if (xhr.status === 200 || (xhr.status < 400 && Database._ValidateXHRData(xhr, !useArrayBuffer ? 1 : 6))) {
  100681. // Blob as response (XHR2)
  100682. fileData = !useArrayBuffer ? xhr.responseText : xhr.response;
  100683. if (!_this._hasReachedQuota && _this._db) {
  100684. // Open a transaction to the database
  100685. var transaction = _this._db.transaction([targetStore], "readwrite");
  100686. // the transaction could abort because of a QuotaExceededError error
  100687. transaction.onabort = function (event) {
  100688. try {
  100689. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  100690. var error = event.srcElement['error'];
  100691. if (error && error.name === "QuotaExceededError") {
  100692. _this._hasReachedQuota = true;
  100693. }
  100694. }
  100695. catch (ex) { }
  100696. callback(fileData);
  100697. };
  100698. transaction.oncomplete = function () {
  100699. callback(fileData);
  100700. };
  100701. var newFile;
  100702. if (targetStore === "scenes") {
  100703. newFile = { sceneUrl: url, data: fileData, version: _this._manifestVersionFound };
  100704. }
  100705. else {
  100706. newFile = { textureUrl: url, data: fileData };
  100707. }
  100708. try {
  100709. // Put the scene into the database
  100710. var addRequest = transaction.objectStore(targetStore).put(newFile);
  100711. addRequest.onsuccess = function () {
  100712. };
  100713. addRequest.onerror = function () {
  100714. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add file request in BABYLON.Database.");
  100715. };
  100716. }
  100717. catch (ex) {
  100718. callback(fileData);
  100719. }
  100720. }
  100721. else {
  100722. callback(fileData);
  100723. }
  100724. }
  100725. else {
  100726. if (xhr.status >= 400 && errorCallback) {
  100727. errorCallback(xhr);
  100728. }
  100729. else {
  100730. callback();
  100731. }
  100732. }
  100733. }, false);
  100734. xhr.addEventListener("error", function () {
  100735. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("error on XHR request.");
  100736. callback();
  100737. }, false);
  100738. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  100739. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  100740. }
  100741. xhr.send();
  100742. }
  100743. else {
  100744. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or Babylon.js Database is not open.");
  100745. callback();
  100746. }
  100747. };
  100748. /**
  100749. * Validates if xhr data is correct
  100750. * @param xhr defines the request to validate
  100751. * @param dataType defines the expected data type
  100752. * @returns true if data is correct
  100753. */
  100754. Database._ValidateXHRData = function (xhr, dataType) {
  100755. // 1 for text (.babylon, manifest and shaders), 2 for TGA, 4 for DDS, 7 for all
  100756. if (dataType === void 0) { dataType = 7; }
  100757. try {
  100758. if (dataType & 1) {
  100759. if (xhr.responseText && xhr.responseText.length > 0) {
  100760. return true;
  100761. }
  100762. else if (dataType === 1) {
  100763. return false;
  100764. }
  100765. }
  100766. if (dataType & 2) {
  100767. // Check header width and height since there is no "TGA" magic number
  100768. var tgaHeader = _Misc_tga__WEBPACK_IMPORTED_MODULE_2__["TGATools"].GetTGAHeader(xhr.response);
  100769. if (tgaHeader.width && tgaHeader.height && tgaHeader.width > 0 && tgaHeader.height > 0) {
  100770. return true;
  100771. }
  100772. else if (dataType === 2) {
  100773. return false;
  100774. }
  100775. }
  100776. if (dataType & 4) {
  100777. // Check for the "DDS" magic number
  100778. var ddsHeader = new Uint8Array(xhr.response, 0, 3);
  100779. if (ddsHeader[0] === 68 && ddsHeader[1] === 68 && ddsHeader[2] === 83) {
  100780. return true;
  100781. }
  100782. else {
  100783. return false;
  100784. }
  100785. }
  100786. }
  100787. catch (e) {
  100788. // Global protection
  100789. }
  100790. return false;
  100791. };
  100792. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  100793. Database.IsUASupportingBlobStorage = true;
  100794. /**
  100795. * Gets a boolean indicating if Database storate is enabled (off by default)
  100796. */
  100797. Database.IDBStorageEnabled = false;
  100798. Database._ParseURL = function (url) {
  100799. var a = document.createElement('a');
  100800. a.href = url;
  100801. var urlWithoutHash = url.substring(0, url.lastIndexOf("#"));
  100802. var fileName = url.substring(urlWithoutHash.lastIndexOf("/") + 1, url.length);
  100803. var absLocation = url.substring(0, url.indexOf(fileName, 0));
  100804. return absLocation;
  100805. };
  100806. Database._ReturnFullUrlLocation = function (url) {
  100807. if (url.indexOf("http:/") === -1 && url.indexOf("https:/") === -1) {
  100808. return (Database._ParseURL(window.location.href) + url);
  100809. }
  100810. else {
  100811. return url;
  100812. }
  100813. };
  100814. return Database;
  100815. }());
  100816. /***/ }),
  100817. /***/ "./Offline/index.ts":
  100818. /*!**************************!*\
  100819. !*** ./Offline/index.ts ***!
  100820. \**************************/
  100821. /*! exports provided: Database */
  100822. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100823. "use strict";
  100824. __webpack_require__.r(__webpack_exports__);
  100825. /* harmony import */ var _database__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database */ "./Offline/database.ts");
  100826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _database__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  100827. /***/ }),
  100828. /***/ "./Particles/EmitterTypes/boxParticleEmitter.ts":
  100829. /*!******************************************************!*\
  100830. !*** ./Particles/EmitterTypes/boxParticleEmitter.ts ***!
  100831. \******************************************************/
  100832. /*! exports provided: BoxParticleEmitter */
  100833. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100834. "use strict";
  100835. __webpack_require__.r(__webpack_exports__);
  100836. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return BoxParticleEmitter; });
  100837. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  100838. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  100839. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  100840. /**
  100841. * Particle emitter emitting particles from the inside of a box.
  100842. * It emits the particles randomly between 2 given directions.
  100843. */
  100844. var BoxParticleEmitter = /** @class */ (function () {
  100845. /**
  100846. * Creates a new instance BoxParticleEmitter
  100847. */
  100848. function BoxParticleEmitter() {
  100849. /**
  100850. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  100851. */
  100852. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  100853. /**
  100854. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  100855. */
  100856. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  100857. /**
  100858. * 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.
  100859. */
  100860. this.minEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-0.5, -0.5, -0.5);
  100861. /**
  100862. * 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.
  100863. */
  100864. this.maxEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.5, 0.5, 0.5);
  100865. }
  100866. /**
  100867. * Called by the particle System when the direction is computed for the created particle.
  100868. * @param worldMatrix is the world matrix of the particle system
  100869. * @param directionToUpdate is the direction vector to update with the result
  100870. * @param particle is the particle we are computed the direction for
  100871. */
  100872. BoxParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  100873. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  100874. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  100875. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  100876. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  100877. };
  100878. /**
  100879. * Called by the particle System when the position is computed for the created particle.
  100880. * @param worldMatrix is the world matrix of the particle system
  100881. * @param positionToUpdate is the position vector to update with the result
  100882. * @param particle is the particle we are computed the position for
  100883. */
  100884. BoxParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  100885. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.x, this.maxEmitBox.x);
  100886. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.y, this.maxEmitBox.y);
  100887. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
  100888. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  100889. };
  100890. /**
  100891. * Clones the current emitter and returns a copy of it
  100892. * @returns the new emitter
  100893. */
  100894. BoxParticleEmitter.prototype.clone = function () {
  100895. var newOne = new BoxParticleEmitter();
  100896. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  100897. return newOne;
  100898. };
  100899. /**
  100900. * Called by the GPUParticleSystem to setup the update shader
  100901. * @param effect defines the update shader
  100902. */
  100903. BoxParticleEmitter.prototype.applyToShader = function (effect) {
  100904. effect.setVector3("direction1", this.direction1);
  100905. effect.setVector3("direction2", this.direction2);
  100906. effect.setVector3("minEmitBox", this.minEmitBox);
  100907. effect.setVector3("maxEmitBox", this.maxEmitBox);
  100908. };
  100909. /**
  100910. * Returns a string to use to update the GPU particles update shader
  100911. * @returns a string containng the defines string
  100912. */
  100913. BoxParticleEmitter.prototype.getEffectDefines = function () {
  100914. return "#define BOXEMITTER";
  100915. };
  100916. /**
  100917. * Returns the string "BoxParticleEmitter"
  100918. * @returns a string containing the class name
  100919. */
  100920. BoxParticleEmitter.prototype.getClassName = function () {
  100921. return "BoxParticleEmitter";
  100922. };
  100923. /**
  100924. * Serializes the particle system to a JSON object.
  100925. * @returns the JSON object
  100926. */
  100927. BoxParticleEmitter.prototype.serialize = function () {
  100928. var serializationObject = {};
  100929. serializationObject.type = this.getClassName();
  100930. serializationObject.direction1 = this.direction1.asArray();
  100931. serializationObject.direction2 = this.direction2.asArray();
  100932. serializationObject.minEmitBox = this.minEmitBox.asArray();
  100933. serializationObject.maxEmitBox = this.maxEmitBox.asArray();
  100934. return serializationObject;
  100935. };
  100936. /**
  100937. * Parse properties from a JSON object
  100938. * @param serializationObject defines the JSON object
  100939. */
  100940. BoxParticleEmitter.prototype.parse = function (serializationObject) {
  100941. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  100942. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  100943. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.minEmitBox, 0, this.minEmitBox);
  100944. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.maxEmitBox, 0, this.maxEmitBox);
  100945. };
  100946. return BoxParticleEmitter;
  100947. }());
  100948. /***/ }),
  100949. /***/ "./Particles/EmitterTypes/coneParticleEmitter.ts":
  100950. /*!*******************************************************!*\
  100951. !*** ./Particles/EmitterTypes/coneParticleEmitter.ts ***!
  100952. \*******************************************************/
  100953. /*! exports provided: ConeParticleEmitter */
  100954. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100955. "use strict";
  100956. __webpack_require__.r(__webpack_exports__);
  100957. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return ConeParticleEmitter; });
  100958. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  100959. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  100960. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  100961. /**
  100962. * Particle emitter emitting particles from the inside of a cone.
  100963. * It emits the particles alongside the cone volume from the base to the particle.
  100964. * The emission direction might be randomized.
  100965. */
  100966. var ConeParticleEmitter = /** @class */ (function () {
  100967. /**
  100968. * Creates a new instance ConeParticleEmitter
  100969. * @param radius the radius of the emission cone (1 by default)
  100970. * @param angles the cone base angle (PI by default)
  100971. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  100972. */
  100973. function ConeParticleEmitter(radius, angle,
  100974. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  100975. directionRandomizer) {
  100976. if (radius === void 0) { radius = 1; }
  100977. if (angle === void 0) { angle = Math.PI; }
  100978. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  100979. this.directionRandomizer = directionRandomizer;
  100980. /**
  100981. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  100982. */
  100983. this.radiusRange = 1;
  100984. /**
  100985. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  100986. */
  100987. this.heightRange = 1;
  100988. /**
  100989. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  100990. */
  100991. this.emitFromSpawnPointOnly = false;
  100992. this.angle = angle;
  100993. this.radius = radius;
  100994. }
  100995. Object.defineProperty(ConeParticleEmitter.prototype, "radius", {
  100996. /**
  100997. * Gets or sets the radius of the emission cone
  100998. */
  100999. get: function () {
  101000. return this._radius;
  101001. },
  101002. set: function (value) {
  101003. this._radius = value;
  101004. this._buildHeight();
  101005. },
  101006. enumerable: true,
  101007. configurable: true
  101008. });
  101009. Object.defineProperty(ConeParticleEmitter.prototype, "angle", {
  101010. /**
  101011. * Gets or sets the angle of the emission cone
  101012. */
  101013. get: function () {
  101014. return this._angle;
  101015. },
  101016. set: function (value) {
  101017. this._angle = value;
  101018. this._buildHeight();
  101019. },
  101020. enumerable: true,
  101021. configurable: true
  101022. });
  101023. ConeParticleEmitter.prototype._buildHeight = function () {
  101024. if (this._angle !== 0) {
  101025. this._height = this._radius / Math.tan(this._angle / 2);
  101026. }
  101027. else {
  101028. this._height = 1;
  101029. }
  101030. };
  101031. /**
  101032. * Called by the particle System when the direction is computed for the created particle.
  101033. * @param worldMatrix is the world matrix of the particle system
  101034. * @param directionToUpdate is the direction vector to update with the result
  101035. * @param particle is the particle we are computed the direction for
  101036. */
  101037. ConeParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101038. if (Math.abs(Math.cos(this._angle)) === 1.0) {
  101039. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(0, 1.0, 0, worldMatrix, directionToUpdate);
  101040. }
  101041. else {
  101042. // measure the direction Vector from the emitter to the particle.
  101043. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  101044. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101045. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101046. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101047. direction.x += randX;
  101048. direction.y += randY;
  101049. direction.z += randZ;
  101050. direction.normalize();
  101051. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  101052. }
  101053. };
  101054. /**
  101055. * Called by the particle System when the position is computed for the created particle.
  101056. * @param worldMatrix is the world matrix of the particle system
  101057. * @param positionToUpdate is the position vector to update with the result
  101058. * @param particle is the particle we are computed the position for
  101059. */
  101060. ConeParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  101061. var s = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, Math.PI * 2);
  101062. var h;
  101063. if (!this.emitFromSpawnPointOnly) {
  101064. h = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.heightRange);
  101065. // Better distribution in a cone at normal angles.
  101066. h = 1 - h * h;
  101067. }
  101068. else {
  101069. h = 0.0001;
  101070. }
  101071. var radius = this._radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this._radius * this.radiusRange);
  101072. radius = radius * h;
  101073. var randX = radius * Math.sin(s);
  101074. var randZ = radius * Math.cos(s);
  101075. var randY = h * this._height;
  101076. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  101077. };
  101078. /**
  101079. * Clones the current emitter and returns a copy of it
  101080. * @returns the new emitter
  101081. */
  101082. ConeParticleEmitter.prototype.clone = function () {
  101083. var newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);
  101084. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  101085. return newOne;
  101086. };
  101087. /**
  101088. * Called by the GPUParticleSystem to setup the update shader
  101089. * @param effect defines the update shader
  101090. */
  101091. ConeParticleEmitter.prototype.applyToShader = function (effect) {
  101092. effect.setFloat2("radius", this._radius, this.radiusRange);
  101093. effect.setFloat("coneAngle", this._angle);
  101094. effect.setFloat2("height", this._height, this.heightRange);
  101095. effect.setFloat("directionRandomizer", this.directionRandomizer);
  101096. };
  101097. /**
  101098. * Returns a string to use to update the GPU particles update shader
  101099. * @returns a string containng the defines string
  101100. */
  101101. ConeParticleEmitter.prototype.getEffectDefines = function () {
  101102. var defines = "#define CONEEMITTER";
  101103. if (this.emitFromSpawnPointOnly) {
  101104. defines += "\n#define CONEEMITTERSPAWNPOINT";
  101105. }
  101106. return defines;
  101107. };
  101108. /**
  101109. * Returns the string "ConeParticleEmitter"
  101110. * @returns a string containing the class name
  101111. */
  101112. ConeParticleEmitter.prototype.getClassName = function () {
  101113. return "ConeParticleEmitter";
  101114. };
  101115. /**
  101116. * Serializes the particle system to a JSON object.
  101117. * @returns the JSON object
  101118. */
  101119. ConeParticleEmitter.prototype.serialize = function () {
  101120. var serializationObject = {};
  101121. serializationObject.type = this.getClassName();
  101122. serializationObject.radius = this._radius;
  101123. serializationObject.angle = this._angle;
  101124. serializationObject.directionRandomizer = this.directionRandomizer;
  101125. return serializationObject;
  101126. };
  101127. /**
  101128. * Parse properties from a JSON object
  101129. * @param serializationObject defines the JSON object
  101130. */
  101131. ConeParticleEmitter.prototype.parse = function (serializationObject) {
  101132. this.radius = serializationObject.radius;
  101133. this.angle = serializationObject.angle;
  101134. this.directionRandomizer = serializationObject.directionRandomizer;
  101135. };
  101136. return ConeParticleEmitter;
  101137. }());
  101138. /***/ }),
  101139. /***/ "./Particles/EmitterTypes/cylinderParticleEmitter.ts":
  101140. /*!***********************************************************!*\
  101141. !*** ./Particles/EmitterTypes/cylinderParticleEmitter.ts ***!
  101142. \***********************************************************/
  101143. /*! exports provided: CylinderParticleEmitter, CylinderDirectedParticleEmitter */
  101144. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101145. "use strict";
  101146. __webpack_require__.r(__webpack_exports__);
  101147. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return CylinderParticleEmitter; });
  101148. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return CylinderDirectedParticleEmitter; });
  101149. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  101150. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  101151. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101152. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  101153. /**
  101154. * Particle emitter emitting particles from the inside of a cylinder.
  101155. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  101156. */
  101157. var CylinderParticleEmitter = /** @class */ (function () {
  101158. /**
  101159. * Creates a new instance CylinderParticleEmitter
  101160. * @param radius the radius of the emission cylinder (1 by default)
  101161. * @param height the height of the emission cylinder (1 by default)
  101162. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101163. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  101164. */
  101165. function CylinderParticleEmitter(
  101166. /**
  101167. * The radius of the emission cylinder.
  101168. */
  101169. radius,
  101170. /**
  101171. * The height of the emission cylinder.
  101172. */
  101173. height,
  101174. /**
  101175. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101176. */
  101177. radiusRange,
  101178. /**
  101179. * How much to randomize the particle direction [0-1].
  101180. */
  101181. directionRandomizer) {
  101182. if (radius === void 0) { radius = 1; }
  101183. if (height === void 0) { height = 1; }
  101184. if (radiusRange === void 0) { radiusRange = 1; }
  101185. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  101186. this.radius = radius;
  101187. this.height = height;
  101188. this.radiusRange = radiusRange;
  101189. this.directionRandomizer = directionRandomizer;
  101190. }
  101191. /**
  101192. * Called by the particle System when the direction is computed for the created particle.
  101193. * @param worldMatrix is the world matrix of the particle system
  101194. * @param directionToUpdate is the direction vector to update with the result
  101195. * @param particle is the particle we are computed the direction for
  101196. */
  101197. CylinderParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101198. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  101199. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2);
  101200. var angle = Math.atan2(direction.x, direction.z);
  101201. angle += _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer;
  101202. direction.y = randY; // set direction y to rand y to mirror normal of cylinder surface
  101203. direction.x = Math.sin(angle);
  101204. direction.z = Math.cos(angle);
  101205. direction.normalize();
  101206. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  101207. };
  101208. /**
  101209. * Called by the particle System when the position is computed for the created particle.
  101210. * @param worldMatrix is the world matrix of the particle system
  101211. * @param positionToUpdate is the position vector to update with the result
  101212. * @param particle is the particle we are computed the position for
  101213. */
  101214. CylinderParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  101215. var yPos = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.height / 2, this.height / 2);
  101216. var angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  101217. // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html
  101218. var radiusDistribution = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1);
  101219. var positionRadius = Math.sqrt(radiusDistribution) * this.radius;
  101220. var xPos = positionRadius * Math.cos(angle);
  101221. var zPos = positionRadius * Math.sin(angle);
  101222. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, worldMatrix, positionToUpdate);
  101223. };
  101224. /**
  101225. * Clones the current emitter and returns a copy of it
  101226. * @returns the new emitter
  101227. */
  101228. CylinderParticleEmitter.prototype.clone = function () {
  101229. var newOne = new CylinderParticleEmitter(this.radius, this.directionRandomizer);
  101230. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  101231. return newOne;
  101232. };
  101233. /**
  101234. * Called by the GPUParticleSystem to setup the update shader
  101235. * @param effect defines the update shader
  101236. */
  101237. CylinderParticleEmitter.prototype.applyToShader = function (effect) {
  101238. effect.setFloat("radius", this.radius);
  101239. effect.setFloat("height", this.height);
  101240. effect.setFloat("radiusRange", this.radiusRange);
  101241. effect.setFloat("directionRandomizer", this.directionRandomizer);
  101242. };
  101243. /**
  101244. * Returns a string to use to update the GPU particles update shader
  101245. * @returns a string containng the defines string
  101246. */
  101247. CylinderParticleEmitter.prototype.getEffectDefines = function () {
  101248. return "#define CYLINDEREMITTER";
  101249. };
  101250. /**
  101251. * Returns the string "CylinderParticleEmitter"
  101252. * @returns a string containing the class name
  101253. */
  101254. CylinderParticleEmitter.prototype.getClassName = function () {
  101255. return "CylinderParticleEmitter";
  101256. };
  101257. /**
  101258. * Serializes the particle system to a JSON object.
  101259. * @returns the JSON object
  101260. */
  101261. CylinderParticleEmitter.prototype.serialize = function () {
  101262. var serializationObject = {};
  101263. serializationObject.type = this.getClassName();
  101264. serializationObject.radius = this.radius;
  101265. serializationObject.height = this.height;
  101266. serializationObject.radiusRange = this.radiusRange;
  101267. serializationObject.directionRandomizer = this.directionRandomizer;
  101268. return serializationObject;
  101269. };
  101270. /**
  101271. * Parse properties from a JSON object
  101272. * @param serializationObject defines the JSON object
  101273. */
  101274. CylinderParticleEmitter.prototype.parse = function (serializationObject) {
  101275. this.radius = serializationObject.radius;
  101276. this.height = serializationObject.height;
  101277. this.radiusRange = serializationObject.radiusRange;
  101278. this.directionRandomizer = serializationObject.directionRandomizer;
  101279. };
  101280. return CylinderParticleEmitter;
  101281. }());
  101282. /**
  101283. * Particle emitter emitting particles from the inside of a cylinder.
  101284. * It emits the particles randomly between two vectors.
  101285. */
  101286. var CylinderDirectedParticleEmitter = /** @class */ (function (_super) {
  101287. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderDirectedParticleEmitter, _super);
  101288. /**
  101289. * Creates a new instance CylinderDirectedParticleEmitter
  101290. * @param radius the radius of the emission cylinder (1 by default)
  101291. * @param height the height of the emission cylinder (1 by default)
  101292. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101293. * @param direction1 the min limit of the emission direction (up vector by default)
  101294. * @param direction2 the max limit of the emission direction (up vector by default)
  101295. */
  101296. function CylinderDirectedParticleEmitter(radius, height, radiusRange,
  101297. /**
  101298. * The min limit of the emission direction.
  101299. */
  101300. direction1,
  101301. /**
  101302. * The max limit of the emission direction.
  101303. */
  101304. direction2) {
  101305. if (radius === void 0) { radius = 1; }
  101306. if (height === void 0) { height = 1; }
  101307. if (radiusRange === void 0) { radiusRange = 1; }
  101308. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  101309. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  101310. var _this = _super.call(this, radius, height, radiusRange) || this;
  101311. _this.direction1 = direction1;
  101312. _this.direction2 = direction2;
  101313. return _this;
  101314. }
  101315. /**
  101316. * Called by the particle System when the direction is computed for the created particle.
  101317. * @param worldMatrix is the world matrix of the particle system
  101318. * @param directionToUpdate is the direction vector to update with the result
  101319. * @param particle is the particle we are computed the direction for
  101320. */
  101321. CylinderDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101322. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  101323. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  101324. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  101325. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  101326. };
  101327. /**
  101328. * Clones the current emitter and returns a copy of it
  101329. * @returns the new emitter
  101330. */
  101331. CylinderDirectedParticleEmitter.prototype.clone = function () {
  101332. var newOne = new CylinderDirectedParticleEmitter(this.radius, this.height, this.radiusRange, this.direction1, this.direction2);
  101333. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  101334. return newOne;
  101335. };
  101336. /**
  101337. * Called by the GPUParticleSystem to setup the update shader
  101338. * @param effect defines the update shader
  101339. */
  101340. CylinderDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  101341. effect.setFloat("radius", this.radius);
  101342. effect.setFloat("height", this.height);
  101343. effect.setFloat("radiusRange", this.radiusRange);
  101344. effect.setVector3("direction1", this.direction1);
  101345. effect.setVector3("direction2", this.direction2);
  101346. };
  101347. /**
  101348. * Returns a string to use to update the GPU particles update shader
  101349. * @returns a string containng the defines string
  101350. */
  101351. CylinderDirectedParticleEmitter.prototype.getEffectDefines = function () {
  101352. return "#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER";
  101353. };
  101354. /**
  101355. * Returns the string "CylinderDirectedParticleEmitter"
  101356. * @returns a string containing the class name
  101357. */
  101358. CylinderDirectedParticleEmitter.prototype.getClassName = function () {
  101359. return "CylinderDirectedParticleEmitter";
  101360. };
  101361. /**
  101362. * Serializes the particle system to a JSON object.
  101363. * @returns the JSON object
  101364. */
  101365. CylinderDirectedParticleEmitter.prototype.serialize = function () {
  101366. var serializationObject = _super.prototype.serialize.call(this);
  101367. serializationObject.direction1 = this.direction1.asArray();
  101368. serializationObject.direction2 = this.direction2.asArray();
  101369. return serializationObject;
  101370. };
  101371. /**
  101372. * Parse properties from a JSON object
  101373. * @param serializationObject defines the JSON object
  101374. */
  101375. CylinderDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  101376. _super.prototype.parse.call(this, serializationObject);
  101377. this.direction1.copyFrom(serializationObject.direction1);
  101378. this.direction2.copyFrom(serializationObject.direction2);
  101379. };
  101380. return CylinderDirectedParticleEmitter;
  101381. }(CylinderParticleEmitter));
  101382. /***/ }),
  101383. /***/ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts":
  101384. /*!**************************************************************!*\
  101385. !*** ./Particles/EmitterTypes/hemisphericParticleEmitter.ts ***!
  101386. \**************************************************************/
  101387. /*! exports provided: HemisphericParticleEmitter */
  101388. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101389. "use strict";
  101390. __webpack_require__.r(__webpack_exports__);
  101391. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return HemisphericParticleEmitter; });
  101392. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  101393. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  101394. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101395. /**
  101396. * Particle emitter emitting particles from the inside of a hemisphere.
  101397. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  101398. */
  101399. var HemisphericParticleEmitter = /** @class */ (function () {
  101400. /**
  101401. * Creates a new instance HemisphericParticleEmitter
  101402. * @param radius the radius of the emission hemisphere (1 by default)
  101403. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101404. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  101405. */
  101406. function HemisphericParticleEmitter(
  101407. /**
  101408. * The radius of the emission hemisphere.
  101409. */
  101410. radius,
  101411. /**
  101412. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101413. */
  101414. radiusRange,
  101415. /**
  101416. * How much to randomize the particle direction [0-1].
  101417. */
  101418. directionRandomizer) {
  101419. if (radius === void 0) { radius = 1; }
  101420. if (radiusRange === void 0) { radiusRange = 1; }
  101421. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  101422. this.radius = radius;
  101423. this.radiusRange = radiusRange;
  101424. this.directionRandomizer = directionRandomizer;
  101425. }
  101426. /**
  101427. * Called by the particle System when the direction is computed for the created particle.
  101428. * @param worldMatrix is the world matrix of the particle system
  101429. * @param directionToUpdate is the direction vector to update with the result
  101430. * @param particle is the particle we are computed the direction for
  101431. */
  101432. HemisphericParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101433. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  101434. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101435. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101436. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101437. direction.x += randX;
  101438. direction.y += randY;
  101439. direction.z += randZ;
  101440. direction.normalize();
  101441. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  101442. };
  101443. /**
  101444. * Called by the particle System when the position is computed for the created particle.
  101445. * @param worldMatrix is the world matrix of the particle system
  101446. * @param positionToUpdate is the position vector to update with the result
  101447. * @param particle is the particle we are computed the position for
  101448. */
  101449. HemisphericParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  101450. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  101451. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  101452. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  101453. var theta = Math.acos(2 * v - 1);
  101454. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  101455. var randY = randRadius * Math.cos(theta);
  101456. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  101457. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, Math.abs(randY), randZ, worldMatrix, positionToUpdate);
  101458. };
  101459. /**
  101460. * Clones the current emitter and returns a copy of it
  101461. * @returns the new emitter
  101462. */
  101463. HemisphericParticleEmitter.prototype.clone = function () {
  101464. var newOne = new HemisphericParticleEmitter(this.radius, this.directionRandomizer);
  101465. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  101466. return newOne;
  101467. };
  101468. /**
  101469. * Called by the GPUParticleSystem to setup the update shader
  101470. * @param effect defines the update shader
  101471. */
  101472. HemisphericParticleEmitter.prototype.applyToShader = function (effect) {
  101473. effect.setFloat("radius", this.radius);
  101474. effect.setFloat("radiusRange", this.radiusRange);
  101475. effect.setFloat("directionRandomizer", this.directionRandomizer);
  101476. };
  101477. /**
  101478. * Returns a string to use to update the GPU particles update shader
  101479. * @returns a string containng the defines string
  101480. */
  101481. HemisphericParticleEmitter.prototype.getEffectDefines = function () {
  101482. return "#define HEMISPHERICEMITTER";
  101483. };
  101484. /**
  101485. * Returns the string "HemisphericParticleEmitter"
  101486. * @returns a string containing the class name
  101487. */
  101488. HemisphericParticleEmitter.prototype.getClassName = function () {
  101489. return "HemisphericParticleEmitter";
  101490. };
  101491. /**
  101492. * Serializes the particle system to a JSON object.
  101493. * @returns the JSON object
  101494. */
  101495. HemisphericParticleEmitter.prototype.serialize = function () {
  101496. var serializationObject = {};
  101497. serializationObject.type = this.getClassName();
  101498. serializationObject.radius = this.radius;
  101499. serializationObject.radiusRange = this.radiusRange;
  101500. serializationObject.directionRandomizer = this.directionRandomizer;
  101501. return serializationObject;
  101502. };
  101503. /**
  101504. * Parse properties from a JSON object
  101505. * @param serializationObject defines the JSON object
  101506. */
  101507. HemisphericParticleEmitter.prototype.parse = function (serializationObject) {
  101508. this.radius = serializationObject.radius;
  101509. this.radiusRange = serializationObject.radiusRange;
  101510. this.directionRandomizer = serializationObject.directionRandomizer;
  101511. };
  101512. return HemisphericParticleEmitter;
  101513. }());
  101514. /***/ }),
  101515. /***/ "./Particles/EmitterTypes/index.ts":
  101516. /*!*****************************************!*\
  101517. !*** ./Particles/EmitterTypes/index.ts ***!
  101518. \*****************************************/
  101519. /*! exports provided: BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  101520. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101521. "use strict";
  101522. __webpack_require__.r(__webpack_exports__);
  101523. /* harmony import */ var _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  101524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  101525. /* harmony import */ var _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./coneParticleEmitter */ "./Particles/EmitterTypes/coneParticleEmitter.ts");
  101526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  101527. /* harmony import */ var _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cylinderParticleEmitter */ "./Particles/EmitterTypes/cylinderParticleEmitter.ts");
  101528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"]; });
  101529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"]; });
  101530. /* harmony import */ var _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hemisphericParticleEmitter */ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts");
  101531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__["HemisphericParticleEmitter"]; });
  101532. /* harmony import */ var _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pointParticleEmitter */ "./Particles/EmitterTypes/pointParticleEmitter.ts");
  101533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__["PointParticleEmitter"]; });
  101534. /* harmony import */ var _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sphereParticleEmitter */ "./Particles/EmitterTypes/sphereParticleEmitter.ts");
  101535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereParticleEmitter"]; });
  101536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereDirectedParticleEmitter"]; });
  101537. /***/ }),
  101538. /***/ "./Particles/EmitterTypes/pointParticleEmitter.ts":
  101539. /*!********************************************************!*\
  101540. !*** ./Particles/EmitterTypes/pointParticleEmitter.ts ***!
  101541. \********************************************************/
  101542. /*! exports provided: PointParticleEmitter */
  101543. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101544. "use strict";
  101545. __webpack_require__.r(__webpack_exports__);
  101546. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return PointParticleEmitter; });
  101547. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  101548. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  101549. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101550. /**
  101551. * Particle emitter emitting particles from a point.
  101552. * It emits the particles randomly between 2 given directions.
  101553. */
  101554. var PointParticleEmitter = /** @class */ (function () {
  101555. /**
  101556. * Creates a new instance PointParticleEmitter
  101557. */
  101558. function PointParticleEmitter() {
  101559. /**
  101560. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101561. */
  101562. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  101563. /**
  101564. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101565. */
  101566. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  101567. }
  101568. /**
  101569. * Called by the particle System when the direction is computed for the created particle.
  101570. * @param worldMatrix is the world matrix of the particle system
  101571. * @param directionToUpdate is the direction vector to update with the result
  101572. * @param particle is the particle we are computed the direction for
  101573. */
  101574. PointParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101575. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  101576. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  101577. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  101578. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  101579. };
  101580. /**
  101581. * Called by the particle System when the position is computed for the created particle.
  101582. * @param worldMatrix is the world matrix of the particle system
  101583. * @param positionToUpdate is the position vector to update with the result
  101584. * @param particle is the particle we are computed the position for
  101585. */
  101586. PointParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  101587. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0, 0, 0, worldMatrix, positionToUpdate);
  101588. };
  101589. /**
  101590. * Clones the current emitter and returns a copy of it
  101591. * @returns the new emitter
  101592. */
  101593. PointParticleEmitter.prototype.clone = function () {
  101594. var newOne = new PointParticleEmitter();
  101595. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  101596. return newOne;
  101597. };
  101598. /**
  101599. * Called by the GPUParticleSystem to setup the update shader
  101600. * @param effect defines the update shader
  101601. */
  101602. PointParticleEmitter.prototype.applyToShader = function (effect) {
  101603. effect.setVector3("direction1", this.direction1);
  101604. effect.setVector3("direction2", this.direction2);
  101605. };
  101606. /**
  101607. * Returns a string to use to update the GPU particles update shader
  101608. * @returns a string containng the defines string
  101609. */
  101610. PointParticleEmitter.prototype.getEffectDefines = function () {
  101611. return "#define POINTEMITTER";
  101612. };
  101613. /**
  101614. * Returns the string "PointParticleEmitter"
  101615. * @returns a string containing the class name
  101616. */
  101617. PointParticleEmitter.prototype.getClassName = function () {
  101618. return "PointParticleEmitter";
  101619. };
  101620. /**
  101621. * Serializes the particle system to a JSON object.
  101622. * @returns the JSON object
  101623. */
  101624. PointParticleEmitter.prototype.serialize = function () {
  101625. var serializationObject = {};
  101626. serializationObject.type = this.getClassName();
  101627. serializationObject.direction1 = this.direction1.asArray();
  101628. serializationObject.direction2 = this.direction2.asArray();
  101629. return serializationObject;
  101630. };
  101631. /**
  101632. * Parse properties from a JSON object
  101633. * @param serializationObject defines the JSON object
  101634. */
  101635. PointParticleEmitter.prototype.parse = function (serializationObject) {
  101636. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  101637. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  101638. };
  101639. return PointParticleEmitter;
  101640. }());
  101641. /***/ }),
  101642. /***/ "./Particles/EmitterTypes/sphereParticleEmitter.ts":
  101643. /*!*********************************************************!*\
  101644. !*** ./Particles/EmitterTypes/sphereParticleEmitter.ts ***!
  101645. \*********************************************************/
  101646. /*! exports provided: SphereParticleEmitter, SphereDirectedParticleEmitter */
  101647. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101648. "use strict";
  101649. __webpack_require__.r(__webpack_exports__);
  101650. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return SphereParticleEmitter; });
  101651. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return SphereDirectedParticleEmitter; });
  101652. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  101653. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  101654. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101655. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  101656. /**
  101657. * Particle emitter emitting particles from the inside of a sphere.
  101658. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  101659. */
  101660. var SphereParticleEmitter = /** @class */ (function () {
  101661. /**
  101662. * Creates a new instance SphereParticleEmitter
  101663. * @param radius the radius of the emission sphere (1 by default)
  101664. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101665. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  101666. */
  101667. function SphereParticleEmitter(
  101668. /**
  101669. * The radius of the emission sphere.
  101670. */
  101671. radius,
  101672. /**
  101673. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101674. */
  101675. radiusRange,
  101676. /**
  101677. * How much to randomize the particle direction [0-1].
  101678. */
  101679. directionRandomizer) {
  101680. if (radius === void 0) { radius = 1; }
  101681. if (radiusRange === void 0) { radiusRange = 1; }
  101682. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  101683. this.radius = radius;
  101684. this.radiusRange = radiusRange;
  101685. this.directionRandomizer = directionRandomizer;
  101686. }
  101687. /**
  101688. * Called by the particle System when the direction is computed for the created particle.
  101689. * @param worldMatrix is the world matrix of the particle system
  101690. * @param directionToUpdate is the direction vector to update with the result
  101691. * @param particle is the particle we are computed the direction for
  101692. */
  101693. SphereParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101694. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  101695. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101696. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101697. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101698. direction.x += randX;
  101699. direction.y += randY;
  101700. direction.z += randZ;
  101701. direction.normalize();
  101702. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  101703. };
  101704. /**
  101705. * Called by the particle System when the position is computed for the created particle.
  101706. * @param worldMatrix is the world matrix of the particle system
  101707. * @param positionToUpdate is the position vector to update with the result
  101708. * @param particle is the particle we are computed the position for
  101709. */
  101710. SphereParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  101711. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  101712. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  101713. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  101714. var theta = Math.acos(2 * v - 1);
  101715. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  101716. var randY = randRadius * Math.cos(theta);
  101717. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  101718. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  101719. };
  101720. /**
  101721. * Clones the current emitter and returns a copy of it
  101722. * @returns the new emitter
  101723. */
  101724. SphereParticleEmitter.prototype.clone = function () {
  101725. var newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);
  101726. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  101727. return newOne;
  101728. };
  101729. /**
  101730. * Called by the GPUParticleSystem to setup the update shader
  101731. * @param effect defines the update shader
  101732. */
  101733. SphereParticleEmitter.prototype.applyToShader = function (effect) {
  101734. effect.setFloat("radius", this.radius);
  101735. effect.setFloat("radiusRange", this.radiusRange);
  101736. effect.setFloat("directionRandomizer", this.directionRandomizer);
  101737. };
  101738. /**
  101739. * Returns a string to use to update the GPU particles update shader
  101740. * @returns a string containng the defines string
  101741. */
  101742. SphereParticleEmitter.prototype.getEffectDefines = function () {
  101743. return "#define SPHEREEMITTER";
  101744. };
  101745. /**
  101746. * Returns the string "SphereParticleEmitter"
  101747. * @returns a string containing the class name
  101748. */
  101749. SphereParticleEmitter.prototype.getClassName = function () {
  101750. return "SphereParticleEmitter";
  101751. };
  101752. /**
  101753. * Serializes the particle system to a JSON object.
  101754. * @returns the JSON object
  101755. */
  101756. SphereParticleEmitter.prototype.serialize = function () {
  101757. var serializationObject = {};
  101758. serializationObject.type = this.getClassName();
  101759. serializationObject.radius = this.radius;
  101760. serializationObject.radiusRange = this.radiusRange;
  101761. serializationObject.directionRandomizer = this.directionRandomizer;
  101762. return serializationObject;
  101763. };
  101764. /**
  101765. * Parse properties from a JSON object
  101766. * @param serializationObject defines the JSON object
  101767. */
  101768. SphereParticleEmitter.prototype.parse = function (serializationObject) {
  101769. this.radius = serializationObject.radius;
  101770. this.radiusRange = serializationObject.radiusRange;
  101771. this.directionRandomizer = serializationObject.directionRandomizer;
  101772. };
  101773. return SphereParticleEmitter;
  101774. }());
  101775. /**
  101776. * Particle emitter emitting particles from the inside of a sphere.
  101777. * It emits the particles randomly between two vectors.
  101778. */
  101779. var SphereDirectedParticleEmitter = /** @class */ (function (_super) {
  101780. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SphereDirectedParticleEmitter, _super);
  101781. /**
  101782. * Creates a new instance SphereDirectedParticleEmitter
  101783. * @param radius the radius of the emission sphere (1 by default)
  101784. * @param direction1 the min limit of the emission direction (up vector by default)
  101785. * @param direction2 the max limit of the emission direction (up vector by default)
  101786. */
  101787. function SphereDirectedParticleEmitter(radius,
  101788. /**
  101789. * The min limit of the emission direction.
  101790. */
  101791. direction1,
  101792. /**
  101793. * The max limit of the emission direction.
  101794. */
  101795. direction2) {
  101796. if (radius === void 0) { radius = 1; }
  101797. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  101798. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  101799. var _this = _super.call(this, radius) || this;
  101800. _this.direction1 = direction1;
  101801. _this.direction2 = direction2;
  101802. return _this;
  101803. }
  101804. /**
  101805. * Called by the particle System when the direction is computed for the created particle.
  101806. * @param worldMatrix is the world matrix of the particle system
  101807. * @param directionToUpdate is the direction vector to update with the result
  101808. * @param particle is the particle we are computed the direction for
  101809. */
  101810. SphereDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101811. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  101812. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  101813. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  101814. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  101815. };
  101816. /**
  101817. * Clones the current emitter and returns a copy of it
  101818. * @returns the new emitter
  101819. */
  101820. SphereDirectedParticleEmitter.prototype.clone = function () {
  101821. var newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);
  101822. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  101823. return newOne;
  101824. };
  101825. /**
  101826. * Called by the GPUParticleSystem to setup the update shader
  101827. * @param effect defines the update shader
  101828. */
  101829. SphereDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  101830. effect.setFloat("radius", this.radius);
  101831. effect.setFloat("radiusRange", this.radiusRange);
  101832. effect.setVector3("direction1", this.direction1);
  101833. effect.setVector3("direction2", this.direction2);
  101834. };
  101835. /**
  101836. * Returns a string to use to update the GPU particles update shader
  101837. * @returns a string containng the defines string
  101838. */
  101839. SphereDirectedParticleEmitter.prototype.getEffectDefines = function () {
  101840. return "#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER";
  101841. };
  101842. /**
  101843. * Returns the string "SphereDirectedParticleEmitter"
  101844. * @returns a string containing the class name
  101845. */
  101846. SphereDirectedParticleEmitter.prototype.getClassName = function () {
  101847. return "SphereDirectedParticleEmitter";
  101848. };
  101849. /**
  101850. * Serializes the particle system to a JSON object.
  101851. * @returns the JSON object
  101852. */
  101853. SphereDirectedParticleEmitter.prototype.serialize = function () {
  101854. var serializationObject = _super.prototype.serialize.call(this);
  101855. serializationObject.direction1 = this.direction1.asArray();
  101856. serializationObject.direction2 = this.direction2.asArray();
  101857. return serializationObject;
  101858. };
  101859. /**
  101860. * Parse properties from a JSON object
  101861. * @param serializationObject defines the JSON object
  101862. */
  101863. SphereDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  101864. _super.prototype.parse.call(this, serializationObject);
  101865. this.direction1.copyFrom(serializationObject.direction1);
  101866. this.direction2.copyFrom(serializationObject.direction2);
  101867. };
  101868. return SphereDirectedParticleEmitter;
  101869. }(SphereParticleEmitter));
  101870. /***/ }),
  101871. /***/ "./Particles/baseParticleSystem.ts":
  101872. /*!*****************************************!*\
  101873. !*** ./Particles/baseParticleSystem.ts ***!
  101874. \*****************************************/
  101875. /*! exports provided: BaseParticleSystem */
  101876. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101877. "use strict";
  101878. __webpack_require__.r(__webpack_exports__);
  101879. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return BaseParticleSystem; });
  101880. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  101881. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  101882. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  101883. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  101884. /**
  101885. * This represents the base class for particle system in Babylon.
  101886. * 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.
  101887. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  101888. * @example https://doc.babylonjs.com/babylon101/particles
  101889. */
  101890. var BaseParticleSystem = /** @class */ (function () {
  101891. /**
  101892. * Instantiates a particle system.
  101893. * 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.
  101894. * @param name The name of the particle system
  101895. */
  101896. function BaseParticleSystem(name) {
  101897. /**
  101898. * List of animations used by the particle system.
  101899. */
  101900. this.animations = [];
  101901. /**
  101902. * The rendering group used by the Particle system to chose when to render.
  101903. */
  101904. this.renderingGroupId = 0;
  101905. /**
  101906. * The emitter represents the Mesh or position we are attaching the particle system to.
  101907. */
  101908. this.emitter = null;
  101909. /**
  101910. * The maximum number of particles to emit per frame
  101911. */
  101912. this.emitRate = 10;
  101913. /**
  101914. * If you want to launch only a few particles at once, that can be done, as well.
  101915. */
  101916. this.manualEmitCount = -1;
  101917. /**
  101918. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  101919. */
  101920. this.updateSpeed = 0.01;
  101921. /**
  101922. * The amount of time the particle system is running (depends of the overall update speed).
  101923. */
  101924. this.targetStopDuration = 0;
  101925. /**
  101926. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  101927. */
  101928. this.disposeOnStop = false;
  101929. /**
  101930. * Minimum power of emitting particles.
  101931. */
  101932. this.minEmitPower = 1;
  101933. /**
  101934. * Maximum power of emitting particles.
  101935. */
  101936. this.maxEmitPower = 1;
  101937. /**
  101938. * Minimum life time of emitting particles.
  101939. */
  101940. this.minLifeTime = 1;
  101941. /**
  101942. * Maximum life time of emitting particles.
  101943. */
  101944. this.maxLifeTime = 1;
  101945. /**
  101946. * Minimum Size of emitting particles.
  101947. */
  101948. this.minSize = 1;
  101949. /**
  101950. * Maximum Size of emitting particles.
  101951. */
  101952. this.maxSize = 1;
  101953. /**
  101954. * Minimum scale of emitting particles on X axis.
  101955. */
  101956. this.minScaleX = 1;
  101957. /**
  101958. * Maximum scale of emitting particles on X axis.
  101959. */
  101960. this.maxScaleX = 1;
  101961. /**
  101962. * Minimum scale of emitting particles on Y axis.
  101963. */
  101964. this.minScaleY = 1;
  101965. /**
  101966. * Maximum scale of emitting particles on Y axis.
  101967. */
  101968. this.maxScaleY = 1;
  101969. /**
  101970. * Gets or sets the minimal initial rotation in radians.
  101971. */
  101972. this.minInitialRotation = 0;
  101973. /**
  101974. * Gets or sets the maximal initial rotation in radians.
  101975. */
  101976. this.maxInitialRotation = 0;
  101977. /**
  101978. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  101979. */
  101980. this.minAngularSpeed = 0;
  101981. /**
  101982. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  101983. */
  101984. this.maxAngularSpeed = 0;
  101985. /**
  101986. * The layer mask we are rendering the particles through.
  101987. */
  101988. this.layerMask = 0x0FFFFFFF;
  101989. /**
  101990. * This can help using your own shader to render the particle system.
  101991. * The according effect will be created
  101992. */
  101993. this.customShader = null;
  101994. /**
  101995. * By default particle system starts as soon as they are created. This prevents the
  101996. * automatic start to happen and let you decide when to start emitting particles.
  101997. */
  101998. this.preventAutoStart = false;
  101999. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  102000. this.noiseStrength = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](10, 10, 10);
  102001. /**
  102002. * Callback triggered when the particle animation is ending.
  102003. */
  102004. this.onAnimationEnd = null;
  102005. /**
  102006. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  102007. */
  102008. this.blendMode = BaseParticleSystem.BLENDMODE_ONEONE;
  102009. /**
  102010. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  102011. * to override the particles.
  102012. */
  102013. this.forceDepthWrite = false;
  102014. /** 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 */
  102015. this.preWarmCycles = 0;
  102016. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  102017. this.preWarmStepOffset = 1;
  102018. /**
  102019. * 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)
  102020. */
  102021. this.spriteCellChangeSpeed = 1;
  102022. /**
  102023. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  102024. */
  102025. this.startSpriteCellID = 0;
  102026. /**
  102027. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  102028. */
  102029. this.endSpriteCellID = 0;
  102030. /**
  102031. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  102032. */
  102033. this.spriteCellWidth = 0;
  102034. /**
  102035. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  102036. */
  102037. this.spriteCellHeight = 0;
  102038. /**
  102039. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  102040. */
  102041. this.spriteRandomStartCell = false;
  102042. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  102043. this.translationPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  102044. /**
  102045. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  102046. */
  102047. this.beginAnimationOnStart = false;
  102048. /**
  102049. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  102050. */
  102051. this.beginAnimationFrom = 0;
  102052. /**
  102053. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  102054. */
  102055. this.beginAnimationTo = 60;
  102056. /**
  102057. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  102058. */
  102059. this.beginAnimationLoop = false;
  102060. /**
  102061. * You can use gravity if you want to give an orientation to your particles.
  102062. */
  102063. this.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  102064. this._colorGradients = null;
  102065. this._sizeGradients = null;
  102066. this._lifeTimeGradients = null;
  102067. this._angularSpeedGradients = null;
  102068. this._velocityGradients = null;
  102069. this._limitVelocityGradients = null;
  102070. this._dragGradients = null;
  102071. this._emitRateGradients = null;
  102072. this._startSizeGradients = null;
  102073. this._rampGradients = null;
  102074. this._colorRemapGradients = null;
  102075. this._alphaRemapGradients = null;
  102076. /**
  102077. * Defines the delay in milliseconds before starting the system (0 by default)
  102078. */
  102079. this.startDelay = 0;
  102080. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  102081. this.limitVelocityDamping = 0.4;
  102082. /**
  102083. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  102084. */
  102085. this.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  102086. /**
  102087. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  102088. */
  102089. this.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  102090. /**
  102091. * Color the particle will have at the end of its lifetime
  102092. */
  102093. this.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 1.0);
  102094. /**
  102095. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  102096. */
  102097. this.textureMask = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  102098. /** @hidden */
  102099. this._isSubEmitter = false;
  102100. /**
  102101. * Gets or sets the billboard mode to use when isBillboardBased = true.
  102102. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  102103. */
  102104. this.billboardMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  102105. this._isBillboardBased = true;
  102106. /**
  102107. * Local cache of defines for image processing.
  102108. */
  102109. this._imageProcessingConfigurationDefines = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__["ImageProcessingConfigurationDefines"]();
  102110. this.id = name;
  102111. this.name = name;
  102112. }
  102113. Object.defineProperty(BaseParticleSystem.prototype, "noiseTexture", {
  102114. /**
  102115. * Gets or sets a texture used to add random noise to particle positions
  102116. */
  102117. get: function () {
  102118. return this._noiseTexture;
  102119. },
  102120. set: function (value) {
  102121. if (this._noiseTexture === value) {
  102122. return;
  102123. }
  102124. this._noiseTexture = value;
  102125. this._reset();
  102126. },
  102127. enumerable: true,
  102128. configurable: true
  102129. });
  102130. Object.defineProperty(BaseParticleSystem.prototype, "isAnimationSheetEnabled", {
  102131. /**
  102132. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  102133. */
  102134. get: function () {
  102135. return this._isAnimationSheetEnabled;
  102136. },
  102137. set: function (value) {
  102138. if (this._isAnimationSheetEnabled == value) {
  102139. return;
  102140. }
  102141. this._isAnimationSheetEnabled = value;
  102142. this._reset();
  102143. },
  102144. enumerable: true,
  102145. configurable: true
  102146. });
  102147. /**
  102148. * Get hosting scene
  102149. * @returns the scene
  102150. */
  102151. BaseParticleSystem.prototype.getScene = function () {
  102152. return this._scene;
  102153. };
  102154. BaseParticleSystem.prototype._hasTargetStopDurationDependantGradient = function () {
  102155. return (this._startSizeGradients && this._startSizeGradients.length > 0)
  102156. || (this._emitRateGradients && this._emitRateGradients.length > 0)
  102157. || (this._lifeTimeGradients && this._lifeTimeGradients.length > 0);
  102158. };
  102159. /**
  102160. * Gets the current list of drag gradients.
  102161. * You must use addDragGradient and removeDragGradient to udpate this list
  102162. * @returns the list of drag gradients
  102163. */
  102164. BaseParticleSystem.prototype.getDragGradients = function () {
  102165. return this._dragGradients;
  102166. };
  102167. /**
  102168. * Gets the current list of limit velocity gradients.
  102169. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  102170. * @returns the list of limit velocity gradients
  102171. */
  102172. BaseParticleSystem.prototype.getLimitVelocityGradients = function () {
  102173. return this._limitVelocityGradients;
  102174. };
  102175. /**
  102176. * Gets the current list of color gradients.
  102177. * You must use addColorGradient and removeColorGradient to udpate this list
  102178. * @returns the list of color gradients
  102179. */
  102180. BaseParticleSystem.prototype.getColorGradients = function () {
  102181. return this._colorGradients;
  102182. };
  102183. /**
  102184. * Gets the current list of size gradients.
  102185. * You must use addSizeGradient and removeSizeGradient to udpate this list
  102186. * @returns the list of size gradients
  102187. */
  102188. BaseParticleSystem.prototype.getSizeGradients = function () {
  102189. return this._sizeGradients;
  102190. };
  102191. /**
  102192. * Gets the current list of color remap gradients.
  102193. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  102194. * @returns the list of color remap gradients
  102195. */
  102196. BaseParticleSystem.prototype.getColorRemapGradients = function () {
  102197. return this._colorRemapGradients;
  102198. };
  102199. /**
  102200. * Gets the current list of alpha remap gradients.
  102201. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  102202. * @returns the list of alpha remap gradients
  102203. */
  102204. BaseParticleSystem.prototype.getAlphaRemapGradients = function () {
  102205. return this._alphaRemapGradients;
  102206. };
  102207. /**
  102208. * Gets the current list of life time gradients.
  102209. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  102210. * @returns the list of life time gradients
  102211. */
  102212. BaseParticleSystem.prototype.getLifeTimeGradients = function () {
  102213. return this._lifeTimeGradients;
  102214. };
  102215. /**
  102216. * Gets the current list of angular speed gradients.
  102217. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  102218. * @returns the list of angular speed gradients
  102219. */
  102220. BaseParticleSystem.prototype.getAngularSpeedGradients = function () {
  102221. return this._angularSpeedGradients;
  102222. };
  102223. /**
  102224. * Gets the current list of velocity gradients.
  102225. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  102226. * @returns the list of velocity gradients
  102227. */
  102228. BaseParticleSystem.prototype.getVelocityGradients = function () {
  102229. return this._velocityGradients;
  102230. };
  102231. /**
  102232. * Gets the current list of start size gradients.
  102233. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  102234. * @returns the list of start size gradients
  102235. */
  102236. BaseParticleSystem.prototype.getStartSizeGradients = function () {
  102237. return this._startSizeGradients;
  102238. };
  102239. /**
  102240. * Gets the current list of emit rate gradients.
  102241. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  102242. * @returns the list of emit rate gradients
  102243. */
  102244. BaseParticleSystem.prototype.getEmitRateGradients = function () {
  102245. return this._emitRateGradients;
  102246. };
  102247. Object.defineProperty(BaseParticleSystem.prototype, "direction1", {
  102248. /**
  102249. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102250. * This only works when particleEmitterTyps is a BoxParticleEmitter
  102251. */
  102252. get: function () {
  102253. if (this.particleEmitterType.direction1) {
  102254. return this.particleEmitterType.direction1;
  102255. }
  102256. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  102257. },
  102258. set: function (value) {
  102259. if (this.particleEmitterType.direction1) {
  102260. this.particleEmitterType.direction1 = value;
  102261. }
  102262. },
  102263. enumerable: true,
  102264. configurable: true
  102265. });
  102266. Object.defineProperty(BaseParticleSystem.prototype, "direction2", {
  102267. /**
  102268. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102269. * This only works when particleEmitterTyps is a BoxParticleEmitter
  102270. */
  102271. get: function () {
  102272. if (this.particleEmitterType.direction2) {
  102273. return this.particleEmitterType.direction2;
  102274. }
  102275. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  102276. },
  102277. set: function (value) {
  102278. if (this.particleEmitterType.direction2) {
  102279. this.particleEmitterType.direction2 = value;
  102280. }
  102281. },
  102282. enumerable: true,
  102283. configurable: true
  102284. });
  102285. Object.defineProperty(BaseParticleSystem.prototype, "minEmitBox", {
  102286. /**
  102287. * 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.
  102288. * This only works when particleEmitterTyps is a BoxParticleEmitter
  102289. */
  102290. get: function () {
  102291. if (this.particleEmitterType.minEmitBox) {
  102292. return this.particleEmitterType.minEmitBox;
  102293. }
  102294. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  102295. },
  102296. set: function (value) {
  102297. if (this.particleEmitterType.minEmitBox) {
  102298. this.particleEmitterType.minEmitBox = value;
  102299. }
  102300. },
  102301. enumerable: true,
  102302. configurable: true
  102303. });
  102304. Object.defineProperty(BaseParticleSystem.prototype, "maxEmitBox", {
  102305. /**
  102306. * 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.
  102307. * This only works when particleEmitterTyps is a BoxParticleEmitter
  102308. */
  102309. get: function () {
  102310. if (this.particleEmitterType.maxEmitBox) {
  102311. return this.particleEmitterType.maxEmitBox;
  102312. }
  102313. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  102314. },
  102315. set: function (value) {
  102316. if (this.particleEmitterType.maxEmitBox) {
  102317. this.particleEmitterType.maxEmitBox = value;
  102318. }
  102319. },
  102320. enumerable: true,
  102321. configurable: true
  102322. });
  102323. Object.defineProperty(BaseParticleSystem.prototype, "isBillboardBased", {
  102324. /**
  102325. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  102326. */
  102327. get: function () {
  102328. return this._isBillboardBased;
  102329. },
  102330. set: function (value) {
  102331. if (this._isBillboardBased === value) {
  102332. return;
  102333. }
  102334. this._isBillboardBased = value;
  102335. this._reset();
  102336. },
  102337. enumerable: true,
  102338. configurable: true
  102339. });
  102340. Object.defineProperty(BaseParticleSystem.prototype, "imageProcessingConfiguration", {
  102341. /**
  102342. * Gets the image processing configuration used either in this material.
  102343. */
  102344. get: function () {
  102345. return this._imageProcessingConfiguration;
  102346. },
  102347. /**
  102348. * Sets the Default image processing configuration used either in the this material.
  102349. *
  102350. * If sets to null, the scene one is in use.
  102351. */
  102352. set: function (value) {
  102353. this._attachImageProcessingConfiguration(value);
  102354. },
  102355. enumerable: true,
  102356. configurable: true
  102357. });
  102358. /**
  102359. * Attaches a new image processing configuration to the Standard Material.
  102360. * @param configuration
  102361. */
  102362. BaseParticleSystem.prototype._attachImageProcessingConfiguration = function (configuration) {
  102363. if (configuration === this._imageProcessingConfiguration) {
  102364. return;
  102365. }
  102366. // Pick the scene configuration if needed.
  102367. if (!configuration) {
  102368. this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration;
  102369. }
  102370. else {
  102371. this._imageProcessingConfiguration = configuration;
  102372. }
  102373. };
  102374. /** @hidden */
  102375. BaseParticleSystem.prototype._reset = function () {
  102376. };
  102377. /** @hidden */
  102378. BaseParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  102379. if (!gradients) {
  102380. return this;
  102381. }
  102382. var index = 0;
  102383. for (var _i = 0, gradients_1 = gradients; _i < gradients_1.length; _i++) {
  102384. var valueGradient = gradients_1[_i];
  102385. if (valueGradient.gradient === gradient) {
  102386. gradients.splice(index, 1);
  102387. break;
  102388. }
  102389. index++;
  102390. }
  102391. if (texture) {
  102392. texture.dispose();
  102393. }
  102394. return this;
  102395. };
  102396. /**
  102397. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  102398. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  102399. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  102400. * @returns the emitter
  102401. */
  102402. BaseParticleSystem.prototype.createPointEmitter = function (direction1, direction2) {
  102403. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["PointParticleEmitter"]();
  102404. particleEmitter.direction1 = direction1;
  102405. particleEmitter.direction2 = direction2;
  102406. this.particleEmitterType = particleEmitter;
  102407. return particleEmitter;
  102408. };
  102409. /**
  102410. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  102411. * @param radius The radius of the hemisphere to emit from
  102412. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  102413. * @returns the emitter
  102414. */
  102415. BaseParticleSystem.prototype.createHemisphericEmitter = function (radius, radiusRange) {
  102416. if (radius === void 0) { radius = 1; }
  102417. if (radiusRange === void 0) { radiusRange = 1; }
  102418. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["HemisphericParticleEmitter"](radius, radiusRange);
  102419. this.particleEmitterType = particleEmitter;
  102420. return particleEmitter;
  102421. };
  102422. /**
  102423. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  102424. * @param radius The radius of the sphere to emit from
  102425. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  102426. * @returns the emitter
  102427. */
  102428. BaseParticleSystem.prototype.createSphereEmitter = function (radius, radiusRange) {
  102429. if (radius === void 0) { radius = 1; }
  102430. if (radiusRange === void 0) { radiusRange = 1; }
  102431. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereParticleEmitter"](radius, radiusRange);
  102432. this.particleEmitterType = particleEmitter;
  102433. return particleEmitter;
  102434. };
  102435. /**
  102436. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  102437. * @param radius The radius of the sphere to emit from
  102438. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  102439. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  102440. * @returns the emitter
  102441. */
  102442. BaseParticleSystem.prototype.createDirectedSphereEmitter = function (radius, direction1, direction2) {
  102443. if (radius === void 0) { radius = 1; }
  102444. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  102445. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  102446. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereDirectedParticleEmitter"](radius, direction1, direction2);
  102447. this.particleEmitterType = particleEmitter;
  102448. return particleEmitter;
  102449. };
  102450. /**
  102451. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  102452. * @param radius The radius of the emission cylinder
  102453. * @param height The height of the emission cylinder
  102454. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  102455. * @param directionRandomizer How much to randomize the particle direction [0-1]
  102456. * @returns the emitter
  102457. */
  102458. BaseParticleSystem.prototype.createCylinderEmitter = function (radius, height, radiusRange, directionRandomizer) {
  102459. if (radius === void 0) { radius = 1; }
  102460. if (height === void 0) { height = 1; }
  102461. if (radiusRange === void 0) { radiusRange = 1; }
  102462. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  102463. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"](radius, height, radiusRange, directionRandomizer);
  102464. this.particleEmitterType = particleEmitter;
  102465. return particleEmitter;
  102466. };
  102467. /**
  102468. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  102469. * @param radius The radius of the cylinder to emit from
  102470. * @param height The height of the emission cylinder
  102471. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102472. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  102473. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  102474. * @returns the emitter
  102475. */
  102476. BaseParticleSystem.prototype.createDirectedCylinderEmitter = function (radius, height, radiusRange, direction1, direction2) {
  102477. if (radius === void 0) { radius = 1; }
  102478. if (height === void 0) { height = 1; }
  102479. if (radiusRange === void 0) { radiusRange = 1; }
  102480. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  102481. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  102482. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"](radius, height, radiusRange, direction1, direction2);
  102483. this.particleEmitterType = particleEmitter;
  102484. return particleEmitter;
  102485. };
  102486. /**
  102487. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  102488. * @param radius The radius of the cone to emit from
  102489. * @param angle The base angle of the cone
  102490. * @returns the emitter
  102491. */
  102492. BaseParticleSystem.prototype.createConeEmitter = function (radius, angle) {
  102493. if (radius === void 0) { radius = 1; }
  102494. if (angle === void 0) { angle = Math.PI / 4; }
  102495. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["ConeParticleEmitter"](radius, angle);
  102496. this.particleEmitterType = particleEmitter;
  102497. return particleEmitter;
  102498. };
  102499. /**
  102500. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  102501. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  102502. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  102503. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  102504. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  102505. * @returns the emitter
  102506. */
  102507. BaseParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
  102508. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["BoxParticleEmitter"]();
  102509. this.particleEmitterType = particleEmitter;
  102510. this.direction1 = direction1;
  102511. this.direction2 = direction2;
  102512. this.minEmitBox = minEmitBox;
  102513. this.maxEmitBox = maxEmitBox;
  102514. return particleEmitter;
  102515. };
  102516. /**
  102517. * Source color is added to the destination color without alpha affecting the result
  102518. */
  102519. BaseParticleSystem.BLENDMODE_ONEONE = 0;
  102520. /**
  102521. * Blend current color and particle color using particle’s alpha
  102522. */
  102523. BaseParticleSystem.BLENDMODE_STANDARD = 1;
  102524. /**
  102525. * Add current color and particle color multiplied by particle’s alpha
  102526. */
  102527. BaseParticleSystem.BLENDMODE_ADD = 2;
  102528. /**
  102529. * Multiply current color with particle color
  102530. */
  102531. BaseParticleSystem.BLENDMODE_MULTIPLY = 3;
  102532. /**
  102533. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  102534. */
  102535. BaseParticleSystem.BLENDMODE_MULTIPLYADD = 4;
  102536. return BaseParticleSystem;
  102537. }());
  102538. /***/ }),
  102539. /***/ "./Particles/gpuParticleSystem.ts":
  102540. /*!****************************************!*\
  102541. !*** ./Particles/gpuParticleSystem.ts ***!
  102542. \****************************************/
  102543. /*! exports provided: GPUParticleSystem */
  102544. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102545. "use strict";
  102546. __webpack_require__.r(__webpack_exports__);
  102547. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return GPUParticleSystem; });
  102548. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  102549. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  102550. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  102551. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  102552. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102553. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  102554. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  102555. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  102556. /* harmony import */ var _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Particles/EmitterTypes/boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  102557. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  102558. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  102559. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  102560. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  102561. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  102562. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  102563. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  102564. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  102565. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  102566. /* harmony import */ var _Shaders_gpuUpdateParticles_fragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.fragment */ "./Shaders/gpuUpdateParticles.fragment.ts");
  102567. /* harmony import */ var _Shaders_gpuUpdateParticles_vertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.vertex */ "./Shaders/gpuUpdateParticles.vertex.ts");
  102568. /* harmony import */ var _Shaders_gpuRenderParticles_fragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.fragment */ "./Shaders/gpuRenderParticles.fragment.ts");
  102569. /* harmony import */ var _Shaders_gpuRenderParticles_vertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.vertex */ "./Shaders/gpuRenderParticles.vertex.ts");
  102570. /**
  102571. * This represents a GPU particle system in Babylon
  102572. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  102573. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  102574. */
  102575. var GPUParticleSystem = /** @class */ (function (_super) {
  102576. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GPUParticleSystem, _super);
  102577. /**
  102578. * Instantiates a GPU particle system.
  102579. * 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.
  102580. * @param name The name of the particle system
  102581. * @param options The options used to create the system
  102582. * @param scene The scene the particle system belongs to
  102583. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  102584. */
  102585. function GPUParticleSystem(name, options, scene, isAnimationSheetEnabled) {
  102586. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  102587. var _this = _super.call(this, name) || this;
  102588. /**
  102589. * The layer mask we are rendering the particles through.
  102590. */
  102591. _this.layerMask = 0x0FFFFFFF;
  102592. _this._accumulatedCount = 0;
  102593. _this._targetIndex = 0;
  102594. _this._currentRenderId = -1;
  102595. _this._started = false;
  102596. _this._stopped = false;
  102597. _this._timeDelta = 0;
  102598. _this._actualFrame = 0;
  102599. _this._rawTextureWidth = 256;
  102600. /**
  102601. * An event triggered when the system is disposed.
  102602. */
  102603. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  102604. /**
  102605. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  102606. * to override the particles.
  102607. */
  102608. _this.forceDepthWrite = false;
  102609. _this._preWarmDone = false;
  102610. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  102611. // Setup the default processing configuration to the scene.
  102612. _this._attachImageProcessingConfiguration(null);
  102613. _this._engine = _this._scene.getEngine();
  102614. if (!options.randomTextureSize) {
  102615. delete options.randomTextureSize;
  102616. }
  102617. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ capacity: 50000, randomTextureSize: _this._engine.getCaps().maxTextureSize }, options);
  102618. var optionsAsNumber = options;
  102619. if (isFinite(optionsAsNumber)) {
  102620. fullOptions.capacity = optionsAsNumber;
  102621. }
  102622. _this._capacity = fullOptions.capacity;
  102623. _this._activeCount = fullOptions.capacity;
  102624. _this._currentActiveCount = 0;
  102625. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  102626. _this._scene.particleSystems.push(_this);
  102627. _this._updateEffectOptions = {
  102628. attributes: ["position", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"],
  102629. uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower",
  102630. "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor",
  102631. "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
  102632. uniformBuffersNames: [],
  102633. samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"],
  102634. defines: "",
  102635. fallbacks: null,
  102636. onCompiled: null,
  102637. onError: null,
  102638. indexParameters: null,
  102639. maxSimultaneousLights: 0,
  102640. transformFeedbackVaryings: []
  102641. };
  102642. _this.particleEmitterType = new _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__["BoxParticleEmitter"]();
  102643. // Random data
  102644. var maxTextureSize = Math.min(_this._engine.getCaps().maxTextureSize, fullOptions.randomTextureSize);
  102645. var d = [];
  102646. for (var i = 0; i < maxTextureSize; ++i) {
  102647. d.push(Math.random());
  102648. d.push(Math.random());
  102649. d.push(Math.random());
  102650. d.push(Math.random());
  102651. }
  102652. _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);
  102653. _this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  102654. _this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  102655. d = [];
  102656. for (var i = 0; i < maxTextureSize; ++i) {
  102657. d.push(Math.random());
  102658. d.push(Math.random());
  102659. d.push(Math.random());
  102660. d.push(Math.random());
  102661. }
  102662. _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);
  102663. _this._randomTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  102664. _this._randomTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  102665. _this._randomTextureSize = maxTextureSize;
  102666. return _this;
  102667. }
  102668. Object.defineProperty(GPUParticleSystem, "IsSupported", {
  102669. /**
  102670. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  102671. */
  102672. get: function () {
  102673. if (!_Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine) {
  102674. return false;
  102675. }
  102676. return _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine.webGLVersion > 1;
  102677. },
  102678. enumerable: true,
  102679. configurable: true
  102680. });
  102681. /**
  102682. * Gets the maximum number of particles active at the same time.
  102683. * @returns The max number of active particles.
  102684. */
  102685. GPUParticleSystem.prototype.getCapacity = function () {
  102686. return this._capacity;
  102687. };
  102688. Object.defineProperty(GPUParticleSystem.prototype, "activeParticleCount", {
  102689. /**
  102690. * Gets or set the number of active particles
  102691. */
  102692. get: function () {
  102693. return this._activeCount;
  102694. },
  102695. set: function (value) {
  102696. this._activeCount = Math.min(value, this._capacity);
  102697. },
  102698. enumerable: true,
  102699. configurable: true
  102700. });
  102701. /**
  102702. * Is this system ready to be used/rendered
  102703. * @return true if the system is ready
  102704. */
  102705. GPUParticleSystem.prototype.isReady = function () {
  102706. if (!this._updateEffect) {
  102707. this._recreateUpdateEffect();
  102708. this._recreateRenderEffect();
  102709. return false;
  102710. }
  102711. if (!this.emitter || !this._updateEffect.isReady() || !this._imageProcessingConfiguration.isReady() || !this._renderEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  102712. return false;
  102713. }
  102714. return true;
  102715. };
  102716. /**
  102717. * Gets if the system has been started. (Note: this will still be true after stop is called)
  102718. * @returns True if it has been started, otherwise false.
  102719. */
  102720. GPUParticleSystem.prototype.isStarted = function () {
  102721. return this._started;
  102722. };
  102723. /**
  102724. * Starts the particle system and begins to emit
  102725. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  102726. */
  102727. GPUParticleSystem.prototype.start = function (delay) {
  102728. var _this = this;
  102729. if (delay === void 0) { delay = this.startDelay; }
  102730. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  102731. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  102732. }
  102733. if (delay) {
  102734. setTimeout(function () {
  102735. _this.start(0);
  102736. }, delay);
  102737. return;
  102738. }
  102739. this._started = true;
  102740. this._stopped = false;
  102741. this._preWarmDone = false;
  102742. // Animations
  102743. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  102744. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  102745. }
  102746. };
  102747. /**
  102748. * Stops the particle system.
  102749. */
  102750. GPUParticleSystem.prototype.stop = function () {
  102751. this._stopped = true;
  102752. };
  102753. /**
  102754. * Remove all active particles
  102755. */
  102756. GPUParticleSystem.prototype.reset = function () {
  102757. this._releaseBuffers();
  102758. this._releaseVAOs();
  102759. this._currentActiveCount = 0;
  102760. this._targetIndex = 0;
  102761. };
  102762. /**
  102763. * Returns the string "GPUParticleSystem"
  102764. * @returns a string containing the class name
  102765. */
  102766. GPUParticleSystem.prototype.getClassName = function () {
  102767. return "GPUParticleSystem";
  102768. };
  102769. GPUParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  102770. _super.prototype._removeGradientAndTexture.call(this, gradient, gradients, texture);
  102771. this._releaseBuffers();
  102772. return this;
  102773. };
  102774. /**
  102775. * Adds a new color gradient
  102776. * @param gradient defines the gradient to use (between 0 and 1)
  102777. * @param color1 defines the color to affect to the specified gradient
  102778. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  102779. * @returns the current particle system
  102780. */
  102781. GPUParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  102782. if (!this._colorGradients) {
  102783. this._colorGradients = [];
  102784. }
  102785. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  102786. colorGradient.gradient = gradient;
  102787. colorGradient.color1 = color1;
  102788. this._colorGradients.push(colorGradient);
  102789. this._colorGradients.sort(function (a, b) {
  102790. if (a.gradient < b.gradient) {
  102791. return -1;
  102792. }
  102793. else if (a.gradient > b.gradient) {
  102794. return 1;
  102795. }
  102796. return 0;
  102797. });
  102798. if (this._colorGradientsTexture) {
  102799. this._colorGradientsTexture.dispose();
  102800. this._colorGradientsTexture = null;
  102801. }
  102802. this._releaseBuffers();
  102803. return this;
  102804. };
  102805. /**
  102806. * Remove a specific color gradient
  102807. * @param gradient defines the gradient to remove
  102808. * @returns the current particle system
  102809. */
  102810. GPUParticleSystem.prototype.removeColorGradient = function (gradient) {
  102811. this._removeGradientAndTexture(gradient, this._colorGradients, this._colorGradientsTexture);
  102812. this._colorGradientsTexture = null;
  102813. return this;
  102814. };
  102815. GPUParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor) {
  102816. var valueGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  102817. valueGradient.gradient = gradient;
  102818. valueGradient.factor1 = factor;
  102819. factorGradients.push(valueGradient);
  102820. factorGradients.sort(function (a, b) {
  102821. if (a.gradient < b.gradient) {
  102822. return -1;
  102823. }
  102824. else if (a.gradient > b.gradient) {
  102825. return 1;
  102826. }
  102827. return 0;
  102828. });
  102829. this._releaseBuffers();
  102830. };
  102831. /**
  102832. * Adds a new size gradient
  102833. * @param gradient defines the gradient to use (between 0 and 1)
  102834. * @param factor defines the size factor to affect to the specified gradient
  102835. * @returns the current particle system
  102836. */
  102837. GPUParticleSystem.prototype.addSizeGradient = function (gradient, factor) {
  102838. if (!this._sizeGradients) {
  102839. this._sizeGradients = [];
  102840. }
  102841. this._addFactorGradient(this._sizeGradients, gradient, factor);
  102842. if (this._sizeGradientsTexture) {
  102843. this._sizeGradientsTexture.dispose();
  102844. this._sizeGradientsTexture = null;
  102845. }
  102846. this._releaseBuffers();
  102847. return this;
  102848. };
  102849. /**
  102850. * Remove a specific size gradient
  102851. * @param gradient defines the gradient to remove
  102852. * @returns the current particle system
  102853. */
  102854. GPUParticleSystem.prototype.removeSizeGradient = function (gradient) {
  102855. this._removeGradientAndTexture(gradient, this._sizeGradients, this._sizeGradientsTexture);
  102856. this._sizeGradientsTexture = null;
  102857. return this;
  102858. };
  102859. /**
  102860. * Adds a new angular speed gradient
  102861. * @param gradient defines the gradient to use (between 0 and 1)
  102862. * @param factor defines the angular speed to affect to the specified gradient
  102863. * @returns the current particle system
  102864. */
  102865. GPUParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor) {
  102866. if (!this._angularSpeedGradients) {
  102867. this._angularSpeedGradients = [];
  102868. }
  102869. this._addFactorGradient(this._angularSpeedGradients, gradient, factor);
  102870. if (this._angularSpeedGradientsTexture) {
  102871. this._angularSpeedGradientsTexture.dispose();
  102872. this._angularSpeedGradientsTexture = null;
  102873. }
  102874. this._releaseBuffers();
  102875. return this;
  102876. };
  102877. /**
  102878. * Remove a specific angular speed gradient
  102879. * @param gradient defines the gradient to remove
  102880. * @returns the current particle system
  102881. */
  102882. GPUParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  102883. this._removeGradientAndTexture(gradient, this._angularSpeedGradients, this._angularSpeedGradientsTexture);
  102884. this._angularSpeedGradientsTexture = null;
  102885. return this;
  102886. };
  102887. /**
  102888. * Adds a new velocity gradient
  102889. * @param gradient defines the gradient to use (between 0 and 1)
  102890. * @param factor defines the velocity to affect to the specified gradient
  102891. * @returns the current particle system
  102892. */
  102893. GPUParticleSystem.prototype.addVelocityGradient = function (gradient, factor) {
  102894. if (!this._velocityGradients) {
  102895. this._velocityGradients = [];
  102896. }
  102897. this._addFactorGradient(this._velocityGradients, gradient, factor);
  102898. if (this._velocityGradientsTexture) {
  102899. this._velocityGradientsTexture.dispose();
  102900. this._velocityGradientsTexture = null;
  102901. }
  102902. this._releaseBuffers();
  102903. return this;
  102904. };
  102905. /**
  102906. * Remove a specific velocity gradient
  102907. * @param gradient defines the gradient to remove
  102908. * @returns the current particle system
  102909. */
  102910. GPUParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  102911. this._removeGradientAndTexture(gradient, this._velocityGradients, this._velocityGradientsTexture);
  102912. this._velocityGradientsTexture = null;
  102913. return this;
  102914. };
  102915. /**
  102916. * Adds a new limit velocity gradient
  102917. * @param gradient defines the gradient to use (between 0 and 1)
  102918. * @param factor defines the limit velocity value to affect to the specified gradient
  102919. * @returns the current particle system
  102920. */
  102921. GPUParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor) {
  102922. if (!this._limitVelocityGradients) {
  102923. this._limitVelocityGradients = [];
  102924. }
  102925. this._addFactorGradient(this._limitVelocityGradients, gradient, factor);
  102926. if (this._limitVelocityGradientsTexture) {
  102927. this._limitVelocityGradientsTexture.dispose();
  102928. this._limitVelocityGradientsTexture = null;
  102929. }
  102930. this._releaseBuffers();
  102931. return this;
  102932. };
  102933. /**
  102934. * Remove a specific limit velocity gradient
  102935. * @param gradient defines the gradient to remove
  102936. * @returns the current particle system
  102937. */
  102938. GPUParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  102939. this._removeGradientAndTexture(gradient, this._limitVelocityGradients, this._limitVelocityGradientsTexture);
  102940. this._limitVelocityGradientsTexture = null;
  102941. return this;
  102942. };
  102943. /**
  102944. * Adds a new drag gradient
  102945. * @param gradient defines the gradient to use (between 0 and 1)
  102946. * @param factor defines the drag value to affect to the specified gradient
  102947. * @returns the current particle system
  102948. */
  102949. GPUParticleSystem.prototype.addDragGradient = function (gradient, factor) {
  102950. if (!this._dragGradients) {
  102951. this._dragGradients = [];
  102952. }
  102953. this._addFactorGradient(this._dragGradients, gradient, factor);
  102954. if (this._dragGradientsTexture) {
  102955. this._dragGradientsTexture.dispose();
  102956. this._dragGradientsTexture = null;
  102957. }
  102958. this._releaseBuffers();
  102959. return this;
  102960. };
  102961. /**
  102962. * Remove a specific drag gradient
  102963. * @param gradient defines the gradient to remove
  102964. * @returns the current particle system
  102965. */
  102966. GPUParticleSystem.prototype.removeDragGradient = function (gradient) {
  102967. this._removeGradientAndTexture(gradient, this._dragGradients, this._dragGradientsTexture);
  102968. this._dragGradientsTexture = null;
  102969. return this;
  102970. };
  102971. /**
  102972. * Not supported by GPUParticleSystem
  102973. * @param gradient defines the gradient to use (between 0 and 1)
  102974. * @param factor defines the emit rate value to affect to the specified gradient
  102975. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102976. * @returns the current particle system
  102977. */
  102978. GPUParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  102979. // Do nothing as emit rate is not supported by GPUParticleSystem
  102980. return this;
  102981. };
  102982. /**
  102983. * Not supported by GPUParticleSystem
  102984. * @param gradient defines the gradient to remove
  102985. * @returns the current particle system
  102986. */
  102987. GPUParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  102988. // Do nothing as emit rate is not supported by GPUParticleSystem
  102989. return this;
  102990. };
  102991. /**
  102992. * Not supported by GPUParticleSystem
  102993. * @param gradient defines the gradient to use (between 0 and 1)
  102994. * @param factor defines the start size value to affect to the specified gradient
  102995. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102996. * @returns the current particle system
  102997. */
  102998. GPUParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  102999. // Do nothing as start size is not supported by GPUParticleSystem
  103000. return this;
  103001. };
  103002. /**
  103003. * Not supported by GPUParticleSystem
  103004. * @param gradient defines the gradient to remove
  103005. * @returns the current particle system
  103006. */
  103007. GPUParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  103008. // Do nothing as start size is not supported by GPUParticleSystem
  103009. return this;
  103010. };
  103011. /**
  103012. * Not supported by GPUParticleSystem
  103013. * @param gradient defines the gradient to use (between 0 and 1)
  103014. * @param min defines the color remap minimal range
  103015. * @param max defines the color remap maximal range
  103016. * @returns the current particle system
  103017. */
  103018. GPUParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  103019. // Do nothing as start size is not supported by GPUParticleSystem
  103020. return this;
  103021. };
  103022. /**
  103023. * Not supported by GPUParticleSystem
  103024. * @param gradient defines the gradient to remove
  103025. * @returns the current particle system
  103026. */
  103027. GPUParticleSystem.prototype.removeColorRemapGradient = function () {
  103028. // Do nothing as start size is not supported by GPUParticleSystem
  103029. return this;
  103030. };
  103031. /**
  103032. * Not supported by GPUParticleSystem
  103033. * @param gradient defines the gradient to use (between 0 and 1)
  103034. * @param min defines the alpha remap minimal range
  103035. * @param max defines the alpha remap maximal range
  103036. * @returns the current particle system
  103037. */
  103038. GPUParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  103039. // Do nothing as start size is not supported by GPUParticleSystem
  103040. return this;
  103041. };
  103042. /**
  103043. * Not supported by GPUParticleSystem
  103044. * @param gradient defines the gradient to remove
  103045. * @returns the current particle system
  103046. */
  103047. GPUParticleSystem.prototype.removeAlphaRemapGradient = function () {
  103048. // Do nothing as start size is not supported by GPUParticleSystem
  103049. return this;
  103050. };
  103051. /**
  103052. * Not supported by GPUParticleSystem
  103053. * @param gradient defines the gradient to use (between 0 and 1)
  103054. * @param color defines the color to affect to the specified gradient
  103055. * @returns the current particle system
  103056. */
  103057. GPUParticleSystem.prototype.addRampGradient = function (gradient, color) {
  103058. //Not supported by GPUParticleSystem
  103059. return this;
  103060. };
  103061. /**
  103062. * Not supported by GPUParticleSystem
  103063. * @param gradient defines the gradient to remove
  103064. * @returns the current particle system
  103065. */
  103066. GPUParticleSystem.prototype.removeRampGradient = function () {
  103067. //Not supported by GPUParticleSystem
  103068. return this;
  103069. };
  103070. /**
  103071. * Not supported by GPUParticleSystem
  103072. * @returns the list of ramp gradients
  103073. */
  103074. GPUParticleSystem.prototype.getRampGradients = function () {
  103075. return null;
  103076. };
  103077. Object.defineProperty(GPUParticleSystem.prototype, "useRampGradients", {
  103078. /**
  103079. * Not supported by GPUParticleSystem
  103080. * Gets or sets a boolean indicating that ramp gradients must be used
  103081. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  103082. */
  103083. get: function () {
  103084. //Not supported by GPUParticleSystem
  103085. return false;
  103086. },
  103087. set: function (value) {
  103088. //Not supported by GPUParticleSystem
  103089. },
  103090. enumerable: true,
  103091. configurable: true
  103092. });
  103093. /**
  103094. * Not supported by GPUParticleSystem
  103095. * @param gradient defines the gradient to use (between 0 and 1)
  103096. * @param factor defines the life time factor to affect to the specified gradient
  103097. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  103098. * @returns the current particle system
  103099. */
  103100. GPUParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  103101. //Not supported by GPUParticleSystem
  103102. return this;
  103103. };
  103104. /**
  103105. * Not supported by GPUParticleSystem
  103106. * @param gradient defines the gradient to remove
  103107. * @returns the current particle system
  103108. */
  103109. GPUParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  103110. //Not supported by GPUParticleSystem
  103111. return this;
  103112. };
  103113. GPUParticleSystem.prototype._reset = function () {
  103114. this._releaseBuffers();
  103115. };
  103116. GPUParticleSystem.prototype._createUpdateVAO = function (source) {
  103117. var updateVertexBuffers = {};
  103118. updateVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3);
  103119. updateVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1);
  103120. updateVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1);
  103121. updateVertexBuffers["seed"] = source.createVertexBuffer("seed", 5, 4);
  103122. updateVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3);
  103123. var offset = 12;
  103124. if (!this._colorGradientsTexture) {
  103125. updateVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4);
  103126. offset += 4;
  103127. }
  103128. updateVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3);
  103129. offset += 3;
  103130. if (!this._isBillboardBased) {
  103131. updateVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3);
  103132. offset += 3;
  103133. }
  103134. if (this._angularSpeedGradientsTexture) {
  103135. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1);
  103136. offset += 1;
  103137. }
  103138. else {
  103139. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 2);
  103140. offset += 2;
  103141. }
  103142. if (this._isAnimationSheetEnabled) {
  103143. updateVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1);
  103144. offset += 1;
  103145. if (this.spriteRandomStartCell) {
  103146. updateVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1);
  103147. offset += 1;
  103148. }
  103149. }
  103150. if (this.noiseTexture) {
  103151. updateVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3);
  103152. offset += 3;
  103153. updateVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3);
  103154. offset += 3;
  103155. }
  103156. var vao = this._engine.recordVertexArrayObject(updateVertexBuffers, null, this._updateEffect);
  103157. this._engine.bindArrayBuffer(null);
  103158. return vao;
  103159. };
  103160. GPUParticleSystem.prototype._createRenderVAO = function (source, spriteSource) {
  103161. var renderVertexBuffers = {};
  103162. renderVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3, this._attributesStrideSize, true);
  103163. renderVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1, this._attributesStrideSize, true);
  103164. renderVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1, this._attributesStrideSize, true);
  103165. renderVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3, this._attributesStrideSize, true);
  103166. var offset = 12;
  103167. if (!this._colorGradientsTexture) {
  103168. renderVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4, this._attributesStrideSize, true);
  103169. offset += 4;
  103170. }
  103171. if (this.billboardMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED) {
  103172. renderVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3, this._attributesStrideSize, true);
  103173. }
  103174. offset += 3; // Direction
  103175. if (!this._isBillboardBased) {
  103176. renderVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3, this._attributesStrideSize, true);
  103177. offset += 3;
  103178. }
  103179. renderVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1, this._attributesStrideSize, true);
  103180. if (this._angularSpeedGradientsTexture) {
  103181. offset++;
  103182. }
  103183. else {
  103184. offset += 2;
  103185. }
  103186. if (this._isAnimationSheetEnabled) {
  103187. renderVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1, this._attributesStrideSize, true);
  103188. offset += 1;
  103189. if (this.spriteRandomStartCell) {
  103190. renderVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1, this._attributesStrideSize, true);
  103191. offset += 1;
  103192. }
  103193. }
  103194. if (this.noiseTexture) {
  103195. renderVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3, this._attributesStrideSize, true);
  103196. offset += 3;
  103197. renderVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3, this._attributesStrideSize, true);
  103198. offset += 3;
  103199. }
  103200. renderVertexBuffers["offset"] = spriteSource.createVertexBuffer("offset", 0, 2);
  103201. renderVertexBuffers["uv"] = spriteSource.createVertexBuffer("uv", 2, 2);
  103202. var vao = this._engine.recordVertexArrayObject(renderVertexBuffers, null, this._renderEffect);
  103203. this._engine.bindArrayBuffer(null);
  103204. return vao;
  103205. };
  103206. GPUParticleSystem.prototype._initialize = function (force) {
  103207. if (force === void 0) { force = false; }
  103208. if (this._buffer0 && !force) {
  103209. return;
  103210. }
  103211. var engine = this._scene.getEngine();
  103212. var data = new Array();
  103213. this._attributesStrideSize = 21;
  103214. this._targetIndex = 0;
  103215. if (!this.isBillboardBased) {
  103216. this._attributesStrideSize += 3;
  103217. }
  103218. if (this._colorGradientsTexture) {
  103219. this._attributesStrideSize -= 4;
  103220. }
  103221. if (this._angularSpeedGradientsTexture) {
  103222. this._attributesStrideSize -= 1;
  103223. }
  103224. if (this._isAnimationSheetEnabled) {
  103225. this._attributesStrideSize += 1;
  103226. if (this.spriteRandomStartCell) {
  103227. this._attributesStrideSize += 1;
  103228. }
  103229. }
  103230. if (this.noiseTexture) {
  103231. this._attributesStrideSize += 6;
  103232. }
  103233. for (var particleIndex = 0; particleIndex < this._capacity; particleIndex++) {
  103234. // position
  103235. data.push(0.0);
  103236. data.push(0.0);
  103237. data.push(0.0);
  103238. // Age and life
  103239. data.push(0.0); // create the particle as a dead one to create a new one at start
  103240. data.push(0.0);
  103241. // Seed
  103242. data.push(Math.random());
  103243. data.push(Math.random());
  103244. data.push(Math.random());
  103245. data.push(Math.random());
  103246. // Size
  103247. data.push(0.0);
  103248. data.push(0.0);
  103249. data.push(0.0);
  103250. if (!this._colorGradientsTexture) {
  103251. // color
  103252. data.push(0.0);
  103253. data.push(0.0);
  103254. data.push(0.0);
  103255. data.push(0.0);
  103256. }
  103257. // direction
  103258. data.push(0.0);
  103259. data.push(0.0);
  103260. data.push(0.0);
  103261. if (!this.isBillboardBased) {
  103262. // initialDirection
  103263. data.push(0.0);
  103264. data.push(0.0);
  103265. data.push(0.0);
  103266. }
  103267. // angle
  103268. data.push(0.0);
  103269. if (!this._angularSpeedGradientsTexture) {
  103270. data.push(0.0);
  103271. }
  103272. if (this._isAnimationSheetEnabled) {
  103273. data.push(0.0);
  103274. if (this.spriteRandomStartCell) {
  103275. data.push(0.0);
  103276. }
  103277. }
  103278. if (this.noiseTexture) { // Random coordinates for reading into noise texture
  103279. data.push(Math.random());
  103280. data.push(Math.random());
  103281. data.push(Math.random());
  103282. data.push(Math.random());
  103283. data.push(Math.random());
  103284. data.push(Math.random());
  103285. }
  103286. }
  103287. // Sprite data
  103288. var spriteData = new Float32Array([0.5, 0.5, 1, 1,
  103289. -0.5, 0.5, 0, 1,
  103290. -0.5, -0.5, 0, 0,
  103291. 0.5, -0.5, 1, 0]);
  103292. // Buffers
  103293. this._buffer0 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  103294. this._buffer1 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  103295. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 4);
  103296. // Update VAO
  103297. this._updateVAO = [];
  103298. this._updateVAO.push(this._createUpdateVAO(this._buffer0));
  103299. this._updateVAO.push(this._createUpdateVAO(this._buffer1));
  103300. // Render VAO
  103301. this._renderVAO = [];
  103302. this._renderVAO.push(this._createRenderVAO(this._buffer1, this._spriteBuffer));
  103303. this._renderVAO.push(this._createRenderVAO(this._buffer0, this._spriteBuffer));
  103304. // Links
  103305. this._sourceBuffer = this._buffer0;
  103306. this._targetBuffer = this._buffer1;
  103307. };
  103308. /** @hidden */
  103309. GPUParticleSystem.prototype._recreateUpdateEffect = function () {
  103310. var defines = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
  103311. if (this._isBillboardBased) {
  103312. defines += "\n#define BILLBOARD";
  103313. }
  103314. if (this._colorGradientsTexture) {
  103315. defines += "\n#define COLORGRADIENTS";
  103316. }
  103317. if (this._sizeGradientsTexture) {
  103318. defines += "\n#define SIZEGRADIENTS";
  103319. }
  103320. if (this._angularSpeedGradientsTexture) {
  103321. defines += "\n#define ANGULARSPEEDGRADIENTS";
  103322. }
  103323. if (this._velocityGradientsTexture) {
  103324. defines += "\n#define VELOCITYGRADIENTS";
  103325. }
  103326. if (this._limitVelocityGradientsTexture) {
  103327. defines += "\n#define LIMITVELOCITYGRADIENTS";
  103328. }
  103329. if (this._dragGradientsTexture) {
  103330. defines += "\n#define DRAGGRADIENTS";
  103331. }
  103332. if (this.isAnimationSheetEnabled) {
  103333. defines += "\n#define ANIMATESHEET";
  103334. if (this.spriteRandomStartCell) {
  103335. defines += "\n#define ANIMATESHEETRANDOMSTART";
  103336. }
  103337. }
  103338. if (this.noiseTexture) {
  103339. defines += "\n#define NOISE";
  103340. }
  103341. if (this._updateEffect && this._updateEffectOptions.defines === defines) {
  103342. return;
  103343. }
  103344. this._updateEffectOptions.transformFeedbackVaryings = ["outPosition", "outAge", "outLife", "outSeed", "outSize"];
  103345. if (!this._colorGradientsTexture) {
  103346. this._updateEffectOptions.transformFeedbackVaryings.push("outColor");
  103347. }
  103348. this._updateEffectOptions.transformFeedbackVaryings.push("outDirection");
  103349. if (!this._isBillboardBased) {
  103350. this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection");
  103351. }
  103352. this._updateEffectOptions.transformFeedbackVaryings.push("outAngle");
  103353. if (this.isAnimationSheetEnabled) {
  103354. this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex");
  103355. if (this.spriteRandomStartCell) {
  103356. this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset");
  103357. }
  103358. }
  103359. if (this.noiseTexture) {
  103360. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1");
  103361. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2");
  103362. }
  103363. this._updateEffectOptions.defines = defines;
  103364. this._updateEffect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["Effect"]("gpuUpdateParticles", this._updateEffectOptions, this._scene.getEngine());
  103365. };
  103366. /** @hidden */
  103367. GPUParticleSystem.prototype._recreateRenderEffect = function () {
  103368. var defines = "";
  103369. if (this._scene.clipPlane) {
  103370. defines = "\n#define CLIPPLANE";
  103371. }
  103372. if (this._scene.clipPlane2) {
  103373. defines = "\n#define CLIPPLANE2";
  103374. }
  103375. if (this._scene.clipPlane3) {
  103376. defines = "\n#define CLIPPLANE3";
  103377. }
  103378. if (this._scene.clipPlane4) {
  103379. defines = "\n#define CLIPPLANE4";
  103380. }
  103381. if (this.blendMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY) {
  103382. defines = "\n#define BLENDMULTIPLYMODE";
  103383. }
  103384. if (this._isBillboardBased) {
  103385. defines += "\n#define BILLBOARD";
  103386. switch (this.billboardMode) {
  103387. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_Y:
  103388. defines += "\n#define BILLBOARDY";
  103389. break;
  103390. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED:
  103391. defines += "\n#define BILLBOARDSTRETCHED";
  103392. break;
  103393. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_ALL:
  103394. default:
  103395. break;
  103396. }
  103397. }
  103398. if (this._colorGradientsTexture) {
  103399. defines += "\n#define COLORGRADIENTS";
  103400. }
  103401. if (this.isAnimationSheetEnabled) {
  103402. defines += "\n#define ANIMATESHEET";
  103403. }
  103404. if (this._imageProcessingConfiguration) {
  103405. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  103406. defines += "\n" + this._imageProcessingConfigurationDefines.toString();
  103407. }
  103408. if (this._renderEffect && this._renderEffect.defines === defines) {
  103409. return;
  103410. }
  103411. var uniforms = ["view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "sheetInfos", "translationPivot", "eyePosition"];
  103412. var samplers = ["textureSampler", "colorGradientSampler"];
  103413. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  103414. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._imageProcessingConfigurationDefines);
  103415. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  103416. }
  103417. 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);
  103418. };
  103419. /**
  103420. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  103421. * @param preWarm defines if we are in the pre-warmimg phase
  103422. */
  103423. GPUParticleSystem.prototype.animate = function (preWarm) {
  103424. if (preWarm === void 0) { preWarm = false; }
  103425. this._timeDelta = this.updateSpeed * (preWarm ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  103426. this._actualFrame += this._timeDelta;
  103427. if (!this._stopped) {
  103428. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  103429. this.stop();
  103430. }
  103431. }
  103432. };
  103433. GPUParticleSystem.prototype._createFactorGradientTexture = function (factorGradients, textureName) {
  103434. var texture = this[textureName];
  103435. if (!factorGradients || !factorGradients.length || texture) {
  103436. return;
  103437. }
  103438. var data = new Float32Array(this._rawTextureWidth);
  103439. for (var x = 0; x < this._rawTextureWidth; x++) {
  103440. var ratio = x / this._rawTextureWidth;
  103441. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, factorGradients, function (currentGradient, nextGradient, scale) {
  103442. data[x] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  103443. });
  103444. }
  103445. 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);
  103446. };
  103447. GPUParticleSystem.prototype._createSizeGradientTexture = function () {
  103448. this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture");
  103449. };
  103450. GPUParticleSystem.prototype._createAngularSpeedGradientTexture = function () {
  103451. this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture");
  103452. };
  103453. GPUParticleSystem.prototype._createVelocityGradientTexture = function () {
  103454. this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture");
  103455. };
  103456. GPUParticleSystem.prototype._createLimitVelocityGradientTexture = function () {
  103457. this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture");
  103458. };
  103459. GPUParticleSystem.prototype._createDragGradientTexture = function () {
  103460. this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture");
  103461. };
  103462. GPUParticleSystem.prototype._createColorGradientTexture = function () {
  103463. if (!this._colorGradients || !this._colorGradients.length || this._colorGradientsTexture) {
  103464. return;
  103465. }
  103466. var data = new Uint8Array(this._rawTextureWidth * 4);
  103467. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color4[0];
  103468. for (var x = 0; x < this._rawTextureWidth; x++) {
  103469. var ratio = x / this._rawTextureWidth;
  103470. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._colorGradients, function (currentGradient, nextGradient, scale) {
  103471. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(currentGradient.color1, nextGradient.color1, scale, tmpColor);
  103472. data[x * 4] = tmpColor.r * 255;
  103473. data[x * 4 + 1] = tmpColor.g * 255;
  103474. data[x * 4 + 2] = tmpColor.b * 255;
  103475. data[x * 4 + 3] = tmpColor.a * 255;
  103476. });
  103477. }
  103478. 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);
  103479. };
  103480. /**
  103481. * Renders the particle system in its current state
  103482. * @param preWarm defines if the system should only update the particles but not render them
  103483. * @returns the current number of particles
  103484. */
  103485. GPUParticleSystem.prototype.render = function (preWarm) {
  103486. if (preWarm === void 0) { preWarm = false; }
  103487. if (!this._started) {
  103488. return 0;
  103489. }
  103490. this._createColorGradientTexture();
  103491. this._createSizeGradientTexture();
  103492. this._createAngularSpeedGradientTexture();
  103493. this._createVelocityGradientTexture();
  103494. this._createLimitVelocityGradientTexture();
  103495. this._createDragGradientTexture();
  103496. this._recreateUpdateEffect();
  103497. this._recreateRenderEffect();
  103498. if (!this.isReady()) {
  103499. return 0;
  103500. }
  103501. if (!preWarm) {
  103502. if (!this._preWarmDone && this.preWarmCycles) {
  103503. for (var index = 0; index < this.preWarmCycles; index++) {
  103504. this.animate(true);
  103505. this.render(true);
  103506. }
  103507. this._preWarmDone = true;
  103508. }
  103509. if (this._currentRenderId === this._scene.getFrameId()) {
  103510. return 0;
  103511. }
  103512. this._currentRenderId = this._scene.getFrameId();
  103513. }
  103514. // Get everything ready to render
  103515. this._initialize();
  103516. this._accumulatedCount += this.emitRate * this._timeDelta;
  103517. if (this._accumulatedCount > 1) {
  103518. var intPart = this._accumulatedCount | 0;
  103519. this._accumulatedCount -= intPart;
  103520. this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + intPart);
  103521. }
  103522. if (!this._currentActiveCount) {
  103523. return 0;
  103524. }
  103525. // Enable update effect
  103526. this._engine.enableEffect(this._updateEffect);
  103527. this._engine.setState(false);
  103528. this._updateEffect.setFloat("currentCount", this._currentActiveCount);
  103529. this._updateEffect.setFloat("timeDelta", this._timeDelta);
  103530. this._updateEffect.setFloat("stopFactor", this._stopped ? 0 : 1);
  103531. this._updateEffect.setTexture("randomSampler", this._randomTexture);
  103532. this._updateEffect.setTexture("randomSampler2", this._randomTexture2);
  103533. this._updateEffect.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
  103534. this._updateEffect.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower);
  103535. if (!this._colorGradientsTexture) {
  103536. this._updateEffect.setDirectColor4("color1", this.color1);
  103537. this._updateEffect.setDirectColor4("color2", this.color2);
  103538. }
  103539. this._updateEffect.setFloat2("sizeRange", this.minSize, this.maxSize);
  103540. this._updateEffect.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY);
  103541. this._updateEffect.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation);
  103542. this._updateEffect.setVector3("gravity", this.gravity);
  103543. if (this._sizeGradientsTexture) {
  103544. this._updateEffect.setTexture("sizeGradientSampler", this._sizeGradientsTexture);
  103545. }
  103546. if (this._angularSpeedGradientsTexture) {
  103547. this._updateEffect.setTexture("angularSpeedGradientSampler", this._angularSpeedGradientsTexture);
  103548. }
  103549. if (this._velocityGradientsTexture) {
  103550. this._updateEffect.setTexture("velocityGradientSampler", this._velocityGradientsTexture);
  103551. }
  103552. if (this._limitVelocityGradientsTexture) {
  103553. this._updateEffect.setTexture("limitVelocityGradientSampler", this._limitVelocityGradientsTexture);
  103554. this._updateEffect.setFloat("limitVelocityDamping", this.limitVelocityDamping);
  103555. }
  103556. if (this._dragGradientsTexture) {
  103557. this._updateEffect.setTexture("dragGradientSampler", this._dragGradientsTexture);
  103558. }
  103559. if (this.particleEmitterType) {
  103560. this.particleEmitterType.applyToShader(this._updateEffect);
  103561. }
  103562. if (this._isAnimationSheetEnabled) {
  103563. this._updateEffect.setFloat3("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed);
  103564. }
  103565. if (this.noiseTexture) {
  103566. this._updateEffect.setTexture("noiseSampler", this.noiseTexture);
  103567. this._updateEffect.setVector3("noiseStrength", this.noiseStrength);
  103568. }
  103569. var emitterWM;
  103570. if (this.emitter.position) {
  103571. var emitterMesh = this.emitter;
  103572. emitterWM = emitterMesh.getWorldMatrix();
  103573. }
  103574. else {
  103575. var emitterPosition = this.emitter;
  103576. emitterWM = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  103577. }
  103578. this._updateEffect.setMatrix("emitterWM", emitterWM);
  103579. // Bind source VAO
  103580. this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex], null);
  103581. // Update
  103582. this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer());
  103583. this._engine.setRasterizerState(false);
  103584. this._engine.beginTransformFeedback(true);
  103585. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].PointListDrawMode, 0, this._currentActiveCount);
  103586. this._engine.endTransformFeedback();
  103587. this._engine.setRasterizerState(true);
  103588. this._engine.bindTransformFeedbackBuffer(null);
  103589. if (!preWarm) {
  103590. // Enable render effect
  103591. this._engine.enableEffect(this._renderEffect);
  103592. var viewMatrix = this._scene.getViewMatrix();
  103593. this._renderEffect.setMatrix("view", viewMatrix);
  103594. this._renderEffect.setMatrix("projection", this._scene.getProjectionMatrix());
  103595. this._renderEffect.setTexture("textureSampler", this.particleTexture);
  103596. this._renderEffect.setVector2("translationPivot", this.translationPivot);
  103597. if (this._colorGradientsTexture) {
  103598. this._renderEffect.setTexture("colorGradientSampler", this._colorGradientsTexture);
  103599. }
  103600. else {
  103601. this._renderEffect.setDirectColor4("colorDead", this.colorDead);
  103602. }
  103603. if (this._isAnimationSheetEnabled && this.particleTexture) {
  103604. var baseSize = this.particleTexture.getBaseSize();
  103605. this._renderEffect.setFloat3("sheetInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  103606. }
  103607. if (this._isBillboardBased) {
  103608. var camera = this._scene.activeCamera;
  103609. this._renderEffect.setVector3("eyePosition", camera.globalPosition);
  103610. }
  103611. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  103612. var invView = viewMatrix.clone();
  103613. invView.invert();
  103614. this._renderEffect.setMatrix("invView", invView);
  103615. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindClipPlane(this._renderEffect, this._scene);
  103616. }
  103617. // image processing
  103618. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  103619. this._imageProcessingConfiguration.bind(this._renderEffect);
  103620. }
  103621. // Draw order
  103622. switch (this.blendMode) {
  103623. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ADD:
  103624. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ADD);
  103625. break;
  103626. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ONEONE:
  103627. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ONEONE);
  103628. break;
  103629. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_STANDARD:
  103630. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_COMBINE);
  103631. break;
  103632. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY:
  103633. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_MULTIPLY);
  103634. break;
  103635. }
  103636. if (this.forceDepthWrite) {
  103637. this._engine.setDepthWrite(true);
  103638. }
  103639. // Bind source VAO
  103640. this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex], null);
  103641. // Render
  103642. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].TriangleFanDrawMode, 0, 4, this._currentActiveCount);
  103643. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_DISABLE);
  103644. }
  103645. // Switch VAOs
  103646. this._targetIndex++;
  103647. if (this._targetIndex === 2) {
  103648. this._targetIndex = 0;
  103649. }
  103650. // Switch buffers
  103651. var tmpBuffer = this._sourceBuffer;
  103652. this._sourceBuffer = this._targetBuffer;
  103653. this._targetBuffer = tmpBuffer;
  103654. return this._currentActiveCount;
  103655. };
  103656. /**
  103657. * Rebuilds the particle system
  103658. */
  103659. GPUParticleSystem.prototype.rebuild = function () {
  103660. this._initialize(true);
  103661. };
  103662. GPUParticleSystem.prototype._releaseBuffers = function () {
  103663. if (this._buffer0) {
  103664. this._buffer0.dispose();
  103665. this._buffer0 = null;
  103666. }
  103667. if (this._buffer1) {
  103668. this._buffer1.dispose();
  103669. this._buffer1 = null;
  103670. }
  103671. if (this._spriteBuffer) {
  103672. this._spriteBuffer.dispose();
  103673. this._spriteBuffer = null;
  103674. }
  103675. };
  103676. GPUParticleSystem.prototype._releaseVAOs = function () {
  103677. if (!this._updateVAO) {
  103678. return;
  103679. }
  103680. for (var index = 0; index < this._updateVAO.length; index++) {
  103681. this._engine.releaseVertexArrayObject(this._updateVAO[index]);
  103682. }
  103683. this._updateVAO = [];
  103684. for (var index = 0; index < this._renderVAO.length; index++) {
  103685. this._engine.releaseVertexArrayObject(this._renderVAO[index]);
  103686. }
  103687. this._renderVAO = [];
  103688. };
  103689. /**
  103690. * Disposes the particle system and free the associated resources
  103691. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  103692. */
  103693. GPUParticleSystem.prototype.dispose = function (disposeTexture) {
  103694. if (disposeTexture === void 0) { disposeTexture = true; }
  103695. var index = this._scene.particleSystems.indexOf(this);
  103696. if (index > -1) {
  103697. this._scene.particleSystems.splice(index, 1);
  103698. }
  103699. this._releaseBuffers();
  103700. this._releaseVAOs();
  103701. if (this._colorGradientsTexture) {
  103702. this._colorGradientsTexture.dispose();
  103703. this._colorGradientsTexture = null;
  103704. }
  103705. if (this._sizeGradientsTexture) {
  103706. this._sizeGradientsTexture.dispose();
  103707. this._sizeGradientsTexture = null;
  103708. }
  103709. if (this._angularSpeedGradientsTexture) {
  103710. this._angularSpeedGradientsTexture.dispose();
  103711. this._angularSpeedGradientsTexture = null;
  103712. }
  103713. if (this._velocityGradientsTexture) {
  103714. this._velocityGradientsTexture.dispose();
  103715. this._velocityGradientsTexture = null;
  103716. }
  103717. if (this._limitVelocityGradientsTexture) {
  103718. this._limitVelocityGradientsTexture.dispose();
  103719. this._limitVelocityGradientsTexture = null;
  103720. }
  103721. if (this._dragGradientsTexture) {
  103722. this._dragGradientsTexture.dispose();
  103723. this._dragGradientsTexture = null;
  103724. }
  103725. if (this._randomTexture) {
  103726. this._randomTexture.dispose();
  103727. this._randomTexture = null;
  103728. }
  103729. if (this._randomTexture2) {
  103730. this._randomTexture2.dispose();
  103731. this._randomTexture2 = null;
  103732. }
  103733. if (disposeTexture && this.particleTexture) {
  103734. this.particleTexture.dispose();
  103735. this.particleTexture = null;
  103736. }
  103737. if (disposeTexture && this.noiseTexture) {
  103738. this.noiseTexture.dispose();
  103739. this.noiseTexture = null;
  103740. }
  103741. // Callback
  103742. this.onDisposeObservable.notifyObservers(this);
  103743. this.onDisposeObservable.clear();
  103744. };
  103745. /**
  103746. * Clones the particle system.
  103747. * @param name The name of the cloned object
  103748. * @param newEmitter The new emitter to use
  103749. * @returns the cloned particle system
  103750. */
  103751. GPUParticleSystem.prototype.clone = function (name, newEmitter) {
  103752. var result = new GPUParticleSystem(name, { capacity: this._capacity, randomTextureSize: this._randomTextureSize }, this._scene);
  103753. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__["DeepCopier"].DeepCopy(this, result);
  103754. if (newEmitter === undefined) {
  103755. newEmitter = this.emitter;
  103756. }
  103757. result.emitter = newEmitter;
  103758. if (this.particleTexture) {
  103759. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"](this.particleTexture.url, this._scene);
  103760. }
  103761. return result;
  103762. };
  103763. /**
  103764. * Serializes the particle system to a JSON object.
  103765. * @returns the JSON object
  103766. */
  103767. GPUParticleSystem.prototype.serialize = function () {
  103768. var serializationObject = {};
  103769. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Serialize(serializationObject, this);
  103770. serializationObject.activeParticleCount = this.activeParticleCount;
  103771. return serializationObject;
  103772. };
  103773. /**
  103774. * Parses a JSON object to create a GPU particle system.
  103775. * @param parsedParticleSystem The JSON object to parse
  103776. * @param scene The scene to create the particle system in
  103777. * @param rootUrl The root url to use to load external dependencies like texture
  103778. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  103779. * @returns the parsed GPU particle system
  103780. */
  103781. GPUParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  103782. if (doNotStart === void 0) { doNotStart = false; }
  103783. var name = parsedParticleSystem.name;
  103784. var particleSystem = new GPUParticleSystem(name, { capacity: parsedParticleSystem.capacity, randomTextureSize: parsedParticleSystem.randomTextureSize }, scene);
  103785. if (parsedParticleSystem.activeParticleCount) {
  103786. particleSystem.activeParticleCount = parsedParticleSystem.activeParticleCount;
  103787. }
  103788. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  103789. // Auto start
  103790. if (parsedParticleSystem.preventAutoStart) {
  103791. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  103792. }
  103793. if (!doNotStart && !particleSystem.preventAutoStart) {
  103794. particleSystem.start();
  103795. }
  103796. return particleSystem;
  103797. };
  103798. return GPUParticleSystem;
  103799. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__["BaseParticleSystem"]));
  103800. /***/ }),
  103801. /***/ "./Particles/index.ts":
  103802. /*!****************************!*\
  103803. !*** ./Particles/index.ts ***!
  103804. \****************************/
  103805. /*! exports provided: BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  103806. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103807. "use strict";
  103808. __webpack_require__.r(__webpack_exports__);
  103809. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  103810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  103811. /* harmony import */ var _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  103812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["BoxParticleEmitter"]; });
  103813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  103814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderParticleEmitter"]; });
  103815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderDirectedParticleEmitter"]; });
  103816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["HemisphericParticleEmitter"]; });
  103817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["PointParticleEmitter"]; });
  103818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereParticleEmitter"]; });
  103819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereDirectedParticleEmitter"]; });
  103820. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  103821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__["GPUParticleSystem"]; });
  103822. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  103823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _particle__WEBPACK_IMPORTED_MODULE_3__["Particle"]; });
  103824. /* harmony import */ var _particleHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleHelper */ "./Particles/particleHelper.ts");
  103825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _particleHelper__WEBPACK_IMPORTED_MODULE_4__["ParticleHelper"]; });
  103826. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  103827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _particleSystem__WEBPACK_IMPORTED_MODULE_5__["ParticleSystem"]; });
  103828. /* harmony import */ var _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystemComponent */ "./Particles/particleSystemComponent.ts");
  103829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__["_IDoNeedToBeInTheBuild"]; });
  103830. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  103831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__["ParticleSystemSet"]; });
  103832. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  103833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["SolidParticle"]; });
  103834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["ModelShape"]; });
  103835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["DepthSortedParticle"]; });
  103836. /* harmony import */ var _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./solidParticleSystem */ "./Particles/solidParticleSystem.ts");
  103837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__["SolidParticleSystem"]; });
  103838. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  103839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitterType"]; });
  103840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitter"]; });
  103841. /***/ }),
  103842. /***/ "./Particles/particle.ts":
  103843. /*!*******************************!*\
  103844. !*** ./Particles/particle.ts ***!
  103845. \*******************************/
  103846. /*! exports provided: Particle */
  103847. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103848. "use strict";
  103849. __webpack_require__.r(__webpack_exports__);
  103850. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return Particle; });
  103851. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  103852. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  103853. /**
  103854. * A particle represents one of the element emitted by a particle system.
  103855. * This is mainly define by its coordinates, direction, velocity and age.
  103856. */
  103857. var Particle = /** @class */ (function () {
  103858. /**
  103859. * Creates a new instance Particle
  103860. * @param particleSystem the particle system the particle belongs to
  103861. */
  103862. function Particle(
  103863. /**
  103864. * The particle system the particle belongs to.
  103865. */
  103866. particleSystem) {
  103867. this.particleSystem = particleSystem;
  103868. /**
  103869. * The world position of the particle in the scene.
  103870. */
  103871. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103872. /**
  103873. * The world direction of the particle in the scene.
  103874. */
  103875. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103876. /**
  103877. * The color of the particle.
  103878. */
  103879. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  103880. /**
  103881. * The color change of the particle per step.
  103882. */
  103883. this.colorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  103884. /**
  103885. * Defines how long will the life of the particle be.
  103886. */
  103887. this.lifeTime = 1.0;
  103888. /**
  103889. * The current age of the particle.
  103890. */
  103891. this.age = 0;
  103892. /**
  103893. * The current size of the particle.
  103894. */
  103895. this.size = 0;
  103896. /**
  103897. * The current scale of the particle.
  103898. */
  103899. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](1, 1);
  103900. /**
  103901. * The current angle of the particle.
  103902. */
  103903. this.angle = 0;
  103904. /**
  103905. * Defines how fast is the angle changing.
  103906. */
  103907. this.angularSpeed = 0;
  103908. /**
  103909. * Defines the cell index used by the particle to be rendered from a sprite.
  103910. */
  103911. this.cellIndex = 0;
  103912. /** @hidden */
  103913. this._attachedSubEmitters = null;
  103914. /** @hidden */
  103915. this._currentColor1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  103916. /** @hidden */
  103917. this._currentColor2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  103918. /** @hidden */
  103919. this._currentSize1 = 0;
  103920. /** @hidden */
  103921. this._currentSize2 = 0;
  103922. /** @hidden */
  103923. this._currentAngularSpeed1 = 0;
  103924. /** @hidden */
  103925. this._currentAngularSpeed2 = 0;
  103926. /** @hidden */
  103927. this._currentVelocity1 = 0;
  103928. /** @hidden */
  103929. this._currentVelocity2 = 0;
  103930. /** @hidden */
  103931. this._currentLimitVelocity1 = 0;
  103932. /** @hidden */
  103933. this._currentLimitVelocity2 = 0;
  103934. /** @hidden */
  103935. this._currentDrag1 = 0;
  103936. /** @hidden */
  103937. this._currentDrag2 = 0;
  103938. this.id = Particle._Count++;
  103939. if (!this.particleSystem.isAnimationSheetEnabled) {
  103940. return;
  103941. }
  103942. this.updateCellInfoFromSystem();
  103943. }
  103944. Particle.prototype.updateCellInfoFromSystem = function () {
  103945. this.cellIndex = this.particleSystem.startSpriteCellID;
  103946. };
  103947. /**
  103948. * Defines how the sprite cell index is updated for the particle
  103949. */
  103950. Particle.prototype.updateCellIndex = function () {
  103951. var offsetAge = this.age;
  103952. var changeSpeed = this.particleSystem.spriteCellChangeSpeed;
  103953. if (this.particleSystem.spriteRandomStartCell) {
  103954. if (this._randomCellOffset === undefined) {
  103955. this._randomCellOffset = Math.random() * this.lifeTime;
  103956. }
  103957. if (changeSpeed === 0) { // Special case when speed = 0 meaning we want to stay on initial cell
  103958. changeSpeed = 1;
  103959. offsetAge = this._randomCellOffset;
  103960. }
  103961. else {
  103962. offsetAge += this._randomCellOffset;
  103963. }
  103964. }
  103965. var dist = (this._initialEndSpriteCellID - this._initialStartSpriteCellID);
  103966. var ratio = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(((offsetAge * changeSpeed) % this.lifeTime) / this.lifeTime);
  103967. this.cellIndex = this._initialStartSpriteCellID + (ratio * dist) | 0;
  103968. };
  103969. /** @hidden */
  103970. Particle.prototype._inheritParticleInfoToSubEmitter = function (subEmitter) {
  103971. if (subEmitter.particleSystem.emitter.position) {
  103972. var emitterMesh = subEmitter.particleSystem.emitter;
  103973. emitterMesh.position.copyFrom(this.position);
  103974. if (subEmitter.inheritDirection) {
  103975. emitterMesh.position.subtractToRef(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  103976. // Look at using Y as forward
  103977. emitterMesh.lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0], 0, Math.PI / 2);
  103978. }
  103979. }
  103980. else {
  103981. var emitterPosition = subEmitter.particleSystem.emitter;
  103982. emitterPosition.copyFrom(this.position);
  103983. }
  103984. // Set inheritedVelocityOffset to be used when new particles are created
  103985. this.direction.scaleToRef(subEmitter.inheritedVelocityAmount / 2, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  103986. subEmitter.particleSystem._inheritedVelocityOffset.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  103987. };
  103988. /** @hidden */
  103989. Particle.prototype._inheritParticleInfoToSubEmitters = function () {
  103990. var _this = this;
  103991. if (this._attachedSubEmitters && this._attachedSubEmitters.length > 0) {
  103992. this._attachedSubEmitters.forEach(function (subEmitter) {
  103993. _this._inheritParticleInfoToSubEmitter(subEmitter);
  103994. });
  103995. }
  103996. };
  103997. /** @hidden */
  103998. Particle.prototype._reset = function () {
  103999. this.age = 0;
  104000. this._currentColorGradient = null;
  104001. this._currentSizeGradient = null;
  104002. this._currentAngularSpeedGradient = null;
  104003. this._currentVelocityGradient = null;
  104004. this._currentLimitVelocityGradient = null;
  104005. this._currentDragGradient = null;
  104006. this.cellIndex = this.particleSystem.startSpriteCellID;
  104007. this._randomCellOffset = undefined;
  104008. };
  104009. /**
  104010. * Copy the properties of particle to another one.
  104011. * @param other the particle to copy the information to.
  104012. */
  104013. Particle.prototype.copyTo = function (other) {
  104014. other.position.copyFrom(this.position);
  104015. if (this._initialDirection) {
  104016. if (other._initialDirection) {
  104017. other._initialDirection.copyFrom(this._initialDirection);
  104018. }
  104019. else {
  104020. other._initialDirection = this._initialDirection.clone();
  104021. }
  104022. }
  104023. else {
  104024. other._initialDirection = null;
  104025. }
  104026. other.direction.copyFrom(this.direction);
  104027. other.color.copyFrom(this.color);
  104028. other.colorStep.copyFrom(this.colorStep);
  104029. other.lifeTime = this.lifeTime;
  104030. other.age = this.age;
  104031. other._randomCellOffset = this._randomCellOffset;
  104032. other.size = this.size;
  104033. other.scale.copyFrom(this.scale);
  104034. other.angle = this.angle;
  104035. other.angularSpeed = this.angularSpeed;
  104036. other.particleSystem = this.particleSystem;
  104037. other.cellIndex = this.cellIndex;
  104038. other.id = this.id;
  104039. other._attachedSubEmitters = this._attachedSubEmitters;
  104040. if (this._currentColorGradient) {
  104041. other._currentColorGradient = this._currentColorGradient;
  104042. other._currentColor1.copyFrom(this._currentColor1);
  104043. other._currentColor2.copyFrom(this._currentColor2);
  104044. }
  104045. if (this._currentSizeGradient) {
  104046. other._currentSizeGradient = this._currentSizeGradient;
  104047. other._currentSize1 = this._currentSize1;
  104048. other._currentSize2 = this._currentSize2;
  104049. }
  104050. if (this._currentAngularSpeedGradient) {
  104051. other._currentAngularSpeedGradient = this._currentAngularSpeedGradient;
  104052. other._currentAngularSpeed1 = this._currentAngularSpeed1;
  104053. other._currentAngularSpeed2 = this._currentAngularSpeed2;
  104054. }
  104055. if (this._currentVelocityGradient) {
  104056. other._currentVelocityGradient = this._currentVelocityGradient;
  104057. other._currentVelocity1 = this._currentVelocity1;
  104058. other._currentVelocity2 = this._currentVelocity2;
  104059. }
  104060. if (this._currentLimitVelocityGradient) {
  104061. other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;
  104062. other._currentLimitVelocity1 = this._currentLimitVelocity1;
  104063. other._currentLimitVelocity2 = this._currentLimitVelocity2;
  104064. }
  104065. if (this._currentDragGradient) {
  104066. other._currentDragGradient = this._currentDragGradient;
  104067. other._currentDrag1 = this._currentDrag1;
  104068. other._currentDrag2 = this._currentDrag2;
  104069. }
  104070. if (this.particleSystem.isAnimationSheetEnabled) {
  104071. other._initialStartSpriteCellID = this._initialStartSpriteCellID;
  104072. other._initialEndSpriteCellID = this._initialEndSpriteCellID;
  104073. }
  104074. if (this.particleSystem.useRampGradients) {
  104075. other.remapData.copyFrom(this.remapData);
  104076. }
  104077. if (this._randomNoiseCoordinates1) {
  104078. if (other._randomNoiseCoordinates1) {
  104079. other._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1);
  104080. other._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2);
  104081. }
  104082. else {
  104083. other._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone();
  104084. other._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone();
  104085. }
  104086. }
  104087. };
  104088. Particle._Count = 0;
  104089. return Particle;
  104090. }());
  104091. /***/ }),
  104092. /***/ "./Particles/particleHelper.ts":
  104093. /*!*************************************!*\
  104094. !*** ./Particles/particleHelper.ts ***!
  104095. \*************************************/
  104096. /*! exports provided: ParticleHelper */
  104097. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104098. "use strict";
  104099. __webpack_require__.r(__webpack_exports__);
  104100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return ParticleHelper; });
  104101. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  104102. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  104103. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  104104. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  104105. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  104106. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  104107. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  104108. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  104109. /**
  104110. * This class is made for on one-liner static method to help creating particle system set.
  104111. */
  104112. var ParticleHelper = /** @class */ (function () {
  104113. function ParticleHelper() {
  104114. }
  104115. /**
  104116. * Create a default particle system that you can tweak
  104117. * @param emitter defines the emitter to use
  104118. * @param capacity defines the system capacity (default is 500 particles)
  104119. * @param scene defines the hosting scene
  104120. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  104121. * @returns the new Particle system
  104122. */
  104123. ParticleHelper.CreateDefault = function (emitter, capacity, scene, useGPU) {
  104124. if (capacity === void 0) { capacity = 500; }
  104125. if (useGPU === void 0) { useGPU = false; }
  104126. var system;
  104127. if (useGPU) {
  104128. system = new _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"]("default system", { capacity: capacity }, scene);
  104129. }
  104130. else {
  104131. system = new _particleSystem__WEBPACK_IMPORTED_MODULE_6__["ParticleSystem"]("default system", capacity, scene);
  104132. }
  104133. system.emitter = emitter;
  104134. system.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]("https://www.babylonjs.com/assets/Flare.png", system.getScene());
  104135. system.createConeEmitter(0.1, Math.PI / 4);
  104136. // Particle color
  104137. system.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  104138. system.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  104139. system.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 0.0);
  104140. // Particle Size
  104141. system.minSize = 0.1;
  104142. system.maxSize = 0.1;
  104143. // Emission speed
  104144. system.minEmitPower = 2;
  104145. system.maxEmitPower = 2;
  104146. // Update speed
  104147. system.updateSpeed = 1 / 60;
  104148. system.emitRate = 30;
  104149. return system;
  104150. };
  104151. /**
  104152. * This is the main static method (one-liner) of this helper to create different particle systems
  104153. * @param type This string represents the type to the particle system to create
  104154. * @param scene The scene where the particle system should live
  104155. * @param gpu If the system will use gpu
  104156. * @returns the ParticleSystemSet created
  104157. */
  104158. ParticleHelper.CreateAsync = function (type, scene, gpu) {
  104159. if (gpu === void 0) { gpu = false; }
  104160. if (!scene) {
  104161. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  104162. }
  104163. var token = {};
  104164. scene._addPendingData(token);
  104165. return new Promise(function (resolve, reject) {
  104166. if (gpu && !_gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"].IsSupported) {
  104167. scene._removePendingData(token);
  104168. return reject("Particle system with GPU is not supported.");
  104169. }
  104170. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(ParticleHelper.BaseAssetsUrl + "/systems/" + type + ".json", function (data) {
  104171. scene._removePendingData(token);
  104172. var newData = JSON.parse(data.toString());
  104173. return resolve(_particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"].Parse(newData, scene, gpu));
  104174. }, undefined, undefined, undefined, function () {
  104175. scene._removePendingData(token);
  104176. return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
  104177. });
  104178. });
  104179. };
  104180. /**
  104181. * Static function used to export a particle system to a ParticleSystemSet variable.
  104182. * Please note that the emitter shape is not exported
  104183. * @param systems defines the particle systems to export
  104184. * @returns the created particle system set
  104185. */
  104186. ParticleHelper.ExportSet = function (systems) {
  104187. var set = new _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"]();
  104188. for (var _i = 0, systems_1 = systems; _i < systems_1.length; _i++) {
  104189. var system = systems_1[_i];
  104190. set.systems.push(system);
  104191. }
  104192. return set;
  104193. };
  104194. /**
  104195. * Gets or sets base Assets URL
  104196. */
  104197. ParticleHelper.BaseAssetsUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].PARTICLES_BaseAssetsUrl;
  104198. return ParticleHelper;
  104199. }());
  104200. /***/ }),
  104201. /***/ "./Particles/particleSystem.ts":
  104202. /*!*************************************!*\
  104203. !*** ./Particles/particleSystem.ts ***!
  104204. \*************************************/
  104205. /*! exports provided: ParticleSystem */
  104206. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104207. "use strict";
  104208. __webpack_require__.r(__webpack_exports__);
  104209. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return ParticleSystem; });
  104210. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  104211. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  104212. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  104213. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  104214. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  104215. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  104216. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  104217. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  104218. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  104219. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  104220. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  104221. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  104222. /* harmony import */ var _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/Textures/Procedurals/proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  104223. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  104224. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  104225. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  104226. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  104227. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  104228. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  104229. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  104230. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  104231. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  104232. /* harmony import */ var _Shaders_particles_fragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Shaders/particles.fragment */ "./Shaders/particles.fragment.ts");
  104233. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  104234. /**
  104235. * This represents a particle system in Babylon.
  104236. * 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.
  104237. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  104238. * @example https://doc.babylonjs.com/babylon101/particles
  104239. */
  104240. var ParticleSystem = /** @class */ (function (_super) {
  104241. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticleSystem, _super);
  104242. /**
  104243. * Instantiates a particle system.
  104244. * 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.
  104245. * @param name The name of the particle system
  104246. * @param capacity The max number of particles alive at the same time
  104247. * @param scene The scene the particle system belongs to
  104248. * @param customEffect a custom effect used to change the way particles are rendered by default
  104249. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  104250. * @param epsilon Offset used to render the particles
  104251. */
  104252. function ParticleSystem(name, capacity, scene, customEffect, isAnimationSheetEnabled, epsilon) {
  104253. if (customEffect === void 0) { customEffect = null; }
  104254. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  104255. if (epsilon === void 0) { epsilon = 0.01; }
  104256. var _this = _super.call(this, name) || this;
  104257. /**
  104258. * @hidden
  104259. */
  104260. _this._inheritedVelocityOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  104261. /**
  104262. * An event triggered when the system is disposed
  104263. */
  104264. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  104265. _this._particles = new Array();
  104266. _this._stockParticles = new Array();
  104267. _this._newPartsExcess = 0;
  104268. _this._vertexBuffers = {};
  104269. _this._scaledColorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  104270. _this._colorDiff = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  104271. _this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  104272. _this._scaledGravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  104273. _this._currentRenderId = -1;
  104274. _this._useInstancing = false;
  104275. _this._started = false;
  104276. _this._stopped = false;
  104277. _this._actualFrame = 0;
  104278. /** @hidden */
  104279. _this._currentEmitRate1 = 0;
  104280. /** @hidden */
  104281. _this._currentEmitRate2 = 0;
  104282. /** @hidden */
  104283. _this._currentStartSize1 = 0;
  104284. /** @hidden */
  104285. _this._currentStartSize2 = 0;
  104286. _this._rawTextureWidth = 256;
  104287. _this._useRampGradients = false;
  104288. /**
  104289. * @hidden
  104290. * If the particle systems emitter should be disposed when the particle system is disposed
  104291. */
  104292. _this._disposeEmitterOnDispose = false;
  104293. // start of sub system methods
  104294. /**
  104295. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  104296. * Its lifetime will start back at 0.
  104297. */
  104298. _this.recycleParticle = function (particle) {
  104299. // move particle from activeParticle list to stock particles
  104300. var lastParticle = _this._particles.pop();
  104301. if (lastParticle !== particle) {
  104302. lastParticle.copyTo(particle);
  104303. }
  104304. _this._stockParticles.push(lastParticle);
  104305. };
  104306. _this._createParticle = function () {
  104307. var particle;
  104308. if (_this._stockParticles.length !== 0) {
  104309. particle = _this._stockParticles.pop();
  104310. particle._reset();
  104311. }
  104312. else {
  104313. particle = new _particle__WEBPACK_IMPORTED_MODULE_17__["Particle"](_this);
  104314. }
  104315. // Attach emitters
  104316. if (_this._subEmitters && _this._subEmitters.length > 0) {
  104317. var subEmitters = _this._subEmitters[Math.floor(Math.random() * _this._subEmitters.length)];
  104318. particle._attachedSubEmitters = [];
  104319. subEmitters.forEach(function (subEmitter) {
  104320. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_18__["SubEmitterType"].ATTACHED) {
  104321. var newEmitter = subEmitter.clone();
  104322. particle._attachedSubEmitters.push(newEmitter);
  104323. newEmitter.particleSystem.start();
  104324. }
  104325. });
  104326. }
  104327. return particle;
  104328. };
  104329. _this._emitFromParticle = function (particle) {
  104330. if (!_this._subEmitters || _this._subEmitters.length === 0) {
  104331. return;
  104332. }
  104333. var templateIndex = Math.floor(Math.random() * _this._subEmitters.length);
  104334. _this._subEmitters[templateIndex].forEach(function (subEmitter) {
  104335. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_18__["SubEmitterType"].END) {
  104336. var subSystem = subEmitter.clone();
  104337. particle._inheritParticleInfoToSubEmitter(subSystem);
  104338. subSystem.particleSystem._rootParticleSystem = _this;
  104339. _this.activeSubSystems.push(subSystem.particleSystem);
  104340. subSystem.particleSystem.start();
  104341. }
  104342. });
  104343. };
  104344. _this._capacity = capacity;
  104345. _this._epsilon = epsilon;
  104346. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  104347. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__["EngineStore"].LastCreatedScene;
  104348. // Setup the default processing configuration to the scene.
  104349. _this._attachImageProcessingConfiguration(null);
  104350. _this._customEffect = customEffect;
  104351. _this._scene.particleSystems.push(_this);
  104352. _this._useInstancing = _this._scene.getEngine().getCaps().instancedArrays;
  104353. _this._createIndexBuffer();
  104354. _this._createVertexBuffers();
  104355. // Default emitter type
  104356. _this.particleEmitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["BoxParticleEmitter"]();
  104357. // Update
  104358. _this.updateFunction = function (particles) {
  104359. var noiseTextureSize = null;
  104360. var noiseTextureData = null;
  104361. if (_this.noiseTexture) { // We need to get texture data back to CPU
  104362. noiseTextureSize = _this.noiseTexture.getSize();
  104363. noiseTextureData = (_this.noiseTexture.getContent());
  104364. }
  104365. var _loop_1 = function () {
  104366. particle = particles[index];
  104367. var scaledUpdateSpeed = _this._scaledUpdateSpeed;
  104368. var previousAge = particle.age;
  104369. particle.age += scaledUpdateSpeed;
  104370. // Evaluate step to death
  104371. if (particle.age > particle.lifeTime) {
  104372. var diff = particle.age - previousAge;
  104373. var oldDiff = particle.lifeTime - previousAge;
  104374. scaledUpdateSpeed = (oldDiff * scaledUpdateSpeed) / diff;
  104375. particle.age = particle.lifeTime;
  104376. }
  104377. var ratio = particle.age / particle.lifeTime;
  104378. // Color
  104379. if (_this._colorGradients && _this._colorGradients.length > 0) {
  104380. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorGradients, function (currentGradient, nextGradient, scale) {
  104381. if (currentGradient !== particle._currentColorGradient) {
  104382. particle._currentColor1.copyFrom(particle._currentColor2);
  104383. nextGradient.getColorToRef(particle._currentColor2);
  104384. particle._currentColorGradient = currentGradient;
  104385. }
  104386. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(particle._currentColor1, particle._currentColor2, scale, particle.color);
  104387. });
  104388. }
  104389. else {
  104390. particle.colorStep.scaleToRef(scaledUpdateSpeed, _this._scaledColorStep);
  104391. particle.color.addInPlace(_this._scaledColorStep);
  104392. if (particle.color.a < 0) {
  104393. particle.color.a = 0;
  104394. }
  104395. }
  104396. // Angular speed
  104397. if (_this._angularSpeedGradients && _this._angularSpeedGradients.length > 0) {
  104398. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._angularSpeedGradients, function (currentGradient, nextGradient, scale) {
  104399. if (currentGradient !== particle._currentAngularSpeedGradient) {
  104400. particle._currentAngularSpeed1 = particle._currentAngularSpeed2;
  104401. particle._currentAngularSpeed2 = nextGradient.getFactor();
  104402. particle._currentAngularSpeedGradient = currentGradient;
  104403. }
  104404. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentAngularSpeed1, particle._currentAngularSpeed2, scale);
  104405. });
  104406. }
  104407. particle.angle += particle.angularSpeed * scaledUpdateSpeed;
  104408. // Direction
  104409. var directionScale = scaledUpdateSpeed;
  104410. /// Velocity
  104411. if (_this._velocityGradients && _this._velocityGradients.length > 0) {
  104412. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._velocityGradients, function (currentGradient, nextGradient, scale) {
  104413. if (currentGradient !== particle._currentVelocityGradient) {
  104414. particle._currentVelocity1 = particle._currentVelocity2;
  104415. particle._currentVelocity2 = nextGradient.getFactor();
  104416. particle._currentVelocityGradient = currentGradient;
  104417. }
  104418. directionScale *= _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
  104419. });
  104420. }
  104421. particle.direction.scaleToRef(directionScale, _this._scaledDirection);
  104422. /// Limit velocity
  104423. if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
  104424. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
  104425. if (currentGradient !== particle._currentLimitVelocityGradient) {
  104426. particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
  104427. particle._currentLimitVelocity2 = nextGradient.getFactor();
  104428. particle._currentLimitVelocityGradient = currentGradient;
  104429. }
  104430. var limitVelocity = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
  104431. var currentVelocity = particle.direction.length();
  104432. if (currentVelocity > limitVelocity) {
  104433. particle.direction.scaleInPlace(_this.limitVelocityDamping);
  104434. }
  104435. });
  104436. }
  104437. /// Drag
  104438. if (_this._dragGradients && _this._dragGradients.length > 0) {
  104439. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._dragGradients, function (currentGradient, nextGradient, scale) {
  104440. if (currentGradient !== particle._currentDragGradient) {
  104441. particle._currentDrag1 = particle._currentDrag2;
  104442. particle._currentDrag2 = nextGradient.getFactor();
  104443. particle._currentDragGradient = currentGradient;
  104444. }
  104445. var drag = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentDrag1, particle._currentDrag2, scale);
  104446. _this._scaledDirection.scaleInPlace(1.0 - drag);
  104447. });
  104448. }
  104449. particle.position.addInPlace(_this._scaledDirection);
  104450. // Noise
  104451. if (noiseTextureData && noiseTextureSize && particle._randomNoiseCoordinates1) {
  104452. var fetchedColorR = _this._fetchR(particle._randomNoiseCoordinates1.x, particle._randomNoiseCoordinates1.y, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  104453. var fetchedColorG = _this._fetchR(particle._randomNoiseCoordinates1.z, particle._randomNoiseCoordinates2.x, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  104454. var fetchedColorB = _this._fetchR(particle._randomNoiseCoordinates2.y, particle._randomNoiseCoordinates2.z, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  104455. var force = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  104456. var scaledForce = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  104457. force.copyFromFloats((2 * fetchedColorR - 1) * _this.noiseStrength.x, (2 * fetchedColorG - 1) * _this.noiseStrength.y, (2 * fetchedColorB - 1) * _this.noiseStrength.z);
  104458. force.scaleToRef(scaledUpdateSpeed, scaledForce);
  104459. particle.direction.addInPlace(scaledForce);
  104460. }
  104461. // Gravity
  104462. _this.gravity.scaleToRef(scaledUpdateSpeed, _this._scaledGravity);
  104463. particle.direction.addInPlace(_this._scaledGravity);
  104464. // Size
  104465. if (_this._sizeGradients && _this._sizeGradients.length > 0) {
  104466. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._sizeGradients, function (currentGradient, nextGradient, scale) {
  104467. if (currentGradient !== particle._currentSizeGradient) {
  104468. particle._currentSize1 = particle._currentSize2;
  104469. particle._currentSize2 = nextGradient.getFactor();
  104470. particle._currentSizeGradient = currentGradient;
  104471. }
  104472. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentSize1, particle._currentSize2, scale);
  104473. });
  104474. }
  104475. // Remap data
  104476. if (_this._useRampGradients) {
  104477. if (_this._colorRemapGradients && _this._colorRemapGradients.length > 0) {
  104478. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorRemapGradients, function (currentGradient, nextGradient, scale) {
  104479. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  104480. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  104481. particle.remapData.x = min;
  104482. particle.remapData.y = max - min;
  104483. });
  104484. }
  104485. if (_this._alphaRemapGradients && _this._alphaRemapGradients.length > 0) {
  104486. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._alphaRemapGradients, function (currentGradient, nextGradient, scale) {
  104487. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  104488. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  104489. particle.remapData.z = min;
  104490. particle.remapData.w = max - min;
  104491. });
  104492. }
  104493. }
  104494. if (_this._isAnimationSheetEnabled) {
  104495. particle.updateCellIndex();
  104496. }
  104497. // Update the position of the attached sub-emitters to match their attached particle
  104498. particle._inheritParticleInfoToSubEmitters();
  104499. if (particle.age >= particle.lifeTime) { // Recycle by swapping with last particle
  104500. _this._emitFromParticle(particle);
  104501. if (particle._attachedSubEmitters) {
  104502. particle._attachedSubEmitters.forEach(function (subEmitter) {
  104503. subEmitter.particleSystem.disposeOnStop = true;
  104504. subEmitter.particleSystem.stop();
  104505. });
  104506. particle._attachedSubEmitters = null;
  104507. }
  104508. _this.recycleParticle(particle);
  104509. index--;
  104510. return "continue";
  104511. }
  104512. };
  104513. var particle;
  104514. for (var index = 0; index < particles.length; index++) {
  104515. _loop_1();
  104516. }
  104517. };
  104518. return _this;
  104519. }
  104520. Object.defineProperty(ParticleSystem.prototype, "onDispose", {
  104521. /**
  104522. * Sets a callback that will be triggered when the system is disposed
  104523. */
  104524. set: function (callback) {
  104525. if (this._onDisposeObserver) {
  104526. this.onDisposeObservable.remove(this._onDisposeObserver);
  104527. }
  104528. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  104529. },
  104530. enumerable: true,
  104531. configurable: true
  104532. });
  104533. Object.defineProperty(ParticleSystem.prototype, "useRampGradients", {
  104534. /** Gets or sets a boolean indicating that ramp gradients must be used
  104535. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  104536. */
  104537. get: function () {
  104538. return this._useRampGradients;
  104539. },
  104540. set: function (value) {
  104541. if (this._useRampGradients === value) {
  104542. return;
  104543. }
  104544. this._useRampGradients = value;
  104545. this._resetEffect();
  104546. },
  104547. enumerable: true,
  104548. configurable: true
  104549. });
  104550. Object.defineProperty(ParticleSystem.prototype, "particles", {
  104551. //end of Sub-emitter
  104552. /**
  104553. * Gets the current list of active particles
  104554. */
  104555. get: function () {
  104556. return this._particles;
  104557. },
  104558. enumerable: true,
  104559. configurable: true
  104560. });
  104561. /**
  104562. * Returns the string "ParticleSystem"
  104563. * @returns a string containing the class name
  104564. */
  104565. ParticleSystem.prototype.getClassName = function () {
  104566. return "ParticleSystem";
  104567. };
  104568. ParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor, factor2) {
  104569. var newGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  104570. newGradient.gradient = gradient;
  104571. newGradient.factor1 = factor;
  104572. newGradient.factor2 = factor2;
  104573. factorGradients.push(newGradient);
  104574. factorGradients.sort(function (a, b) {
  104575. if (a.gradient < b.gradient) {
  104576. return -1;
  104577. }
  104578. else if (a.gradient > b.gradient) {
  104579. return 1;
  104580. }
  104581. return 0;
  104582. });
  104583. };
  104584. ParticleSystem.prototype._removeFactorGradient = function (factorGradients, gradient) {
  104585. if (!factorGradients) {
  104586. return;
  104587. }
  104588. var index = 0;
  104589. for (var _i = 0, factorGradients_1 = factorGradients; _i < factorGradients_1.length; _i++) {
  104590. var factorGradient = factorGradients_1[_i];
  104591. if (factorGradient.gradient === gradient) {
  104592. factorGradients.splice(index, 1);
  104593. break;
  104594. }
  104595. index++;
  104596. }
  104597. };
  104598. /**
  104599. * Adds a new life time gradient
  104600. * @param gradient defines the gradient to use (between 0 and 1)
  104601. * @param factor defines the life time factor to affect to the specified gradient
  104602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104603. * @returns the current particle system
  104604. */
  104605. ParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  104606. if (!this._lifeTimeGradients) {
  104607. this._lifeTimeGradients = [];
  104608. }
  104609. this._addFactorGradient(this._lifeTimeGradients, gradient, factor, factor2);
  104610. return this;
  104611. };
  104612. /**
  104613. * Remove a specific life time gradient
  104614. * @param gradient defines the gradient to remove
  104615. * @returns the current particle system
  104616. */
  104617. ParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  104618. this._removeFactorGradient(this._lifeTimeGradients, gradient);
  104619. return this;
  104620. };
  104621. /**
  104622. * Adds a new size gradient
  104623. * @param gradient defines the gradient to use (between 0 and 1)
  104624. * @param factor defines the size factor to affect to the specified gradient
  104625. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104626. * @returns the current particle system
  104627. */
  104628. ParticleSystem.prototype.addSizeGradient = function (gradient, factor, factor2) {
  104629. if (!this._sizeGradients) {
  104630. this._sizeGradients = [];
  104631. }
  104632. this._addFactorGradient(this._sizeGradients, gradient, factor, factor2);
  104633. return this;
  104634. };
  104635. /**
  104636. * Remove a specific size gradient
  104637. * @param gradient defines the gradient to remove
  104638. * @returns the current particle system
  104639. */
  104640. ParticleSystem.prototype.removeSizeGradient = function (gradient) {
  104641. this._removeFactorGradient(this._sizeGradients, gradient);
  104642. return this;
  104643. };
  104644. /**
  104645. * Adds a new color remap gradient
  104646. * @param gradient defines the gradient to use (between 0 and 1)
  104647. * @param min defines the color remap minimal range
  104648. * @param max defines the color remap maximal range
  104649. * @returns the current particle system
  104650. */
  104651. ParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  104652. if (!this._colorRemapGradients) {
  104653. this._colorRemapGradients = [];
  104654. }
  104655. this._addFactorGradient(this._colorRemapGradients, gradient, min, max);
  104656. return this;
  104657. };
  104658. /**
  104659. * Remove a specific color remap gradient
  104660. * @param gradient defines the gradient to remove
  104661. * @returns the current particle system
  104662. */
  104663. ParticleSystem.prototype.removeColorRemapGradient = function (gradient) {
  104664. this._removeFactorGradient(this._colorRemapGradients, gradient);
  104665. return this;
  104666. };
  104667. /**
  104668. * Adds a new alpha remap gradient
  104669. * @param gradient defines the gradient to use (between 0 and 1)
  104670. * @param min defines the alpha remap minimal range
  104671. * @param max defines the alpha remap maximal range
  104672. * @returns the current particle system
  104673. */
  104674. ParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  104675. if (!this._alphaRemapGradients) {
  104676. this._alphaRemapGradients = [];
  104677. }
  104678. this._addFactorGradient(this._alphaRemapGradients, gradient, min, max);
  104679. return this;
  104680. };
  104681. /**
  104682. * Remove a specific alpha remap gradient
  104683. * @param gradient defines the gradient to remove
  104684. * @returns the current particle system
  104685. */
  104686. ParticleSystem.prototype.removeAlphaRemapGradient = function (gradient) {
  104687. this._removeFactorGradient(this._alphaRemapGradients, gradient);
  104688. return this;
  104689. };
  104690. /**
  104691. * Adds a new angular speed gradient
  104692. * @param gradient defines the gradient to use (between 0 and 1)
  104693. * @param factor defines the angular speed to affect to the specified gradient
  104694. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104695. * @returns the current particle system
  104696. */
  104697. ParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor, factor2) {
  104698. if (!this._angularSpeedGradients) {
  104699. this._angularSpeedGradients = [];
  104700. }
  104701. this._addFactorGradient(this._angularSpeedGradients, gradient, factor, factor2);
  104702. return this;
  104703. };
  104704. /**
  104705. * Remove a specific angular speed gradient
  104706. * @param gradient defines the gradient to remove
  104707. * @returns the current particle system
  104708. */
  104709. ParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  104710. this._removeFactorGradient(this._angularSpeedGradients, gradient);
  104711. return this;
  104712. };
  104713. /**
  104714. * Adds a new velocity gradient
  104715. * @param gradient defines the gradient to use (between 0 and 1)
  104716. * @param factor defines the velocity to affect to the specified gradient
  104717. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104718. * @returns the current particle system
  104719. */
  104720. ParticleSystem.prototype.addVelocityGradient = function (gradient, factor, factor2) {
  104721. if (!this._velocityGradients) {
  104722. this._velocityGradients = [];
  104723. }
  104724. this._addFactorGradient(this._velocityGradients, gradient, factor, factor2);
  104725. return this;
  104726. };
  104727. /**
  104728. * Remove a specific velocity gradient
  104729. * @param gradient defines the gradient to remove
  104730. * @returns the current particle system
  104731. */
  104732. ParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  104733. this._removeFactorGradient(this._velocityGradients, gradient);
  104734. return this;
  104735. };
  104736. /**
  104737. * Adds a new limit velocity gradient
  104738. * @param gradient defines the gradient to use (between 0 and 1)
  104739. * @param factor defines the limit velocity value to affect to the specified gradient
  104740. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104741. * @returns the current particle system
  104742. */
  104743. ParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor, factor2) {
  104744. if (!this._limitVelocityGradients) {
  104745. this._limitVelocityGradients = [];
  104746. }
  104747. this._addFactorGradient(this._limitVelocityGradients, gradient, factor, factor2);
  104748. return this;
  104749. };
  104750. /**
  104751. * Remove a specific limit velocity gradient
  104752. * @param gradient defines the gradient to remove
  104753. * @returns the current particle system
  104754. */
  104755. ParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  104756. this._removeFactorGradient(this._limitVelocityGradients, gradient);
  104757. return this;
  104758. };
  104759. /**
  104760. * Adds a new drag gradient
  104761. * @param gradient defines the gradient to use (between 0 and 1)
  104762. * @param factor defines the drag value to affect to the specified gradient
  104763. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104764. * @returns the current particle system
  104765. */
  104766. ParticleSystem.prototype.addDragGradient = function (gradient, factor, factor2) {
  104767. if (!this._dragGradients) {
  104768. this._dragGradients = [];
  104769. }
  104770. this._addFactorGradient(this._dragGradients, gradient, factor, factor2);
  104771. return this;
  104772. };
  104773. /**
  104774. * Remove a specific drag gradient
  104775. * @param gradient defines the gradient to remove
  104776. * @returns the current particle system
  104777. */
  104778. ParticleSystem.prototype.removeDragGradient = function (gradient) {
  104779. this._removeFactorGradient(this._dragGradients, gradient);
  104780. return this;
  104781. };
  104782. /**
  104783. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  104784. * @param gradient defines the gradient to use (between 0 and 1)
  104785. * @param factor defines the emit rate value to affect to the specified gradient
  104786. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104787. * @returns the current particle system
  104788. */
  104789. ParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  104790. if (!this._emitRateGradients) {
  104791. this._emitRateGradients = [];
  104792. }
  104793. this._addFactorGradient(this._emitRateGradients, gradient, factor, factor2);
  104794. return this;
  104795. };
  104796. /**
  104797. * Remove a specific emit rate gradient
  104798. * @param gradient defines the gradient to remove
  104799. * @returns the current particle system
  104800. */
  104801. ParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  104802. this._removeFactorGradient(this._emitRateGradients, gradient);
  104803. return this;
  104804. };
  104805. /**
  104806. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  104807. * @param gradient defines the gradient to use (between 0 and 1)
  104808. * @param factor defines the start size value to affect to the specified gradient
  104809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104810. * @returns the current particle system
  104811. */
  104812. ParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  104813. if (!this._startSizeGradients) {
  104814. this._startSizeGradients = [];
  104815. }
  104816. this._addFactorGradient(this._startSizeGradients, gradient, factor, factor2);
  104817. return this;
  104818. };
  104819. /**
  104820. * Remove a specific start size gradient
  104821. * @param gradient defines the gradient to remove
  104822. * @returns the current particle system
  104823. */
  104824. ParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  104825. this._removeFactorGradient(this._emitRateGradients, gradient);
  104826. return this;
  104827. };
  104828. ParticleSystem.prototype._createRampGradientTexture = function () {
  104829. if (!this._rampGradients || !this._rampGradients.length || this._rampGradientsTexture) {
  104830. return;
  104831. }
  104832. var data = new Uint8Array(this._rawTextureWidth * 4);
  104833. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color3[0];
  104834. for (var x = 0; x < this._rawTextureWidth; x++) {
  104835. var ratio = x / this._rawTextureWidth;
  104836. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._rampGradients, function (currentGradient, nextGradient, scale) {
  104837. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].LerpToRef(currentGradient.color, nextGradient.color, scale, tmpColor);
  104838. data[x * 4] = tmpColor.r * 255;
  104839. data[x * 4 + 1] = tmpColor.g * 255;
  104840. data[x * 4 + 2] = tmpColor.b * 255;
  104841. data[x * 4 + 3] = 255;
  104842. });
  104843. }
  104844. 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);
  104845. };
  104846. /**
  104847. * Gets the current list of ramp gradients.
  104848. * You must use addRampGradient and removeRampGradient to udpate this list
  104849. * @returns the list of ramp gradients
  104850. */
  104851. ParticleSystem.prototype.getRampGradients = function () {
  104852. return this._rampGradients;
  104853. };
  104854. /**
  104855. * Adds a new ramp gradient used to remap particle colors
  104856. * @param gradient defines the gradient to use (between 0 and 1)
  104857. * @param color defines the color to affect to the specified gradient
  104858. * @returns the current particle system
  104859. */
  104860. ParticleSystem.prototype.addRampGradient = function (gradient, color) {
  104861. if (!this._rampGradients) {
  104862. this._rampGradients = [];
  104863. }
  104864. var rampGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Color3Gradient"]();
  104865. rampGradient.gradient = gradient;
  104866. rampGradient.color = color;
  104867. this._rampGradients.push(rampGradient);
  104868. this._rampGradients.sort(function (a, b) {
  104869. if (a.gradient < b.gradient) {
  104870. return -1;
  104871. }
  104872. else if (a.gradient > b.gradient) {
  104873. return 1;
  104874. }
  104875. return 0;
  104876. });
  104877. if (this._rampGradientsTexture) {
  104878. this._rampGradientsTexture.dispose();
  104879. this._rampGradientsTexture = null;
  104880. }
  104881. this._createRampGradientTexture();
  104882. return this;
  104883. };
  104884. /**
  104885. * Remove a specific ramp gradient
  104886. * @param gradient defines the gradient to remove
  104887. * @returns the current particle system
  104888. */
  104889. ParticleSystem.prototype.removeRampGradient = function (gradient) {
  104890. this._removeGradientAndTexture(gradient, this._rampGradients, this._rampGradientsTexture);
  104891. this._rampGradientsTexture = null;
  104892. if (this._rampGradients && this._rampGradients.length > 0) {
  104893. this._createRampGradientTexture();
  104894. }
  104895. return this;
  104896. };
  104897. /**
  104898. * Adds a new color gradient
  104899. * @param gradient defines the gradient to use (between 0 and 1)
  104900. * @param color1 defines the color to affect to the specified gradient
  104901. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  104902. * @returns this particle system
  104903. */
  104904. ParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  104905. if (!this._colorGradients) {
  104906. this._colorGradients = [];
  104907. }
  104908. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  104909. colorGradient.gradient = gradient;
  104910. colorGradient.color1 = color1;
  104911. colorGradient.color2 = color2;
  104912. this._colorGradients.push(colorGradient);
  104913. this._colorGradients.sort(function (a, b) {
  104914. if (a.gradient < b.gradient) {
  104915. return -1;
  104916. }
  104917. else if (a.gradient > b.gradient) {
  104918. return 1;
  104919. }
  104920. return 0;
  104921. });
  104922. return this;
  104923. };
  104924. /**
  104925. * Remove a specific color gradient
  104926. * @param gradient defines the gradient to remove
  104927. * @returns this particle system
  104928. */
  104929. ParticleSystem.prototype.removeColorGradient = function (gradient) {
  104930. if (!this._colorGradients) {
  104931. return this;
  104932. }
  104933. var index = 0;
  104934. for (var _i = 0, _a = this._colorGradients; _i < _a.length; _i++) {
  104935. var colorGradient = _a[_i];
  104936. if (colorGradient.gradient === gradient) {
  104937. this._colorGradients.splice(index, 1);
  104938. break;
  104939. }
  104940. index++;
  104941. }
  104942. return this;
  104943. };
  104944. ParticleSystem.prototype._fetchR = function (u, v, width, height, pixels) {
  104945. u = Math.abs(u) * 0.5 + 0.5;
  104946. v = Math.abs(v) * 0.5 + 0.5;
  104947. var wrappedU = ((u * width) % width) | 0;
  104948. var wrappedV = ((v * height) % height) | 0;
  104949. var position = (wrappedU + wrappedV * width) * 4;
  104950. return pixels[position] / 255;
  104951. };
  104952. ParticleSystem.prototype._reset = function () {
  104953. this._resetEffect();
  104954. };
  104955. ParticleSystem.prototype._resetEffect = function () {
  104956. if (this._vertexBuffer) {
  104957. this._vertexBuffer.dispose();
  104958. this._vertexBuffer = null;
  104959. }
  104960. if (this._spriteBuffer) {
  104961. this._spriteBuffer.dispose();
  104962. this._spriteBuffer = null;
  104963. }
  104964. this._createVertexBuffers();
  104965. };
  104966. ParticleSystem.prototype._createVertexBuffers = function () {
  104967. this._vertexBufferSize = this._useInstancing ? 10 : 12;
  104968. if (this._isAnimationSheetEnabled) {
  104969. this._vertexBufferSize += 1;
  104970. }
  104971. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  104972. this._vertexBufferSize += 3;
  104973. }
  104974. if (this._useRampGradients) {
  104975. this._vertexBufferSize += 4;
  104976. }
  104977. var engine = this._scene.getEngine();
  104978. this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4));
  104979. this._vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, this._vertexData, true, this._vertexBufferSize);
  104980. var dataOffset = 0;
  104981. var positions = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  104982. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind] = positions;
  104983. dataOffset += 3;
  104984. var colors = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  104985. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind] = colors;
  104986. dataOffset += 4;
  104987. var options = this._vertexBuffer.createVertexBuffer("angle", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  104988. this._vertexBuffers["angle"] = options;
  104989. dataOffset += 1;
  104990. var size = this._vertexBuffer.createVertexBuffer("size", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  104991. this._vertexBuffers["size"] = size;
  104992. dataOffset += 2;
  104993. if (this._isAnimationSheetEnabled) {
  104994. var cellIndexBuffer = this._vertexBuffer.createVertexBuffer("cellIndex", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  104995. this._vertexBuffers["cellIndex"] = cellIndexBuffer;
  104996. dataOffset += 1;
  104997. }
  104998. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  104999. var directionBuffer = this._vertexBuffer.createVertexBuffer("direction", dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  105000. this._vertexBuffers["direction"] = directionBuffer;
  105001. dataOffset += 3;
  105002. }
  105003. if (this._useRampGradients) {
  105004. var rampDataBuffer = this._vertexBuffer.createVertexBuffer("remapData", dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  105005. this._vertexBuffers["remapData"] = rampDataBuffer;
  105006. dataOffset += 4;
  105007. }
  105008. var offsets;
  105009. if (this._useInstancing) {
  105010. var spriteData = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
  105011. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 2);
  105012. offsets = this._spriteBuffer.createVertexBuffer("offset", 0, 2);
  105013. }
  105014. else {
  105015. offsets = this._vertexBuffer.createVertexBuffer("offset", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  105016. dataOffset += 2;
  105017. }
  105018. this._vertexBuffers["offset"] = offsets;
  105019. };
  105020. ParticleSystem.prototype._createIndexBuffer = function () {
  105021. if (this._useInstancing) {
  105022. return;
  105023. }
  105024. var indices = [];
  105025. var index = 0;
  105026. for (var count = 0; count < this._capacity; count++) {
  105027. indices.push(index);
  105028. indices.push(index + 1);
  105029. indices.push(index + 2);
  105030. indices.push(index);
  105031. indices.push(index + 2);
  105032. indices.push(index + 3);
  105033. index += 4;
  105034. }
  105035. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  105036. };
  105037. /**
  105038. * Gets the maximum number of particles active at the same time.
  105039. * @returns The max number of active particles.
  105040. */
  105041. ParticleSystem.prototype.getCapacity = function () {
  105042. return this._capacity;
  105043. };
  105044. /**
  105045. * Gets whether there are still active particles in the system.
  105046. * @returns True if it is alive, otherwise false.
  105047. */
  105048. ParticleSystem.prototype.isAlive = function () {
  105049. return this._alive;
  105050. };
  105051. /**
  105052. * Gets if the system has been started. (Note: this will still be true after stop is called)
  105053. * @returns True if it has been started, otherwise false.
  105054. */
  105055. ParticleSystem.prototype.isStarted = function () {
  105056. return this._started;
  105057. };
  105058. ParticleSystem.prototype._prepareSubEmitterInternalArray = function () {
  105059. var _this = this;
  105060. this._subEmitters = new Array();
  105061. if (this.subEmitters) {
  105062. this.subEmitters.forEach(function (subEmitter) {
  105063. if (subEmitter instanceof ParticleSystem) {
  105064. _this._subEmitters.push([new _subEmitter__WEBPACK_IMPORTED_MODULE_18__["SubEmitter"](subEmitter)]);
  105065. }
  105066. else if (subEmitter instanceof _subEmitter__WEBPACK_IMPORTED_MODULE_18__["SubEmitter"]) {
  105067. _this._subEmitters.push([subEmitter]);
  105068. }
  105069. else if (subEmitter instanceof Array) {
  105070. _this._subEmitters.push(subEmitter);
  105071. }
  105072. });
  105073. }
  105074. };
  105075. /**
  105076. * Starts the particle system and begins to emit
  105077. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  105078. */
  105079. ParticleSystem.prototype.start = function (delay) {
  105080. var _this = this;
  105081. if (delay === void 0) { delay = this.startDelay; }
  105082. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  105083. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  105084. }
  105085. if (delay) {
  105086. setTimeout(function () {
  105087. _this.start(0);
  105088. }, delay);
  105089. return;
  105090. }
  105091. // Convert the subEmitters field to the constant type field _subEmitters
  105092. this._prepareSubEmitterInternalArray();
  105093. this._started = true;
  105094. this._stopped = false;
  105095. this._actualFrame = 0;
  105096. if (this._subEmitters && this._subEmitters.length != 0) {
  105097. this.activeSubSystems = new Array();
  105098. }
  105099. // Reset emit gradient so it acts the same on every start
  105100. if (this._emitRateGradients) {
  105101. if (this._emitRateGradients.length > 0) {
  105102. this._currentEmitRateGradient = this._emitRateGradients[0];
  105103. this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
  105104. this._currentEmitRate2 = this._currentEmitRate1;
  105105. }
  105106. if (this._emitRateGradients.length > 1) {
  105107. this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
  105108. }
  105109. }
  105110. // Reset start size gradient so it acts the same on every start
  105111. if (this._startSizeGradients) {
  105112. if (this._startSizeGradients.length > 0) {
  105113. this._currentStartSizeGradient = this._startSizeGradients[0];
  105114. this._currentStartSize1 = this._currentStartSizeGradient.getFactor();
  105115. this._currentStartSize2 = this._currentStartSize1;
  105116. }
  105117. if (this._startSizeGradients.length > 1) {
  105118. this._currentStartSize2 = this._startSizeGradients[1].getFactor();
  105119. }
  105120. }
  105121. if (this.preWarmCycles) {
  105122. if (this.emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__["AbstractMesh"]) {
  105123. this.emitter.computeWorldMatrix(true);
  105124. }
  105125. var noiseTextureAsProcedural_1 = this.noiseTexture;
  105126. if (noiseTextureAsProcedural_1 && noiseTextureAsProcedural_1.onGeneratedObservable) {
  105127. noiseTextureAsProcedural_1.onGeneratedObservable.addOnce(function () {
  105128. setTimeout(function () {
  105129. for (var index = 0; index < _this.preWarmCycles; index++) {
  105130. _this.animate(true);
  105131. noiseTextureAsProcedural_1.render();
  105132. }
  105133. });
  105134. });
  105135. }
  105136. else {
  105137. for (var index = 0; index < this.preWarmCycles; index++) {
  105138. this.animate(true);
  105139. }
  105140. }
  105141. }
  105142. // Animations
  105143. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  105144. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  105145. }
  105146. };
  105147. /**
  105148. * Stops the particle system.
  105149. * @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.
  105150. */
  105151. ParticleSystem.prototype.stop = function (stopSubEmitters) {
  105152. if (stopSubEmitters === void 0) { stopSubEmitters = true; }
  105153. this._stopped = true;
  105154. if (stopSubEmitters) {
  105155. this._stopSubEmitters();
  105156. }
  105157. };
  105158. // animation sheet
  105159. /**
  105160. * Remove all active particles
  105161. */
  105162. ParticleSystem.prototype.reset = function () {
  105163. this._stockParticles = [];
  105164. this._particles = [];
  105165. };
  105166. /**
  105167. * @hidden (for internal use only)
  105168. */
  105169. ParticleSystem.prototype._appendParticleVertex = function (index, particle, offsetX, offsetY) {
  105170. var offset = index * this._vertexBufferSize;
  105171. this._vertexData[offset++] = particle.position.x;
  105172. this._vertexData[offset++] = particle.position.y;
  105173. this._vertexData[offset++] = particle.position.z;
  105174. this._vertexData[offset++] = particle.color.r;
  105175. this._vertexData[offset++] = particle.color.g;
  105176. this._vertexData[offset++] = particle.color.b;
  105177. this._vertexData[offset++] = particle.color.a;
  105178. this._vertexData[offset++] = particle.angle;
  105179. this._vertexData[offset++] = particle.scale.x * particle.size;
  105180. this._vertexData[offset++] = particle.scale.y * particle.size;
  105181. if (this._isAnimationSheetEnabled) {
  105182. this._vertexData[offset++] = particle.cellIndex;
  105183. }
  105184. if (!this._isBillboardBased) {
  105185. if (particle._initialDirection) {
  105186. this._vertexData[offset++] = particle._initialDirection.x;
  105187. this._vertexData[offset++] = particle._initialDirection.y;
  105188. this._vertexData[offset++] = particle._initialDirection.z;
  105189. }
  105190. else {
  105191. this._vertexData[offset++] = particle.direction.x;
  105192. this._vertexData[offset++] = particle.direction.y;
  105193. this._vertexData[offset++] = particle.direction.z;
  105194. }
  105195. }
  105196. else if (this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  105197. this._vertexData[offset++] = particle.direction.x;
  105198. this._vertexData[offset++] = particle.direction.y;
  105199. this._vertexData[offset++] = particle.direction.z;
  105200. }
  105201. if (this._useRampGradients) {
  105202. this._vertexData[offset++] = particle.remapData.x;
  105203. this._vertexData[offset++] = particle.remapData.y;
  105204. this._vertexData[offset++] = particle.remapData.z;
  105205. this._vertexData[offset++] = particle.remapData.w;
  105206. }
  105207. if (!this._useInstancing) {
  105208. if (this._isAnimationSheetEnabled) {
  105209. if (offsetX === 0) {
  105210. offsetX = this._epsilon;
  105211. }
  105212. else if (offsetX === 1) {
  105213. offsetX = 1 - this._epsilon;
  105214. }
  105215. if (offsetY === 0) {
  105216. offsetY = this._epsilon;
  105217. }
  105218. else if (offsetY === 1) {
  105219. offsetY = 1 - this._epsilon;
  105220. }
  105221. }
  105222. this._vertexData[offset++] = offsetX;
  105223. this._vertexData[offset++] = offsetY;
  105224. }
  105225. };
  105226. ParticleSystem.prototype._stopSubEmitters = function () {
  105227. if (!this.activeSubSystems) {
  105228. return;
  105229. }
  105230. this.activeSubSystems.forEach(function (subSystem) {
  105231. subSystem.stop(true);
  105232. });
  105233. this.activeSubSystems = new Array();
  105234. };
  105235. ParticleSystem.prototype._removeFromRoot = function () {
  105236. if (!this._rootParticleSystem) {
  105237. return;
  105238. }
  105239. var index = this._rootParticleSystem.activeSubSystems.indexOf(this);
  105240. if (index !== -1) {
  105241. this._rootParticleSystem.activeSubSystems.splice(index, 1);
  105242. }
  105243. this._rootParticleSystem = null;
  105244. };
  105245. // End of sub system methods
  105246. ParticleSystem.prototype._update = function (newParticles) {
  105247. var _this = this;
  105248. // Update current
  105249. this._alive = this._particles.length > 0;
  105250. if (this.emitter.position) {
  105251. var emitterMesh = this.emitter;
  105252. this._emitterWorldMatrix = emitterMesh.getWorldMatrix();
  105253. }
  105254. else {
  105255. var emitterPosition = this.emitter;
  105256. this._emitterWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  105257. }
  105258. this.updateFunction(this._particles);
  105259. // Add new ones
  105260. var particle;
  105261. var _loop_2 = function () {
  105262. if (this_1._particles.length === this_1._capacity) {
  105263. return "break";
  105264. }
  105265. particle = this_1._createParticle();
  105266. this_1._particles.push(particle);
  105267. // Emitter
  105268. var emitPower = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minEmitPower, this_1.maxEmitPower);
  105269. if (this_1.startPositionFunction) {
  105270. this_1.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  105271. }
  105272. else {
  105273. this_1.particleEmitterType.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  105274. }
  105275. if (this_1.startDirectionFunction) {
  105276. this_1.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  105277. }
  105278. else {
  105279. this_1.particleEmitterType.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  105280. }
  105281. if (emitPower === 0) {
  105282. if (!particle._initialDirection) {
  105283. particle._initialDirection = particle.direction.clone();
  105284. }
  105285. else {
  105286. particle._initialDirection.copyFrom(particle.direction);
  105287. }
  105288. }
  105289. else {
  105290. particle._initialDirection = null;
  105291. }
  105292. particle.direction.scaleInPlace(emitPower);
  105293. // Life time
  105294. if (this_1.targetStopDuration && this_1._lifeTimeGradients && this_1._lifeTimeGradients.length > 0) {
  105295. var ratio_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(this_1._actualFrame / this_1.targetStopDuration);
  105296. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio_1, this_1._lifeTimeGradients, function (currentGradient, nextGradient) {
  105297. var factorGradient1 = currentGradient;
  105298. var factorGradient2 = nextGradient;
  105299. var lifeTime1 = factorGradient1.getFactor();
  105300. var lifeTime2 = factorGradient2.getFactor();
  105301. var gradient = (ratio_1 - factorGradient1.gradient) / (factorGradient2.gradient - factorGradient1.gradient);
  105302. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(lifeTime1, lifeTime2, gradient);
  105303. });
  105304. }
  105305. else {
  105306. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minLifeTime, this_1.maxLifeTime);
  105307. }
  105308. // Size
  105309. if (!this_1._sizeGradients || this_1._sizeGradients.length === 0) {
  105310. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minSize, this_1.maxSize);
  105311. }
  105312. else {
  105313. particle._currentSizeGradient = this_1._sizeGradients[0];
  105314. particle._currentSize1 = particle._currentSizeGradient.getFactor();
  105315. particle.size = particle._currentSize1;
  105316. if (this_1._sizeGradients.length > 1) {
  105317. particle._currentSize2 = this_1._sizeGradients[1].getFactor();
  105318. }
  105319. else {
  105320. particle._currentSize2 = particle._currentSize1;
  105321. }
  105322. }
  105323. // Size and scale
  105324. 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));
  105325. // Adjust scale by start size
  105326. if (this_1._startSizeGradients && this_1._startSizeGradients[0] && this_1.targetStopDuration) {
  105327. var ratio = this_1._actualFrame / this_1.targetStopDuration;
  105328. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this_1._startSizeGradients, function (currentGradient, nextGradient, scale) {
  105329. if (currentGradient !== _this._currentStartSizeGradient) {
  105330. _this._currentStartSize1 = _this._currentStartSize2;
  105331. _this._currentStartSize2 = nextGradient.getFactor();
  105332. _this._currentStartSizeGradient = currentGradient;
  105333. }
  105334. var value = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentStartSize1, _this._currentStartSize2, scale);
  105335. particle.scale.scaleInPlace(value);
  105336. });
  105337. }
  105338. // Angle
  105339. if (!this_1._angularSpeedGradients || this_1._angularSpeedGradients.length === 0) {
  105340. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minAngularSpeed, this_1.maxAngularSpeed);
  105341. }
  105342. else {
  105343. particle._currentAngularSpeedGradient = this_1._angularSpeedGradients[0];
  105344. particle.angularSpeed = particle._currentAngularSpeedGradient.getFactor();
  105345. particle._currentAngularSpeed1 = particle.angularSpeed;
  105346. if (this_1._angularSpeedGradients.length > 1) {
  105347. particle._currentAngularSpeed2 = this_1._angularSpeedGradients[1].getFactor();
  105348. }
  105349. else {
  105350. particle._currentAngularSpeed2 = particle._currentAngularSpeed1;
  105351. }
  105352. }
  105353. particle.angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minInitialRotation, this_1.maxInitialRotation);
  105354. // Velocity
  105355. if (this_1._velocityGradients && this_1._velocityGradients.length > 0) {
  105356. particle._currentVelocityGradient = this_1._velocityGradients[0];
  105357. particle._currentVelocity1 = particle._currentVelocityGradient.getFactor();
  105358. if (this_1._velocityGradients.length > 1) {
  105359. particle._currentVelocity2 = this_1._velocityGradients[1].getFactor();
  105360. }
  105361. else {
  105362. particle._currentVelocity2 = particle._currentVelocity1;
  105363. }
  105364. }
  105365. // Limit velocity
  105366. if (this_1._limitVelocityGradients && this_1._limitVelocityGradients.length > 0) {
  105367. particle._currentLimitVelocityGradient = this_1._limitVelocityGradients[0];
  105368. particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
  105369. if (this_1._limitVelocityGradients.length > 1) {
  105370. particle._currentLimitVelocity2 = this_1._limitVelocityGradients[1].getFactor();
  105371. }
  105372. else {
  105373. particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
  105374. }
  105375. }
  105376. // Drag
  105377. if (this_1._dragGradients && this_1._dragGradients.length > 0) {
  105378. particle._currentDragGradient = this_1._dragGradients[0];
  105379. particle._currentDrag1 = particle._currentDragGradient.getFactor();
  105380. if (this_1._dragGradients.length > 1) {
  105381. particle._currentDrag2 = this_1._dragGradients[1].getFactor();
  105382. }
  105383. else {
  105384. particle._currentDrag2 = particle._currentDrag1;
  105385. }
  105386. }
  105387. // Color
  105388. if (!this_1._colorGradients || this_1._colorGradients.length === 0) {
  105389. step = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(0, 1.0);
  105390. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(this_1.color1, this_1.color2, step, particle.color);
  105391. this_1.colorDead.subtractToRef(particle.color, this_1._colorDiff);
  105392. this_1._colorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);
  105393. }
  105394. else {
  105395. particle._currentColorGradient = this_1._colorGradients[0];
  105396. particle._currentColorGradient.getColorToRef(particle.color);
  105397. particle._currentColor1.copyFrom(particle.color);
  105398. if (this_1._colorGradients.length > 1) {
  105399. this_1._colorGradients[1].getColorToRef(particle._currentColor2);
  105400. }
  105401. else {
  105402. particle._currentColor2.copyFrom(particle.color);
  105403. }
  105404. }
  105405. // Sheet
  105406. if (this_1._isAnimationSheetEnabled) {
  105407. particle._initialStartSpriteCellID = this_1.startSpriteCellID;
  105408. particle._initialEndSpriteCellID = this_1.endSpriteCellID;
  105409. }
  105410. // Inherited Velocity
  105411. particle.direction.addInPlace(this_1._inheritedVelocityOffset);
  105412. // Ramp
  105413. if (this_1._useRampGradients) {
  105414. particle.remapData = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector4"](0, 1, 0, 1);
  105415. }
  105416. // Noise texture coordinates
  105417. if (this_1.noiseTexture) {
  105418. if (particle._randomNoiseCoordinates1) {
  105419. particle._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random());
  105420. particle._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random());
  105421. }
  105422. else {
  105423. particle._randomNoiseCoordinates1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  105424. particle._randomNoiseCoordinates2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  105425. }
  105426. }
  105427. // Update the position of the attached sub-emitters to match their attached particle
  105428. particle._inheritParticleInfoToSubEmitters();
  105429. };
  105430. var this_1 = this, step;
  105431. for (var index = 0; index < newParticles; index++) {
  105432. var state_1 = _loop_2();
  105433. if (state_1 === "break")
  105434. break;
  105435. }
  105436. };
  105437. /** @hidden */
  105438. ParticleSystem._GetAttributeNamesOrOptions = function (isAnimationSheetEnabled, isBillboardBased, useRampGradients) {
  105439. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  105440. if (isBillboardBased === void 0) { isBillboardBased = false; }
  105441. if (useRampGradients === void 0) { useRampGradients = false; }
  105442. var attributeNamesOrOptions = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, "angle", "offset", "size"];
  105443. if (isAnimationSheetEnabled) {
  105444. attributeNamesOrOptions.push("cellIndex");
  105445. }
  105446. if (!isBillboardBased) {
  105447. attributeNamesOrOptions.push("direction");
  105448. }
  105449. if (useRampGradients) {
  105450. attributeNamesOrOptions.push("remapData");
  105451. }
  105452. return attributeNamesOrOptions;
  105453. };
  105454. /** @hidden */
  105455. ParticleSystem._GetEffectCreationOptions = function (isAnimationSheetEnabled) {
  105456. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  105457. var effectCreationOption = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMask", "translationPivot", "eyePosition"];
  105458. if (isAnimationSheetEnabled) {
  105459. effectCreationOption.push("particlesInfos");
  105460. }
  105461. return effectCreationOption;
  105462. };
  105463. /** @hidden */
  105464. ParticleSystem.prototype._getEffect = function (blendMode) {
  105465. if (this._customEffect) {
  105466. return this._customEffect;
  105467. }
  105468. var defines = [];
  105469. if (this._scene.clipPlane) {
  105470. defines.push("#define CLIPPLANE");
  105471. }
  105472. if (this._scene.clipPlane2) {
  105473. defines.push("#define CLIPPLANE2");
  105474. }
  105475. if (this._scene.clipPlane3) {
  105476. defines.push("#define CLIPPLANE3");
  105477. }
  105478. if (this._scene.clipPlane4) {
  105479. defines.push("#define CLIPPLANE4");
  105480. }
  105481. if (this._isAnimationSheetEnabled) {
  105482. defines.push("#define ANIMATESHEET");
  105483. }
  105484. if (blendMode === ParticleSystem.BLENDMODE_MULTIPLY) {
  105485. defines.push("#define BLENDMULTIPLYMODE");
  105486. }
  105487. if (this._useRampGradients) {
  105488. defines.push("#define RAMPGRADIENT");
  105489. }
  105490. if (this._isBillboardBased) {
  105491. defines.push("#define BILLBOARD");
  105492. switch (this.billboardMode) {
  105493. case ParticleSystem.BILLBOARDMODE_Y:
  105494. defines.push("#define BILLBOARDY");
  105495. break;
  105496. case ParticleSystem.BILLBOARDMODE_STRETCHED:
  105497. defines.push("#define BILLBOARDSTRETCHED");
  105498. break;
  105499. case ParticleSystem.BILLBOARDMODE_ALL:
  105500. default:
  105501. break;
  105502. }
  105503. }
  105504. if (this._imageProcessingConfiguration) {
  105505. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  105506. defines.push(this._imageProcessingConfigurationDefines.toString());
  105507. }
  105508. // Effect
  105509. var join = defines.join("\n");
  105510. if (this._cachedDefines !== join) {
  105511. this._cachedDefines = join;
  105512. var attributesNamesOrOptions = ParticleSystem._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== ParticleSystem.BILLBOARDMODE_STRETCHED, this._useRampGradients);
  105513. var effectCreationOption = ParticleSystem._GetEffectCreationOptions(this._isAnimationSheetEnabled);
  105514. var samplers = ["diffuseSampler", "rampSampler"];
  105515. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"]) {
  105516. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareUniforms(effectCreationOption, this._imageProcessingConfigurationDefines);
  105517. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  105518. }
  105519. this._effect = this._scene.getEngine().createEffect("particles", attributesNamesOrOptions, effectCreationOption, samplers, join);
  105520. }
  105521. return this._effect;
  105522. };
  105523. /**
  105524. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  105525. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  105526. */
  105527. ParticleSystem.prototype.animate = function (preWarmOnly) {
  105528. var _this = this;
  105529. if (preWarmOnly === void 0) { preWarmOnly = false; }
  105530. if (!this._started) {
  105531. return;
  105532. }
  105533. if (!preWarmOnly) {
  105534. // Check
  105535. if (!this.isReady()) {
  105536. return;
  105537. }
  105538. if (this._currentRenderId === this._scene.getFrameId()) {
  105539. return;
  105540. }
  105541. this._currentRenderId = this._scene.getFrameId();
  105542. }
  105543. this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  105544. // Determine the number of particles we need to create
  105545. var newParticles;
  105546. if (this.manualEmitCount > -1) {
  105547. newParticles = this.manualEmitCount;
  105548. this._newPartsExcess = 0;
  105549. this.manualEmitCount = 0;
  105550. }
  105551. else {
  105552. var rate_1 = this.emitRate;
  105553. if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
  105554. var ratio = this._actualFrame / this.targetStopDuration;
  105555. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._emitRateGradients, function (currentGradient, nextGradient, scale) {
  105556. if (currentGradient !== _this._currentEmitRateGradient) {
  105557. _this._currentEmitRate1 = _this._currentEmitRate2;
  105558. _this._currentEmitRate2 = nextGradient.getFactor();
  105559. _this._currentEmitRateGradient = currentGradient;
  105560. }
  105561. rate_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentEmitRate1, _this._currentEmitRate2, scale);
  105562. });
  105563. }
  105564. newParticles = ((rate_1 * this._scaledUpdateSpeed) >> 0);
  105565. this._newPartsExcess += rate_1 * this._scaledUpdateSpeed - newParticles;
  105566. }
  105567. if (this._newPartsExcess > 1.0) {
  105568. newParticles += this._newPartsExcess >> 0;
  105569. this._newPartsExcess -= this._newPartsExcess >> 0;
  105570. }
  105571. this._alive = false;
  105572. if (!this._stopped) {
  105573. this._actualFrame += this._scaledUpdateSpeed;
  105574. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  105575. this.stop();
  105576. }
  105577. }
  105578. else {
  105579. newParticles = 0;
  105580. }
  105581. this._update(newParticles);
  105582. // Stopped?
  105583. if (this._stopped) {
  105584. if (!this._alive) {
  105585. this._started = false;
  105586. if (this.onAnimationEnd) {
  105587. this.onAnimationEnd();
  105588. }
  105589. if (this.disposeOnStop) {
  105590. this._scene._toBeDisposed.push(this);
  105591. }
  105592. }
  105593. }
  105594. if (!preWarmOnly) {
  105595. // Update VBO
  105596. var offset = 0;
  105597. for (var index = 0; index < this._particles.length; index++) {
  105598. var particle = this._particles[index];
  105599. this._appendParticleVertices(offset, particle);
  105600. offset += this._useInstancing ? 1 : 4;
  105601. }
  105602. if (this._vertexBuffer) {
  105603. this._vertexBuffer.update(this._vertexData);
  105604. }
  105605. }
  105606. if (this.manualEmitCount === 0 && this.disposeOnStop) {
  105607. this.stop();
  105608. }
  105609. };
  105610. ParticleSystem.prototype._appendParticleVertices = function (offset, particle) {
  105611. this._appendParticleVertex(offset++, particle, 0, 0);
  105612. if (!this._useInstancing) {
  105613. this._appendParticleVertex(offset++, particle, 1, 0);
  105614. this._appendParticleVertex(offset++, particle, 1, 1);
  105615. this._appendParticleVertex(offset++, particle, 0, 1);
  105616. }
  105617. };
  105618. /**
  105619. * Rebuilds the particle system.
  105620. */
  105621. ParticleSystem.prototype.rebuild = function () {
  105622. this._createIndexBuffer();
  105623. if (this._vertexBuffer) {
  105624. this._vertexBuffer._rebuild();
  105625. }
  105626. };
  105627. /**
  105628. * Is this system ready to be used/rendered
  105629. * @return true if the system is ready
  105630. */
  105631. ParticleSystem.prototype.isReady = function () {
  105632. if (!this.emitter || !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  105633. return false;
  105634. }
  105635. if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
  105636. if (!this._getEffect(this.blendMode).isReady()) {
  105637. return false;
  105638. }
  105639. }
  105640. else {
  105641. if (!this._getEffect(ParticleSystem.BLENDMODE_MULTIPLY).isReady()) {
  105642. return false;
  105643. }
  105644. if (!this._getEffect(ParticleSystem.BLENDMODE_ADD).isReady()) {
  105645. return false;
  105646. }
  105647. }
  105648. return true;
  105649. };
  105650. ParticleSystem.prototype._render = function (blendMode) {
  105651. var effect = this._getEffect(blendMode);
  105652. var engine = this._scene.getEngine();
  105653. // Render
  105654. engine.enableEffect(effect);
  105655. var viewMatrix = this._scene.getViewMatrix();
  105656. effect.setTexture("diffuseSampler", this.particleTexture);
  105657. effect.setMatrix("view", viewMatrix);
  105658. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  105659. if (this._isAnimationSheetEnabled && this.particleTexture) {
  105660. var baseSize = this.particleTexture.getBaseSize();
  105661. effect.setFloat3("particlesInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  105662. }
  105663. effect.setVector2("translationPivot", this.translationPivot);
  105664. effect.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a);
  105665. if (this._isBillboardBased) {
  105666. var camera = this._scene.activeCamera;
  105667. effect.setVector3("eyePosition", camera.globalPosition);
  105668. }
  105669. if (this._rampGradientsTexture) {
  105670. effect.setTexture("rampSampler", this._rampGradientsTexture);
  105671. }
  105672. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  105673. var invView = viewMatrix.clone();
  105674. invView.invert();
  105675. effect.setMatrix("invView", invView);
  105676. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__["MaterialHelper"].BindClipPlane(effect, this._scene);
  105677. }
  105678. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  105679. // image processing
  105680. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  105681. this._imageProcessingConfiguration.bind(effect);
  105682. }
  105683. // Draw order
  105684. switch (blendMode) {
  105685. case ParticleSystem.BLENDMODE_ADD:
  105686. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].ALPHA_ADD);
  105687. break;
  105688. case ParticleSystem.BLENDMODE_ONEONE:
  105689. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].ALPHA_ONEONE);
  105690. break;
  105691. case ParticleSystem.BLENDMODE_STANDARD:
  105692. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].ALPHA_COMBINE);
  105693. break;
  105694. case ParticleSystem.BLENDMODE_MULTIPLY:
  105695. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].ALPHA_MULTIPLY);
  105696. break;
  105697. }
  105698. if (this._useInstancing) {
  105699. engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFanDrawMode, 0, 4, this._particles.length);
  105700. }
  105701. else {
  105702. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, this._particles.length * 6);
  105703. }
  105704. return this._particles.length;
  105705. };
  105706. /**
  105707. * Renders the particle system in its current state.
  105708. * @returns the current number of particles
  105709. */
  105710. ParticleSystem.prototype.render = function () {
  105711. // Check
  105712. if (!this.isReady() || !this._particles.length) {
  105713. return 0;
  105714. }
  105715. var engine = this._scene.getEngine();
  105716. engine.setState(false);
  105717. if (this.forceDepthWrite) {
  105718. engine.setDepthWrite(true);
  105719. }
  105720. var outparticles = 0;
  105721. if (this.blendMode === ParticleSystem.BLENDMODE_MULTIPLYADD) {
  105722. outparticles = this._render(ParticleSystem.BLENDMODE_MULTIPLY) + this._render(ParticleSystem.BLENDMODE_ADD);
  105723. }
  105724. outparticles = this._render(this.blendMode);
  105725. engine.unbindInstanceAttributes();
  105726. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].ALPHA_DISABLE);
  105727. return outparticles;
  105728. };
  105729. /**
  105730. * Disposes the particle system and free the associated resources
  105731. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  105732. */
  105733. ParticleSystem.prototype.dispose = function (disposeTexture) {
  105734. if (disposeTexture === void 0) { disposeTexture = true; }
  105735. if (this._vertexBuffer) {
  105736. this._vertexBuffer.dispose();
  105737. this._vertexBuffer = null;
  105738. }
  105739. if (this._spriteBuffer) {
  105740. this._spriteBuffer.dispose();
  105741. this._spriteBuffer = null;
  105742. }
  105743. if (this._indexBuffer) {
  105744. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  105745. this._indexBuffer = null;
  105746. }
  105747. if (disposeTexture && this.particleTexture) {
  105748. this.particleTexture.dispose();
  105749. this.particleTexture = null;
  105750. }
  105751. if (disposeTexture && this.noiseTexture) {
  105752. this.noiseTexture.dispose();
  105753. this.noiseTexture = null;
  105754. }
  105755. if (this._rampGradientsTexture) {
  105756. this._rampGradientsTexture.dispose();
  105757. this._rampGradientsTexture = null;
  105758. }
  105759. this._removeFromRoot();
  105760. if (this._subEmitters && this._subEmitters.length) {
  105761. for (var index = 0; index < this._subEmitters.length; index++) {
  105762. for (var _i = 0, _a = this._subEmitters[index]; _i < _a.length; _i++) {
  105763. var subEmitter = _a[_i];
  105764. subEmitter.dispose();
  105765. }
  105766. }
  105767. this._subEmitters = [];
  105768. this.subEmitters = [];
  105769. }
  105770. if (this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose) {
  105771. this.emitter.dispose(true);
  105772. }
  105773. // Remove from scene
  105774. var index = this._scene.particleSystems.indexOf(this);
  105775. if (index > -1) {
  105776. this._scene.particleSystems.splice(index, 1);
  105777. }
  105778. this._scene._activeParticleSystems.dispose();
  105779. // Callback
  105780. this.onDisposeObservable.notifyObservers(this);
  105781. this.onDisposeObservable.clear();
  105782. this.reset();
  105783. };
  105784. // Clone
  105785. /**
  105786. * Clones the particle system.
  105787. * @param name The name of the cloned object
  105788. * @param newEmitter The new emitter to use
  105789. * @returns the cloned particle system
  105790. */
  105791. ParticleSystem.prototype.clone = function (name, newEmitter) {
  105792. var custom = null;
  105793. var program = null;
  105794. if (this.customShader != null) {
  105795. program = this.customShader;
  105796. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  105797. custom = this._scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  105798. }
  105799. else if (this._customEffect) {
  105800. custom = this._customEffect;
  105801. }
  105802. var result = new ParticleSystem(name, this._capacity, this._scene, custom);
  105803. result.customShader = program;
  105804. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_21__["DeepCopier"].DeepCopy(this, result, ["particles", "customShader", "noiseTexture"]);
  105805. if (newEmitter === undefined) {
  105806. newEmitter = this.emitter;
  105807. }
  105808. result.noiseTexture = this.noiseTexture;
  105809. result.emitter = newEmitter;
  105810. if (this.particleTexture) {
  105811. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](this.particleTexture.url, this._scene);
  105812. }
  105813. // Clone gradients
  105814. if (this._colorGradients) {
  105815. this._colorGradients.forEach(function (v) {
  105816. result.addColorGradient(v.gradient, v.color1, v.color2);
  105817. });
  105818. }
  105819. if (this._dragGradients) {
  105820. this._dragGradients.forEach(function (v) {
  105821. result.addDragGradient(v.gradient, v.factor1, v.factor2);
  105822. });
  105823. }
  105824. if (this._angularSpeedGradients) {
  105825. this._angularSpeedGradients.forEach(function (v) {
  105826. result.addAngularSpeedGradient(v.gradient, v.factor1, v.factor2);
  105827. });
  105828. }
  105829. if (this._emitRateGradients) {
  105830. this._emitRateGradients.forEach(function (v) {
  105831. result.addEmitRateGradient(v.gradient, v.factor1, v.factor2);
  105832. });
  105833. }
  105834. if (this._lifeTimeGradients) {
  105835. this._lifeTimeGradients.forEach(function (v) {
  105836. result.addLifeTimeGradient(v.gradient, v.factor1, v.factor2);
  105837. });
  105838. }
  105839. if (this._limitVelocityGradients) {
  105840. this._limitVelocityGradients.forEach(function (v) {
  105841. result.addLimitVelocityGradient(v.gradient, v.factor1, v.factor2);
  105842. });
  105843. }
  105844. if (this._sizeGradients) {
  105845. this._sizeGradients.forEach(function (v) {
  105846. result.addSizeGradient(v.gradient, v.factor1, v.factor2);
  105847. });
  105848. }
  105849. if (this._startSizeGradients) {
  105850. this._startSizeGradients.forEach(function (v) {
  105851. result.addStartSizeGradient(v.gradient, v.factor1, v.factor2);
  105852. });
  105853. }
  105854. if (this._velocityGradients) {
  105855. this._velocityGradients.forEach(function (v) {
  105856. result.addVelocityGradient(v.gradient, v.factor1, v.factor2);
  105857. });
  105858. }
  105859. if (this._rampGradients) {
  105860. this._rampGradients.forEach(function (v) {
  105861. result.addRampGradient(v.gradient, v.color);
  105862. });
  105863. }
  105864. if (this._colorRemapGradients) {
  105865. this._colorRemapGradients.forEach(function (v) {
  105866. result.addColorRemapGradient(v.gradient, v.factor1, v.factor2);
  105867. });
  105868. }
  105869. if (this._alphaRemapGradients) {
  105870. this._alphaRemapGradients.forEach(function (v) {
  105871. result.addAlphaRemapGradient(v.gradient, v.factor1, v.factor2);
  105872. });
  105873. }
  105874. if (!this.preventAutoStart) {
  105875. result.start();
  105876. }
  105877. return result;
  105878. };
  105879. /**
  105880. * Serializes the particle system to a JSON object.
  105881. * @returns the JSON object
  105882. */
  105883. ParticleSystem.prototype.serialize = function () {
  105884. var serializationObject = {};
  105885. ParticleSystem._Serialize(serializationObject, this);
  105886. serializationObject.textureMask = this.textureMask.asArray();
  105887. serializationObject.customShader = this.customShader;
  105888. serializationObject.preventAutoStart = this.preventAutoStart;
  105889. // SubEmitters
  105890. if (this.subEmitters) {
  105891. serializationObject.subEmitters = [];
  105892. if (!this._subEmitters) {
  105893. this._prepareSubEmitterInternalArray();
  105894. }
  105895. for (var _i = 0, _a = this._subEmitters; _i < _a.length; _i++) {
  105896. var subs = _a[_i];
  105897. var cell = [];
  105898. for (var _b = 0, subs_1 = subs; _b < subs_1.length; _b++) {
  105899. var sub = subs_1[_b];
  105900. cell.push(sub.serialize());
  105901. }
  105902. serializationObject.subEmitters.push(cell);
  105903. }
  105904. }
  105905. return serializationObject;
  105906. };
  105907. /** @hidden */
  105908. ParticleSystem._Serialize = function (serializationObject, particleSystem) {
  105909. serializationObject.name = particleSystem.name;
  105910. serializationObject.id = particleSystem.id;
  105911. serializationObject.capacity = particleSystem.getCapacity();
  105912. // Emitter
  105913. if (particleSystem.emitter.position) {
  105914. var emitterMesh = particleSystem.emitter;
  105915. serializationObject.emitterId = emitterMesh.id;
  105916. }
  105917. else {
  105918. var emitterPosition = particleSystem.emitter;
  105919. serializationObject.emitter = emitterPosition.asArray();
  105920. }
  105921. // Emitter
  105922. if (particleSystem.particleEmitterType) {
  105923. serializationObject.particleEmitterType = particleSystem.particleEmitterType.serialize();
  105924. }
  105925. if (particleSystem.particleTexture) {
  105926. serializationObject.textureName = particleSystem.particleTexture.name;
  105927. serializationObject.invertY = particleSystem.particleTexture._invertY;
  105928. }
  105929. // Animations
  105930. _Misc_decorators__WEBPACK_IMPORTED_MODULE_20__["SerializationHelper"].AppendSerializedAnimations(particleSystem, serializationObject);
  105931. serializationObject.beginAnimationOnStart = particleSystem.beginAnimationOnStart;
  105932. serializationObject.beginAnimationFrom = particleSystem.beginAnimationFrom;
  105933. serializationObject.beginAnimationTo = particleSystem.beginAnimationTo;
  105934. serializationObject.beginAnimationLoop = particleSystem.beginAnimationLoop;
  105935. // Particle system
  105936. serializationObject.startDelay = particleSystem.startDelay;
  105937. serializationObject.renderingGroupId = particleSystem.renderingGroupId;
  105938. serializationObject.isBillboardBased = particleSystem.isBillboardBased;
  105939. serializationObject.billboardMode = particleSystem.billboardMode;
  105940. serializationObject.minAngularSpeed = particleSystem.minAngularSpeed;
  105941. serializationObject.maxAngularSpeed = particleSystem.maxAngularSpeed;
  105942. serializationObject.minSize = particleSystem.minSize;
  105943. serializationObject.maxSize = particleSystem.maxSize;
  105944. serializationObject.minScaleX = particleSystem.minScaleX;
  105945. serializationObject.maxScaleX = particleSystem.maxScaleX;
  105946. serializationObject.minScaleY = particleSystem.minScaleY;
  105947. serializationObject.maxScaleY = particleSystem.maxScaleY;
  105948. serializationObject.minEmitPower = particleSystem.minEmitPower;
  105949. serializationObject.maxEmitPower = particleSystem.maxEmitPower;
  105950. serializationObject.minLifeTime = particleSystem.minLifeTime;
  105951. serializationObject.maxLifeTime = particleSystem.maxLifeTime;
  105952. serializationObject.emitRate = particleSystem.emitRate;
  105953. serializationObject.gravity = particleSystem.gravity.asArray();
  105954. serializationObject.noiseStrength = particleSystem.noiseStrength.asArray();
  105955. serializationObject.color1 = particleSystem.color1.asArray();
  105956. serializationObject.color2 = particleSystem.color2.asArray();
  105957. serializationObject.colorDead = particleSystem.colorDead.asArray();
  105958. serializationObject.updateSpeed = particleSystem.updateSpeed;
  105959. serializationObject.targetStopDuration = particleSystem.targetStopDuration;
  105960. serializationObject.blendMode = particleSystem.blendMode;
  105961. serializationObject.preWarmCycles = particleSystem.preWarmCycles;
  105962. serializationObject.preWarmStepOffset = particleSystem.preWarmStepOffset;
  105963. serializationObject.minInitialRotation = particleSystem.minInitialRotation;
  105964. serializationObject.maxInitialRotation = particleSystem.maxInitialRotation;
  105965. serializationObject.startSpriteCellID = particleSystem.startSpriteCellID;
  105966. serializationObject.endSpriteCellID = particleSystem.endSpriteCellID;
  105967. serializationObject.spriteCellChangeSpeed = particleSystem.spriteCellChangeSpeed;
  105968. serializationObject.spriteCellWidth = particleSystem.spriteCellWidth;
  105969. serializationObject.spriteCellHeight = particleSystem.spriteCellHeight;
  105970. serializationObject.spriteRandomStartCell = particleSystem.spriteRandomStartCell;
  105971. serializationObject.isAnimationSheetEnabled = particleSystem.isAnimationSheetEnabled;
  105972. var colorGradients = particleSystem.getColorGradients();
  105973. if (colorGradients) {
  105974. serializationObject.colorGradients = [];
  105975. for (var _i = 0, colorGradients_1 = colorGradients; _i < colorGradients_1.length; _i++) {
  105976. var colorGradient = colorGradients_1[_i];
  105977. var serializedGradient = {
  105978. gradient: colorGradient.gradient,
  105979. color1: colorGradient.color1.asArray()
  105980. };
  105981. if (colorGradient.color2) {
  105982. serializedGradient.color2 = colorGradient.color2.asArray();
  105983. }
  105984. serializationObject.colorGradients.push(serializedGradient);
  105985. }
  105986. }
  105987. var rampGradients = particleSystem.getRampGradients();
  105988. if (rampGradients) {
  105989. serializationObject.rampGradients = [];
  105990. for (var _a = 0, rampGradients_1 = rampGradients; _a < rampGradients_1.length; _a++) {
  105991. var rampGradient = rampGradients_1[_a];
  105992. var serializedGradient = {
  105993. gradient: rampGradient.gradient,
  105994. color: rampGradient.color.asArray()
  105995. };
  105996. serializationObject.rampGradients.push(serializedGradient);
  105997. }
  105998. serializationObject.useRampGradients = particleSystem.useRampGradients;
  105999. }
  106000. var colorRemapGradients = particleSystem.getColorRemapGradients();
  106001. if (colorRemapGradients) {
  106002. serializationObject.colorRemapGradients = [];
  106003. for (var _b = 0, colorRemapGradients_1 = colorRemapGradients; _b < colorRemapGradients_1.length; _b++) {
  106004. var colorRemapGradient = colorRemapGradients_1[_b];
  106005. var serializedGradient = {
  106006. gradient: colorRemapGradient.gradient,
  106007. factor1: colorRemapGradient.factor1
  106008. };
  106009. if (colorRemapGradient.factor2 !== undefined) {
  106010. serializedGradient.factor2 = colorRemapGradient.factor2;
  106011. }
  106012. serializationObject.colorRemapGradients.push(serializedGradient);
  106013. }
  106014. }
  106015. var alphaRemapGradients = particleSystem.getAlphaRemapGradients();
  106016. if (alphaRemapGradients) {
  106017. serializationObject.alphaRemapGradients = [];
  106018. for (var _c = 0, alphaRemapGradients_1 = alphaRemapGradients; _c < alphaRemapGradients_1.length; _c++) {
  106019. var alphaRemapGradient = alphaRemapGradients_1[_c];
  106020. var serializedGradient = {
  106021. gradient: alphaRemapGradient.gradient,
  106022. factor1: alphaRemapGradient.factor1
  106023. };
  106024. if (alphaRemapGradient.factor2 !== undefined) {
  106025. serializedGradient.factor2 = alphaRemapGradient.factor2;
  106026. }
  106027. serializationObject.alphaRemapGradients.push(serializedGradient);
  106028. }
  106029. }
  106030. var sizeGradients = particleSystem.getSizeGradients();
  106031. if (sizeGradients) {
  106032. serializationObject.sizeGradients = [];
  106033. for (var _d = 0, sizeGradients_1 = sizeGradients; _d < sizeGradients_1.length; _d++) {
  106034. var sizeGradient = sizeGradients_1[_d];
  106035. var serializedGradient = {
  106036. gradient: sizeGradient.gradient,
  106037. factor1: sizeGradient.factor1
  106038. };
  106039. if (sizeGradient.factor2 !== undefined) {
  106040. serializedGradient.factor2 = sizeGradient.factor2;
  106041. }
  106042. serializationObject.sizeGradients.push(serializedGradient);
  106043. }
  106044. }
  106045. var angularSpeedGradients = particleSystem.getAngularSpeedGradients();
  106046. if (angularSpeedGradients) {
  106047. serializationObject.angularSpeedGradients = [];
  106048. for (var _e = 0, angularSpeedGradients_1 = angularSpeedGradients; _e < angularSpeedGradients_1.length; _e++) {
  106049. var angularSpeedGradient = angularSpeedGradients_1[_e];
  106050. var serializedGradient = {
  106051. gradient: angularSpeedGradient.gradient,
  106052. factor1: angularSpeedGradient.factor1
  106053. };
  106054. if (angularSpeedGradient.factor2 !== undefined) {
  106055. serializedGradient.factor2 = angularSpeedGradient.factor2;
  106056. }
  106057. serializationObject.angularSpeedGradients.push(serializedGradient);
  106058. }
  106059. }
  106060. var velocityGradients = particleSystem.getVelocityGradients();
  106061. if (velocityGradients) {
  106062. serializationObject.velocityGradients = [];
  106063. for (var _f = 0, velocityGradients_1 = velocityGradients; _f < velocityGradients_1.length; _f++) {
  106064. var velocityGradient = velocityGradients_1[_f];
  106065. var serializedGradient = {
  106066. gradient: velocityGradient.gradient,
  106067. factor1: velocityGradient.factor1
  106068. };
  106069. if (velocityGradient.factor2 !== undefined) {
  106070. serializedGradient.factor2 = velocityGradient.factor2;
  106071. }
  106072. serializationObject.velocityGradients.push(serializedGradient);
  106073. }
  106074. }
  106075. var dragGradients = particleSystem.getDragGradients();
  106076. if (dragGradients) {
  106077. serializationObject.dragyGradients = [];
  106078. for (var _g = 0, dragGradients_1 = dragGradients; _g < dragGradients_1.length; _g++) {
  106079. var dragGradient = dragGradients_1[_g];
  106080. var serializedGradient = {
  106081. gradient: dragGradient.gradient,
  106082. factor1: dragGradient.factor1
  106083. };
  106084. if (dragGradient.factor2 !== undefined) {
  106085. serializedGradient.factor2 = dragGradient.factor2;
  106086. }
  106087. serializationObject.dragGradients.push(serializedGradient);
  106088. }
  106089. }
  106090. var emitRateGradients = particleSystem.getEmitRateGradients();
  106091. if (emitRateGradients) {
  106092. serializationObject.emitRateGradients = [];
  106093. for (var _h = 0, emitRateGradients_1 = emitRateGradients; _h < emitRateGradients_1.length; _h++) {
  106094. var emitRateGradient = emitRateGradients_1[_h];
  106095. var serializedGradient = {
  106096. gradient: emitRateGradient.gradient,
  106097. factor1: emitRateGradient.factor1
  106098. };
  106099. if (emitRateGradient.factor2 !== undefined) {
  106100. serializedGradient.factor2 = emitRateGradient.factor2;
  106101. }
  106102. serializationObject.emitRateGradients.push(serializedGradient);
  106103. }
  106104. }
  106105. var startSizeGradients = particleSystem.getStartSizeGradients();
  106106. if (startSizeGradients) {
  106107. serializationObject.startSizeGradients = [];
  106108. for (var _j = 0, startSizeGradients_1 = startSizeGradients; _j < startSizeGradients_1.length; _j++) {
  106109. var startSizeGradient = startSizeGradients_1[_j];
  106110. var serializedGradient = {
  106111. gradient: startSizeGradient.gradient,
  106112. factor1: startSizeGradient.factor1
  106113. };
  106114. if (startSizeGradient.factor2 !== undefined) {
  106115. serializedGradient.factor2 = startSizeGradient.factor2;
  106116. }
  106117. serializationObject.startSizeGradients.push(serializedGradient);
  106118. }
  106119. }
  106120. var lifeTimeGradients = particleSystem.getLifeTimeGradients();
  106121. if (lifeTimeGradients) {
  106122. serializationObject.lifeTimeGradients = [];
  106123. for (var _k = 0, lifeTimeGradients_1 = lifeTimeGradients; _k < lifeTimeGradients_1.length; _k++) {
  106124. var lifeTimeGradient = lifeTimeGradients_1[_k];
  106125. var serializedGradient = {
  106126. gradient: lifeTimeGradient.gradient,
  106127. factor1: lifeTimeGradient.factor1
  106128. };
  106129. if (lifeTimeGradient.factor2 !== undefined) {
  106130. serializedGradient.factor2 = lifeTimeGradient.factor2;
  106131. }
  106132. serializationObject.lifeTimeGradients.push(serializedGradient);
  106133. }
  106134. }
  106135. var limitVelocityGradients = particleSystem.getLimitVelocityGradients();
  106136. if (limitVelocityGradients) {
  106137. serializationObject.limitVelocityGradients = [];
  106138. for (var _l = 0, limitVelocityGradients_1 = limitVelocityGradients; _l < limitVelocityGradients_1.length; _l++) {
  106139. var limitVelocityGradient = limitVelocityGradients_1[_l];
  106140. var serializedGradient = {
  106141. gradient: limitVelocityGradient.gradient,
  106142. factor1: limitVelocityGradient.factor1
  106143. };
  106144. if (limitVelocityGradient.factor2 !== undefined) {
  106145. serializedGradient.factor2 = limitVelocityGradient.factor2;
  106146. }
  106147. serializationObject.limitVelocityGradients.push(serializedGradient);
  106148. }
  106149. serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
  106150. }
  106151. if (particleSystem.noiseTexture) {
  106152. serializationObject.noiseTexture = particleSystem.noiseTexture.serialize();
  106153. }
  106154. };
  106155. /** @hidden */
  106156. ParticleSystem._Parse = function (parsedParticleSystem, particleSystem, scene, rootUrl) {
  106157. // Texture
  106158. if (parsedParticleSystem.textureName) {
  106159. particleSystem.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](rootUrl + parsedParticleSystem.textureName, scene, false, parsedParticleSystem.invertY !== undefined ? parsedParticleSystem.invertY : true);
  106160. particleSystem.particleTexture.name = parsedParticleSystem.textureName;
  106161. }
  106162. // Emitter
  106163. if (!parsedParticleSystem.emitterId && parsedParticleSystem.emitterId !== 0 && parsedParticleSystem.emitter === undefined) {
  106164. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  106165. }
  106166. else if (parsedParticleSystem.emitterId) {
  106167. particleSystem.emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
  106168. }
  106169. else {
  106170. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.emitter);
  106171. }
  106172. // Misc.
  106173. if (parsedParticleSystem.renderingGroupId !== undefined) {
  106174. particleSystem.renderingGroupId = parsedParticleSystem.renderingGroupId;
  106175. }
  106176. if (parsedParticleSystem.isBillboardBased !== undefined) {
  106177. particleSystem.isBillboardBased = parsedParticleSystem.isBillboardBased;
  106178. }
  106179. if (parsedParticleSystem.billboardMode !== undefined) {
  106180. particleSystem.billboardMode = parsedParticleSystem.billboardMode;
  106181. }
  106182. // Animations
  106183. if (parsedParticleSystem.animations) {
  106184. for (var animationIndex = 0; animationIndex < parsedParticleSystem.animations.length; animationIndex++) {
  106185. var parsedAnimation = parsedParticleSystem.animations[animationIndex];
  106186. particleSystem.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_14__["Animation"].Parse(parsedAnimation));
  106187. }
  106188. particleSystem.beginAnimationOnStart = parsedParticleSystem.beginAnimationOnStart;
  106189. particleSystem.beginAnimationFrom = parsedParticleSystem.beginAnimationFrom;
  106190. particleSystem.beginAnimationTo = parsedParticleSystem.beginAnimationTo;
  106191. particleSystem.beginAnimationLoop = parsedParticleSystem.beginAnimationLoop;
  106192. }
  106193. if (parsedParticleSystem.autoAnimate) {
  106194. scene.beginAnimation(particleSystem, parsedParticleSystem.autoAnimateFrom, parsedParticleSystem.autoAnimateTo, parsedParticleSystem.autoAnimateLoop, parsedParticleSystem.autoAnimateSpeed || 1.0);
  106195. }
  106196. // Particle system
  106197. particleSystem.startDelay = parsedParticleSystem.startDelay | 0;
  106198. particleSystem.minAngularSpeed = parsedParticleSystem.minAngularSpeed;
  106199. particleSystem.maxAngularSpeed = parsedParticleSystem.maxAngularSpeed;
  106200. particleSystem.minSize = parsedParticleSystem.minSize;
  106201. particleSystem.maxSize = parsedParticleSystem.maxSize;
  106202. if (parsedParticleSystem.minScaleX) {
  106203. particleSystem.minScaleX = parsedParticleSystem.minScaleX;
  106204. particleSystem.maxScaleX = parsedParticleSystem.maxScaleX;
  106205. particleSystem.minScaleY = parsedParticleSystem.minScaleY;
  106206. particleSystem.maxScaleY = parsedParticleSystem.maxScaleY;
  106207. }
  106208. if (parsedParticleSystem.preWarmCycles !== undefined) {
  106209. particleSystem.preWarmCycles = parsedParticleSystem.preWarmCycles;
  106210. particleSystem.preWarmStepOffset = parsedParticleSystem.preWarmStepOffset;
  106211. }
  106212. if (parsedParticleSystem.minInitialRotation !== undefined) {
  106213. particleSystem.minInitialRotation = parsedParticleSystem.minInitialRotation;
  106214. particleSystem.maxInitialRotation = parsedParticleSystem.maxInitialRotation;
  106215. }
  106216. particleSystem.minLifeTime = parsedParticleSystem.minLifeTime;
  106217. particleSystem.maxLifeTime = parsedParticleSystem.maxLifeTime;
  106218. particleSystem.minEmitPower = parsedParticleSystem.minEmitPower;
  106219. particleSystem.maxEmitPower = parsedParticleSystem.maxEmitPower;
  106220. particleSystem.emitRate = parsedParticleSystem.emitRate;
  106221. particleSystem.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.gravity);
  106222. if (parsedParticleSystem.noiseStrength) {
  106223. particleSystem.noiseStrength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.noiseStrength);
  106224. }
  106225. particleSystem.color1 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color1);
  106226. particleSystem.color2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color2);
  106227. particleSystem.colorDead = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.colorDead);
  106228. particleSystem.updateSpeed = parsedParticleSystem.updateSpeed;
  106229. particleSystem.targetStopDuration = parsedParticleSystem.targetStopDuration;
  106230. particleSystem.blendMode = parsedParticleSystem.blendMode;
  106231. if (parsedParticleSystem.colorGradients) {
  106232. for (var _i = 0, _a = parsedParticleSystem.colorGradients; _i < _a.length; _i++) {
  106233. var colorGradient = _a[_i];
  106234. 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);
  106235. }
  106236. }
  106237. if (parsedParticleSystem.rampGradients) {
  106238. for (var _b = 0, _c = parsedParticleSystem.rampGradients; _b < _c.length; _b++) {
  106239. var rampGradient = _c[_b];
  106240. particleSystem.addRampGradient(rampGradient.gradient, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].FromArray(rampGradient.color));
  106241. }
  106242. particleSystem.useRampGradients = parsedParticleSystem.useRampGradients;
  106243. }
  106244. if (parsedParticleSystem.colorRemapGradients) {
  106245. for (var _d = 0, _e = parsedParticleSystem.colorRemapGradients; _d < _e.length; _d++) {
  106246. var colorRemapGradient = _e[_d];
  106247. particleSystem.addColorRemapGradient(colorRemapGradient.gradient, colorRemapGradient.factor1 !== undefined ? colorRemapGradient.factor1 : colorRemapGradient.factor, colorRemapGradient.factor2);
  106248. }
  106249. }
  106250. if (parsedParticleSystem.alphaRemapGradients) {
  106251. for (var _f = 0, _g = parsedParticleSystem.alphaRemapGradients; _f < _g.length; _f++) {
  106252. var alphaRemapGradient = _g[_f];
  106253. particleSystem.addAlphaRemapGradient(alphaRemapGradient.gradient, alphaRemapGradient.factor1 !== undefined ? alphaRemapGradient.factor1 : alphaRemapGradient.factor, alphaRemapGradient.factor2);
  106254. }
  106255. }
  106256. if (parsedParticleSystem.sizeGradients) {
  106257. for (var _h = 0, _j = parsedParticleSystem.sizeGradients; _h < _j.length; _h++) {
  106258. var sizeGradient = _j[_h];
  106259. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  106260. }
  106261. }
  106262. if (parsedParticleSystem.sizeGradients) {
  106263. for (var _k = 0, _l = parsedParticleSystem.sizeGradients; _k < _l.length; _k++) {
  106264. var sizeGradient = _l[_k];
  106265. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  106266. }
  106267. }
  106268. if (parsedParticleSystem.angularSpeedGradients) {
  106269. for (var _m = 0, _o = parsedParticleSystem.angularSpeedGradients; _m < _o.length; _m++) {
  106270. var angularSpeedGradient = _o[_m];
  106271. particleSystem.addAngularSpeedGradient(angularSpeedGradient.gradient, angularSpeedGradient.factor1 !== undefined ? angularSpeedGradient.factor1 : angularSpeedGradient.factor, angularSpeedGradient.factor2);
  106272. }
  106273. }
  106274. if (parsedParticleSystem.velocityGradients) {
  106275. for (var _p = 0, _q = parsedParticleSystem.velocityGradients; _p < _q.length; _p++) {
  106276. var velocityGradient = _q[_p];
  106277. particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
  106278. }
  106279. }
  106280. if (parsedParticleSystem.dragGradients) {
  106281. for (var _r = 0, _s = parsedParticleSystem.dragGradients; _r < _s.length; _r++) {
  106282. var dragGradient = _s[_r];
  106283. particleSystem.addDragGradient(dragGradient.gradient, dragGradient.factor1 !== undefined ? dragGradient.factor1 : dragGradient.factor, dragGradient.factor2);
  106284. }
  106285. }
  106286. if (parsedParticleSystem.emitRateGradients) {
  106287. for (var _t = 0, _u = parsedParticleSystem.emitRateGradients; _t < _u.length; _t++) {
  106288. var emitRateGradient = _u[_t];
  106289. particleSystem.addEmitRateGradient(emitRateGradient.gradient, emitRateGradient.factor1 !== undefined ? emitRateGradient.factor1 : emitRateGradient.factor, emitRateGradient.factor2);
  106290. }
  106291. }
  106292. if (parsedParticleSystem.startSizeGradients) {
  106293. for (var _v = 0, _w = parsedParticleSystem.startSizeGradients; _v < _w.length; _v++) {
  106294. var startSizeGradient = _w[_v];
  106295. particleSystem.addStartSizeGradient(startSizeGradient.gradient, startSizeGradient.factor1 !== undefined ? startSizeGradient.factor1 : startSizeGradient.factor, startSizeGradient.factor2);
  106296. }
  106297. }
  106298. if (parsedParticleSystem.lifeTimeGradients) {
  106299. for (var _x = 0, _y = parsedParticleSystem.lifeTimeGradients; _x < _y.length; _x++) {
  106300. var lifeTimeGradient = _y[_x];
  106301. particleSystem.addLifeTimeGradient(lifeTimeGradient.gradient, lifeTimeGradient.factor1 !== undefined ? lifeTimeGradient.factor1 : lifeTimeGradient.factor, lifeTimeGradient.factor2);
  106302. }
  106303. }
  106304. if (parsedParticleSystem.limitVelocityGradients) {
  106305. for (var _z = 0, _0 = parsedParticleSystem.limitVelocityGradients; _z < _0.length; _z++) {
  106306. var limitVelocityGradient = _0[_z];
  106307. particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
  106308. }
  106309. particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
  106310. }
  106311. if (parsedParticleSystem.noiseTexture) {
  106312. particleSystem.noiseTexture = _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__["ProceduralTexture"].Parse(parsedParticleSystem.noiseTexture, scene, rootUrl);
  106313. }
  106314. // Emitter
  106315. var emitterType;
  106316. if (parsedParticleSystem.particleEmitterType) {
  106317. switch (parsedParticleSystem.particleEmitterType.type) {
  106318. case "SphereParticleEmitter":
  106319. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["SphereParticleEmitter"]();
  106320. break;
  106321. case "SphereDirectedParticleEmitter":
  106322. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["SphereDirectedParticleEmitter"]();
  106323. break;
  106324. case "ConeEmitter":
  106325. case "ConeParticleEmitter":
  106326. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["ConeParticleEmitter"]();
  106327. break;
  106328. case "CylinderParticleEmitter":
  106329. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["CylinderParticleEmitter"]();
  106330. break;
  106331. case "HemisphericParticleEmitter":
  106332. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["HemisphericParticleEmitter"]();
  106333. break;
  106334. case "BoxEmitter":
  106335. case "BoxParticleEmitter":
  106336. default:
  106337. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["BoxParticleEmitter"]();
  106338. break;
  106339. }
  106340. emitterType.parse(parsedParticleSystem.particleEmitterType);
  106341. }
  106342. else {
  106343. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["BoxParticleEmitter"]();
  106344. emitterType.parse(parsedParticleSystem);
  106345. }
  106346. particleSystem.particleEmitterType = emitterType;
  106347. // Animation sheet
  106348. particleSystem.startSpriteCellID = parsedParticleSystem.startSpriteCellID;
  106349. particleSystem.endSpriteCellID = parsedParticleSystem.endSpriteCellID;
  106350. particleSystem.spriteCellWidth = parsedParticleSystem.spriteCellWidth;
  106351. particleSystem.spriteCellHeight = parsedParticleSystem.spriteCellHeight;
  106352. particleSystem.spriteCellChangeSpeed = parsedParticleSystem.spriteCellChangeSpeed;
  106353. particleSystem.spriteRandomStartCell = parsedParticleSystem.spriteRandomStartCell;
  106354. };
  106355. /**
  106356. * Parses a JSON object to create a particle system.
  106357. * @param parsedParticleSystem The JSON object to parse
  106358. * @param scene The scene to create the particle system in
  106359. * @param rootUrl The root url to use to load external dependencies like texture
  106360. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  106361. * @returns the Parsed particle system
  106362. */
  106363. ParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  106364. if (doNotStart === void 0) { doNotStart = false; }
  106365. var name = parsedParticleSystem.name;
  106366. var custom = null;
  106367. var program = null;
  106368. if (parsedParticleSystem.customShader) {
  106369. program = parsedParticleSystem.customShader;
  106370. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  106371. custom = scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  106372. }
  106373. var particleSystem = new ParticleSystem(name, parsedParticleSystem.capacity, scene, custom, parsedParticleSystem.isAnimationSheetEnabled);
  106374. particleSystem.customShader = program;
  106375. if (parsedParticleSystem.id) {
  106376. particleSystem.id = parsedParticleSystem.id;
  106377. }
  106378. // SubEmitters
  106379. if (parsedParticleSystem.subEmitters) {
  106380. particleSystem.subEmitters = [];
  106381. for (var _i = 0, _a = parsedParticleSystem.subEmitters; _i < _a.length; _i++) {
  106382. var cell = _a[_i];
  106383. var cellArray = [];
  106384. for (var _b = 0, cell_1 = cell; _b < cell_1.length; _b++) {
  106385. var sub = cell_1[_b];
  106386. cellArray.push(_subEmitter__WEBPACK_IMPORTED_MODULE_18__["SubEmitter"].Parse(sub, scene, rootUrl));
  106387. }
  106388. particleSystem.subEmitters.push(cellArray);
  106389. }
  106390. }
  106391. ParticleSystem._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  106392. particleSystem.textureMask = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.textureMask);
  106393. // Auto start
  106394. if (parsedParticleSystem.preventAutoStart) {
  106395. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  106396. }
  106397. if (!doNotStart && !particleSystem.preventAutoStart) {
  106398. particleSystem.start();
  106399. }
  106400. return particleSystem;
  106401. };
  106402. /**
  106403. * Billboard mode will only apply to Y axis
  106404. */
  106405. ParticleSystem.BILLBOARDMODE_Y = _Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].PARTICLES_BILLBOARDMODE_Y;
  106406. /**
  106407. * Billboard mode will apply to all axes
  106408. */
  106409. ParticleSystem.BILLBOARDMODE_ALL = _Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  106410. /**
  106411. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  106412. */
  106413. ParticleSystem.BILLBOARDMODE_STRETCHED = _Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].PARTICLES_BILLBOARDMODE_STRETCHED;
  106414. return ParticleSystem;
  106415. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_16__["BaseParticleSystem"]));
  106416. _subEmitter__WEBPACK_IMPORTED_MODULE_18__["SubEmitter"]._ParseParticleSystem = ParticleSystem.Parse;
  106417. /***/ }),
  106418. /***/ "./Particles/particleSystemComponent.ts":
  106419. /*!**********************************************!*\
  106420. !*** ./Particles/particleSystemComponent.ts ***!
  106421. \**********************************************/
  106422. /*! exports provided: _IDoNeedToBeInTheBuild */
  106423. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106424. "use strict";
  106425. __webpack_require__.r(__webpack_exports__);
  106426. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _IDoNeedToBeInTheBuild; });
  106427. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  106428. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  106429. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  106430. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  106431. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  106432. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  106433. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  106434. // Adds the parsers to the scene parsers.
  106435. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedData, scene, container, rootUrl) {
  106436. var individualParser = _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  106437. if (!individualParser) {
  106438. return;
  106439. }
  106440. // Particles Systems
  106441. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  106442. for (var index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  106443. var parsedParticleSystem = parsedData.particleSystems[index];
  106444. container.particleSystems.push(individualParser(parsedParticleSystem, scene, rootUrl));
  106445. }
  106446. }
  106447. });
  106448. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedParticleSystem, scene, rootUrl) {
  106449. if (parsedParticleSystem.activeParticleCount) {
  106450. var ps = _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__["GPUParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  106451. return ps;
  106452. }
  106453. else {
  106454. var ps = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  106455. return ps;
  106456. }
  106457. });
  106458. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createEffectForParticles = function (fragmentName, uniformsNames, samplers, defines, fallbacks, onCompiled, onError) {
  106459. if (uniformsNames === void 0) { uniformsNames = []; }
  106460. if (samplers === void 0) { samplers = []; }
  106461. if (defines === void 0) { defines = ""; }
  106462. var attributesNamesOrOptions = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetAttributeNamesOrOptions();
  106463. var effectCreationOption = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetEffectCreationOptions();
  106464. if (defines.indexOf(" BILLBOARD") === -1) {
  106465. defines += "\n#define BILLBOARD\n";
  106466. }
  106467. if (samplers.indexOf("diffuseSampler") === -1) {
  106468. samplers.push("diffuseSampler");
  106469. }
  106470. return this.createEffect({
  106471. vertex: "particles",
  106472. fragmentElement: fragmentName
  106473. }, attributesNamesOrOptions, effectCreationOption.concat(uniformsNames), samplers, defines, fallbacks, onCompiled, onError);
  106474. };
  106475. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getEmittedParticleSystems = function () {
  106476. var results = new Array();
  106477. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  106478. var particleSystem = this.getScene().particleSystems[index];
  106479. if (particleSystem.emitter === this) {
  106480. results.push(particleSystem);
  106481. }
  106482. }
  106483. return results;
  106484. };
  106485. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getHierarchyEmittedParticleSystems = function () {
  106486. var results = new Array();
  106487. var descendants = this.getDescendants();
  106488. descendants.push(this);
  106489. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  106490. var particleSystem = this.getScene().particleSystems[index];
  106491. var emitter = particleSystem.emitter;
  106492. if (emitter.position && descendants.indexOf(emitter) !== -1) {
  106493. results.push(particleSystem);
  106494. }
  106495. }
  106496. return results;
  106497. };
  106498. /**
  106499. * @hidden
  106500. */
  106501. var _IDoNeedToBeInTheBuild = 42;
  106502. /***/ }),
  106503. /***/ "./Particles/particleSystemSet.ts":
  106504. /*!****************************************!*\
  106505. !*** ./Particles/particleSystemSet.ts ***!
  106506. \****************************************/
  106507. /*! exports provided: ParticleSystemSet */
  106508. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106509. "use strict";
  106510. __webpack_require__.r(__webpack_exports__);
  106511. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return ParticleSystemSet; });
  106512. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  106513. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  106514. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  106515. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  106516. /* harmony import */ var _Particles_particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Particles/particleSystem */ "./Particles/particleSystem.ts");
  106517. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  106518. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  106519. /** Internal class used to store shapes for emitters */
  106520. var ParticleSystemSetEmitterCreationOptions = /** @class */ (function () {
  106521. function ParticleSystemSetEmitterCreationOptions() {
  106522. }
  106523. return ParticleSystemSetEmitterCreationOptions;
  106524. }());
  106525. /**
  106526. * Represents a set of particle systems working together to create a specific effect
  106527. */
  106528. var ParticleSystemSet = /** @class */ (function () {
  106529. function ParticleSystemSet() {
  106530. /**
  106531. * Gets the particle system list
  106532. */
  106533. this.systems = new Array();
  106534. }
  106535. Object.defineProperty(ParticleSystemSet.prototype, "emitterNode", {
  106536. /**
  106537. * Gets the emitter node used with this set
  106538. */
  106539. get: function () {
  106540. return this._emitterNode;
  106541. },
  106542. enumerable: true,
  106543. configurable: true
  106544. });
  106545. /**
  106546. * Creates a new emitter mesh as a sphere
  106547. * @param options defines the options used to create the sphere
  106548. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  106549. * @param scene defines the hosting scene
  106550. */
  106551. ParticleSystemSet.prototype.setEmitterAsSphere = function (options, renderingGroupId, scene) {
  106552. if (this._emitterNode) {
  106553. this._emitterNode.dispose();
  106554. }
  106555. this._emitterCreationOptions = {
  106556. kind: "Sphere",
  106557. options: options,
  106558. renderingGroupId: renderingGroupId
  106559. };
  106560. var emitterMesh = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_1__["MeshBuilder"].CreateSphere("emitterSphere", { diameter: options.diameter, segments: options.segments }, scene);
  106561. emitterMesh.renderingGroupId = renderingGroupId;
  106562. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("emitterSphereMaterial", scene);
  106563. material.emissiveColor = options.color;
  106564. emitterMesh.material = material;
  106565. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  106566. var system = _a[_i];
  106567. system.emitter = emitterMesh;
  106568. }
  106569. this._emitterNode = emitterMesh;
  106570. };
  106571. /**
  106572. * Starts all particle systems of the set
  106573. * @param emitter defines an optional mesh to use as emitter for the particle systems
  106574. */
  106575. ParticleSystemSet.prototype.start = function (emitter) {
  106576. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  106577. var system = _a[_i];
  106578. if (emitter) {
  106579. system.emitter = emitter;
  106580. }
  106581. system.start();
  106582. }
  106583. };
  106584. /**
  106585. * Release all associated resources
  106586. */
  106587. ParticleSystemSet.prototype.dispose = function () {
  106588. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  106589. var system = _a[_i];
  106590. system.dispose();
  106591. }
  106592. this.systems = [];
  106593. if (this._emitterNode) {
  106594. this._emitterNode.dispose();
  106595. this._emitterNode = null;
  106596. }
  106597. };
  106598. /**
  106599. * Serialize the set into a JSON compatible object
  106600. * @returns a JSON compatible representation of the set
  106601. */
  106602. ParticleSystemSet.prototype.serialize = function () {
  106603. var result = {};
  106604. result.systems = [];
  106605. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  106606. var system = _a[_i];
  106607. result.systems.push(system.serialize());
  106608. }
  106609. if (this._emitterNode) {
  106610. result.emitter = this._emitterCreationOptions;
  106611. }
  106612. return result;
  106613. };
  106614. /**
  106615. * Parse a new ParticleSystemSet from a serialized source
  106616. * @param data defines a JSON compatible representation of the set
  106617. * @param scene defines the hosting scene
  106618. * @param gpu defines if we want GPU particles or CPU particles
  106619. * @returns a new ParticleSystemSet
  106620. */
  106621. ParticleSystemSet.Parse = function (data, scene, gpu) {
  106622. if (gpu === void 0) { gpu = false; }
  106623. var result = new ParticleSystemSet();
  106624. var rootUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].PARTICLES_BaseAssetsUrl + "/textures/";
  106625. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  106626. for (var _i = 0, _a = data.systems; _i < _a.length; _i++) {
  106627. var system = _a[_i];
  106628. 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));
  106629. }
  106630. if (data.emitter) {
  106631. var options = data.emitter.options;
  106632. switch (data.emitter.kind) {
  106633. case "Sphere":
  106634. result.setEmitterAsSphere({
  106635. diameter: options.diameter,
  106636. segments: options.segments,
  106637. color: _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(options.color)
  106638. }, data.emitter.renderingGroupId, scene);
  106639. break;
  106640. }
  106641. }
  106642. return result;
  106643. };
  106644. return ParticleSystemSet;
  106645. }());
  106646. /***/ }),
  106647. /***/ "./Particles/solidParticle.ts":
  106648. /*!************************************!*\
  106649. !*** ./Particles/solidParticle.ts ***!
  106650. \************************************/
  106651. /*! exports provided: SolidParticle, ModelShape, DepthSortedParticle */
  106652. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106653. "use strict";
  106654. __webpack_require__.r(__webpack_exports__);
  106655. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return SolidParticle; });
  106656. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return ModelShape; });
  106657. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return DepthSortedParticle; });
  106658. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  106659. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  106660. /* harmony import */ var _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/boundingSphere */ "./Culling/boundingSphere.ts");
  106661. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  106662. /**
  106663. * Represents one particle of a solid particle system.
  106664. */
  106665. var SolidParticle = /** @class */ (function () {
  106666. /**
  106667. * Creates a Solid Particle object.
  106668. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  106669. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  106670. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  106671. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  106672. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  106673. * @param shapeId (integer) is the model shape identifier in the SPS.
  106674. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  106675. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  106676. */
  106677. function SolidParticle(particleIndex, positionIndex, indiceIndex, model, shapeId, idxInShape, sps, modelBoundingInfo) {
  106678. if (modelBoundingInfo === void 0) { modelBoundingInfo = null; }
  106679. /**
  106680. * particle global index
  106681. */
  106682. this.idx = 0;
  106683. /**
  106684. * The color of the particle
  106685. */
  106686. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  106687. /**
  106688. * The world space position of the particle.
  106689. */
  106690. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106691. /**
  106692. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  106693. */
  106694. this.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106695. /**
  106696. * The scaling of the particle.
  106697. */
  106698. this.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  106699. /**
  106700. * The uvs of the particle.
  106701. */
  106702. this.uvs = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  106703. /**
  106704. * The current speed of the particle.
  106705. */
  106706. this.velocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106707. /**
  106708. * The pivot point in the particle local space.
  106709. */
  106710. this.pivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106711. /**
  106712. * Must the particle be translated from its pivot point in its local space ?
  106713. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  106714. * Default : false
  106715. */
  106716. this.translateFromPivot = false;
  106717. /**
  106718. * Is the particle active or not ?
  106719. */
  106720. this.alive = true;
  106721. /**
  106722. * Is the particle visible or not ?
  106723. */
  106724. this.isVisible = true;
  106725. /**
  106726. * Index of this particle in the global "positions" array (Internal use)
  106727. * @hidden
  106728. */
  106729. this._pos = 0;
  106730. /**
  106731. * @hidden Index of this particle in the global "indices" array (Internal use)
  106732. */
  106733. this._ind = 0;
  106734. /**
  106735. * ModelShape id of this particle
  106736. */
  106737. this.shapeId = 0;
  106738. /**
  106739. * Index of the particle in its shape id (Internal use)
  106740. */
  106741. this.idxInShape = 0;
  106742. /**
  106743. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  106744. */
  106745. this._stillInvisible = false;
  106746. /**
  106747. * @hidden Last computed particle rotation matrix
  106748. */
  106749. this._rotationMatrix = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0];
  106750. /**
  106751. * Parent particle Id, if any.
  106752. * Default null.
  106753. */
  106754. this.parentId = null;
  106755. /**
  106756. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  106757. * The possible values are :
  106758. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  106759. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  106760. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  106761. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  106762. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  106763. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  106764. * */
  106765. this.cullingStrategy = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"].CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  106766. /**
  106767. * @hidden Internal global position in the SPS.
  106768. */
  106769. this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106770. this.idx = particleIndex;
  106771. this._pos = positionIndex;
  106772. this._ind = indiceIndex;
  106773. this._model = model;
  106774. this.shapeId = shapeId;
  106775. this.idxInShape = idxInShape;
  106776. this._sps = sps;
  106777. if (modelBoundingInfo) {
  106778. this._modelBoundingInfo = modelBoundingInfo;
  106779. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"](modelBoundingInfo.minimum, modelBoundingInfo.maximum);
  106780. }
  106781. }
  106782. Object.defineProperty(SolidParticle.prototype, "scale", {
  106783. /**
  106784. * Legacy support, changed scale to scaling
  106785. */
  106786. get: function () {
  106787. return this.scaling;
  106788. },
  106789. /**
  106790. * Legacy support, changed scale to scaling
  106791. */
  106792. set: function (scale) {
  106793. this.scaling = scale;
  106794. },
  106795. enumerable: true,
  106796. configurable: true
  106797. });
  106798. Object.defineProperty(SolidParticle.prototype, "quaternion", {
  106799. /**
  106800. * Legacy support, changed quaternion to rotationQuaternion
  106801. */
  106802. get: function () {
  106803. return this.rotationQuaternion;
  106804. },
  106805. /**
  106806. * Legacy support, changed quaternion to rotationQuaternion
  106807. */
  106808. set: function (q) {
  106809. this.rotationQuaternion = q;
  106810. },
  106811. enumerable: true,
  106812. configurable: true
  106813. });
  106814. /**
  106815. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  106816. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  106817. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  106818. * @returns true if it intersects
  106819. */
  106820. SolidParticle.prototype.intersectsMesh = function (target) {
  106821. if (!this._boundingInfo || !target._boundingInfo) {
  106822. return false;
  106823. }
  106824. if (this._sps._bSphereOnly) {
  106825. return _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"].Intersects(this._boundingInfo.boundingSphere, target._boundingInfo.boundingSphere);
  106826. }
  106827. return this._boundingInfo.intersects(target._boundingInfo, false);
  106828. };
  106829. /**
  106830. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  106831. * A particle is in the frustum if its bounding box intersects the frustum
  106832. * @param frustumPlanes defines the frustum to test
  106833. * @returns true if the particle is in the frustum planes
  106834. */
  106835. SolidParticle.prototype.isInFrustum = function (frustumPlanes) {
  106836. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  106837. };
  106838. /**
  106839. * get the rotation matrix of the particle
  106840. * @hidden
  106841. */
  106842. SolidParticle.prototype.getRotationMatrix = function (m) {
  106843. var quaternion;
  106844. if (this.rotationQuaternion) {
  106845. quaternion = this.rotationQuaternion;
  106846. }
  106847. else {
  106848. quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  106849. var rotation = this.rotation;
  106850. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  106851. }
  106852. quaternion.toRotationMatrix(m);
  106853. };
  106854. return SolidParticle;
  106855. }());
  106856. /**
  106857. * Represents the shape of the model used by one particle of a solid particle system.
  106858. * SPS internal tool, don't use it manually.
  106859. */
  106860. var ModelShape = /** @class */ (function () {
  106861. /**
  106862. * 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.
  106863. * SPS internal tool, don't use it manually.
  106864. * @hidden
  106865. */
  106866. function ModelShape(id, shape, indicesLength, shapeUV, posFunction, vtxFunction) {
  106867. /**
  106868. * length of the shape in the model indices array (internal use)
  106869. * @hidden
  106870. */
  106871. this._indicesLength = 0;
  106872. this.shapeID = id;
  106873. this._shape = shape;
  106874. this._indicesLength = indicesLength;
  106875. this._shapeUV = shapeUV;
  106876. this._positionFunction = posFunction;
  106877. this._vertexFunction = vtxFunction;
  106878. }
  106879. return ModelShape;
  106880. }());
  106881. /**
  106882. * Represents a Depth Sorted Particle in the solid particle system.
  106883. */
  106884. var DepthSortedParticle = /** @class */ (function () {
  106885. function DepthSortedParticle() {
  106886. /**
  106887. * Index of the particle in the "indices" array
  106888. */
  106889. this.ind = 0;
  106890. /**
  106891. * Length of the particle shape in the "indices" array
  106892. */
  106893. this.indicesLength = 0;
  106894. /**
  106895. * Squared distance from the particle to the camera
  106896. */
  106897. this.sqDistance = 0.0;
  106898. }
  106899. return DepthSortedParticle;
  106900. }());
  106901. /***/ }),
  106902. /***/ "./Particles/solidParticleSystem.ts":
  106903. /*!******************************************!*\
  106904. !*** ./Particles/solidParticleSystem.ts ***!
  106905. \******************************************/
  106906. /*! exports provided: SolidParticleSystem */
  106907. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106908. "use strict";
  106909. __webpack_require__.r(__webpack_exports__);
  106910. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return SolidParticleSystem; });
  106911. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  106912. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  106913. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  106914. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  106915. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  106916. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  106917. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  106918. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  106919. var depthSortFunction = function (p1, p2) { return p2.sqDistance - p1.sqDistance; };
  106920. /**
  106921. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  106922. *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.
  106923. * The SPS is also a particle system. It provides some methods to manage the particles.
  106924. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  106925. *
  106926. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  106927. */
  106928. var SolidParticleSystem = /** @class */ (function () {
  106929. /**
  106930. * Creates a SPS (Solid Particle System) object.
  106931. * @param name (String) is the SPS name, this will be the underlying mesh name.
  106932. * @param scene (Scene) is the scene in which the SPS is added.
  106933. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  106934. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  106935. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  106936. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  106937. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  106938. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  106939. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  106940. */
  106941. function SolidParticleSystem(name, scene, options) {
  106942. /**
  106943. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  106944. * Example : var p = SPS.particles[i];
  106945. */
  106946. this.particles = new Array();
  106947. /**
  106948. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  106949. */
  106950. this.nbParticles = 0;
  106951. /**
  106952. * If the particles must ever face the camera (default false). Useful for planar particles.
  106953. */
  106954. this.billboard = false;
  106955. /**
  106956. * Recompute normals when adding a shape
  106957. */
  106958. this.recomputeNormals = true;
  106959. /**
  106960. * This a counter ofr your own usage. It's not set by any SPS functions.
  106961. */
  106962. this.counter = 0;
  106963. /**
  106964. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  106965. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  106966. */
  106967. this.vars = {};
  106968. /**
  106969. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  106970. * @hidden
  106971. */
  106972. this._bSphereOnly = false;
  106973. /**
  106974. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  106975. * @hidden
  106976. */
  106977. this._bSphereRadiusFactor = 1.0;
  106978. this._positions = new Array();
  106979. this._indices = new Array();
  106980. this._normals = new Array();
  106981. this._colors = new Array();
  106982. this._uvs = new Array();
  106983. this._index = 0; // indices index
  106984. this._updatable = true;
  106985. this._pickable = false;
  106986. this._isVisibilityBoxLocked = false;
  106987. this._alwaysVisible = false;
  106988. this._depthSort = false;
  106989. this._shapeCounter = 0;
  106990. this._copy = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](0, 0, 0, null, 0, 0, this);
  106991. this._color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  106992. this._computeParticleColor = true;
  106993. this._computeParticleTexture = true;
  106994. this._computeParticleRotation = true;
  106995. this._computeParticleVertex = false;
  106996. this._computeBoundingBox = false;
  106997. this._depthSortParticles = true;
  106998. this._mustUnrotateFixedNormals = false;
  106999. this._particlesIntersect = false;
  107000. this._needs32Bits = false;
  107001. this.name = name;
  107002. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  107003. this._camera = scene.activeCamera;
  107004. this._pickable = options ? options.isPickable : false;
  107005. this._depthSort = options ? options.enableDepthSort : false;
  107006. this._particlesIntersect = options ? options.particleIntersection : false;
  107007. this._bSphereOnly = options ? options.boundingSphereOnly : false;
  107008. this._bSphereRadiusFactor = (options && options.bSphereRadiusFactor) ? options.bSphereRadiusFactor : 1.0;
  107009. if (options && options.updatable !== undefined) {
  107010. this._updatable = options.updatable;
  107011. }
  107012. else {
  107013. this._updatable = true;
  107014. }
  107015. if (this._pickable) {
  107016. this.pickedParticles = [];
  107017. }
  107018. if (this._depthSort) {
  107019. this.depthSortedParticles = [];
  107020. }
  107021. }
  107022. /**
  107023. * Builds the SPS underlying mesh. Returns a standard Mesh.
  107024. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  107025. * @returns the created mesh
  107026. */
  107027. SolidParticleSystem.prototype.buildMesh = function () {
  107028. if (this.nbParticles === 0) {
  107029. var triangle = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_4__["MeshBuilder"].CreateDisc("", { radius: 1, tessellation: 3 }, this._scene);
  107030. this.addShape(triangle, 1);
  107031. triangle.dispose();
  107032. }
  107033. this._indices32 = (this._needs32Bits) ? new Uint32Array(this._indices) : new Uint16Array(this._indices);
  107034. this._positions32 = new Float32Array(this._positions);
  107035. this._uvs32 = new Float32Array(this._uvs);
  107036. this._colors32 = new Float32Array(this._colors);
  107037. if (this.recomputeNormals) {
  107038. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(this._positions32, this._indices32, this._normals);
  107039. }
  107040. this._normals32 = new Float32Array(this._normals);
  107041. this._fixedNormal32 = new Float32Array(this._normals);
  107042. if (this._mustUnrotateFixedNormals) { // the particles could be created already rotated in the mesh with a positionFunction
  107043. this._unrotateFixedNormals();
  107044. }
  107045. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  107046. vertexData.indices = (this._depthSort) ? this._indices : this._indices32;
  107047. vertexData.set(this._positions32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  107048. vertexData.set(this._normals32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  107049. if (this._uvs32.length > 0) {
  107050. vertexData.set(this._uvs32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  107051. }
  107052. if (this._colors32.length > 0) {
  107053. vertexData.set(this._colors32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  107054. }
  107055. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this.name, this._scene);
  107056. vertexData.applyToMesh(mesh, this._updatable);
  107057. this.mesh = mesh;
  107058. this.mesh.isPickable = this._pickable;
  107059. // free memory
  107060. if (!this._depthSort) {
  107061. this._indices = null;
  107062. }
  107063. this._positions = null;
  107064. this._normals = null;
  107065. this._uvs = null;
  107066. this._colors = null;
  107067. if (!this._updatable) {
  107068. this.particles.length = 0;
  107069. }
  107070. return mesh;
  107071. };
  107072. /**
  107073. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  107074. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  107075. * Thus the particles generated from `digest()` have their property `position` set yet.
  107076. * @param mesh ( Mesh ) is the mesh to be digested
  107077. * @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
  107078. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  107079. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  107080. * @returns the current SPS
  107081. */
  107082. SolidParticleSystem.prototype.digest = function (mesh, options) {
  107083. var size = (options && options.facetNb) || 1;
  107084. var number = (options && options.number) || 0;
  107085. var delta = (options && options.delta) || 0;
  107086. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  107087. var meshInd = mesh.getIndices();
  107088. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  107089. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  107090. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  107091. var f = 0; // facet counter
  107092. var totalFacets = meshInd.length / 3; // a facet is a triangle, so 3 indices
  107093. // compute size from number
  107094. if (number) {
  107095. number = (number > totalFacets) ? totalFacets : number;
  107096. size = Math.round(totalFacets / number);
  107097. delta = 0;
  107098. }
  107099. else {
  107100. size = (size > totalFacets) ? totalFacets : size;
  107101. }
  107102. var facetPos = []; // submesh positions
  107103. var facetInd = []; // submesh indices
  107104. var facetUV = []; // submesh UV
  107105. var facetCol = []; // submesh colors
  107106. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107107. var sizeO = size;
  107108. while (f < totalFacets) {
  107109. size = sizeO + Math.floor((1 + delta) * Math.random());
  107110. if (f > totalFacets - size) {
  107111. size = totalFacets - f;
  107112. }
  107113. // reset temp arrays
  107114. facetPos.length = 0;
  107115. facetInd.length = 0;
  107116. facetUV.length = 0;
  107117. facetCol.length = 0;
  107118. // iterate over "size" facets
  107119. var fi = 0;
  107120. for (var j = f * 3; j < (f + size) * 3; j++) {
  107121. facetInd.push(fi);
  107122. var i = meshInd[j];
  107123. facetPos.push(meshPos[i * 3], meshPos[i * 3 + 1], meshPos[i * 3 + 2]);
  107124. if (meshUV) {
  107125. facetUV.push(meshUV[i * 2], meshUV[i * 2 + 1]);
  107126. }
  107127. if (meshCol) {
  107128. facetCol.push(meshCol[i * 4], meshCol[i * 4 + 1], meshCol[i * 4 + 2], meshCol[i * 4 + 3]);
  107129. }
  107130. fi++;
  107131. }
  107132. // create a model shape for each single particle
  107133. var idx = this.nbParticles;
  107134. var shape = this._posToShape(facetPos);
  107135. var shapeUV = this._uvsToShapeUV(facetUV);
  107136. // compute the barycenter of the shape
  107137. var v;
  107138. for (v = 0; v < shape.length; v++) {
  107139. barycenter.addInPlace(shape[v]);
  107140. }
  107141. barycenter.scaleInPlace(1 / shape.length);
  107142. // shift the shape from its barycenter to the origin
  107143. for (v = 0; v < shape.length; v++) {
  107144. shape[v].subtractInPlace(barycenter);
  107145. }
  107146. var bInfo;
  107147. if (this._particlesIntersect) {
  107148. bInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](barycenter, barycenter);
  107149. }
  107150. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, size * 3, shapeUV, null, null);
  107151. // add the particle in the SPS
  107152. var currentPos = this._positions.length;
  107153. var currentInd = this._indices.length;
  107154. this._meshBuilder(this._index, shape, this._positions, facetInd, this._indices, facetUV, this._uvs, facetCol, this._colors, meshNor, this._normals, idx, 0, null);
  107155. this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, 0, bInfo);
  107156. // initialize the particle position
  107157. this.particles[this.nbParticles].position.addInPlace(barycenter);
  107158. this._index += shape.length;
  107159. idx++;
  107160. this.nbParticles++;
  107161. this._shapeCounter++;
  107162. f += size;
  107163. }
  107164. return this;
  107165. };
  107166. // unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  107167. SolidParticleSystem.prototype._unrotateFixedNormals = function () {
  107168. var index = 0;
  107169. var idx = 0;
  107170. var tmpNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  107171. var quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  107172. var invertedRotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  107173. for (var p = 0; p < this.particles.length; p++) {
  107174. var particle = this.particles[p];
  107175. var shape = particle._model._shape;
  107176. // computing the inverse of the rotation matrix from the quaternion
  107177. // is equivalent to computing the matrix of the inverse quaternion, i.e of the conjugate quaternion
  107178. if (particle.rotationQuaternion) {
  107179. particle.rotationQuaternion.conjugateToRef(quaternion);
  107180. }
  107181. else {
  107182. var rotation = particle.rotation;
  107183. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  107184. quaternion.conjugateInPlace();
  107185. }
  107186. quaternion.toRotationMatrix(invertedRotMatrix);
  107187. for (var pt = 0; pt < shape.length; pt++) {
  107188. idx = index + pt * 3;
  107189. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(this._normals32[idx], this._normals32[idx + 1], this._normals32[idx + 2], invertedRotMatrix, tmpNormal);
  107190. tmpNormal.toArray(this._fixedNormal32, idx);
  107191. }
  107192. index = idx + 3;
  107193. }
  107194. };
  107195. //reset copy
  107196. SolidParticleSystem.prototype._resetCopy = function () {
  107197. var copy = this._copy;
  107198. copy.position.setAll(0);
  107199. copy.rotation.setAll(0);
  107200. copy.rotationQuaternion = null;
  107201. copy.scaling.setAll(1);
  107202. copy.uvs.copyFromFloats(0.0, 0.0, 1.0, 1.0);
  107203. copy.color = null;
  107204. copy.translateFromPivot = false;
  107205. };
  107206. // _meshBuilder : inserts the shape model in the global SPS mesh
  107207. SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options) {
  107208. var i;
  107209. var u = 0;
  107210. var c = 0;
  107211. var n = 0;
  107212. this._resetCopy();
  107213. var copy = this._copy;
  107214. if (options && options.positionFunction) { // call to custom positionFunction
  107215. options.positionFunction(copy, idx, idxInShape);
  107216. this._mustUnrotateFixedNormals = true;
  107217. }
  107218. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  107219. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  107220. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  107221. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  107222. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  107223. copy.getRotationMatrix(rotMatrix);
  107224. copy.pivot.multiplyToRef(copy.scaling, scaledPivot);
  107225. if (copy.translateFromPivot) {
  107226. pivotBackTranslation.setAll(0.0);
  107227. }
  107228. else {
  107229. pivotBackTranslation.copyFrom(scaledPivot);
  107230. }
  107231. for (i = 0; i < shape.length; i++) {
  107232. tmpVertex.copyFrom(shape[i]);
  107233. if (options && options.vertexFunction) {
  107234. options.vertexFunction(copy, tmpVertex, i);
  107235. }
  107236. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  107237. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  107238. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position);
  107239. positions.push(tmpRotated.x, tmpRotated.y, tmpRotated.z);
  107240. if (meshUV) {
  107241. var copyUvs = copy.uvs;
  107242. uvs.push((copyUvs.z - copyUvs.x) * meshUV[u] + copyUvs.x, (copyUvs.w - copyUvs.y) * meshUV[u + 1] + copyUvs.y);
  107243. u += 2;
  107244. }
  107245. if (copy.color) {
  107246. this._color = copy.color;
  107247. }
  107248. else {
  107249. var color = this._color;
  107250. if (meshCol && meshCol[c] !== undefined) {
  107251. color.r = meshCol[c];
  107252. color.g = meshCol[c + 1];
  107253. color.b = meshCol[c + 2];
  107254. color.a = meshCol[c + 3];
  107255. }
  107256. else {
  107257. color.r = 1.0;
  107258. color.g = 1.0;
  107259. color.b = 1.0;
  107260. color.a = 1.0;
  107261. }
  107262. }
  107263. colors.push(this._color.r, this._color.g, this._color.b, this._color.a);
  107264. c += 4;
  107265. if (!this.recomputeNormals && meshNor) {
  107266. tmpVertex.x = meshNor[n];
  107267. tmpVertex.y = meshNor[n + 1];
  107268. tmpVertex.z = meshNor[n + 2];
  107269. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, rotMatrix, tmpVertex);
  107270. normals.push(tmpVertex.x, tmpVertex.y, tmpVertex.z);
  107271. n += 3;
  107272. }
  107273. }
  107274. for (i = 0; i < meshInd.length; i++) {
  107275. var current_ind = p + meshInd[i];
  107276. indices.push(current_ind);
  107277. if (current_ind > 65535) {
  107278. this._needs32Bits = true;
  107279. }
  107280. }
  107281. if (this._pickable) {
  107282. var nbfaces = meshInd.length / 3;
  107283. for (i = 0; i < nbfaces; i++) {
  107284. this.pickedParticles.push({ idx: idx, faceId: i });
  107285. }
  107286. }
  107287. if (this._depthSort) {
  107288. this.depthSortedParticles.push(new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["DepthSortedParticle"]());
  107289. }
  107290. return copy;
  107291. };
  107292. // returns a shape array from positions array
  107293. SolidParticleSystem.prototype._posToShape = function (positions) {
  107294. var shape = [];
  107295. for (var i = 0; i < positions.length; i += 3) {
  107296. shape.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, i));
  107297. }
  107298. return shape;
  107299. };
  107300. // returns a shapeUV array from a Vector4 uvs
  107301. SolidParticleSystem.prototype._uvsToShapeUV = function (uvs) {
  107302. var shapeUV = [];
  107303. if (uvs) {
  107304. for (var i = 0; i < uvs.length; i++) {
  107305. shapeUV.push(uvs[i]);
  107306. }
  107307. }
  107308. return shapeUV;
  107309. };
  107310. // adds a new particle object in the particles array
  107311. SolidParticleSystem.prototype._addParticle = function (idx, idxpos, idxind, model, shapeId, idxInShape, bInfo) {
  107312. if (bInfo === void 0) { bInfo = null; }
  107313. var sp = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](idx, idxpos, idxind, model, shapeId, idxInShape, this, bInfo);
  107314. this.particles.push(sp);
  107315. return sp;
  107316. };
  107317. /**
  107318. * Adds some particles to the SPS from the model shape. Returns the shape id.
  107319. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  107320. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  107321. * @param nb (positive integer) the number of particles to be created from this model
  107322. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  107323. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  107324. * @returns the number of shapes in the system
  107325. */
  107326. SolidParticleSystem.prototype.addShape = function (mesh, nb, options) {
  107327. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  107328. var meshInd = mesh.getIndices();
  107329. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  107330. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  107331. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  107332. var bbInfo;
  107333. if (this._particlesIntersect) {
  107334. bbInfo = mesh.getBoundingInfo();
  107335. }
  107336. var shape = this._posToShape(meshPos);
  107337. var shapeUV = this._uvsToShapeUV(meshUV);
  107338. var posfunc = options ? options.positionFunction : null;
  107339. var vtxfunc = options ? options.vertexFunction : null;
  107340. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, meshInd.length, shapeUV, posfunc, vtxfunc);
  107341. // particles
  107342. var sp;
  107343. var currentCopy;
  107344. var idx = this.nbParticles;
  107345. for (var i = 0; i < nb; i++) {
  107346. var currentPos = this._positions.length;
  107347. var currentInd = this._indices.length;
  107348. currentCopy = this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors, meshNor, this._normals, idx, i, options);
  107349. if (this._updatable) {
  107350. sp = this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, i, bbInfo);
  107351. sp.position.copyFrom(currentCopy.position);
  107352. sp.rotation.copyFrom(currentCopy.rotation);
  107353. if (currentCopy.rotationQuaternion && sp.rotationQuaternion) {
  107354. sp.rotationQuaternion.copyFrom(currentCopy.rotationQuaternion);
  107355. }
  107356. if (currentCopy.color && sp.color) {
  107357. sp.color.copyFrom(currentCopy.color);
  107358. }
  107359. sp.scaling.copyFrom(currentCopy.scaling);
  107360. sp.uvs.copyFrom(currentCopy.uvs);
  107361. }
  107362. this._index += shape.length;
  107363. idx++;
  107364. }
  107365. this.nbParticles += nb;
  107366. this._shapeCounter++;
  107367. return this._shapeCounter - 1;
  107368. };
  107369. // rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  107370. SolidParticleSystem.prototype._rebuildParticle = function (particle) {
  107371. this._resetCopy();
  107372. var copy = this._copy;
  107373. if (particle._model._positionFunction) { // recall to stored custom positionFunction
  107374. particle._model._positionFunction(copy, particle.idx, particle.idxInShape);
  107375. }
  107376. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  107377. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  107378. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  107379. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  107380. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  107381. copy.getRotationMatrix(rotMatrix);
  107382. particle.pivot.multiplyToRef(particle.scaling, scaledPivot);
  107383. if (copy.translateFromPivot) {
  107384. pivotBackTranslation.copyFromFloats(0.0, 0.0, 0.0);
  107385. }
  107386. else {
  107387. pivotBackTranslation.copyFrom(scaledPivot);
  107388. }
  107389. var shape = particle._model._shape;
  107390. for (var pt = 0; pt < shape.length; pt++) {
  107391. tmpVertex.copyFrom(shape[pt]);
  107392. if (particle._model._vertexFunction) {
  107393. particle._model._vertexFunction(copy, tmpVertex, pt); // recall to stored vertexFunction
  107394. }
  107395. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  107396. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  107397. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position).toArray(this._positions32, particle._pos + pt * 3);
  107398. }
  107399. particle.position.setAll(0.0);
  107400. particle.rotation.setAll(0.0);
  107401. particle.rotationQuaternion = null;
  107402. particle.scaling.setAll(1.0);
  107403. particle.uvs.setAll(0.0);
  107404. particle.pivot.setAll(0.0);
  107405. particle.translateFromPivot = false;
  107406. particle.parentId = null;
  107407. };
  107408. /**
  107409. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  107410. * @returns the SPS.
  107411. */
  107412. SolidParticleSystem.prototype.rebuildMesh = function () {
  107413. for (var p = 0; p < this.particles.length; p++) {
  107414. this._rebuildParticle(this.particles[p]);
  107415. }
  107416. this.mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this._positions32, false, false);
  107417. return this;
  107418. };
  107419. /**
  107420. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  107421. * This method calls `updateParticle()` for each particle of the SPS.
  107422. * For an animated SPS, it is usually called within the render loop.
  107423. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  107424. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  107425. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  107426. * @returns the SPS.
  107427. */
  107428. SolidParticleSystem.prototype.setParticles = function (start, end, update) {
  107429. if (start === void 0) { start = 0; }
  107430. if (end === void 0) { end = this.nbParticles - 1; }
  107431. if (update === void 0) { update = true; }
  107432. if (!this._updatable) {
  107433. return this;
  107434. }
  107435. // custom beforeUpdate
  107436. this.beforeUpdateParticles(start, end, update);
  107437. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  107438. var invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  107439. var mesh = this.mesh;
  107440. var colors32 = this._colors32;
  107441. var positions32 = this._positions32;
  107442. var normals32 = this._normals32;
  107443. var uvs32 = this._uvs32;
  107444. var indices32 = this._indices32;
  107445. var indices = this._indices;
  107446. var fixedNormal32 = this._fixedNormal32;
  107447. var tempVectors = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3;
  107448. var camAxisX = tempVectors[5].copyFromFloats(1.0, 0.0, 0.0);
  107449. var camAxisY = tempVectors[6].copyFromFloats(0.0, 1.0, 0.0);
  107450. var camAxisZ = tempVectors[7].copyFromFloats(0.0, 0.0, 1.0);
  107451. var minimum = tempVectors[8].setAll(Number.MAX_VALUE);
  107452. var maximum = tempVectors[9].setAll(-Number.MAX_VALUE);
  107453. var camInvertedPosition = tempVectors[10].setAll(0);
  107454. // cases when the World Matrix is to be computed first
  107455. if (this.billboard || this._depthSort) {
  107456. this.mesh.computeWorldMatrix(true);
  107457. this.mesh._worldMatrix.invertToRef(invertedMatrix);
  107458. }
  107459. // if the particles will always face the camera
  107460. if (this.billboard) {
  107461. // compute the camera position and un-rotate it by the current mesh rotation
  107462. var tmpVertex = tempVectors[0];
  107463. this._camera.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Z, tmpVertex);
  107464. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, invertedMatrix, camAxisZ);
  107465. camAxisZ.normalize();
  107466. // same for camera up vector extracted from the cam view matrix
  107467. var view = this._camera.getViewMatrix(true);
  107468. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], invertedMatrix, camAxisY);
  107469. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(camAxisY, camAxisZ, camAxisX);
  107470. camAxisY.normalize();
  107471. camAxisX.normalize();
  107472. }
  107473. // if depthSort, compute the camera global position in the mesh local system
  107474. if (this._depthSort) {
  107475. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._camera.globalPosition, invertedMatrix, camInvertedPosition); // then un-rotate the camera
  107476. }
  107477. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(rotMatrix);
  107478. var idx = 0; // current position index in the global array positions32
  107479. var index = 0; // position start index in the global array positions32 of the current particle
  107480. var colidx = 0; // current color index in the global array colors32
  107481. var colorIndex = 0; // color start index in the global array colors32 of the current particle
  107482. var uvidx = 0; // current uv index in the global array uvs32
  107483. var uvIndex = 0; // uv start index in the global array uvs32 of the current particle
  107484. var pt = 0; // current index in the particle model shape
  107485. if (this.mesh.isFacetDataEnabled) {
  107486. this._computeBoundingBox = true;
  107487. }
  107488. end = (end >= this.nbParticles) ? this.nbParticles - 1 : end;
  107489. if (this._computeBoundingBox) {
  107490. if (start != 0 || end != this.nbParticles - 1) { // only some particles are updated, then use the current existing BBox basis. Note : it can only increase.
  107491. var boundingInfo = this.mesh._boundingInfo;
  107492. if (boundingInfo) {
  107493. minimum.copyFrom(boundingInfo.minimum);
  107494. maximum.copyFrom(boundingInfo.maximum);
  107495. }
  107496. }
  107497. }
  107498. // particle loop
  107499. index = this.particles[start]._pos;
  107500. var vpos = (index / 3) | 0;
  107501. colorIndex = vpos * 4;
  107502. uvIndex = vpos * 2;
  107503. for (var p = start; p <= end; p++) {
  107504. var particle = this.particles[p];
  107505. // call to custom user function to update the particle properties
  107506. this.updateParticle(particle);
  107507. var shape = particle._model._shape;
  107508. var shapeUV = particle._model._shapeUV;
  107509. var particleRotationMatrix = particle._rotationMatrix;
  107510. var particlePosition = particle.position;
  107511. var particleRotation = particle.rotation;
  107512. var particleScaling = particle.scaling;
  107513. var particleGlobalPosition = particle._globalPosition;
  107514. // camera-particle distance for depth sorting
  107515. if (this._depthSort && this._depthSortParticles) {
  107516. var dsp = this.depthSortedParticles[p];
  107517. dsp.ind = particle._ind;
  107518. dsp.indicesLength = particle._model._indicesLength;
  107519. dsp.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(particle.position, camInvertedPosition);
  107520. }
  107521. // skip the computations for inactive or already invisible particles
  107522. if (!particle.alive || (particle._stillInvisible && !particle.isVisible)) {
  107523. // increment indexes for the next particle
  107524. pt = shape.length;
  107525. index += pt * 3;
  107526. colorIndex += pt * 4;
  107527. uvIndex += pt * 2;
  107528. continue;
  107529. }
  107530. if (particle.isVisible) {
  107531. particle._stillInvisible = false; // un-mark permanent invisibility
  107532. var scaledPivot = tempVectors[12];
  107533. particle.pivot.multiplyToRef(particleScaling, scaledPivot);
  107534. // particle rotation matrix
  107535. if (this.billboard) {
  107536. particleRotation.x = 0.0;
  107537. particleRotation.y = 0.0;
  107538. }
  107539. if (this._computeParticleRotation || this.billboard) {
  107540. particle.getRotationMatrix(rotMatrix);
  107541. }
  107542. var particleHasParent = (particle.parentId !== null);
  107543. if (particleHasParent) {
  107544. var parent_1 = this.particles[particle.parentId];
  107545. var parentRotationMatrix = parent_1._rotationMatrix;
  107546. var parentGlobalPosition = parent_1._globalPosition;
  107547. var rotatedY = particlePosition.x * parentRotationMatrix[1] + particlePosition.y * parentRotationMatrix[4] + particlePosition.z * parentRotationMatrix[7];
  107548. var rotatedX = particlePosition.x * parentRotationMatrix[0] + particlePosition.y * parentRotationMatrix[3] + particlePosition.z * parentRotationMatrix[6];
  107549. var rotatedZ = particlePosition.x * parentRotationMatrix[2] + particlePosition.y * parentRotationMatrix[5] + particlePosition.z * parentRotationMatrix[8];
  107550. particleGlobalPosition.x = parentGlobalPosition.x + rotatedX;
  107551. particleGlobalPosition.y = parentGlobalPosition.y + rotatedY;
  107552. particleGlobalPosition.z = parentGlobalPosition.z + rotatedZ;
  107553. if (this._computeParticleRotation || this.billboard) {
  107554. var rotMatrixValues = rotMatrix.m;
  107555. particleRotationMatrix[0] = rotMatrixValues[0] * parentRotationMatrix[0] + rotMatrixValues[1] * parentRotationMatrix[3] + rotMatrixValues[2] * parentRotationMatrix[6];
  107556. particleRotationMatrix[1] = rotMatrixValues[0] * parentRotationMatrix[1] + rotMatrixValues[1] * parentRotationMatrix[4] + rotMatrixValues[2] * parentRotationMatrix[7];
  107557. particleRotationMatrix[2] = rotMatrixValues[0] * parentRotationMatrix[2] + rotMatrixValues[1] * parentRotationMatrix[5] + rotMatrixValues[2] * parentRotationMatrix[8];
  107558. particleRotationMatrix[3] = rotMatrixValues[4] * parentRotationMatrix[0] + rotMatrixValues[5] * parentRotationMatrix[3] + rotMatrixValues[6] * parentRotationMatrix[6];
  107559. particleRotationMatrix[4] = rotMatrixValues[4] * parentRotationMatrix[1] + rotMatrixValues[5] * parentRotationMatrix[4] + rotMatrixValues[6] * parentRotationMatrix[7];
  107560. particleRotationMatrix[5] = rotMatrixValues[4] * parentRotationMatrix[2] + rotMatrixValues[5] * parentRotationMatrix[5] + rotMatrixValues[6] * parentRotationMatrix[8];
  107561. particleRotationMatrix[6] = rotMatrixValues[8] * parentRotationMatrix[0] + rotMatrixValues[9] * parentRotationMatrix[3] + rotMatrixValues[10] * parentRotationMatrix[6];
  107562. particleRotationMatrix[7] = rotMatrixValues[8] * parentRotationMatrix[1] + rotMatrixValues[9] * parentRotationMatrix[4] + rotMatrixValues[10] * parentRotationMatrix[7];
  107563. particleRotationMatrix[8] = rotMatrixValues[8] * parentRotationMatrix[2] + rotMatrixValues[9] * parentRotationMatrix[5] + rotMatrixValues[10] * parentRotationMatrix[8];
  107564. }
  107565. }
  107566. else {
  107567. particleGlobalPosition.x = particlePosition.x;
  107568. particleGlobalPosition.y = particlePosition.y;
  107569. particleGlobalPosition.z = particlePosition.z;
  107570. if (this._computeParticleRotation || this.billboard) {
  107571. var rotMatrixValues = rotMatrix.m;
  107572. particleRotationMatrix[0] = rotMatrixValues[0];
  107573. particleRotationMatrix[1] = rotMatrixValues[1];
  107574. particleRotationMatrix[2] = rotMatrixValues[2];
  107575. particleRotationMatrix[3] = rotMatrixValues[4];
  107576. particleRotationMatrix[4] = rotMatrixValues[5];
  107577. particleRotationMatrix[5] = rotMatrixValues[6];
  107578. particleRotationMatrix[6] = rotMatrixValues[8];
  107579. particleRotationMatrix[7] = rotMatrixValues[9];
  107580. particleRotationMatrix[8] = rotMatrixValues[10];
  107581. }
  107582. }
  107583. var pivotBackTranslation = tempVectors[11];
  107584. if (particle.translateFromPivot) {
  107585. pivotBackTranslation.setAll(0.0);
  107586. }
  107587. else {
  107588. pivotBackTranslation.copyFrom(scaledPivot);
  107589. }
  107590. // particle vertex loop
  107591. for (pt = 0; pt < shape.length; pt++) {
  107592. idx = index + pt * 3;
  107593. colidx = colorIndex + pt * 4;
  107594. uvidx = uvIndex + pt * 2;
  107595. var tmpVertex = tempVectors[0];
  107596. tmpVertex.copyFrom(shape[pt]);
  107597. if (this._computeParticleVertex) {
  107598. this.updateParticleVertex(particle, tmpVertex, pt);
  107599. }
  107600. // positions
  107601. var vertexX = tmpVertex.x * particleScaling.x - scaledPivot.x;
  107602. var vertexY = tmpVertex.y * particleScaling.y - scaledPivot.y;
  107603. var vertexZ = tmpVertex.z * particleScaling.z - scaledPivot.z;
  107604. var rotatedX = vertexX * particleRotationMatrix[0] + vertexY * particleRotationMatrix[3] + vertexZ * particleRotationMatrix[6];
  107605. var rotatedY = vertexX * particleRotationMatrix[1] + vertexY * particleRotationMatrix[4] + vertexZ * particleRotationMatrix[7];
  107606. var rotatedZ = vertexX * particleRotationMatrix[2] + vertexY * particleRotationMatrix[5] + vertexZ * particleRotationMatrix[8];
  107607. rotatedX += pivotBackTranslation.x;
  107608. rotatedY += pivotBackTranslation.y;
  107609. rotatedZ += pivotBackTranslation.z;
  107610. var px = positions32[idx] = particleGlobalPosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  107611. var py = positions32[idx + 1] = particleGlobalPosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  107612. var pz = positions32[idx + 2] = particleGlobalPosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  107613. if (this._computeBoundingBox) {
  107614. minimum.minimizeInPlaceFromFloats(px, py, pz);
  107615. maximum.maximizeInPlaceFromFloats(px, py, pz);
  107616. }
  107617. // normals : if the particles can't be morphed then just rotate the normals, what is much more faster than ComputeNormals()
  107618. if (!this._computeParticleVertex) {
  107619. var normalx = fixedNormal32[idx];
  107620. var normaly = fixedNormal32[idx + 1];
  107621. var normalz = fixedNormal32[idx + 2];
  107622. var rotatedx = normalx * particleRotationMatrix[0] + normaly * particleRotationMatrix[3] + normalz * particleRotationMatrix[6];
  107623. var rotatedy = normalx * particleRotationMatrix[1] + normaly * particleRotationMatrix[4] + normalz * particleRotationMatrix[7];
  107624. var rotatedz = normalx * particleRotationMatrix[2] + normaly * particleRotationMatrix[5] + normalz * particleRotationMatrix[8];
  107625. normals32[idx] = camAxisX.x * rotatedx + camAxisY.x * rotatedy + camAxisZ.x * rotatedz;
  107626. normals32[idx + 1] = camAxisX.y * rotatedx + camAxisY.y * rotatedy + camAxisZ.y * rotatedz;
  107627. normals32[idx + 2] = camAxisX.z * rotatedx + camAxisY.z * rotatedy + camAxisZ.z * rotatedz;
  107628. }
  107629. if (this._computeParticleColor && particle.color) {
  107630. var color = particle.color;
  107631. var colors32_1 = this._colors32;
  107632. colors32_1[colidx] = color.r;
  107633. colors32_1[colidx + 1] = color.g;
  107634. colors32_1[colidx + 2] = color.b;
  107635. colors32_1[colidx + 3] = color.a;
  107636. }
  107637. if (this._computeParticleTexture) {
  107638. var uvs = particle.uvs;
  107639. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  107640. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  107641. }
  107642. }
  107643. }
  107644. // particle just set invisible : scaled to zero and positioned at the origin
  107645. else {
  107646. particle._stillInvisible = true; // mark the particle as invisible
  107647. for (pt = 0; pt < shape.length; pt++) {
  107648. idx = index + pt * 3;
  107649. colidx = colorIndex + pt * 4;
  107650. uvidx = uvIndex + pt * 2;
  107651. positions32[idx] = positions32[idx + 1] = positions32[idx + 2] = 0;
  107652. normals32[idx] = normals32[idx + 1] = normals32[idx + 2] = 0;
  107653. if (this._computeParticleColor && particle.color) {
  107654. var color = particle.color;
  107655. colors32[colidx] = color.r;
  107656. colors32[colidx + 1] = color.g;
  107657. colors32[colidx + 2] = color.b;
  107658. colors32[colidx + 3] = color.a;
  107659. }
  107660. if (this._computeParticleTexture) {
  107661. var uvs = particle.uvs;
  107662. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  107663. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  107664. }
  107665. }
  107666. }
  107667. // if the particle intersections must be computed : update the bbInfo
  107668. if (this._particlesIntersect) {
  107669. var bInfo = particle._boundingInfo;
  107670. var bBox = bInfo.boundingBox;
  107671. var bSphere = bInfo.boundingSphere;
  107672. var modelBoundingInfo = particle._modelBoundingInfo;
  107673. if (!this._bSphereOnly) {
  107674. // place, scale and rotate the particle bbox within the SPS local system, then update it
  107675. var modelBoundingInfoVectors = modelBoundingInfo.boundingBox.vectors;
  107676. var tempMin = tempVectors[1];
  107677. var tempMax = tempVectors[2];
  107678. tempMin.setAll(Number.MAX_VALUE);
  107679. tempMax.setAll(-Number.MAX_VALUE);
  107680. for (var b = 0; b < 8; b++) {
  107681. var scaledX = modelBoundingInfoVectors[b].x * particleScaling.x;
  107682. var scaledY = modelBoundingInfoVectors[b].y * particleScaling.y;
  107683. var scaledZ = modelBoundingInfoVectors[b].z * particleScaling.z;
  107684. var rotatedX = scaledX * particleRotationMatrix[0] + scaledY * particleRotationMatrix[3] + scaledZ * particleRotationMatrix[6];
  107685. var rotatedY = scaledX * particleRotationMatrix[1] + scaledY * particleRotationMatrix[4] + scaledZ * particleRotationMatrix[7];
  107686. var rotatedZ = scaledX * particleRotationMatrix[2] + scaledY * particleRotationMatrix[5] + scaledZ * particleRotationMatrix[8];
  107687. var x = particlePosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  107688. var y = particlePosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  107689. var z = particlePosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  107690. tempMin.minimizeInPlaceFromFloats(x, y, z);
  107691. tempMax.maximizeInPlaceFromFloats(x, y, z);
  107692. }
  107693. bBox.reConstruct(tempMin, tempMax, mesh._worldMatrix);
  107694. }
  107695. // place and scale the particle bouding sphere in the SPS local system, then update it
  107696. var minBbox = modelBoundingInfo.minimum.multiplyToRef(particleScaling, tempVectors[1]);
  107697. var maxBbox = modelBoundingInfo.maximum.multiplyToRef(particleScaling, tempVectors[2]);
  107698. var bSphereCenter = maxBbox.addToRef(minBbox, tempVectors[3]).scaleInPlace(0.5).addInPlace(particleGlobalPosition);
  107699. var halfDiag = maxBbox.subtractToRef(minBbox, tempVectors[4]).scaleInPlace(0.5 * this._bSphereRadiusFactor);
  107700. var bSphereMinBbox = bSphereCenter.subtractToRef(halfDiag, tempVectors[1]);
  107701. var bSphereMaxBbox = bSphereCenter.addToRef(halfDiag, tempVectors[2]);
  107702. bSphere.reConstruct(bSphereMinBbox, bSphereMaxBbox, mesh._worldMatrix);
  107703. }
  107704. // increment indexes for the next particle
  107705. index = idx + 3;
  107706. colorIndex = colidx + 4;
  107707. uvIndex = uvidx + 2;
  107708. }
  107709. // if the VBO must be updated
  107710. if (update) {
  107711. if (this._computeParticleColor) {
  107712. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, colors32, false, false);
  107713. }
  107714. if (this._computeParticleTexture) {
  107715. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs32, false, false);
  107716. }
  107717. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, positions32, false, false);
  107718. if (!mesh.areNormalsFrozen || mesh.isFacetDataEnabled) {
  107719. if (this._computeParticleVertex || mesh.isFacetDataEnabled) {
  107720. // recompute the normals only if the particles can be morphed, update then also the normal reference array _fixedNormal32[]
  107721. var params = mesh.isFacetDataEnabled ? mesh.getFacetDataParameters() : null;
  107722. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions32, indices32, normals32, params);
  107723. for (var i = 0; i < normals32.length; i++) {
  107724. fixedNormal32[i] = normals32[i];
  107725. }
  107726. }
  107727. if (!mesh.areNormalsFrozen) {
  107728. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals32, false, false);
  107729. }
  107730. }
  107731. if (this._depthSort && this._depthSortParticles) {
  107732. var depthSortedParticles = this.depthSortedParticles;
  107733. depthSortedParticles.sort(depthSortFunction);
  107734. var dspl = depthSortedParticles.length;
  107735. var sid = 0;
  107736. for (var sorted = 0; sorted < dspl; sorted++) {
  107737. var lind = depthSortedParticles[sorted].indicesLength;
  107738. var sind = depthSortedParticles[sorted].ind;
  107739. for (var i = 0; i < lind; i++) {
  107740. indices32[sid] = indices[sind + i];
  107741. sid++;
  107742. }
  107743. }
  107744. mesh.updateIndices(indices32);
  107745. }
  107746. }
  107747. if (this._computeBoundingBox) {
  107748. if (mesh._boundingInfo) {
  107749. mesh._boundingInfo.reConstruct(minimum, maximum, mesh._worldMatrix);
  107750. }
  107751. else {
  107752. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](minimum, maximum, mesh._worldMatrix);
  107753. }
  107754. }
  107755. this.afterUpdateParticles(start, end, update);
  107756. return this;
  107757. };
  107758. /**
  107759. * Disposes the SPS.
  107760. */
  107761. SolidParticleSystem.prototype.dispose = function () {
  107762. this.mesh.dispose();
  107763. this.vars = null;
  107764. // drop references to internal big arrays for the GC
  107765. this._positions = null;
  107766. this._indices = null;
  107767. this._normals = null;
  107768. this._uvs = null;
  107769. this._colors = null;
  107770. this._indices32 = null;
  107771. this._positions32 = null;
  107772. this._normals32 = null;
  107773. this._fixedNormal32 = null;
  107774. this._uvs32 = null;
  107775. this._colors32 = null;
  107776. this.pickedParticles = null;
  107777. };
  107778. /**
  107779. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  107780. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  107781. * @returns the SPS.
  107782. */
  107783. SolidParticleSystem.prototype.refreshVisibleSize = function () {
  107784. if (!this._isVisibilityBoxLocked) {
  107785. this.mesh.refreshBoundingInfo();
  107786. }
  107787. return this;
  107788. };
  107789. /**
  107790. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  107791. * @param size the size (float) of the visibility box
  107792. * note : this doesn't lock the SPS mesh bounding box.
  107793. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  107794. */
  107795. SolidParticleSystem.prototype.setVisibilityBox = function (size) {
  107796. var vis = size / 2;
  107797. 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));
  107798. };
  107799. Object.defineProperty(SolidParticleSystem.prototype, "isAlwaysVisible", {
  107800. /**
  107801. * Gets whether the SPS as always visible or not
  107802. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  107803. */
  107804. get: function () {
  107805. return this._alwaysVisible;
  107806. },
  107807. /**
  107808. * Sets the SPS as always visible or not
  107809. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  107810. */
  107811. set: function (val) {
  107812. this._alwaysVisible = val;
  107813. this.mesh.alwaysSelectAsActiveMesh = val;
  107814. },
  107815. enumerable: true,
  107816. configurable: true
  107817. });
  107818. Object.defineProperty(SolidParticleSystem.prototype, "isVisibilityBoxLocked", {
  107819. /**
  107820. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  107821. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  107822. */
  107823. get: function () {
  107824. return this._isVisibilityBoxLocked;
  107825. },
  107826. /**
  107827. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  107828. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  107829. */
  107830. set: function (val) {
  107831. this._isVisibilityBoxLocked = val;
  107832. var boundingInfo = this.mesh.getBoundingInfo();
  107833. boundingInfo.isLocked = val;
  107834. },
  107835. enumerable: true,
  107836. configurable: true
  107837. });
  107838. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleRotation", {
  107839. /**
  107840. * Gets if `setParticles()` computes the particle rotations or not.
  107841. * Default value : true. The SPS is faster when it's set to false.
  107842. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  107843. */
  107844. get: function () {
  107845. return this._computeParticleRotation;
  107846. },
  107847. /**
  107848. * Tells to `setParticles()` to compute the particle rotations or not.
  107849. * Default value : true. The SPS is faster when it's set to false.
  107850. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  107851. */
  107852. set: function (val) {
  107853. this._computeParticleRotation = val;
  107854. },
  107855. enumerable: true,
  107856. configurable: true
  107857. });
  107858. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleColor", {
  107859. /**
  107860. * Gets if `setParticles()` computes the particle colors or not.
  107861. * Default value : true. The SPS is faster when it's set to false.
  107862. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  107863. */
  107864. get: function () {
  107865. return this._computeParticleColor;
  107866. },
  107867. /**
  107868. * Tells to `setParticles()` to compute the particle colors or not.
  107869. * Default value : true. The SPS is faster when it's set to false.
  107870. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  107871. */
  107872. set: function (val) {
  107873. this._computeParticleColor = val;
  107874. },
  107875. enumerable: true,
  107876. configurable: true
  107877. });
  107878. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleTexture", {
  107879. /**
  107880. * Gets if `setParticles()` computes the particle textures or not.
  107881. * Default value : true. The SPS is faster when it's set to false.
  107882. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  107883. */
  107884. get: function () {
  107885. return this._computeParticleTexture;
  107886. },
  107887. set: function (val) {
  107888. this._computeParticleTexture = val;
  107889. },
  107890. enumerable: true,
  107891. configurable: true
  107892. });
  107893. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleVertex", {
  107894. /**
  107895. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  107896. * Default value : false. The SPS is faster when it's set to false.
  107897. * Note : the particle custom vertex positions aren't stored values.
  107898. */
  107899. get: function () {
  107900. return this._computeParticleVertex;
  107901. },
  107902. /**
  107903. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  107904. * Default value : false. The SPS is faster when it's set to false.
  107905. * Note : the particle custom vertex positions aren't stored values.
  107906. */
  107907. set: function (val) {
  107908. this._computeParticleVertex = val;
  107909. },
  107910. enumerable: true,
  107911. configurable: true
  107912. });
  107913. Object.defineProperty(SolidParticleSystem.prototype, "computeBoundingBox", {
  107914. /**
  107915. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  107916. */
  107917. get: function () {
  107918. return this._computeBoundingBox;
  107919. },
  107920. /**
  107921. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  107922. */
  107923. set: function (val) {
  107924. this._computeBoundingBox = val;
  107925. },
  107926. enumerable: true,
  107927. configurable: true
  107928. });
  107929. Object.defineProperty(SolidParticleSystem.prototype, "depthSortParticles", {
  107930. /**
  107931. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  107932. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  107933. * Default : `true`
  107934. */
  107935. get: function () {
  107936. return this._depthSortParticles;
  107937. },
  107938. /**
  107939. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  107940. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  107941. * Default : `true`
  107942. */
  107943. set: function (val) {
  107944. this._depthSortParticles = val;
  107945. },
  107946. enumerable: true,
  107947. configurable: true
  107948. });
  107949. // =======================================================================
  107950. // Particle behavior logic
  107951. // these following methods may be overwritten by the user to fit his needs
  107952. /**
  107953. * This function does nothing. It may be overwritten to set all the particle first values.
  107954. * The SPS doesn't call this function, you may have to call it by your own.
  107955. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  107956. */
  107957. SolidParticleSystem.prototype.initParticles = function () {
  107958. };
  107959. /**
  107960. * This function does nothing. It may be overwritten to recycle a particle.
  107961. * The SPS doesn't call this function, you may have to call it by your own.
  107962. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  107963. * @param particle The particle to recycle
  107964. * @returns the recycled particle
  107965. */
  107966. SolidParticleSystem.prototype.recycleParticle = function (particle) {
  107967. return particle;
  107968. };
  107969. /**
  107970. * Updates a particle : this function should be overwritten by the user.
  107971. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  107972. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  107973. * @example : just set a particle position or velocity and recycle conditions
  107974. * @param particle The particle to update
  107975. * @returns the updated particle
  107976. */
  107977. SolidParticleSystem.prototype.updateParticle = function (particle) {
  107978. return particle;
  107979. };
  107980. /**
  107981. * Updates a vertex of a particle : it can be overwritten by the user.
  107982. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  107983. * @param particle the current particle
  107984. * @param vertex the current index of the current particle
  107985. * @param pt the index of the current vertex in the particle shape
  107986. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  107987. * @example : just set a vertex particle position
  107988. * @returns the updated vertex
  107989. */
  107990. SolidParticleSystem.prototype.updateParticleVertex = function (particle, vertex, pt) {
  107991. return vertex;
  107992. };
  107993. /**
  107994. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  107995. * This does nothing and may be overwritten by the user.
  107996. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107997. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107998. * @param update the boolean update value actually passed to setParticles()
  107999. */
  108000. SolidParticleSystem.prototype.beforeUpdateParticles = function (start, stop, update) {
  108001. };
  108002. /**
  108003. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  108004. * This will be passed three parameters.
  108005. * This does nothing and may be overwritten by the user.
  108006. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108007. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108008. * @param update the boolean update value actually passed to setParticles()
  108009. */
  108010. SolidParticleSystem.prototype.afterUpdateParticles = function (start, stop, update) {
  108011. };
  108012. return SolidParticleSystem;
  108013. }());
  108014. /***/ }),
  108015. /***/ "./Particles/subEmitter.ts":
  108016. /*!*********************************!*\
  108017. !*** ./Particles/subEmitter.ts ***!
  108018. \*********************************/
  108019. /*! exports provided: SubEmitterType, SubEmitter */
  108020. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108021. "use strict";
  108022. __webpack_require__.r(__webpack_exports__);
  108023. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return SubEmitterType; });
  108024. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return SubEmitter; });
  108025. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  108026. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  108027. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  108028. /**
  108029. * Type of sub emitter
  108030. */
  108031. var SubEmitterType;
  108032. (function (SubEmitterType) {
  108033. /**
  108034. * Attached to the particle over it's lifetime
  108035. */
  108036. SubEmitterType[SubEmitterType["ATTACHED"] = 0] = "ATTACHED";
  108037. /**
  108038. * Created when the particle dies
  108039. */
  108040. SubEmitterType[SubEmitterType["END"] = 1] = "END";
  108041. })(SubEmitterType || (SubEmitterType = {}));
  108042. /**
  108043. * Sub emitter class used to emit particles from an existing particle
  108044. */
  108045. var SubEmitter = /** @class */ (function () {
  108046. /**
  108047. * Creates a sub emitter
  108048. * @param particleSystem the particle system to be used by the sub emitter
  108049. */
  108050. function SubEmitter(
  108051. /**
  108052. * the particle system to be used by the sub emitter
  108053. */
  108054. particleSystem) {
  108055. this.particleSystem = particleSystem;
  108056. /**
  108057. * Type of the submitter (Default: END)
  108058. */
  108059. this.type = SubEmitterType.END;
  108060. /**
  108061. * 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)
  108062. * Note: This only is supported when using an emitter of type Mesh
  108063. */
  108064. this.inheritDirection = false;
  108065. /**
  108066. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  108067. */
  108068. this.inheritedVelocityAmount = 0;
  108069. // Create mesh as emitter to support rotation
  108070. if (!particleSystem.emitter || !particleSystem.emitter.dispose) {
  108071. particleSystem.emitter = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("SubemitterSystemEmitter", particleSystem.getScene());
  108072. }
  108073. // Automatically dispose of subemitter when system is disposed
  108074. particleSystem.onDisposeObservable.add(function () {
  108075. if (particleSystem.emitter && particleSystem.emitter.dispose) {
  108076. particleSystem.emitter.dispose();
  108077. }
  108078. });
  108079. }
  108080. /**
  108081. * Clones the sub emitter
  108082. * @returns the cloned sub emitter
  108083. */
  108084. SubEmitter.prototype.clone = function () {
  108085. // Clone particle system
  108086. var emitter = this.particleSystem.emitter;
  108087. if (!emitter) {
  108088. emitter = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  108089. }
  108090. else if (emitter instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  108091. emitter = emitter.clone();
  108092. }
  108093. else if (emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  108094. emitter = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", emitter.getScene());
  108095. emitter.isVisible = false;
  108096. }
  108097. var clone = new SubEmitter(this.particleSystem.clone("", emitter));
  108098. // Clone properties
  108099. clone.type = this.type;
  108100. clone.inheritDirection = this.inheritDirection;
  108101. clone.inheritedVelocityAmount = this.inheritedVelocityAmount;
  108102. clone.particleSystem._disposeEmitterOnDispose = true;
  108103. clone.particleSystem.disposeOnStop = true;
  108104. return clone;
  108105. };
  108106. /**
  108107. * Serialize current object to a JSON object
  108108. * @returns the serialized object
  108109. */
  108110. SubEmitter.prototype.serialize = function () {
  108111. var serializationObject = {};
  108112. serializationObject.type = this.type;
  108113. serializationObject.inheritDirection = this.inheritDirection;
  108114. serializationObject.inheritedVelocityAmount = this.inheritedVelocityAmount;
  108115. serializationObject.particleSystem = this.particleSystem.serialize();
  108116. return serializationObject;
  108117. };
  108118. /** @hidden */
  108119. SubEmitter._ParseParticleSystem = function (system, scene, rootUrl) {
  108120. throw "Import ParseParticle before parsing SubEmitter.";
  108121. };
  108122. /**
  108123. * Creates a new SubEmitter from a serialized JSON version
  108124. * @param serializationObject defines the JSON object to read from
  108125. * @param scene defines the hosting scene
  108126. * @param rootUrl defines the rootUrl for data loading
  108127. * @returns a new SubEmitter
  108128. */
  108129. SubEmitter.Parse = function (serializationObject, scene, rootUrl) {
  108130. var system = serializationObject.particleSystem;
  108131. var subEmitter = new SubEmitter(SubEmitter._ParseParticleSystem(system, scene, rootUrl));
  108132. subEmitter.type = serializationObject.type;
  108133. subEmitter.inheritDirection = serializationObject.inheritDirection;
  108134. subEmitter.inheritedVelocityAmount = serializationObject.inheritedVelocityAmount;
  108135. subEmitter.particleSystem._isSubEmitter = true;
  108136. return subEmitter;
  108137. };
  108138. /** Release associated resources */
  108139. SubEmitter.prototype.dispose = function () {
  108140. this.particleSystem.dispose();
  108141. };
  108142. return SubEmitter;
  108143. }());
  108144. /***/ }),
  108145. /***/ "./Physics/Plugins/ammoJSPlugin.ts":
  108146. /*!*****************************************!*\
  108147. !*** ./Physics/Plugins/ammoJSPlugin.ts ***!
  108148. \*****************************************/
  108149. /*! exports provided: AmmoJSPlugin */
  108150. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108151. "use strict";
  108152. __webpack_require__.r(__webpack_exports__);
  108153. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return AmmoJSPlugin; });
  108154. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  108155. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  108156. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  108157. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  108158. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  108159. /**
  108160. * AmmoJS Physics plugin
  108161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108162. * @see https://github.com/kripken/ammo.js/
  108163. */
  108164. var AmmoJSPlugin = /** @class */ (function () {
  108165. /**
  108166. * Initializes the ammoJS plugin
  108167. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  108168. * @param ammoInjection can be used to inject your own ammo reference
  108169. */
  108170. function AmmoJSPlugin(_useDeltaForWorldStep, ammoInjection) {
  108171. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  108172. if (ammoInjection === void 0) { ammoInjection = Ammo; }
  108173. var _this = this;
  108174. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  108175. /**
  108176. * Reference to the Ammo library
  108177. */
  108178. this.bjsAMMO = {};
  108179. /**
  108180. * Name of the plugin
  108181. */
  108182. this.name = "AmmoJSPlugin";
  108183. this._timeStep = 1 / 60;
  108184. this._fixedTimeStep = 1 / 60;
  108185. this._maxSteps = 5;
  108186. this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  108187. this._tmpContactCallbackResult = false;
  108188. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  108189. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  108190. if (typeof ammoInjection === "function") {
  108191. ammoInjection(this.bjsAMMO);
  108192. }
  108193. else {
  108194. this.bjsAMMO = ammoInjection;
  108195. }
  108196. if (!this.isSupported()) {
  108197. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("AmmoJS is not available. Please make sure you included the js file.");
  108198. return;
  108199. }
  108200. // Initialize the physics world
  108201. this._collisionConfiguration = new this.bjsAMMO.btDefaultCollisionConfiguration();
  108202. this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration);
  108203. this._overlappingPairCache = new this.bjsAMMO.btDbvtBroadphase();
  108204. this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver();
  108205. this.world = new this.bjsAMMO.btDiscreteDynamicsWorld(this._dispatcher, this._overlappingPairCache, this._solver, this._collisionConfiguration);
  108206. this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback();
  108207. this._tmpAmmoConcreteContactResultCallback.addSingleResult = function () { _this._tmpContactCallbackResult = true; };
  108208. // Create temp ammo variables
  108209. this._tmpAmmoTransform = new this.bjsAMMO.btTransform();
  108210. this._tmpAmmoTransform.setIdentity();
  108211. this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0, 0, 0, 1);
  108212. this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0, 0, 0);
  108213. this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0, 0, 0);
  108214. this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0, 0, 0);
  108215. }
  108216. /**
  108217. * Sets the gravity of the physics world (m/(s^2))
  108218. * @param gravity Gravity to set
  108219. */
  108220. AmmoJSPlugin.prototype.setGravity = function (gravity) {
  108221. this._tmpAmmoVectorA.setValue(gravity.x, gravity.y, gravity.z);
  108222. this.world.setGravity(this._tmpAmmoVectorA);
  108223. };
  108224. /**
  108225. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  108226. * @param timeStep timestep to use in seconds
  108227. */
  108228. AmmoJSPlugin.prototype.setTimeStep = function (timeStep) {
  108229. this._timeStep = timeStep;
  108230. };
  108231. /**
  108232. * 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)
  108233. * @param fixedTimeStep fixedTimeStep to use in seconds
  108234. */
  108235. AmmoJSPlugin.prototype.setFixedTimeStep = function (fixedTimeStep) {
  108236. this._fixedTimeStep = fixedTimeStep;
  108237. };
  108238. /**
  108239. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  108240. * @param maxSteps the maximum number of steps by the physics engine per frame
  108241. */
  108242. AmmoJSPlugin.prototype.setMaxSteps = function (maxSteps) {
  108243. this._maxSteps = maxSteps;
  108244. };
  108245. /**
  108246. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  108247. * @returns the current timestep in seconds
  108248. */
  108249. AmmoJSPlugin.prototype.getTimeStep = function () {
  108250. return this._timeStep;
  108251. };
  108252. // Ammo's contactTest and contactPairTest take a callback that runs synchronously, wrap them so that they are easier to consume
  108253. AmmoJSPlugin.prototype._isImpostorInContact = function (impostor) {
  108254. this._tmpContactCallbackResult = false;
  108255. this.world.contactTest(impostor.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  108256. return this._tmpContactCallbackResult;
  108257. };
  108258. // Ammo's collision events have some weird quirks
  108259. // contactPairTest fires too many events as it fires events even when objects are close together but contactTest does not
  108260. // so only fire event if both contactTest and contactPairTest have a hit
  108261. AmmoJSPlugin.prototype._isImpostorPairInContact = function (impostorA, impostorB) {
  108262. this._tmpContactCallbackResult = false;
  108263. this.world.contactPairTest(impostorA.physicsBody, impostorB.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  108264. return this._tmpContactCallbackResult;
  108265. };
  108266. // Ammo's behavior when maxSteps > 0 does not behave as described in docs
  108267. // @see http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_The_World
  108268. //
  108269. // When maxSteps is 0 do the entire simulation in one step
  108270. // 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)
  108271. // Note: To get deterministic physics, timeStep would always need to be divisible by fixedTimeStep
  108272. AmmoJSPlugin.prototype._stepSimulation = function (timeStep, maxSteps, fixedTimeStep) {
  108273. if (timeStep === void 0) { timeStep = 1 / 60; }
  108274. if (maxSteps === void 0) { maxSteps = 10; }
  108275. if (fixedTimeStep === void 0) { fixedTimeStep = 1 / 60; }
  108276. if (maxSteps == 0) {
  108277. this.world.stepSimulation(timeStep, 0);
  108278. }
  108279. else {
  108280. while (maxSteps > 0 && timeStep > 0) {
  108281. if (timeStep - fixedTimeStep < fixedTimeStep) {
  108282. this.world.stepSimulation(timeStep, 0);
  108283. timeStep = 0;
  108284. }
  108285. else {
  108286. timeStep -= fixedTimeStep;
  108287. this.world.stepSimulation(fixedTimeStep, 0);
  108288. }
  108289. maxSteps--;
  108290. }
  108291. }
  108292. };
  108293. /**
  108294. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  108295. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  108296. * After the step the babylon meshes are set to the position of the physics imposters
  108297. * @param delta amount of time to step forward
  108298. * @param impostors array of imposters to update before/after the step
  108299. */
  108300. AmmoJSPlugin.prototype.executeStep = function (delta, impostors) {
  108301. for (var _i = 0, impostors_1 = impostors; _i < impostors_1.length; _i++) {
  108302. var impostor = impostors_1[_i];
  108303. // Update physics world objects to match babylon world
  108304. impostor.beforeStep();
  108305. }
  108306. this._stepSimulation(this._useDeltaForWorldStep ? delta : this._timeStep, this._maxSteps, this._fixedTimeStep);
  108307. for (var _a = 0, impostors_2 = impostors; _a < impostors_2.length; _a++) {
  108308. var mainImpostor = impostors_2[_a];
  108309. // After physics update make babylon world objects match physics world objects
  108310. mainImpostor.afterStep();
  108311. // Handle collision event
  108312. if (mainImpostor._onPhysicsCollideCallbacks.length > 0) {
  108313. if (this._isImpostorInContact(mainImpostor)) {
  108314. for (var _b = 0, _c = mainImpostor._onPhysicsCollideCallbacks; _b < _c.length; _b++) {
  108315. var collideCallback = _c[_b];
  108316. for (var _d = 0, _e = collideCallback.otherImpostors; _d < _e.length; _d++) {
  108317. var otherImpostor = _e[_d];
  108318. if (mainImpostor.physicsBody.isActive() || otherImpostor.physicsBody.isActive()) {
  108319. if (this._isImpostorPairInContact(mainImpostor, otherImpostor)) {
  108320. mainImpostor.onCollide({ body: otherImpostor.physicsBody });
  108321. otherImpostor.onCollide({ body: mainImpostor.physicsBody });
  108322. }
  108323. }
  108324. }
  108325. }
  108326. }
  108327. }
  108328. }
  108329. };
  108330. /**
  108331. * Applies an implulse on the imposter
  108332. * @param impostor imposter to apply impulse
  108333. * @param force amount of force to be applied to the imposter
  108334. * @param contactPoint the location to apply the impulse on the imposter
  108335. */
  108336. AmmoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  108337. var worldPoint = this._tmpAmmoVectorA;
  108338. var impulse = this._tmpAmmoVectorB;
  108339. // Convert contactPoint into world space
  108340. if (impostor.object && impostor.object.getWorldMatrix) {
  108341. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  108342. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  108343. contactPoint = this._tmpVector;
  108344. }
  108345. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  108346. impulse.setValue(force.x, force.y, force.z);
  108347. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  108348. };
  108349. /**
  108350. * Applies a force on the imposter
  108351. * @param impostor imposter to apply force
  108352. * @param force amount of force to be applied to the imposter
  108353. * @param contactPoint the location to apply the force on the imposter
  108354. */
  108355. AmmoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  108356. var worldPoint = this._tmpAmmoVectorA;
  108357. var impulse = this._tmpAmmoVectorB;
  108358. // Convert contactPoint into world space
  108359. if (impostor.object && impostor.object.getWorldMatrix) {
  108360. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  108361. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  108362. contactPoint = this._tmpVector;
  108363. }
  108364. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  108365. impulse.setValue(force.x, force.y, force.z);
  108366. impostor.physicsBody.applyForce(impulse, worldPoint);
  108367. };
  108368. /**
  108369. * Creates a physics body using the plugin
  108370. * @param impostor the imposter to create the physics body on
  108371. */
  108372. AmmoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  108373. impostor._pluginData = { toDispose: [] };
  108374. //parent-child relationship
  108375. if (impostor.parent) {
  108376. if (impostor.physicsBody) {
  108377. this.removePhysicsBody(impostor);
  108378. impostor.forceUpdate();
  108379. }
  108380. return;
  108381. }
  108382. if (impostor.isBodyInitRequired()) {
  108383. var colShape = this._createShape(impostor);
  108384. var mass = impostor.getParam("mass");
  108385. impostor._pluginData.mass = mass;
  108386. var localInertia = new Ammo.btVector3(0, 0, 0);
  108387. var startTransform = new Ammo.btTransform();
  108388. startTransform.setIdentity();
  108389. if (mass !== 0) {
  108390. colShape.calculateLocalInertia(mass, localInertia);
  108391. }
  108392. this._tmpAmmoVectorA.setValue(impostor.object.position.x, impostor.object.position.y, impostor.object.position.z);
  108393. this._tmpAmmoQuaternion.setValue(impostor.object.rotationQuaternion.x, impostor.object.rotationQuaternion.y, impostor.object.rotationQuaternion.z, impostor.object.rotationQuaternion.w);
  108394. startTransform.setOrigin(this._tmpAmmoVectorA);
  108395. startTransform.setRotation(this._tmpAmmoQuaternion);
  108396. var myMotionState = new Ammo.btDefaultMotionState(startTransform);
  108397. var rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
  108398. var body = new Ammo.btRigidBody(rbInfo);
  108399. // Make objects kinematic if it's mass is 0
  108400. if (mass === 0) {
  108401. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
  108402. body.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  108403. }
  108404. // Disable collision if NoImpostor, but keep collision if shape is btCompoundShape
  108405. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor && !colShape.getChildShape) {
  108406. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
  108407. }
  108408. this.world.addRigidBody(body);
  108409. impostor.physicsBody = body;
  108410. this.setBodyRestitution(impostor, impostor.getParam("restitution"));
  108411. this.setBodyFriction(impostor, impostor.getParam("friction"));
  108412. impostor._pluginData.toDispose.concat([body, rbInfo, myMotionState, startTransform, localInertia, colShape]);
  108413. }
  108414. };
  108415. /**
  108416. * Removes the physics body from the imposter and disposes of the body's memory
  108417. * @param impostor imposter to remove the physics body from
  108418. */
  108419. AmmoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  108420. var _this = this;
  108421. if (this.world) {
  108422. this.world.removeRigidBody(impostor.physicsBody);
  108423. impostor._pluginData.toDispose.forEach(function (d) {
  108424. _this.bjsAMMO.destroy(d);
  108425. });
  108426. }
  108427. };
  108428. /**
  108429. * Generates a joint
  108430. * @param impostorJoint the imposter joint to create the joint with
  108431. */
  108432. AmmoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  108433. var mainBody = impostorJoint.mainImpostor.physicsBody;
  108434. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  108435. if (!mainBody || !connectedBody) {
  108436. return;
  108437. }
  108438. var jointData = impostorJoint.joint.jointData;
  108439. if (!jointData.mainPivot) {
  108440. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  108441. }
  108442. if (!jointData.connectedPivot) {
  108443. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  108444. }
  108445. var joint;
  108446. switch (impostorJoint.joint.type) {
  108447. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].DistanceJoint:
  108448. var distance = jointData.maxDistance;
  108449. if (distance) {
  108450. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -distance / 2, 0);
  108451. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, distance / 2, 0);
  108452. }
  108453. 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));
  108454. break;
  108455. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].HingeJoint:
  108456. if (!jointData.mainAxis) {
  108457. jointData.mainAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  108458. }
  108459. if (!jointData.connectedAxis) {
  108460. jointData.connectedAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  108461. }
  108462. var mainAxis = new Ammo.btVector3(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z);
  108463. var connectedAxis = new Ammo.btVector3(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z);
  108464. 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);
  108465. break;
  108466. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].BallAndSocketJoint:
  108467. 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));
  108468. break;
  108469. default:
  108470. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint");
  108471. 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));
  108472. break;
  108473. }
  108474. this.world.addConstraint(joint, !impostorJoint.joint.jointData.collision);
  108475. impostorJoint.joint.physicsJoint = joint;
  108476. };
  108477. /**
  108478. * Removes a joint
  108479. * @param impostorJoint the imposter joint to remove the joint from
  108480. */
  108481. AmmoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  108482. if (this.world) {
  108483. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  108484. }
  108485. };
  108486. // adds all verticies (including child verticies) to the triangle mesh
  108487. AmmoJSPlugin.prototype._addMeshVerts = function (btTriangleMesh, topLevelObject, object) {
  108488. var _this = this;
  108489. var triangleCount = 0;
  108490. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  108491. var indices = object.getIndices();
  108492. if (!indices) {
  108493. indices = [];
  108494. }
  108495. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  108496. if (!vertexPositions) {
  108497. vertexPositions = [];
  108498. }
  108499. object.computeWorldMatrix(false);
  108500. var faceCount = indices.length / 3;
  108501. for (var i = 0; i < faceCount; i++) {
  108502. var triPoints = [];
  108503. for (var point = 0; point < 3; point++) {
  108504. 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]);
  108505. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, object.getWorldMatrix());
  108506. v.subtractInPlace(topLevelObject.position);
  108507. var vec;
  108508. if (point == 0) {
  108509. vec = this._tmpAmmoVectorA;
  108510. }
  108511. else if (point == 1) {
  108512. vec = this._tmpAmmoVectorB;
  108513. }
  108514. else {
  108515. vec = this._tmpAmmoVectorC;
  108516. }
  108517. vec.setValue(v.x, v.y, v.z);
  108518. triPoints.push(vec);
  108519. }
  108520. btTriangleMesh.addTriangle(triPoints[0], triPoints[1], triPoints[2]);
  108521. triangleCount++;
  108522. }
  108523. object.getChildMeshes().forEach(function (m) {
  108524. triangleCount += _this._addMeshVerts(btTriangleMesh, topLevelObject, m);
  108525. });
  108526. }
  108527. return triangleCount;
  108528. };
  108529. AmmoJSPlugin.prototype._createShape = function (impostor, ignoreChildren) {
  108530. var _this = this;
  108531. if (ignoreChildren === void 0) { ignoreChildren = false; }
  108532. var object = impostor.object;
  108533. var returnValue;
  108534. var extendSize = impostor.getObjectExtendSize();
  108535. if (!ignoreChildren) {
  108536. var meshChildren = impostor.object.getChildMeshes ? impostor.object.getChildMeshes(true) : [];
  108537. returnValue = new Ammo.btCompoundShape();
  108538. // Add shape of all children to the compound shape
  108539. var childrenAdded = 0;
  108540. meshChildren.forEach(function (childMesh) {
  108541. var childImpostor = childMesh.getPhysicsImpostor();
  108542. if (childImpostor) {
  108543. var shape = _this._createShape(childImpostor);
  108544. // Position needs to be scaled based on parent's scaling
  108545. var parentMat = childMesh.parent.getWorldMatrix().clone();
  108546. var s = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  108547. parentMat.decompose(s);
  108548. _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
  108549. _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
  108550. _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
  108551. returnValue.addChildShape(_this._tmpAmmoTransform, shape);
  108552. childImpostor.dispose();
  108553. childrenAdded++;
  108554. }
  108555. });
  108556. if (childrenAdded > 0) {
  108557. // Add parents shape as a child if present
  108558. if (impostor.type != _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor) {
  108559. var shape = this._createShape(impostor, true);
  108560. if (shape) {
  108561. this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
  108562. this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
  108563. this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
  108564. returnValue.addChildShape(this._tmpAmmoTransform, shape);
  108565. }
  108566. }
  108567. return returnValue;
  108568. }
  108569. else {
  108570. // If no children with impostors create the actual shape below instead
  108571. Ammo.destroy(returnValue);
  108572. returnValue = null;
  108573. }
  108574. }
  108575. switch (impostor.type) {
  108576. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SphereImpostor:
  108577. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  108578. break;
  108579. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].CylinderImpostor:
  108580. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  108581. returnValue = new Ammo.btCylinderShape(this._tmpAmmoVectorA);
  108582. break;
  108583. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].PlaneImpostor:
  108584. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].BoxImpostor:
  108585. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  108586. returnValue = new Ammo.btBoxShape(this._tmpAmmoVectorA);
  108587. break;
  108588. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor:
  108589. var tetraMesh = new Ammo.btTriangleMesh();
  108590. impostor._pluginData.toDispose.concat([tetraMesh]);
  108591. var triangeCount = this._addMeshVerts(tetraMesh, object, object);
  108592. if (triangeCount == 0) {
  108593. returnValue = new Ammo.btCompoundShape();
  108594. }
  108595. else {
  108596. returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
  108597. }
  108598. break;
  108599. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor:
  108600. // Fill with sphere but collision is disabled on the rigid body in generatePhysicsBody, using an empty shape caused unexpected movement with joints
  108601. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  108602. break;
  108603. default:
  108604. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The impostor type is not currently supported by the ammo plugin.");
  108605. break;
  108606. }
  108607. return returnValue;
  108608. };
  108609. /**
  108610. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  108611. * @param impostor imposter containing the physics body and babylon object
  108612. */
  108613. AmmoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  108614. impostor.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  108615. impostor.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z());
  108616. if (!impostor.object.rotationQuaternion) {
  108617. if (impostor.object.rotation) {
  108618. this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  108619. this._tmpQuaternion.toEulerAnglesToRef(impostor.object.rotation);
  108620. }
  108621. }
  108622. else {
  108623. impostor.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  108624. }
  108625. };
  108626. /**
  108627. * Sets the babylon object's position/rotation from the physics body's position/rotation
  108628. * @param impostor imposter containing the physics body and babylon object
  108629. * @param newPosition new position
  108630. * @param newRotation new rotation
  108631. */
  108632. AmmoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  108633. var trans = impostor.physicsBody.getWorldTransform();
  108634. // If rotation/position has changed update and activate riged body
  108635. if (trans.getOrigin().x() != newPosition.x ||
  108636. trans.getOrigin().y() != newPosition.y ||
  108637. trans.getOrigin().z() != newPosition.z ||
  108638. trans.getRotation().x() != newRotation.x ||
  108639. trans.getRotation().y() != newRotation.y ||
  108640. trans.getRotation().z() != newRotation.z ||
  108641. trans.getRotation().w() != newRotation.w) {
  108642. this._tmpAmmoVectorA.setValue(newPosition.x, newPosition.y, newPosition.z);
  108643. trans.setOrigin(this._tmpAmmoVectorA);
  108644. this._tmpAmmoQuaternion.setValue(newRotation.x, newRotation.y, newRotation.z, newRotation.w);
  108645. trans.setRotation(this._tmpAmmoQuaternion);
  108646. impostor.physicsBody.setWorldTransform(trans);
  108647. if (impostor.mass == 0) {
  108648. // Kinematic objects must be updated using motion state
  108649. var motionState = impostor.physicsBody.getMotionState();
  108650. if (motionState) {
  108651. motionState.setWorldTransform(trans);
  108652. }
  108653. }
  108654. else {
  108655. impostor.physicsBody.activate();
  108656. }
  108657. }
  108658. };
  108659. /**
  108660. * If this plugin is supported
  108661. * @returns true if its supported
  108662. */
  108663. AmmoJSPlugin.prototype.isSupported = function () {
  108664. return this.bjsAMMO !== undefined;
  108665. };
  108666. /**
  108667. * Sets the linear velocity of the physics body
  108668. * @param impostor imposter to set the velocity on
  108669. * @param velocity velocity to set
  108670. */
  108671. AmmoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  108672. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  108673. impostor.physicsBody.setLinearVelocity(this._tmpAmmoVectorA);
  108674. };
  108675. /**
  108676. * Sets the angular velocity of the physics body
  108677. * @param impostor imposter to set the velocity on
  108678. * @param velocity velocity to set
  108679. */
  108680. AmmoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  108681. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  108682. impostor.physicsBody.setAngularVelocity(this._tmpAmmoVectorA);
  108683. };
  108684. /**
  108685. * gets the linear velocity
  108686. * @param impostor imposter to get linear velocity from
  108687. * @returns linear velocity
  108688. */
  108689. AmmoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  108690. var v = impostor.physicsBody.getLinearVelocity();
  108691. if (!v) {
  108692. return null;
  108693. }
  108694. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  108695. };
  108696. /**
  108697. * gets the angular velocity
  108698. * @param impostor imposter to get angular velocity from
  108699. * @returns angular velocity
  108700. */
  108701. AmmoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  108702. var v = impostor.physicsBody.getAngularVelocity();
  108703. if (!v) {
  108704. return null;
  108705. }
  108706. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  108707. };
  108708. /**
  108709. * Sets the mass of physics body
  108710. * @param impostor imposter to set the mass on
  108711. * @param mass mass to set
  108712. */
  108713. AmmoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  108714. impostor.physicsBody.setMassProps(mass);
  108715. impostor._pluginData.mass = mass;
  108716. };
  108717. /**
  108718. * Gets the mass of the physics body
  108719. * @param impostor imposter to get the mass from
  108720. * @returns mass
  108721. */
  108722. AmmoJSPlugin.prototype.getBodyMass = function (impostor) {
  108723. return impostor._pluginData.mass;
  108724. };
  108725. /**
  108726. * Gets friction of the impostor
  108727. * @param impostor impostor to get friction from
  108728. * @returns friction value
  108729. */
  108730. AmmoJSPlugin.prototype.getBodyFriction = function (impostor) {
  108731. return impostor._pluginData.friction;
  108732. };
  108733. /**
  108734. * Sets friction of the impostor
  108735. * @param impostor impostor to set friction on
  108736. * @param friction friction value
  108737. */
  108738. AmmoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  108739. impostor.physicsBody.setFriction(friction);
  108740. impostor._pluginData.friction = friction;
  108741. };
  108742. /**
  108743. * Gets restitution of the impostor
  108744. * @param impostor impostor to get restitution from
  108745. * @returns restitution value
  108746. */
  108747. AmmoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  108748. return impostor._pluginData.restitution;
  108749. };
  108750. /**
  108751. * Sets resitution of the impostor
  108752. * @param impostor impostor to set resitution on
  108753. * @param restitution resitution value
  108754. */
  108755. AmmoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  108756. impostor.physicsBody.setRestitution(restitution);
  108757. impostor._pluginData.restitution = restitution;
  108758. };
  108759. /**
  108760. * Sleeps the physics body and stops it from being active
  108761. * @param impostor impostor to sleep
  108762. */
  108763. AmmoJSPlugin.prototype.sleepBody = function (impostor) {
  108764. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("sleepBody is not currently supported by the Ammo physics plugin");
  108765. };
  108766. /**
  108767. * Activates the physics body
  108768. * @param impostor impostor to activate
  108769. */
  108770. AmmoJSPlugin.prototype.wakeUpBody = function (impostor) {
  108771. impostor.physicsBody.activate();
  108772. };
  108773. /**
  108774. * Updates the distance parameters of the joint
  108775. * @param joint joint to update
  108776. * @param maxDistance maximum distance of the joint
  108777. * @param minDistance minimum distance of the joint
  108778. */
  108779. AmmoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  108780. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin");
  108781. };
  108782. /**
  108783. * Sets a motor on the joint
  108784. * @param joint joint to set motor on
  108785. * @param speed speed of the motor
  108786. * @param maxForce maximum force of the motor
  108787. * @param motorIndex index of the motor
  108788. */
  108789. AmmoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  108790. joint.physicsJoint.enableAngularMotor(true, speed, maxForce);
  108791. };
  108792. /**
  108793. * Sets the motors limit
  108794. * @param joint joint to set limit on
  108795. * @param upperLimit upper limit
  108796. * @param lowerLimit lower limit
  108797. */
  108798. AmmoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  108799. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("setLimit is not currently supported by the Ammo physics plugin");
  108800. };
  108801. /**
  108802. * Syncs the position and rotation of a mesh with the impostor
  108803. * @param mesh mesh to sync
  108804. * @param impostor impostor to update the mesh with
  108805. */
  108806. AmmoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  108807. var body = impostor.physicsBody;
  108808. body.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  108809. mesh.position.x = this._tmpAmmoTransform.getOrigin().x();
  108810. mesh.position.y = this._tmpAmmoTransform.getOrigin().y();
  108811. mesh.position.z = this._tmpAmmoTransform.getOrigin().z();
  108812. if (mesh.rotationQuaternion) {
  108813. mesh.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x();
  108814. mesh.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y();
  108815. mesh.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z();
  108816. mesh.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w();
  108817. }
  108818. };
  108819. /**
  108820. * Gets the radius of the impostor
  108821. * @param impostor impostor to get radius from
  108822. * @returns the radius
  108823. */
  108824. AmmoJSPlugin.prototype.getRadius = function (impostor) {
  108825. var exntend = impostor.getObjectExtendSize();
  108826. return exntend.x / 2;
  108827. };
  108828. /**
  108829. * Gets the box size of the impostor
  108830. * @param impostor impostor to get box size from
  108831. * @param result the resulting box size
  108832. */
  108833. AmmoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  108834. var exntend = impostor.getObjectExtendSize();
  108835. result.x = exntend.x;
  108836. result.y = exntend.y;
  108837. result.z = exntend.z;
  108838. };
  108839. /**
  108840. * Disposes of the impostor
  108841. */
  108842. AmmoJSPlugin.prototype.dispose = function () {
  108843. // Dispose of world
  108844. Ammo.destroy(this.world);
  108845. Ammo.destroy(this._solver);
  108846. Ammo.destroy(this._overlappingPairCache);
  108847. Ammo.destroy(this._dispatcher);
  108848. Ammo.destroy(this._collisionConfiguration);
  108849. // Dispose of tmp variables
  108850. Ammo.destroy(this._tmpAmmoVectorA);
  108851. Ammo.destroy(this._tmpAmmoVectorB);
  108852. Ammo.destroy(this._tmpAmmoVectorC);
  108853. Ammo.destroy(this._tmpAmmoTransform);
  108854. Ammo.destroy(this._tmpAmmoQuaternion);
  108855. Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
  108856. this.world = null;
  108857. };
  108858. AmmoJSPlugin.DISABLE_COLLISION_FLAG = 4;
  108859. AmmoJSPlugin.KINEMATIC_FLAG = 2;
  108860. AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
  108861. return AmmoJSPlugin;
  108862. }());
  108863. /***/ }),
  108864. /***/ "./Physics/Plugins/cannonJSPlugin.ts":
  108865. /*!*******************************************!*\
  108866. !*** ./Physics/Plugins/cannonJSPlugin.ts ***!
  108867. \*******************************************/
  108868. /*! exports provided: CannonJSPlugin */
  108869. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108870. "use strict";
  108871. __webpack_require__.r(__webpack_exports__);
  108872. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return CannonJSPlugin; });
  108873. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  108874. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  108875. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  108876. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  108877. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  108878. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  108879. /** @hidden */
  108880. var CannonJSPlugin = /** @class */ (function () {
  108881. function CannonJSPlugin(_useDeltaForWorldStep, iterations, cannonInjection) {
  108882. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  108883. if (iterations === void 0) { iterations = 10; }
  108884. if (cannonInjection === void 0) { cannonInjection = CANNON; }
  108885. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  108886. this.name = "CannonJSPlugin";
  108887. this._physicsMaterials = new Array();
  108888. this._fixedTimeStep = 1 / 60;
  108889. this._minus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-0.7071067811865475, 0, 0, 0.7071067811865475);
  108890. this._plus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](0.7071067811865475, 0, 0, 0.7071067811865475);
  108891. this._tmpPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  108892. this._tmpDeltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  108893. this._tmpUnityRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  108894. this.BJSCANNON = cannonInjection;
  108895. if (!this.isSupported()) {
  108896. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("CannonJS is not available. Please make sure you included the js file.");
  108897. return;
  108898. }
  108899. this._extendNamespace();
  108900. this.world = new this.BJSCANNON.World();
  108901. this.world.broadphase = new this.BJSCANNON.NaiveBroadphase();
  108902. this.world.solver.iterations = iterations;
  108903. }
  108904. CannonJSPlugin.prototype.setGravity = function (gravity) {
  108905. this.world.gravity.copy(gravity);
  108906. };
  108907. CannonJSPlugin.prototype.setTimeStep = function (timeStep) {
  108908. this._fixedTimeStep = timeStep;
  108909. };
  108910. CannonJSPlugin.prototype.getTimeStep = function () {
  108911. return this._fixedTimeStep;
  108912. };
  108913. CannonJSPlugin.prototype.executeStep = function (delta) {
  108914. this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta : 0, 3);
  108915. };
  108916. CannonJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  108917. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  108918. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  108919. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  108920. };
  108921. CannonJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  108922. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  108923. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  108924. impostor.physicsBody.applyForce(impulse, worldPoint);
  108925. };
  108926. CannonJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  108927. //parent-child relationship. Does this impostor has a parent impostor?
  108928. if (impostor.parent) {
  108929. if (impostor.physicsBody) {
  108930. this.removePhysicsBody(impostor);
  108931. //TODO is that needed?
  108932. impostor.forceUpdate();
  108933. }
  108934. return;
  108935. }
  108936. //should a new body be created for this impostor?
  108937. if (impostor.isBodyInitRequired()) {
  108938. var shape = this._createShape(impostor);
  108939. //unregister events, if body is being changed
  108940. var oldBody = impostor.physicsBody;
  108941. if (oldBody) {
  108942. this.removePhysicsBody(impostor);
  108943. }
  108944. //create the body and material
  108945. var material = this._addMaterial("mat-" + impostor.uniqueId, impostor.getParam("friction"), impostor.getParam("restitution"));
  108946. var bodyCreationObject = {
  108947. mass: impostor.getParam("mass"),
  108948. material: material
  108949. };
  108950. // A simple extend, in case native options were used.
  108951. var nativeOptions = impostor.getParam("nativeOptions");
  108952. for (var key in nativeOptions) {
  108953. if (nativeOptions.hasOwnProperty(key)) {
  108954. bodyCreationObject[key] = nativeOptions[key];
  108955. }
  108956. }
  108957. impostor.physicsBody = new this.BJSCANNON.Body(bodyCreationObject);
  108958. impostor.physicsBody.addEventListener("collide", impostor.onCollide);
  108959. this.world.addEventListener("preStep", impostor.beforeStep);
  108960. this.world.addEventListener("postStep", impostor.afterStep);
  108961. impostor.physicsBody.addShape(shape);
  108962. this.world.add(impostor.physicsBody);
  108963. //try to keep the body moving in the right direction by taking old properties.
  108964. //Should be tested!
  108965. if (oldBody) {
  108966. ['force', 'torque', 'velocity', 'angularVelocity'].forEach(function (param) {
  108967. impostor.physicsBody[param].copy(oldBody[param]);
  108968. });
  108969. }
  108970. this._processChildMeshes(impostor);
  108971. }
  108972. //now update the body's transformation
  108973. this._updatePhysicsBodyTransformation(impostor);
  108974. };
  108975. CannonJSPlugin.prototype._processChildMeshes = function (mainImpostor) {
  108976. var _this = this;
  108977. var meshChildren = mainImpostor.object.getChildMeshes ? mainImpostor.object.getChildMeshes(true) : [];
  108978. var currentRotation = mainImpostor.object.rotationQuaternion;
  108979. if (meshChildren.length) {
  108980. var processMesh = function (localPosition, mesh) {
  108981. if (!currentRotation || !mesh.rotationQuaternion) {
  108982. return;
  108983. }
  108984. var childImpostor = mesh.getPhysicsImpostor();
  108985. if (childImpostor) {
  108986. var parent = childImpostor.parent;
  108987. if (parent !== mainImpostor) {
  108988. var pPosition = mesh.getAbsolutePosition().subtract(mainImpostor.object.getAbsolutePosition());
  108989. var localRotation = mesh.rotationQuaternion.multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Inverse(currentRotation));
  108990. if (childImpostor.physicsBody) {
  108991. _this.removePhysicsBody(childImpostor);
  108992. childImpostor.physicsBody = null;
  108993. }
  108994. childImpostor.parent = mainImpostor;
  108995. childImpostor.resetUpdateFlags();
  108996. 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));
  108997. //Add the mass of the children.
  108998. mainImpostor.physicsBody.mass += childImpostor.getParam("mass");
  108999. }
  109000. }
  109001. currentRotation.multiplyInPlace(mesh.rotationQuaternion);
  109002. mesh.getChildMeshes(true).filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(_this, mesh.getAbsolutePosition()));
  109003. };
  109004. meshChildren.filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(this, mainImpostor.object.getAbsolutePosition()));
  109005. }
  109006. };
  109007. CannonJSPlugin.prototype.removePhysicsBody = function (impostor) {
  109008. impostor.physicsBody.removeEventListener("collide", impostor.onCollide);
  109009. this.world.removeEventListener("preStep", impostor.beforeStep);
  109010. this.world.removeEventListener("postStep", impostor.afterStep);
  109011. this.world.remove(impostor.physicsBody);
  109012. };
  109013. CannonJSPlugin.prototype.generateJoint = function (impostorJoint) {
  109014. var mainBody = impostorJoint.mainImpostor.physicsBody;
  109015. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  109016. if (!mainBody || !connectedBody) {
  109017. return;
  109018. }
  109019. var constraint;
  109020. var jointData = impostorJoint.joint.jointData;
  109021. //TODO - https://github.com/schteppe/this.BJSCANNON.js/blob/gh-pages/demos/collisionFilter.html
  109022. var constraintData = {
  109023. pivotA: jointData.mainPivot ? new this.BJSCANNON.Vec3().copy(jointData.mainPivot) : null,
  109024. pivotB: jointData.connectedPivot ? new this.BJSCANNON.Vec3().copy(jointData.connectedPivot) : null,
  109025. axisA: jointData.mainAxis ? new this.BJSCANNON.Vec3().copy(jointData.mainAxis) : null,
  109026. axisB: jointData.connectedAxis ? new this.BJSCANNON.Vec3().copy(jointData.connectedAxis) : null,
  109027. maxForce: jointData.nativeParams.maxForce,
  109028. collideConnected: !!jointData.collision
  109029. };
  109030. switch (impostorJoint.joint.type) {
  109031. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].HingeJoint:
  109032. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].Hinge2Joint:
  109033. constraint = new this.BJSCANNON.HingeConstraint(mainBody, connectedBody, constraintData);
  109034. break;
  109035. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].DistanceJoint:
  109036. constraint = new this.BJSCANNON.DistanceConstraint(mainBody, connectedBody, jointData.maxDistance || 2);
  109037. break;
  109038. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint:
  109039. var springData = jointData;
  109040. constraint = new this.BJSCANNON.Spring(mainBody, connectedBody, {
  109041. restLength: springData.length,
  109042. stiffness: springData.stiffness,
  109043. damping: springData.damping,
  109044. localAnchorA: constraintData.pivotA,
  109045. localAnchorB: constraintData.pivotB
  109046. });
  109047. break;
  109048. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].LockJoint:
  109049. constraint = new this.BJSCANNON.LockConstraint(mainBody, connectedBody, constraintData);
  109050. break;
  109051. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].PointToPointJoint:
  109052. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].BallAndSocketJoint:
  109053. default:
  109054. constraint = new this.BJSCANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotB, constraintData.maxForce);
  109055. break;
  109056. }
  109057. //set the collideConnected flag after the creation, since DistanceJoint ignores it.
  109058. constraint.collideConnected = !!jointData.collision;
  109059. impostorJoint.joint.physicsJoint = constraint;
  109060. //don't add spring as constraint, as it is not one.
  109061. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  109062. this.world.addConstraint(constraint);
  109063. }
  109064. else {
  109065. impostorJoint.joint.jointData.forceApplicationCallback = impostorJoint.joint.jointData.forceApplicationCallback || function () {
  109066. constraint.applyForce();
  109067. };
  109068. impostorJoint.mainImpostor.registerAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  109069. }
  109070. };
  109071. CannonJSPlugin.prototype.removeJoint = function (impostorJoint) {
  109072. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  109073. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  109074. }
  109075. else {
  109076. impostorJoint.mainImpostor.unregisterAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  109077. }
  109078. };
  109079. CannonJSPlugin.prototype._addMaterial = function (name, friction, restitution) {
  109080. var index;
  109081. var mat;
  109082. for (index = 0; index < this._physicsMaterials.length; index++) {
  109083. mat = this._physicsMaterials[index];
  109084. if (mat.friction === friction && mat.restitution === restitution) {
  109085. return mat;
  109086. }
  109087. }
  109088. var currentMat = new this.BJSCANNON.Material(name);
  109089. currentMat.friction = friction;
  109090. currentMat.restitution = restitution;
  109091. this._physicsMaterials.push(currentMat);
  109092. return currentMat;
  109093. };
  109094. CannonJSPlugin.prototype._checkWithEpsilon = function (value) {
  109095. return value < _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon ? _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon : value;
  109096. };
  109097. CannonJSPlugin.prototype._createShape = function (impostor) {
  109098. var object = impostor.object;
  109099. var returnValue;
  109100. var extendSize = impostor.getObjectExtendSize();
  109101. switch (impostor.type) {
  109102. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].SphereImpostor:
  109103. var radiusX = extendSize.x;
  109104. var radiusY = extendSize.y;
  109105. var radiusZ = extendSize.z;
  109106. returnValue = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);
  109107. break;
  109108. //TMP also for cylinder - TODO Cannon supports cylinder natively.
  109109. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].CylinderImpostor:
  109110. var nativeParams = impostor.getParam("nativeOptions");
  109111. var radiusTop = nativeParams.radiusTop !== undefined ? nativeParams.radiusTop : this._checkWithEpsilon(extendSize.x) / 2;
  109112. var radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(extendSize.x) / 2;
  109113. var height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(extendSize.y) / 2;
  109114. var numSegments = nativeParams.numSegments !== undefined ? nativeParams.numSegments : 16;
  109115. returnValue = new this.BJSCANNON.Cylinder(radiusTop, radiusBottom, height, numSegments);
  109116. break;
  109117. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].BoxImpostor:
  109118. var box = extendSize.scale(0.5);
  109119. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
  109120. break;
  109121. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor:
  109122. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead");
  109123. returnValue = new this.BJSCANNON.Plane();
  109124. break;
  109125. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor:
  109126. // should transform the vertex data to world coordinates!!
  109127. var rawVerts = object.getVerticesData ? object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) : [];
  109128. var rawFaces = object.getIndices ? object.getIndices() : [];
  109129. if (!rawVerts) {
  109130. return;
  109131. }
  109132. // get only scale! so the object could transform correctly.
  109133. var oldPosition = object.position.clone();
  109134. var oldRotation = object.rotation && object.rotation.clone();
  109135. var oldQuaternion = object.rotationQuaternion && object.rotationQuaternion.clone();
  109136. object.position.copyFromFloats(0, 0, 0);
  109137. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  109138. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  109139. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  109140. var transform = object.computeWorldMatrix(true);
  109141. // convert rawVerts to object space
  109142. var temp = new Array();
  109143. var index;
  109144. for (index = 0; index < rawVerts.length; index += 3) {
  109145. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(rawVerts, index), transform).toArray(temp, index);
  109146. }
  109147. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("MeshImpostor only collides against spheres.");
  109148. returnValue = new this.BJSCANNON.Trimesh(temp, rawFaces);
  109149. //now set back the transformation!
  109150. object.position.copyFrom(oldPosition);
  109151. oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);
  109152. oldQuaternion && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion);
  109153. break;
  109154. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor:
  109155. var oldPosition2 = object.position.clone();
  109156. var oldRotation2 = object.rotation && object.rotation.clone();
  109157. var oldQuaternion2 = object.rotationQuaternion && object.rotationQuaternion.clone();
  109158. object.position.copyFromFloats(0, 0, 0);
  109159. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  109160. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  109161. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  109162. object.rotationQuaternion && object.rotationQuaternion.multiplyInPlace(this._minus90X);
  109163. returnValue = this._createHeightmap(object);
  109164. object.position.copyFrom(oldPosition2);
  109165. oldRotation2 && object.rotation && object.rotation.copyFrom(oldRotation2);
  109166. oldQuaternion2 && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion2);
  109167. object.computeWorldMatrix(true);
  109168. break;
  109169. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].ParticleImpostor:
  109170. returnValue = new this.BJSCANNON.Particle();
  109171. break;
  109172. }
  109173. return returnValue;
  109174. };
  109175. CannonJSPlugin.prototype._createHeightmap = function (object, pointDepth) {
  109176. var pos = (object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  109177. var transform = object.computeWorldMatrix(true);
  109178. // convert rawVerts to object space
  109179. var temp = new Array();
  109180. var index;
  109181. for (index = 0; index < pos.length; index += 3) {
  109182. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(pos, index), transform).toArray(temp, index);
  109183. }
  109184. pos = temp;
  109185. var matrix = new Array();
  109186. //For now pointDepth will not be used and will be automatically calculated.
  109187. //Future reference - try and find the best place to add a reference to the pointDepth variable.
  109188. var arraySize = pointDepth || ~~(Math.sqrt(pos.length / 3) - 1);
  109189. var boundingInfo = object.getBoundingInfo();
  109190. var dim = Math.min(boundingInfo.boundingBox.extendSizeWorld.x, boundingInfo.boundingBox.extendSizeWorld.y);
  109191. var minY = boundingInfo.boundingBox.extendSizeWorld.z;
  109192. var elementSize = dim * 2 / arraySize;
  109193. for (var i = 0; i < pos.length; i = i + 3) {
  109194. var x = Math.round((pos[i + 0]) / elementSize + arraySize / 2);
  109195. var z = Math.round(((pos[i + 1]) / elementSize - arraySize / 2) * -1);
  109196. var y = -pos[i + 2] + minY;
  109197. if (!matrix[x]) {
  109198. matrix[x] = [];
  109199. }
  109200. if (!matrix[x][z]) {
  109201. matrix[x][z] = y;
  109202. }
  109203. matrix[x][z] = Math.max(y, matrix[x][z]);
  109204. }
  109205. for (var x = 0; x <= arraySize; ++x) {
  109206. if (!matrix[x]) {
  109207. var loc = 1;
  109208. while (!matrix[(x + loc) % arraySize]) {
  109209. loc++;
  109210. }
  109211. matrix[x] = matrix[(x + loc) % arraySize].slice();
  109212. //console.log("missing x", x);
  109213. }
  109214. for (var z = 0; z <= arraySize; ++z) {
  109215. if (!matrix[x][z]) {
  109216. var loc = 1;
  109217. var newValue;
  109218. while (newValue === undefined) {
  109219. newValue = matrix[x][(z + loc++) % arraySize];
  109220. }
  109221. matrix[x][z] = newValue;
  109222. }
  109223. }
  109224. }
  109225. var shape = new this.BJSCANNON.Heightfield(matrix, {
  109226. elementSize: elementSize
  109227. });
  109228. //For future reference, needed for body transformation
  109229. shape.minY = minY;
  109230. return shape;
  109231. };
  109232. CannonJSPlugin.prototype._updatePhysicsBodyTransformation = function (impostor) {
  109233. var object = impostor.object;
  109234. //make sure it is updated...
  109235. object.computeWorldMatrix && object.computeWorldMatrix(true);
  109236. // The delta between the mesh position and the mesh bounding box center
  109237. var bInfo = object.getBoundingInfo();
  109238. if (!bInfo) {
  109239. return;
  109240. }
  109241. var center = impostor.getObjectCenter();
  109242. //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)
  109243. this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));
  109244. this._tmpDeltaPosition.divideInPlace(impostor.object.scaling);
  109245. this._tmpPosition.copyFrom(center);
  109246. var quaternion = object.rotationQuaternion;
  109247. if (!quaternion) {
  109248. return;
  109249. }
  109250. //is shape is a plane or a heightmap, it must be rotated 90 degs in the X axis.
  109251. 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) {
  109252. //-90 DEG in X, precalculated
  109253. quaternion = quaternion.multiply(this._minus90X);
  109254. //Invert! (Precalculated, 90 deg in X)
  109255. //No need to clone. this will never change.
  109256. impostor.setDeltaRotation(this._plus90X);
  109257. }
  109258. //If it is a heightfield, if should be centered.
  109259. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  109260. var mesh = object;
  109261. var boundingInfo = mesh.getBoundingInfo();
  109262. //calculate the correct body position:
  109263. var rotationQuaternion = mesh.rotationQuaternion;
  109264. mesh.rotationQuaternion = this._tmpUnityRotation;
  109265. mesh.computeWorldMatrix(true);
  109266. //get original center with no rotation
  109267. var c = center.clone();
  109268. var oldPivot = mesh.getPivotMatrix();
  109269. if (oldPivot) {
  109270. // create a copy the pivot Matrix as it is modified in place
  109271. oldPivot = oldPivot.clone();
  109272. }
  109273. else {
  109274. oldPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  109275. }
  109276. //calculate the new center using a pivot (since this.BJSCANNON.js doesn't center height maps)
  109277. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Translation(boundingInfo.boundingBox.extendSizeWorld.x, 0, -boundingInfo.boundingBox.extendSizeWorld.z);
  109278. mesh.setPreTransformMatrix(p);
  109279. mesh.computeWorldMatrix(true);
  109280. //calculate the translation
  109281. var translation = boundingInfo.boundingBox.centerWorld.subtract(center).subtract(mesh.position).negate();
  109282. this._tmpPosition.copyFromFloats(translation.x, translation.y - boundingInfo.boundingBox.extendSizeWorld.y, translation.z);
  109283. //add it inverted to the delta
  109284. this._tmpDeltaPosition.copyFrom(boundingInfo.boundingBox.centerWorld.subtract(c));
  109285. this._tmpDeltaPosition.y += boundingInfo.boundingBox.extendSizeWorld.y;
  109286. //rotation is back
  109287. mesh.rotationQuaternion = rotationQuaternion;
  109288. mesh.setPreTransformMatrix(oldPivot);
  109289. mesh.computeWorldMatrix(true);
  109290. }
  109291. else if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor) {
  109292. this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
  109293. //this._tmpPosition.copyFrom(object.position);
  109294. }
  109295. impostor.setDeltaPosition(this._tmpDeltaPosition);
  109296. //Now update the impostor object
  109297. impostor.physicsBody.position.copy(this._tmpPosition);
  109298. impostor.physicsBody.quaternion.copy(quaternion);
  109299. };
  109300. CannonJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  109301. impostor.object.position.copyFrom(impostor.physicsBody.position);
  109302. if (impostor.object.rotationQuaternion) {
  109303. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.quaternion);
  109304. }
  109305. };
  109306. CannonJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  109307. impostor.physicsBody.position.copy(newPosition);
  109308. impostor.physicsBody.quaternion.copy(newRotation);
  109309. };
  109310. CannonJSPlugin.prototype.isSupported = function () {
  109311. return this.BJSCANNON !== undefined;
  109312. };
  109313. CannonJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  109314. impostor.physicsBody.velocity.copy(velocity);
  109315. };
  109316. CannonJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  109317. impostor.physicsBody.angularVelocity.copy(velocity);
  109318. };
  109319. CannonJSPlugin.prototype.getLinearVelocity = function (impostor) {
  109320. var v = impostor.physicsBody.velocity;
  109321. if (!v) {
  109322. return null;
  109323. }
  109324. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  109325. };
  109326. CannonJSPlugin.prototype.getAngularVelocity = function (impostor) {
  109327. var v = impostor.physicsBody.angularVelocity;
  109328. if (!v) {
  109329. return null;
  109330. }
  109331. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  109332. };
  109333. CannonJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  109334. impostor.physicsBody.mass = mass;
  109335. impostor.physicsBody.updateMassProperties();
  109336. };
  109337. CannonJSPlugin.prototype.getBodyMass = function (impostor) {
  109338. return impostor.physicsBody.mass;
  109339. };
  109340. CannonJSPlugin.prototype.getBodyFriction = function (impostor) {
  109341. return impostor.physicsBody.material.friction;
  109342. };
  109343. CannonJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  109344. impostor.physicsBody.material.friction = friction;
  109345. };
  109346. CannonJSPlugin.prototype.getBodyRestitution = function (impostor) {
  109347. return impostor.physicsBody.material.restitution;
  109348. };
  109349. CannonJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  109350. impostor.physicsBody.material.restitution = restitution;
  109351. };
  109352. CannonJSPlugin.prototype.sleepBody = function (impostor) {
  109353. impostor.physicsBody.sleep();
  109354. };
  109355. CannonJSPlugin.prototype.wakeUpBody = function (impostor) {
  109356. impostor.physicsBody.wakeUp();
  109357. };
  109358. CannonJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance) {
  109359. joint.physicsJoint.distance = maxDistance;
  109360. };
  109361. // private enableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  109362. // if (!motorIndex) {
  109363. // joint.physicsJoint.enableMotor();
  109364. // }
  109365. // }
  109366. // private disableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  109367. // if (!motorIndex) {
  109368. // joint.physicsJoint.disableMotor();
  109369. // }
  109370. // }
  109371. CannonJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  109372. if (!motorIndex) {
  109373. joint.physicsJoint.enableMotor();
  109374. joint.physicsJoint.setMotorSpeed(speed);
  109375. if (maxForce) {
  109376. this.setLimit(joint, maxForce);
  109377. }
  109378. }
  109379. };
  109380. CannonJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  109381. joint.physicsJoint.motorEquation.maxForce = upperLimit;
  109382. joint.physicsJoint.motorEquation.minForce = lowerLimit === void 0 ? -upperLimit : lowerLimit;
  109383. };
  109384. CannonJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  109385. var body = impostor.physicsBody;
  109386. mesh.position.x = body.position.x;
  109387. mesh.position.y = body.position.y;
  109388. mesh.position.z = body.position.z;
  109389. if (mesh.rotationQuaternion) {
  109390. mesh.rotationQuaternion.x = body.quaternion.x;
  109391. mesh.rotationQuaternion.y = body.quaternion.y;
  109392. mesh.rotationQuaternion.z = body.quaternion.z;
  109393. mesh.rotationQuaternion.w = body.quaternion.w;
  109394. }
  109395. };
  109396. CannonJSPlugin.prototype.getRadius = function (impostor) {
  109397. var shape = impostor.physicsBody.shapes[0];
  109398. return shape.boundingSphereRadius;
  109399. };
  109400. CannonJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  109401. var shape = impostor.physicsBody.shapes[0];
  109402. result.x = shape.halfExtents.x * 2;
  109403. result.y = shape.halfExtents.y * 2;
  109404. result.z = shape.halfExtents.z * 2;
  109405. };
  109406. CannonJSPlugin.prototype.dispose = function () {
  109407. };
  109408. CannonJSPlugin.prototype._extendNamespace = function () {
  109409. //this will force cannon to execute at least one step when using interpolation
  109410. var step_tmp1 = new this.BJSCANNON.Vec3();
  109411. var Engine = this.BJSCANNON;
  109412. this.BJSCANNON.World.prototype.step = function (dt, timeSinceLastCalled, maxSubSteps) {
  109413. maxSubSteps = maxSubSteps || 10;
  109414. timeSinceLastCalled = timeSinceLastCalled || 0;
  109415. if (timeSinceLastCalled === 0) {
  109416. this.internalStep(dt);
  109417. this.time += dt;
  109418. }
  109419. else {
  109420. var internalSteps = Math.floor((this.time + timeSinceLastCalled) / dt) - Math.floor(this.time / dt);
  109421. internalSteps = Math.min(internalSteps, maxSubSteps) || 1;
  109422. var t0 = performance.now();
  109423. for (var i = 0; i !== internalSteps; i++) {
  109424. this.internalStep(dt);
  109425. if (performance.now() - t0 > dt * 1000) {
  109426. break;
  109427. }
  109428. }
  109429. this.time += timeSinceLastCalled;
  109430. var h = this.time % dt;
  109431. var h_div_dt = h / dt;
  109432. var interpvelo = step_tmp1;
  109433. var bodies = this.bodies;
  109434. for (var j = 0; j !== bodies.length; j++) {
  109435. var b = bodies[j];
  109436. if (b.type !== Engine.Body.STATIC && b.sleepState !== Engine.Body.SLEEPING) {
  109437. b.position.vsub(b.previousPosition, interpvelo);
  109438. interpvelo.scale(h_div_dt, interpvelo);
  109439. b.position.vadd(interpvelo, b.interpolatedPosition);
  109440. }
  109441. else {
  109442. b.interpolatedPosition.copy(b.position);
  109443. b.interpolatedQuaternion.copy(b.quaternion);
  109444. }
  109445. }
  109446. }
  109447. };
  109448. };
  109449. return CannonJSPlugin;
  109450. }());
  109451. _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].DefaultPluginFactory = function () { return new CannonJSPlugin(); };
  109452. /***/ }),
  109453. /***/ "./Physics/Plugins/index.ts":
  109454. /*!**********************************!*\
  109455. !*** ./Physics/Plugins/index.ts ***!
  109456. \**********************************/
  109457. /*! exports provided: CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  109458. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109459. "use strict";
  109460. __webpack_require__.r(__webpack_exports__);
  109461. /* harmony import */ var _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  109462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  109463. /* harmony import */ var _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  109464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__["AmmoJSPlugin"]; });
  109465. /* harmony import */ var _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  109466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__["OimoJSPlugin"]; });
  109467. /***/ }),
  109468. /***/ "./Physics/Plugins/oimoJSPlugin.ts":
  109469. /*!*****************************************!*\
  109470. !*** ./Physics/Plugins/oimoJSPlugin.ts ***!
  109471. \*****************************************/
  109472. /*! exports provided: OimoJSPlugin */
  109473. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109474. "use strict";
  109475. __webpack_require__.r(__webpack_exports__);
  109476. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return OimoJSPlugin; });
  109477. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  109478. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  109479. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  109480. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  109481. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  109482. /** @hidden */
  109483. var OimoJSPlugin = /** @class */ (function () {
  109484. function OimoJSPlugin(iterations, oimoInjection) {
  109485. if (oimoInjection === void 0) { oimoInjection = OIMO; }
  109486. this.name = "OimoJSPlugin";
  109487. this._tmpImpostorsArray = [];
  109488. this._tmpPositionVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  109489. this.BJSOIMO = oimoInjection;
  109490. this.world = new this.BJSOIMO.World({
  109491. iterations: iterations
  109492. });
  109493. this.world.clear();
  109494. }
  109495. OimoJSPlugin.prototype.setGravity = function (gravity) {
  109496. this.world.gravity.copy(gravity);
  109497. };
  109498. OimoJSPlugin.prototype.setTimeStep = function (timeStep) {
  109499. this.world.timeStep = timeStep;
  109500. };
  109501. OimoJSPlugin.prototype.getTimeStep = function () {
  109502. return this.world.timeStep;
  109503. };
  109504. OimoJSPlugin.prototype.executeStep = function (delta, impostors) {
  109505. var _this = this;
  109506. impostors.forEach(function (impostor) {
  109507. impostor.beforeStep();
  109508. });
  109509. this.world.step();
  109510. impostors.forEach(function (impostor) {
  109511. impostor.afterStep();
  109512. //update the ordered impostors array
  109513. _this._tmpImpostorsArray[impostor.uniqueId] = impostor;
  109514. });
  109515. //check for collisions
  109516. var contact = this.world.contacts;
  109517. while (contact !== null) {
  109518. if (contact.touching && !contact.body1.sleeping && !contact.body2.sleeping) {
  109519. contact = contact.next;
  109520. continue;
  109521. }
  109522. //is this body colliding with any other? get the impostor
  109523. var mainImpostor = this._tmpImpostorsArray[+contact.body1.name];
  109524. var collidingImpostor = this._tmpImpostorsArray[+contact.body2.name];
  109525. if (!mainImpostor || !collidingImpostor) {
  109526. contact = contact.next;
  109527. continue;
  109528. }
  109529. mainImpostor.onCollide({ body: collidingImpostor.physicsBody });
  109530. collidingImpostor.onCollide({ body: mainImpostor.physicsBody });
  109531. contact = contact.next;
  109532. }
  109533. };
  109534. OimoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  109535. var mass = impostor.physicsBody.mass;
  109536. impostor.physicsBody.applyImpulse(contactPoint.scale(this.world.invScale), force.scale(this.world.invScale * mass));
  109537. };
  109538. OimoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  109539. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("Oimo doesn't support applying force. Using impule instead.");
  109540. this.applyImpulse(impostor, force, contactPoint);
  109541. };
  109542. OimoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  109543. var _this = this;
  109544. //parent-child relationship. Does this impostor has a parent impostor?
  109545. if (impostor.parent) {
  109546. if (impostor.physicsBody) {
  109547. this.removePhysicsBody(impostor);
  109548. //TODO is that needed?
  109549. impostor.forceUpdate();
  109550. }
  109551. return;
  109552. }
  109553. if (impostor.isBodyInitRequired()) {
  109554. var bodyConfig = {
  109555. name: impostor.uniqueId,
  109556. //Oimo must have mass, also for static objects.
  109557. config: [impostor.getParam("mass") || 1, impostor.getParam("friction"), impostor.getParam("restitution")],
  109558. size: [],
  109559. type: [],
  109560. pos: [],
  109561. posShape: [],
  109562. rot: [],
  109563. rotShape: [],
  109564. move: impostor.getParam("mass") !== 0,
  109565. density: impostor.getParam("mass"),
  109566. friction: impostor.getParam("friction"),
  109567. restitution: impostor.getParam("restitution"),
  109568. //Supporting older versions of Oimo
  109569. world: this.world
  109570. };
  109571. var impostors = [impostor];
  109572. var addToArray = function (parent) {
  109573. if (!parent.getChildMeshes) {
  109574. return;
  109575. }
  109576. parent.getChildMeshes().forEach(function (m) {
  109577. if (m.physicsImpostor) {
  109578. impostors.push(m.physicsImpostor);
  109579. //m.physicsImpostor._init();
  109580. }
  109581. });
  109582. };
  109583. addToArray(impostor.object);
  109584. var checkWithEpsilon_1 = function (value) {
  109585. return Math.max(value, _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__["PhysicsEngine"].Epsilon);
  109586. };
  109587. var globalQuaternion_1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  109588. impostors.forEach(function (i) {
  109589. if (!i.object.rotationQuaternion) {
  109590. return;
  109591. }
  109592. //get the correct bounding box
  109593. var oldQuaternion = i.object.rotationQuaternion;
  109594. globalQuaternion_1 = oldQuaternion.clone();
  109595. var rot = oldQuaternion.toEulerAngles();
  109596. var extendSize = i.getObjectExtendSize();
  109597. var radToDeg = 57.295779513082320876;
  109598. if (i === impostor) {
  109599. var center = impostor.getObjectCenter();
  109600. impostor.object.getAbsolutePivotPoint().subtractToRef(center, _this._tmpPositionVector);
  109601. _this._tmpPositionVector.divideInPlace(impostor.object.scaling);
  109602. //Can also use Array.prototype.push.apply
  109603. bodyConfig.pos.push(center.x);
  109604. bodyConfig.pos.push(center.y);
  109605. bodyConfig.pos.push(center.z);
  109606. bodyConfig.posShape.push(0, 0, 0);
  109607. bodyConfig.rotShape.push(0, 0, 0);
  109608. }
  109609. else {
  109610. var localPosition = i.object.getAbsolutePosition().subtract(impostor.object.getAbsolutePosition());
  109611. bodyConfig.posShape.push(localPosition.x);
  109612. bodyConfig.posShape.push(localPosition.y);
  109613. bodyConfig.posShape.push(localPosition.z);
  109614. bodyConfig.pos.push(0, 0, 0);
  109615. bodyConfig.rotShape.push(rot.x * radToDeg);
  109616. bodyConfig.rotShape.push(rot.y * radToDeg);
  109617. bodyConfig.rotShape.push(rot.z * radToDeg);
  109618. }
  109619. // register mesh
  109620. switch (i.type) {
  109621. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].ParticleImpostor:
  109622. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("No Particle support in OIMO.js. using SphereImpostor instead");
  109623. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].SphereImpostor:
  109624. var radiusX = extendSize.x;
  109625. var radiusY = extendSize.y;
  109626. var radiusZ = extendSize.z;
  109627. var size = Math.max(checkWithEpsilon_1(radiusX), checkWithEpsilon_1(radiusY), checkWithEpsilon_1(radiusZ)) / 2;
  109628. bodyConfig.type.push('sphere');
  109629. //due to the way oimo works with compounds, add 3 times
  109630. bodyConfig.size.push(size);
  109631. bodyConfig.size.push(size);
  109632. bodyConfig.size.push(size);
  109633. break;
  109634. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].CylinderImpostor:
  109635. var sizeX = checkWithEpsilon_1(extendSize.x) / 2;
  109636. var sizeY = checkWithEpsilon_1(extendSize.y);
  109637. bodyConfig.type.push('cylinder');
  109638. bodyConfig.size.push(sizeX);
  109639. bodyConfig.size.push(sizeY);
  109640. //due to the way oimo works with compounds, add one more value.
  109641. bodyConfig.size.push(sizeY);
  109642. break;
  109643. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].PlaneImpostor:
  109644. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].BoxImpostor:
  109645. default:
  109646. var sizeX = checkWithEpsilon_1(extendSize.x);
  109647. var sizeY = checkWithEpsilon_1(extendSize.y);
  109648. var sizeZ = checkWithEpsilon_1(extendSize.z);
  109649. bodyConfig.type.push('box');
  109650. //if (i === impostor) {
  109651. bodyConfig.size.push(sizeX);
  109652. bodyConfig.size.push(sizeY);
  109653. bodyConfig.size.push(sizeZ);
  109654. //} else {
  109655. // bodyConfig.size.push(0,0,0);
  109656. //}
  109657. break;
  109658. }
  109659. //actually not needed, but hey...
  109660. i.object.rotationQuaternion = oldQuaternion;
  109661. });
  109662. impostor.physicsBody = this.world.add(bodyConfig);
  109663. // set the quaternion, ignoring the previously defined (euler) rotation
  109664. impostor.physicsBody.resetQuaternion(globalQuaternion_1);
  109665. // update with delta 0, so the body will reveive the new rotation.
  109666. impostor.physicsBody.updatePosition(0);
  109667. }
  109668. else {
  109669. this._tmpPositionVector.copyFromFloats(0, 0, 0);
  109670. }
  109671. impostor.setDeltaPosition(this._tmpPositionVector);
  109672. //this._tmpPositionVector.addInPlace(impostor.mesh.getBoundingInfo().boundingBox.center);
  109673. //this.setPhysicsBodyTransformation(impostor, this._tmpPositionVector, impostor.mesh.rotationQuaternion);
  109674. };
  109675. OimoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  109676. //impostor.physicsBody.dispose();
  109677. //Same as : (older oimo versions)
  109678. this.world.removeRigidBody(impostor.physicsBody);
  109679. };
  109680. OimoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  109681. var mainBody = impostorJoint.mainImpostor.physicsBody;
  109682. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  109683. if (!mainBody || !connectedBody) {
  109684. return;
  109685. }
  109686. var jointData = impostorJoint.joint.jointData;
  109687. var options = jointData.nativeParams || {};
  109688. var type;
  109689. var nativeJointData = {
  109690. body1: mainBody,
  109691. body2: connectedBody,
  109692. axe1: options.axe1 || (jointData.mainAxis ? jointData.mainAxis.asArray() : null),
  109693. axe2: options.axe2 || (jointData.connectedAxis ? jointData.connectedAxis.asArray() : null),
  109694. pos1: options.pos1 || (jointData.mainPivot ? jointData.mainPivot.asArray() : null),
  109695. pos2: options.pos2 || (jointData.connectedPivot ? jointData.connectedPivot.asArray() : null),
  109696. min: options.min,
  109697. max: options.max,
  109698. collision: options.collision || jointData.collision,
  109699. spring: options.spring,
  109700. //supporting older version of Oimo
  109701. world: this.world
  109702. };
  109703. switch (impostorJoint.joint.type) {
  109704. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].BallAndSocketJoint:
  109705. type = "jointBall";
  109706. break;
  109707. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SpringJoint:
  109708. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
  109709. var springData = jointData;
  109710. nativeJointData.min = springData.length || nativeJointData.min;
  109711. //Max should also be set, just make sure it is at least min
  109712. nativeJointData.max = Math.max(nativeJointData.min, nativeJointData.max);
  109713. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].DistanceJoint:
  109714. type = "jointDistance";
  109715. nativeJointData.max = jointData.maxDistance;
  109716. break;
  109717. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].PrismaticJoint:
  109718. type = "jointPrisme";
  109719. break;
  109720. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SliderJoint:
  109721. type = "jointSlide";
  109722. break;
  109723. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].WheelJoint:
  109724. type = "jointWheel";
  109725. break;
  109726. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].HingeJoint:
  109727. default:
  109728. type = "jointHinge";
  109729. break;
  109730. }
  109731. nativeJointData.type = type;
  109732. impostorJoint.joint.physicsJoint = this.world.add(nativeJointData);
  109733. };
  109734. OimoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  109735. //Bug in Oimo prevents us from disposing a joint in the playground
  109736. //joint.joint.physicsJoint.dispose();
  109737. //So we will bruteforce it!
  109738. try {
  109739. this.world.removeJoint(impostorJoint.joint.physicsJoint);
  109740. }
  109741. catch (e) {
  109742. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn(e);
  109743. }
  109744. };
  109745. OimoJSPlugin.prototype.isSupported = function () {
  109746. return this.BJSOIMO !== undefined;
  109747. };
  109748. OimoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  109749. if (!impostor.physicsBody.sleeping) {
  109750. //TODO check that
  109751. /*if (impostor.physicsBody.shapes.next) {
  109752. var parentShape = this._getLastShape(impostor.physicsBody);
  109753. impostor.object.position.copyFrom(parentShape.position);
  109754. console.log(parentShape.position);
  109755. } else {*/
  109756. impostor.object.position.copyFrom(impostor.physicsBody.getPosition());
  109757. //}
  109758. if (impostor.object.rotationQuaternion) {
  109759. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.getQuaternion());
  109760. }
  109761. }
  109762. };
  109763. OimoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  109764. var body = impostor.physicsBody;
  109765. body.position.copy(newPosition);
  109766. body.orientation.copy(newRotation);
  109767. body.syncShapes();
  109768. body.awake();
  109769. };
  109770. /*private _getLastShape(body: any): any {
  109771. var lastShape = body.shapes;
  109772. while (lastShape.next) {
  109773. lastShape = lastShape.next;
  109774. }
  109775. return lastShape;
  109776. }*/
  109777. OimoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  109778. impostor.physicsBody.linearVelocity.copy(velocity);
  109779. };
  109780. OimoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  109781. impostor.physicsBody.angularVelocity.copy(velocity);
  109782. };
  109783. OimoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  109784. var v = impostor.physicsBody.linearVelocity;
  109785. if (!v) {
  109786. return null;
  109787. }
  109788. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  109789. };
  109790. OimoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  109791. var v = impostor.physicsBody.angularVelocity;
  109792. if (!v) {
  109793. return null;
  109794. }
  109795. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  109796. };
  109797. OimoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  109798. var staticBody = mass === 0;
  109799. //this will actually set the body's density and not its mass.
  109800. //But this is how oimo treats the mass variable.
  109801. impostor.physicsBody.shapes.density = staticBody ? 1 : mass;
  109802. impostor.physicsBody.setupMass(staticBody ? 0x2 : 0x1);
  109803. };
  109804. OimoJSPlugin.prototype.getBodyMass = function (impostor) {
  109805. return impostor.physicsBody.shapes.density;
  109806. };
  109807. OimoJSPlugin.prototype.getBodyFriction = function (impostor) {
  109808. return impostor.physicsBody.shapes.friction;
  109809. };
  109810. OimoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  109811. impostor.physicsBody.shapes.friction = friction;
  109812. };
  109813. OimoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  109814. return impostor.physicsBody.shapes.restitution;
  109815. };
  109816. OimoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  109817. impostor.physicsBody.shapes.restitution = restitution;
  109818. };
  109819. OimoJSPlugin.prototype.sleepBody = function (impostor) {
  109820. impostor.physicsBody.sleep();
  109821. };
  109822. OimoJSPlugin.prototype.wakeUpBody = function (impostor) {
  109823. impostor.physicsBody.awake();
  109824. };
  109825. OimoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  109826. joint.physicsJoint.limitMotor.upperLimit = maxDistance;
  109827. if (minDistance !== void 0) {
  109828. joint.physicsJoint.limitMotor.lowerLimit = minDistance;
  109829. }
  109830. };
  109831. OimoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  109832. //TODO separate rotational and transational motors.
  109833. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  109834. if (motor) {
  109835. motor.setMotor(speed, maxForce);
  109836. }
  109837. };
  109838. OimoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit, motorIndex) {
  109839. //TODO separate rotational and transational motors.
  109840. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  109841. if (motor) {
  109842. motor.setLimit(upperLimit, lowerLimit === void 0 ? -upperLimit : lowerLimit);
  109843. }
  109844. };
  109845. OimoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  109846. var body = impostor.physicsBody;
  109847. mesh.position.x = body.position.x;
  109848. mesh.position.y = body.position.y;
  109849. mesh.position.z = body.position.z;
  109850. if (mesh.rotationQuaternion) {
  109851. mesh.rotationQuaternion.x = body.orientation.x;
  109852. mesh.rotationQuaternion.y = body.orientation.y;
  109853. mesh.rotationQuaternion.z = body.orientation.z;
  109854. mesh.rotationQuaternion.w = body.orientation.s;
  109855. }
  109856. };
  109857. OimoJSPlugin.prototype.getRadius = function (impostor) {
  109858. return impostor.physicsBody.shapes.radius;
  109859. };
  109860. OimoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  109861. var shape = impostor.physicsBody.shapes;
  109862. result.x = shape.halfWidth * 2;
  109863. result.y = shape.halfHeight * 2;
  109864. result.z = shape.halfDepth * 2;
  109865. };
  109866. OimoJSPlugin.prototype.dispose = function () {
  109867. this.world.clear();
  109868. };
  109869. return OimoJSPlugin;
  109870. }());
  109871. /***/ }),
  109872. /***/ "./Physics/index.ts":
  109873. /*!**************************!*\
  109874. !*** ./Physics/index.ts ***!
  109875. \**************************/
  109876. /*! exports provided: PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  109877. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109878. "use strict";
  109879. __webpack_require__.r(__webpack_exports__);
  109880. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  109881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _physicsEngine__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  109882. /* harmony import */ var _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./physicsEngineComponent */ "./Physics/physicsEngineComponent.ts");
  109883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__["PhysicsEngineSceneComponent"]; });
  109884. /* harmony import */ var _physicsHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./physicsHelper */ "./Physics/physicsHelper.ts");
  109885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsHelper"]; });
  109886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialExplosionEvent"]; });
  109887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsGravitationalFieldEvent"]; });
  109888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftEvent"]; });
  109889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsVortexEvent"]; });
  109890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialImpulseFalloff"]; });
  109891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftMode"]; });
  109892. /* harmony import */ var _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsImpostor */ "./Physics/physicsImpostor.ts");
  109893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"]; });
  109894. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  109895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"]; });
  109896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["DistanceJoint"]; });
  109897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["MotorEnabledJoint"]; });
  109898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["HingeJoint"]; });
  109899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["Hinge2Joint"]; });
  109900. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Plugins/index */ "./Physics/Plugins/index.ts");
  109901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["CannonJSPlugin"]; });
  109902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["AmmoJSPlugin"]; });
  109903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["OimoJSPlugin"]; });
  109904. /***/ }),
  109905. /***/ "./Physics/physicsEngine.ts":
  109906. /*!**********************************!*\
  109907. !*** ./Physics/physicsEngine.ts ***!
  109908. \**********************************/
  109909. /*! exports provided: PhysicsEngine */
  109910. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109911. "use strict";
  109912. __webpack_require__.r(__webpack_exports__);
  109913. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return PhysicsEngine; });
  109914. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  109915. /**
  109916. * Class used to control physics engine
  109917. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  109918. */
  109919. var PhysicsEngine = /** @class */ (function () {
  109920. /**
  109921. * Creates a new Physics Engine
  109922. * @param gravity defines the gravity vector used by the simulation
  109923. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  109924. */
  109925. function PhysicsEngine(gravity, _physicsPlugin) {
  109926. if (_physicsPlugin === void 0) { _physicsPlugin = PhysicsEngine.DefaultPluginFactory(); }
  109927. this._physicsPlugin = _physicsPlugin;
  109928. this._impostors = [];
  109929. this._joints = [];
  109930. if (!this._physicsPlugin.isSupported()) {
  109931. throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. "
  109932. + "Please make sure it is included.");
  109933. }
  109934. gravity = gravity || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -9.807, 0);
  109935. this.setGravity(gravity);
  109936. this.setTimeStep();
  109937. }
  109938. /**
  109939. * Factory used to create the default physics plugin.
  109940. * @returns The default physics plugin
  109941. */
  109942. PhysicsEngine.DefaultPluginFactory = function () {
  109943. throw "Import CannonJSPlugin or Fill DefaultPluginFactory static property on PhysicsEngine before relying on default physics plugin.";
  109944. };
  109945. /**
  109946. * Sets the gravity vector used by the simulation
  109947. * @param gravity defines the gravity vector to use
  109948. */
  109949. PhysicsEngine.prototype.setGravity = function (gravity) {
  109950. this.gravity = gravity;
  109951. this._physicsPlugin.setGravity(this.gravity);
  109952. };
  109953. /**
  109954. * Set the time step of the physics engine.
  109955. * Default is 1/60.
  109956. * To slow it down, enter 1/600 for example.
  109957. * To speed it up, 1/30
  109958. * @param newTimeStep defines the new timestep to apply to this world.
  109959. */
  109960. PhysicsEngine.prototype.setTimeStep = function (newTimeStep) {
  109961. if (newTimeStep === void 0) { newTimeStep = 1 / 60; }
  109962. this._physicsPlugin.setTimeStep(newTimeStep);
  109963. };
  109964. /**
  109965. * Get the time step of the physics engine.
  109966. * @returns the current time step
  109967. */
  109968. PhysicsEngine.prototype.getTimeStep = function () {
  109969. return this._physicsPlugin.getTimeStep();
  109970. };
  109971. /**
  109972. * Release all resources
  109973. */
  109974. PhysicsEngine.prototype.dispose = function () {
  109975. this._impostors.forEach(function (impostor) {
  109976. impostor.dispose();
  109977. });
  109978. this._physicsPlugin.dispose();
  109979. };
  109980. /**
  109981. * Gets the name of the current physics plugin
  109982. * @returns the name of the plugin
  109983. */
  109984. PhysicsEngine.prototype.getPhysicsPluginName = function () {
  109985. return this._physicsPlugin.name;
  109986. };
  109987. /**
  109988. * Adding a new impostor for the impostor tracking.
  109989. * This will be done by the impostor itself.
  109990. * @param impostor the impostor to add
  109991. */
  109992. PhysicsEngine.prototype.addImpostor = function (impostor) {
  109993. impostor.uniqueId = this._impostors.push(impostor);
  109994. //if no parent, generate the body
  109995. if (!impostor.parent) {
  109996. this._physicsPlugin.generatePhysicsBody(impostor);
  109997. }
  109998. };
  109999. /**
  110000. * Remove an impostor from the engine.
  110001. * This impostor and its mesh will not longer be updated by the physics engine.
  110002. * @param impostor the impostor to remove
  110003. */
  110004. PhysicsEngine.prototype.removeImpostor = function (impostor) {
  110005. var index = this._impostors.indexOf(impostor);
  110006. if (index > -1) {
  110007. var removed = this._impostors.splice(index, 1);
  110008. //Is it needed?
  110009. if (removed.length) {
  110010. //this will also remove it from the world.
  110011. removed[0].physicsBody = null;
  110012. }
  110013. }
  110014. };
  110015. /**
  110016. * Add a joint to the physics engine
  110017. * @param mainImpostor defines the main impostor to which the joint is added.
  110018. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  110019. * @param joint defines the joint that will connect both impostors.
  110020. */
  110021. PhysicsEngine.prototype.addJoint = function (mainImpostor, connectedImpostor, joint) {
  110022. var impostorJoint = {
  110023. mainImpostor: mainImpostor,
  110024. connectedImpostor: connectedImpostor,
  110025. joint: joint
  110026. };
  110027. joint.physicsPlugin = this._physicsPlugin;
  110028. this._joints.push(impostorJoint);
  110029. this._physicsPlugin.generateJoint(impostorJoint);
  110030. };
  110031. /**
  110032. * Removes a joint from the simulation
  110033. * @param mainImpostor defines the impostor used with the joint
  110034. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  110035. * @param joint defines the joint to remove
  110036. */
  110037. PhysicsEngine.prototype.removeJoint = function (mainImpostor, connectedImpostor, joint) {
  110038. var matchingJoints = this._joints.filter(function (impostorJoint) {
  110039. return (impostorJoint.connectedImpostor === connectedImpostor
  110040. && impostorJoint.joint === joint
  110041. && impostorJoint.mainImpostor === mainImpostor);
  110042. });
  110043. if (matchingJoints.length) {
  110044. this._physicsPlugin.removeJoint(matchingJoints[0]);
  110045. //TODO remove it from the list as well
  110046. }
  110047. };
  110048. /**
  110049. * Called by the scene. No need to call it.
  110050. * @param delta defines the timespam between frames
  110051. */
  110052. PhysicsEngine.prototype._step = function (delta) {
  110053. var _this = this;
  110054. //check if any mesh has no body / requires an update
  110055. this._impostors.forEach(function (impostor) {
  110056. if (impostor.isBodyInitRequired()) {
  110057. _this._physicsPlugin.generatePhysicsBody(impostor);
  110058. }
  110059. });
  110060. if (delta > 0.1) {
  110061. delta = 0.1;
  110062. }
  110063. else if (delta <= 0) {
  110064. delta = 1.0 / 60.0;
  110065. }
  110066. this._physicsPlugin.executeStep(delta, this._impostors);
  110067. };
  110068. /**
  110069. * Gets the current plugin used to run the simulation
  110070. * @returns current plugin
  110071. */
  110072. PhysicsEngine.prototype.getPhysicsPlugin = function () {
  110073. return this._physicsPlugin;
  110074. };
  110075. /**
  110076. * Gets the list of physic impostors
  110077. * @returns an array of PhysicsImpostor
  110078. */
  110079. PhysicsEngine.prototype.getImpostors = function () {
  110080. return this._impostors;
  110081. };
  110082. /**
  110083. * Gets the impostor for a physics enabled object
  110084. * @param object defines the object impersonated by the impostor
  110085. * @returns the PhysicsImpostor or null if not found
  110086. */
  110087. PhysicsEngine.prototype.getImpostorForPhysicsObject = function (object) {
  110088. for (var i = 0; i < this._impostors.length; ++i) {
  110089. if (this._impostors[i].object === object) {
  110090. return this._impostors[i];
  110091. }
  110092. }
  110093. return null;
  110094. };
  110095. /**
  110096. * Gets the impostor for a physics body object
  110097. * @param body defines physics body used by the impostor
  110098. * @returns the PhysicsImpostor or null if not found
  110099. */
  110100. PhysicsEngine.prototype.getImpostorWithPhysicsBody = function (body) {
  110101. for (var i = 0; i < this._impostors.length; ++i) {
  110102. if (this._impostors[i].physicsBody === body) {
  110103. return this._impostors[i];
  110104. }
  110105. }
  110106. return null;
  110107. };
  110108. /**
  110109. * Global value used to control the smallest number supported by the simulation
  110110. */
  110111. PhysicsEngine.Epsilon = 0.001;
  110112. return PhysicsEngine;
  110113. }());
  110114. /***/ }),
  110115. /***/ "./Physics/physicsEngineComponent.ts":
  110116. /*!*******************************************!*\
  110117. !*** ./Physics/physicsEngineComponent.ts ***!
  110118. \*******************************************/
  110119. /*! exports provided: PhysicsEngineSceneComponent */
  110120. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110121. "use strict";
  110122. __webpack_require__.r(__webpack_exports__);
  110123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return PhysicsEngineSceneComponent; });
  110124. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  110125. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  110126. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  110127. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  110128. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  110129. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  110130. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  110131. /**
  110132. * Gets the current physics engine
  110133. * @returns a IPhysicsEngine or null if none attached
  110134. */
  110135. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.getPhysicsEngine = function () {
  110136. return this._physicsEngine;
  110137. };
  110138. /**
  110139. * Enables physics to the current scene
  110140. * @param gravity defines the scene's gravity for the physics engine
  110141. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  110142. * @return a boolean indicating if the physics engine was initialized
  110143. */
  110144. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.enablePhysics = function (gravity, plugin) {
  110145. if (gravity === void 0) { gravity = null; }
  110146. if (this._physicsEngine) {
  110147. return true;
  110148. }
  110149. // Register the component to the scene
  110150. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE);
  110151. if (!component) {
  110152. component = new PhysicsEngineSceneComponent(this);
  110153. this._addComponent(component);
  110154. }
  110155. try {
  110156. this._physicsEngine = new _physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"](gravity, plugin);
  110157. return true;
  110158. }
  110159. catch (e) {
  110160. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error(e.message);
  110161. return false;
  110162. }
  110163. };
  110164. /**
  110165. * Disables and disposes the physics engine associated with the scene
  110166. */
  110167. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.disablePhysicsEngine = function () {
  110168. if (!this._physicsEngine) {
  110169. return;
  110170. }
  110171. this._physicsEngine.dispose();
  110172. this._physicsEngine = null;
  110173. };
  110174. /**
  110175. * Gets a boolean indicating if there is an active physics engine
  110176. * @returns a boolean indicating if there is an active physics engine
  110177. */
  110178. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.isPhysicsEnabled = function () {
  110179. return this._physicsEngine !== undefined;
  110180. };
  110181. /**
  110182. * Deletes a physics compound impostor
  110183. * @param compound defines the compound to delete
  110184. */
  110185. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.deleteCompoundImpostor = function (compound) {
  110186. var mesh = compound.parts[0].mesh;
  110187. if (mesh.physicsImpostor) {
  110188. mesh.physicsImpostor.dispose( /*true*/);
  110189. mesh.physicsImpostor = null;
  110190. }
  110191. };
  110192. /** @hidden */
  110193. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._advancePhysicsEngineStep = function (step) {
  110194. if (this._physicsEngine) {
  110195. this.onBeforePhysicsObservable.notifyObservers(this);
  110196. this._physicsEngine._step(step / 1000);
  110197. this.onAfterPhysicsObservable.notifyObservers(this);
  110198. }
  110199. };
  110200. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "physicsImpostor", {
  110201. get: function () {
  110202. return this._physicsImpostor;
  110203. },
  110204. set: function (value) {
  110205. var _this = this;
  110206. if (this._physicsImpostor === value) {
  110207. return;
  110208. }
  110209. if (this._disposePhysicsObserver) {
  110210. this.onDisposeObservable.remove(this._disposePhysicsObserver);
  110211. }
  110212. this._physicsImpostor = value;
  110213. if (value) {
  110214. this._disposePhysicsObserver = this.onDisposeObservable.add(function () {
  110215. // Physics
  110216. if (_this.physicsImpostor) {
  110217. _this.physicsImpostor.dispose( /*!doNotRecurse*/);
  110218. _this.physicsImpostor = null;
  110219. }
  110220. });
  110221. }
  110222. },
  110223. enumerable: true,
  110224. configurable: true
  110225. });
  110226. /**
  110227. * Gets the current physics impostor
  110228. * @see http://doc.babylonjs.com/features/physics_engine
  110229. * @returns a physics impostor or null
  110230. */
  110231. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.getPhysicsImpostor = function () {
  110232. return this.physicsImpostor;
  110233. };
  110234. /**
  110235. * Apply a physic impulse to the mesh
  110236. * @param force defines the force to apply
  110237. * @param contactPoint defines where to apply the force
  110238. * @returns the current mesh
  110239. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  110240. */
  110241. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.applyImpulse = function (force, contactPoint) {
  110242. if (!this.physicsImpostor) {
  110243. return this;
  110244. }
  110245. this.physicsImpostor.applyImpulse(force, contactPoint);
  110246. return this;
  110247. };
  110248. /**
  110249. * Creates a physic joint between two meshes
  110250. * @param otherMesh defines the other mesh to use
  110251. * @param pivot1 defines the pivot to use on this mesh
  110252. * @param pivot2 defines the pivot to use on the other mesh
  110253. * @param options defines additional options (can be plugin dependent)
  110254. * @returns the current mesh
  110255. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  110256. */
  110257. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.setPhysicsLinkWith = function (otherMesh, pivot1, pivot2, options) {
  110258. if (!this.physicsImpostor || !otherMesh.physicsImpostor) {
  110259. return this;
  110260. }
  110261. this.physicsImpostor.createJoint(otherMesh.physicsImpostor, _physicsJoint__WEBPACK_IMPORTED_MODULE_6__["PhysicsJoint"].HingeJoint, {
  110262. mainPivot: pivot1,
  110263. connectedPivot: pivot2,
  110264. nativeParams: options
  110265. });
  110266. return this;
  110267. };
  110268. /**
  110269. * Defines the physics engine scene component responsible to manage a physics engine
  110270. */
  110271. var PhysicsEngineSceneComponent = /** @class */ (function () {
  110272. /**
  110273. * Creates a new instance of the component for the given scene
  110274. * @param scene Defines the scene to register the component in
  110275. */
  110276. function PhysicsEngineSceneComponent(scene) {
  110277. var _this = this;
  110278. /**
  110279. * The component name helpful to identify the component in the list of scene components.
  110280. */
  110281. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE;
  110282. this.scene = scene;
  110283. this.scene.onBeforePhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  110284. this.scene.onAfterPhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  110285. // Replace the function used to get the deterministic frame time
  110286. this.scene.getDeterministicFrameTime = function () {
  110287. if (_this.scene._physicsEngine) {
  110288. return _this.scene._physicsEngine.getTimeStep() * 1000;
  110289. }
  110290. return 1000.0 / 60.0;
  110291. };
  110292. }
  110293. /**
  110294. * Registers the component in a given scene
  110295. */
  110296. PhysicsEngineSceneComponent.prototype.register = function () {
  110297. };
  110298. /**
  110299. * Rebuilds the elements related to this component in case of
  110300. * context lost for instance.
  110301. */
  110302. PhysicsEngineSceneComponent.prototype.rebuild = function () {
  110303. // Nothing to do for this component
  110304. };
  110305. /**
  110306. * Disposes the component and the associated ressources
  110307. */
  110308. PhysicsEngineSceneComponent.prototype.dispose = function () {
  110309. this.scene.onBeforePhysicsObservable.clear();
  110310. this.scene.onAfterPhysicsObservable.clear();
  110311. if (this.scene._physicsEngine) {
  110312. this.scene.disablePhysicsEngine();
  110313. }
  110314. };
  110315. return PhysicsEngineSceneComponent;
  110316. }());
  110317. /***/ }),
  110318. /***/ "./Physics/physicsHelper.ts":
  110319. /*!**********************************!*\
  110320. !*** ./Physics/physicsHelper.ts ***!
  110321. \**********************************/
  110322. /*! exports provided: PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode */
  110323. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110324. "use strict";
  110325. __webpack_require__.r(__webpack_exports__);
  110326. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return PhysicsHelper; });
  110327. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return PhysicsRadialExplosionEvent; });
  110328. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return PhysicsGravitationalFieldEvent; });
  110329. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return PhysicsUpdraftEvent; });
  110330. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return PhysicsVortexEvent; });
  110331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return PhysicsRadialImpulseFalloff; });
  110332. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return PhysicsUpdraftMode; });
  110333. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  110334. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  110335. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  110336. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  110337. /**
  110338. * A helper for physics simulations
  110339. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110340. */
  110341. var PhysicsHelper = /** @class */ (function () {
  110342. /**
  110343. * Initializes the Physics helper
  110344. * @param scene Babylon.js scene
  110345. */
  110346. function PhysicsHelper(scene) {
  110347. this._scene = scene;
  110348. this._physicsEngine = this._scene.getPhysicsEngine();
  110349. if (!this._physicsEngine) {
  110350. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you can use the methods.');
  110351. }
  110352. }
  110353. /**
  110354. * Applies a radial explosion impulse
  110355. * @param origin the origin of the explosion
  110356. * @param radius the explosion radius
  110357. * @param strength the explosion strength
  110358. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110359. * @returns A physics radial explosion event, or null
  110360. */
  110361. PhysicsHelper.prototype.applyRadialExplosionImpulse = function (origin, radius, strength, falloff) {
  110362. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  110363. if (!this._physicsEngine) {
  110364. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call this method.');
  110365. return null;
  110366. }
  110367. var impostors = this._physicsEngine.getImpostors();
  110368. if (impostors.length === 0) {
  110369. return null;
  110370. }
  110371. var event = new PhysicsRadialExplosionEvent(this._scene);
  110372. impostors.forEach(function (impostor) {
  110373. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin, radius, strength, falloff);
  110374. if (!impostorForceAndContactPoint) {
  110375. return;
  110376. }
  110377. impostor.applyImpulse(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  110378. });
  110379. event.dispose(false);
  110380. return event;
  110381. };
  110382. /**
  110383. * Applies a radial explosion force
  110384. * @param origin the origin of the explosion
  110385. * @param radius the explosion radius
  110386. * @param strength the explosion strength
  110387. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110388. * @returns A physics radial explosion event, or null
  110389. */
  110390. PhysicsHelper.prototype.applyRadialExplosionForce = function (origin, radius, strength, falloff) {
  110391. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  110392. if (!this._physicsEngine) {
  110393. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  110394. return null;
  110395. }
  110396. var impostors = this._physicsEngine.getImpostors();
  110397. if (impostors.length === 0) {
  110398. return null;
  110399. }
  110400. var event = new PhysicsRadialExplosionEvent(this._scene);
  110401. impostors.forEach(function (impostor) {
  110402. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin, radius, strength, falloff);
  110403. if (!impostorForceAndContactPoint) {
  110404. return;
  110405. }
  110406. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  110407. });
  110408. event.dispose(false);
  110409. return event;
  110410. };
  110411. /**
  110412. * Creates a gravitational field
  110413. * @param origin the origin of the explosion
  110414. * @param radius the explosion radius
  110415. * @param strength the explosion strength
  110416. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110417. * @returns A physics gravitational field event, or null
  110418. */
  110419. PhysicsHelper.prototype.gravitationalField = function (origin, radius, strength, falloff) {
  110420. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  110421. if (!this._physicsEngine) {
  110422. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  110423. return null;
  110424. }
  110425. var impostors = this._physicsEngine.getImpostors();
  110426. if (impostors.length === 0) {
  110427. return null;
  110428. }
  110429. var event = new PhysicsGravitationalFieldEvent(this, this._scene, origin, radius, strength, falloff);
  110430. event.dispose(false);
  110431. return event;
  110432. };
  110433. /**
  110434. * Creates a physics updraft event
  110435. * @param origin the origin of the updraft
  110436. * @param radius the radius of the updraft
  110437. * @param strength the strength of the updraft
  110438. * @param height the height of the updraft
  110439. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  110440. * @returns A physics updraft event, or null
  110441. */
  110442. PhysicsHelper.prototype.updraft = function (origin, radius, strength, height, updraftMode) {
  110443. if (updraftMode === void 0) { updraftMode = PhysicsUpdraftMode.Center; }
  110444. if (!this._physicsEngine) {
  110445. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  110446. return null;
  110447. }
  110448. if (this._physicsEngine.getImpostors().length === 0) {
  110449. return null;
  110450. }
  110451. var event = new PhysicsUpdraftEvent(this._scene, origin, radius, strength, height, updraftMode);
  110452. event.dispose(false);
  110453. return event;
  110454. };
  110455. /**
  110456. * Creates a physics vortex event
  110457. * @param origin the of the vortex
  110458. * @param radius the radius of the vortex
  110459. * @param strength the strength of the vortex
  110460. * @param height the height of the vortex
  110461. * @returns a Physics vortex event, or null
  110462. * A physics vortex event or null
  110463. */
  110464. PhysicsHelper.prototype.vortex = function (origin, radius, strength, height) {
  110465. if (!this._physicsEngine) {
  110466. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  110467. return null;
  110468. }
  110469. if (this._physicsEngine.getImpostors().length === 0) {
  110470. return null;
  110471. }
  110472. var event = new PhysicsVortexEvent(this._scene, origin, radius, strength, height);
  110473. event.dispose(false);
  110474. return event;
  110475. };
  110476. return PhysicsHelper;
  110477. }());
  110478. /**
  110479. * Represents a physics radial explosion event
  110480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110481. */
  110482. var PhysicsRadialExplosionEvent = /** @class */ (function () {
  110483. /**
  110484. * Initializes a radial explosioin event
  110485. * @param scene BabylonJS scene
  110486. */
  110487. function PhysicsRadialExplosionEvent(scene) {
  110488. this._sphereOptions = { segments: 32, diameter: 1 }; // TODO: make configurable
  110489. this._rays = [];
  110490. this._dataFetched = false; // check if the data has been fetched. If not, do cleanup
  110491. this._scene = scene;
  110492. }
  110493. /**
  110494. * Returns the data related to the radial explosion event (sphere & rays).
  110495. * @returns The radial explosion event data
  110496. */
  110497. PhysicsRadialExplosionEvent.prototype.getData = function () {
  110498. this._dataFetched = true;
  110499. return {
  110500. sphere: this._sphere,
  110501. rays: this._rays,
  110502. };
  110503. };
  110504. /**
  110505. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  110506. * @param impostor A physics imposter
  110507. * @param origin the origin of the explosion
  110508. * @param radius the explosion radius
  110509. * @param strength the explosion strength
  110510. * @param falloff possible options: Constant & Linear
  110511. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  110512. */
  110513. PhysicsRadialExplosionEvent.prototype.getImpostorForceAndContactPoint = function (impostor, origin, radius, strength, falloff) {
  110514. if (impostor.mass === 0) {
  110515. return null;
  110516. }
  110517. if (!this._intersectsWithSphere(impostor, origin, radius)) {
  110518. return null;
  110519. }
  110520. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  110521. return null;
  110522. }
  110523. var impostorObjectCenter = impostor.getObjectCenter();
  110524. var direction = impostorObjectCenter.subtract(origin);
  110525. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](origin, direction, radius);
  110526. this._rays.push(ray);
  110527. var hit = ray.intersectsMesh(impostor.object);
  110528. var contactPoint = hit.pickedPoint;
  110529. if (!contactPoint) {
  110530. return null;
  110531. }
  110532. var distanceFromOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(origin, contactPoint);
  110533. if (distanceFromOrigin > radius) {
  110534. return null;
  110535. }
  110536. var multiplier = falloff === PhysicsRadialImpulseFalloff.Constant
  110537. ? strength
  110538. : strength * (1 - (distanceFromOrigin / radius));
  110539. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  110540. return { force: force, contactPoint: contactPoint };
  110541. };
  110542. /**
  110543. * Disposes the sphere.
  110544. * @param force Specifies if the sphere should be disposed by force
  110545. */
  110546. PhysicsRadialExplosionEvent.prototype.dispose = function (force) {
  110547. var _this = this;
  110548. if (force === void 0) { force = true; }
  110549. if (force) {
  110550. this._sphere.dispose();
  110551. }
  110552. else {
  110553. setTimeout(function () {
  110554. if (!_this._dataFetched) {
  110555. _this._sphere.dispose();
  110556. }
  110557. }, 0);
  110558. }
  110559. };
  110560. /*** Helpers ***/
  110561. PhysicsRadialExplosionEvent.prototype._prepareSphere = function () {
  110562. if (!this._sphere) {
  110563. this._sphere = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_2__["MeshBuilder"].CreateSphere("radialExplosionEventSphere", this._sphereOptions, this._scene);
  110564. this._sphere.isVisible = false;
  110565. }
  110566. };
  110567. PhysicsRadialExplosionEvent.prototype._intersectsWithSphere = function (impostor, origin, radius) {
  110568. var impostorObject = impostor.object;
  110569. this._prepareSphere();
  110570. this._sphere.position = origin;
  110571. this._sphere.scaling = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](radius * 2, radius * 2, radius * 2);
  110572. this._sphere._updateBoundingInfo();
  110573. this._sphere.computeWorldMatrix(true);
  110574. return this._sphere.intersectsMesh(impostorObject, true);
  110575. };
  110576. return PhysicsRadialExplosionEvent;
  110577. }());
  110578. /**
  110579. * Represents a gravitational field event
  110580. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110581. */
  110582. var PhysicsGravitationalFieldEvent = /** @class */ (function () {
  110583. /**
  110584. * Initializes the physics gravitational field event
  110585. * @param physicsHelper A physics helper
  110586. * @param scene BabylonJS scene
  110587. * @param origin The origin position of the gravitational field event
  110588. * @param radius The radius of the gravitational field event
  110589. * @param strength The strength of the gravitational field event
  110590. * @param falloff The falloff for the gravitational field event
  110591. */
  110592. function PhysicsGravitationalFieldEvent(physicsHelper, scene, origin, radius, strength, falloff) {
  110593. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  110594. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  110595. this._physicsHelper = physicsHelper;
  110596. this._scene = scene;
  110597. this._origin = origin;
  110598. this._radius = radius;
  110599. this._strength = strength;
  110600. this._falloff = falloff;
  110601. this._tickCallback = this._tick.bind(this);
  110602. }
  110603. /**
  110604. * Returns the data related to the gravitational field event (sphere).
  110605. * @returns A gravitational field event
  110606. */
  110607. PhysicsGravitationalFieldEvent.prototype.getData = function () {
  110608. this._dataFetched = true;
  110609. return {
  110610. sphere: this._sphere,
  110611. };
  110612. };
  110613. /**
  110614. * Enables the gravitational field.
  110615. */
  110616. PhysicsGravitationalFieldEvent.prototype.enable = function () {
  110617. this._tickCallback.call(this);
  110618. this._scene.registerBeforeRender(this._tickCallback);
  110619. };
  110620. /**
  110621. * Disables the gravitational field.
  110622. */
  110623. PhysicsGravitationalFieldEvent.prototype.disable = function () {
  110624. this._scene.unregisterBeforeRender(this._tickCallback);
  110625. };
  110626. /**
  110627. * Disposes the sphere.
  110628. * @param force The force to dispose from the gravitational field event
  110629. */
  110630. PhysicsGravitationalFieldEvent.prototype.dispose = function (force) {
  110631. var _this = this;
  110632. if (force === void 0) { force = true; }
  110633. if (force) {
  110634. this._sphere.dispose();
  110635. }
  110636. else {
  110637. setTimeout(function () {
  110638. if (!_this._dataFetched) {
  110639. _this._sphere.dispose();
  110640. }
  110641. }, 0);
  110642. }
  110643. };
  110644. PhysicsGravitationalFieldEvent.prototype._tick = function () {
  110645. // Since the params won't change, we fetch the event only once
  110646. if (this._sphere) {
  110647. this._physicsHelper.applyRadialExplosionForce(this._origin, this._radius, this._strength * -1, this._falloff);
  110648. }
  110649. else {
  110650. var radialExplosionEvent = this._physicsHelper.applyRadialExplosionForce(this._origin, this._radius, this._strength * -1, this._falloff);
  110651. if (radialExplosionEvent) {
  110652. this._sphere = radialExplosionEvent.getData().sphere.clone('radialExplosionEventSphereClone');
  110653. }
  110654. }
  110655. };
  110656. return PhysicsGravitationalFieldEvent;
  110657. }());
  110658. /**
  110659. * Represents a physics updraft event
  110660. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110661. */
  110662. var PhysicsUpdraftEvent = /** @class */ (function () {
  110663. /**
  110664. * Initializes the physics updraft event
  110665. * @param _scene BabylonJS scene
  110666. * @param _origin The origin position of the updraft
  110667. * @param _radius The radius of the updraft
  110668. * @param _strength The strength of the updraft
  110669. * @param _height The height of the updraft
  110670. * @param _updraftMode The mode of the updraft
  110671. */
  110672. function PhysicsUpdraftEvent(_scene, _origin, _radius, _strength, _height, _updraftMode) {
  110673. this._scene = _scene;
  110674. this._origin = _origin;
  110675. this._radius = _radius;
  110676. this._strength = _strength;
  110677. this._height = _height;
  110678. this._updraftMode = _updraftMode;
  110679. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // the most upper part of the cylinder
  110680. this._originDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // used if the updraftMode is perpendicular
  110681. 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
  110682. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  110683. this._physicsEngine = this._scene.getPhysicsEngine();
  110684. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height / 2, 0), this._cylinderPosition);
  110685. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height, 0), this._originTop);
  110686. if (this._updraftMode === PhysicsUpdraftMode.Perpendicular) {
  110687. this._originDirection = this._origin.subtract(this._originTop).normalize();
  110688. }
  110689. this._tickCallback = this._tick.bind(this);
  110690. this._prepareCylinder();
  110691. }
  110692. /**
  110693. * Returns the data related to the updraft event (cylinder).
  110694. * @returns A physics updraft event
  110695. */
  110696. PhysicsUpdraftEvent.prototype.getData = function () {
  110697. this._dataFetched = true;
  110698. return {
  110699. cylinder: this._cylinder,
  110700. };
  110701. };
  110702. /**
  110703. * Enables the updraft.
  110704. */
  110705. PhysicsUpdraftEvent.prototype.enable = function () {
  110706. this._tickCallback.call(this);
  110707. this._scene.registerBeforeRender(this._tickCallback);
  110708. };
  110709. /**
  110710. * Disables the cortex.
  110711. */
  110712. PhysicsUpdraftEvent.prototype.disable = function () {
  110713. this._scene.unregisterBeforeRender(this._tickCallback);
  110714. };
  110715. /**
  110716. * Disposes the sphere.
  110717. * @param force Specifies if the updraft should be disposed by force
  110718. */
  110719. PhysicsUpdraftEvent.prototype.dispose = function (force) {
  110720. var _this = this;
  110721. if (force === void 0) { force = true; }
  110722. if (!this._cylinder) {
  110723. return;
  110724. }
  110725. if (force) {
  110726. this._cylinder.dispose();
  110727. }
  110728. else {
  110729. setTimeout(function () {
  110730. if (!_this._dataFetched) {
  110731. _this._cylinder.dispose();
  110732. }
  110733. }, 0);
  110734. }
  110735. };
  110736. PhysicsUpdraftEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  110737. if (impostor.mass === 0) {
  110738. return null;
  110739. }
  110740. if (!this._intersectsWithCylinder(impostor)) {
  110741. return null;
  110742. }
  110743. var impostorObjectCenter = impostor.getObjectCenter();
  110744. if (this._updraftMode === PhysicsUpdraftMode.Perpendicular) {
  110745. var direction = this._originDirection;
  110746. }
  110747. else {
  110748. var direction = impostorObjectCenter.subtract(this._originTop);
  110749. }
  110750. var multiplier = this._strength * -1;
  110751. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  110752. return { force: force, contactPoint: impostorObjectCenter };
  110753. };
  110754. PhysicsUpdraftEvent.prototype._tick = function () {
  110755. var _this = this;
  110756. this._physicsEngine.getImpostors().forEach(function (impostor) {
  110757. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  110758. if (!impostorForceAndContactPoint) {
  110759. return;
  110760. }
  110761. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  110762. });
  110763. };
  110764. /*** Helpers ***/
  110765. PhysicsUpdraftEvent.prototype._prepareCylinder = function () {
  110766. if (!this._cylinder) {
  110767. this._cylinder = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_2__["MeshBuilder"].CreateCylinder("updraftEventCylinder", {
  110768. height: this._height,
  110769. diameter: this._radius * 2,
  110770. }, this._scene);
  110771. this._cylinder.isVisible = false;
  110772. }
  110773. };
  110774. PhysicsUpdraftEvent.prototype._intersectsWithCylinder = function (impostor) {
  110775. var impostorObject = impostor.object;
  110776. this._cylinder.position = this._cylinderPosition;
  110777. return this._cylinder.intersectsMesh(impostorObject, true);
  110778. };
  110779. return PhysicsUpdraftEvent;
  110780. }());
  110781. /**
  110782. * Represents a physics vortex event
  110783. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110784. */
  110785. var PhysicsVortexEvent = /** @class */ (function () {
  110786. /**
  110787. * Initializes the physics vortex event
  110788. * @param _scene The BabylonJS scene
  110789. * @param _origin The origin position of the vortex
  110790. * @param _radius The radius of the vortex
  110791. * @param _strength The strength of the vortex
  110792. * @param _height The height of the vortex
  110793. */
  110794. function PhysicsVortexEvent(_scene, _origin, _radius, _strength, _height) {
  110795. this._scene = _scene;
  110796. this._origin = _origin;
  110797. this._radius = _radius;
  110798. this._strength = _strength;
  110799. this._height = _height;
  110800. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // the most upper part of the cylinder
  110801. this._centripetalForceThreshold = 0.7; // at which distance, relative to the radius the centripetal forces should kick in
  110802. this._updraftMultiplier = 0.02;
  110803. 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
  110804. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  110805. this._physicsEngine = this._scene.getPhysicsEngine();
  110806. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height / 2, 0), this._cylinderPosition);
  110807. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height, 0), this._originTop);
  110808. this._tickCallback = this._tick.bind(this);
  110809. this._prepareCylinder();
  110810. }
  110811. /**
  110812. * Returns the data related to the vortex event (cylinder).
  110813. * @returns The physics vortex event data
  110814. */
  110815. PhysicsVortexEvent.prototype.getData = function () {
  110816. this._dataFetched = true;
  110817. return {
  110818. cylinder: this._cylinder,
  110819. };
  110820. };
  110821. /**
  110822. * Enables the vortex.
  110823. */
  110824. PhysicsVortexEvent.prototype.enable = function () {
  110825. this._tickCallback.call(this);
  110826. this._scene.registerBeforeRender(this._tickCallback);
  110827. };
  110828. /**
  110829. * Disables the cortex.
  110830. */
  110831. PhysicsVortexEvent.prototype.disable = function () {
  110832. this._scene.unregisterBeforeRender(this._tickCallback);
  110833. };
  110834. /**
  110835. * Disposes the sphere.
  110836. * @param force
  110837. */
  110838. PhysicsVortexEvent.prototype.dispose = function (force) {
  110839. var _this = this;
  110840. if (force === void 0) { force = true; }
  110841. if (force) {
  110842. this._cylinder.dispose();
  110843. }
  110844. else {
  110845. setTimeout(function () {
  110846. if (!_this._dataFetched) {
  110847. _this._cylinder.dispose();
  110848. }
  110849. }, 0);
  110850. }
  110851. };
  110852. PhysicsVortexEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  110853. if (impostor.mass === 0) {
  110854. return null;
  110855. }
  110856. if (!this._intersectsWithCylinder(impostor)) {
  110857. return null;
  110858. }
  110859. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  110860. return null;
  110861. }
  110862. var impostorObjectCenter = impostor.getObjectCenter();
  110863. 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)
  110864. var originToImpostorDirection = impostorObjectCenter.subtract(originOnPlane);
  110865. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](originOnPlane, originToImpostorDirection, this._radius);
  110866. var hit = ray.intersectsMesh(impostor.object);
  110867. var contactPoint = hit.pickedPoint;
  110868. if (!contactPoint) {
  110869. return null;
  110870. }
  110871. var absoluteDistanceFromOrigin = hit.distance / this._radius;
  110872. var perpendicularDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(originOnPlane, impostorObjectCenter).normalize();
  110873. var directionToOrigin = contactPoint.normalize();
  110874. if (absoluteDistanceFromOrigin > this._centripetalForceThreshold) {
  110875. directionToOrigin = directionToOrigin.negate();
  110876. }
  110877. // TODO: find a more physically based solution
  110878. if (absoluteDistanceFromOrigin > this._centripetalForceThreshold) {
  110879. var forceX = directionToOrigin.x * this._strength / 8;
  110880. var forceY = directionToOrigin.y * this._updraftMultiplier;
  110881. var forceZ = directionToOrigin.z * this._strength / 8;
  110882. }
  110883. else {
  110884. var forceX = (perpendicularDirection.x + directionToOrigin.x) / 2;
  110885. var forceY = this._originTop.y * this._updraftMultiplier;
  110886. var forceZ = (perpendicularDirection.z + directionToOrigin.z) / 2;
  110887. }
  110888. var force = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](forceX, forceY, forceZ);
  110889. force = force.multiplyByFloats(this._strength, this._strength, this._strength);
  110890. return { force: force, contactPoint: impostorObjectCenter };
  110891. };
  110892. PhysicsVortexEvent.prototype._tick = function () {
  110893. var _this = this;
  110894. this._physicsEngine.getImpostors().forEach(function (impostor) {
  110895. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  110896. if (!impostorForceAndContactPoint) {
  110897. return;
  110898. }
  110899. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  110900. });
  110901. };
  110902. /*** Helpers ***/
  110903. PhysicsVortexEvent.prototype._prepareCylinder = function () {
  110904. if (!this._cylinder) {
  110905. this._cylinder = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_2__["MeshBuilder"].CreateCylinder("vortexEventCylinder", {
  110906. height: this._height,
  110907. diameter: this._radius * 2,
  110908. }, this._scene);
  110909. this._cylinder.isVisible = false;
  110910. }
  110911. };
  110912. PhysicsVortexEvent.prototype._intersectsWithCylinder = function (impostor) {
  110913. var impostorObject = impostor.object;
  110914. this._cylinder.position = this._cylinderPosition;
  110915. return this._cylinder.intersectsMesh(impostorObject, true);
  110916. };
  110917. return PhysicsVortexEvent;
  110918. }());
  110919. /**
  110920. * The strenght of the force in correspondence to the distance of the affected object
  110921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110922. */
  110923. var PhysicsRadialImpulseFalloff;
  110924. (function (PhysicsRadialImpulseFalloff) {
  110925. /** Defines that impulse is constant in strength across it's whole radius */
  110926. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Constant"] = 0] = "Constant";
  110927. /** DEfines that impulse gets weaker if it's further from the origin */
  110928. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Linear"] = 1] = "Linear";
  110929. })(PhysicsRadialImpulseFalloff || (PhysicsRadialImpulseFalloff = {}));
  110930. /**
  110931. * The strength of the force in correspondence to the distance of the affected object
  110932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110933. */
  110934. var PhysicsUpdraftMode;
  110935. (function (PhysicsUpdraftMode) {
  110936. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  110937. PhysicsUpdraftMode[PhysicsUpdraftMode["Center"] = 0] = "Center";
  110938. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  110939. PhysicsUpdraftMode[PhysicsUpdraftMode["Perpendicular"] = 1] = "Perpendicular";
  110940. })(PhysicsUpdraftMode || (PhysicsUpdraftMode = {}));
  110941. /***/ }),
  110942. /***/ "./Physics/physicsImpostor.ts":
  110943. /*!************************************!*\
  110944. !*** ./Physics/physicsImpostor.ts ***!
  110945. \************************************/
  110946. /*! exports provided: PhysicsImpostor */
  110947. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110948. "use strict";
  110949. __webpack_require__.r(__webpack_exports__);
  110950. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return PhysicsImpostor; });
  110951. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  110952. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  110953. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  110954. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  110955. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  110956. /**
  110957. * Represents a physics imposter
  110958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110959. */
  110960. var PhysicsImpostor = /** @class */ (function () {
  110961. /**
  110962. * Initializes the physics imposter
  110963. * @param object The physics-enabled object used as the physics imposter
  110964. * @param type The type of the physics imposter
  110965. * @param _options The options for the physics imposter
  110966. * @param _scene The Babylon scene
  110967. */
  110968. function PhysicsImpostor(
  110969. /**
  110970. * The physics-enabled object used as the physics imposter
  110971. */
  110972. object,
  110973. /**
  110974. * The type of the physics imposter
  110975. */
  110976. type, _options, _scene) {
  110977. if (_options === void 0) { _options = { mass: 0 }; }
  110978. var _this = this;
  110979. this.object = object;
  110980. this.type = type;
  110981. this._options = _options;
  110982. this._scene = _scene;
  110983. this._bodyUpdateRequired = false;
  110984. this._onBeforePhysicsStepCallbacks = new Array();
  110985. this._onAfterPhysicsStepCallbacks = new Array();
  110986. /** @hidden */
  110987. this._onPhysicsCollideCallbacks = [];
  110988. this._deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  110989. this._isDisposed = false;
  110990. //temp variables for parent rotation calculations
  110991. //private _mats: Array<Matrix> = [new Matrix(), new Matrix()];
  110992. this._tmpQuat = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  110993. this._tmpQuat2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  110994. /**
  110995. * this function is executed by the physics engine.
  110996. */
  110997. this.beforeStep = function () {
  110998. if (!_this._physicsEngine) {
  110999. return;
  111000. }
  111001. _this.object.translate(_this._deltaPosition, -1);
  111002. _this._deltaRotationConjugated && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this.object.rotationQuaternion);
  111003. _this.object.computeWorldMatrix(false);
  111004. if (_this.object.parent && _this.object.rotationQuaternion) {
  111005. _this.getParentsRotation();
  111006. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this._tmpQuat);
  111007. }
  111008. else {
  111009. _this._tmpQuat.copyFrom(_this.object.rotationQuaternion || new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]());
  111010. }
  111011. if (!_this._options.disableBidirectionalTransformation) {
  111012. _this.object.rotationQuaternion && _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, /*bInfo.boundingBox.centerWorld*/ _this.object.getAbsolutePosition(), _this._tmpQuat);
  111013. }
  111014. _this._onBeforePhysicsStepCallbacks.forEach(function (func) {
  111015. func(_this);
  111016. });
  111017. };
  111018. /**
  111019. * this function is executed by the physics engine
  111020. */
  111021. this.afterStep = function () {
  111022. if (!_this._physicsEngine) {
  111023. return;
  111024. }
  111025. _this._onAfterPhysicsStepCallbacks.forEach(function (func) {
  111026. func(_this);
  111027. });
  111028. _this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(_this);
  111029. // object has now its world rotation. needs to be converted to local.
  111030. if (_this.object.parent && _this.object.rotationQuaternion) {
  111031. _this.getParentsRotation();
  111032. _this._tmpQuat.conjugateInPlace();
  111033. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this.object.rotationQuaternion);
  111034. }
  111035. // take the position set and make it the absolute position of this object.
  111036. _this.object.setAbsolutePosition(_this.object.position);
  111037. _this._deltaRotation && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotation, _this.object.rotationQuaternion);
  111038. _this.object.translate(_this._deltaPosition, 1);
  111039. };
  111040. /**
  111041. * Legacy collision detection event support
  111042. */
  111043. this.onCollideEvent = null;
  111044. /**
  111045. * event and body object due to cannon's event-based architecture.
  111046. */
  111047. this.onCollide = function (e) {
  111048. if (!_this._onPhysicsCollideCallbacks.length && !_this.onCollideEvent) {
  111049. return;
  111050. }
  111051. if (!_this._physicsEngine) {
  111052. return;
  111053. }
  111054. var otherImpostor = _this._physicsEngine.getImpostorWithPhysicsBody(e.body);
  111055. if (otherImpostor) {
  111056. // Legacy collision detection event support
  111057. if (_this.onCollideEvent) {
  111058. _this.onCollideEvent(_this, otherImpostor);
  111059. }
  111060. _this._onPhysicsCollideCallbacks.filter(function (obj) {
  111061. return obj.otherImpostors.indexOf(otherImpostor) !== -1;
  111062. }).forEach(function (obj) {
  111063. obj.callback(_this, otherImpostor);
  111064. });
  111065. }
  111066. };
  111067. //sanity check!
  111068. if (!this.object) {
  111069. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("No object was provided. A physics object is obligatory");
  111070. return;
  111071. }
  111072. // Legacy support for old syntax.
  111073. if (!this._scene && object.getScene) {
  111074. this._scene = object.getScene();
  111075. }
  111076. if (!this._scene) {
  111077. return;
  111078. }
  111079. this._physicsEngine = this._scene.getPhysicsEngine();
  111080. if (!this._physicsEngine) {
  111081. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.");
  111082. }
  111083. else {
  111084. //set the object's quaternion, if not set
  111085. if (!this.object.rotationQuaternion) {
  111086. if (this.object.rotation) {
  111087. this.object.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z);
  111088. }
  111089. else {
  111090. this.object.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  111091. }
  111092. }
  111093. //default options params
  111094. this._options.mass = (_options.mass === void 0) ? 0 : _options.mass;
  111095. this._options.friction = (_options.friction === void 0) ? 0.2 : _options.friction;
  111096. this._options.restitution = (_options.restitution === void 0) ? 0.2 : _options.restitution;
  111097. this._joints = [];
  111098. //If the mesh has a parent, don't initialize the physicsBody. Instead wait for the parent to do that.
  111099. if (!this.object.parent || this._options.ignoreParent) {
  111100. this._init();
  111101. }
  111102. else if (this.object.parent.physicsImpostor) {
  111103. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("You must affect impostors to children before affecting impostor to parent.");
  111104. }
  111105. }
  111106. }
  111107. Object.defineProperty(PhysicsImpostor.prototype, "isDisposed", {
  111108. /**
  111109. * Specifies if the physics imposter is disposed
  111110. */
  111111. get: function () {
  111112. return this._isDisposed;
  111113. },
  111114. enumerable: true,
  111115. configurable: true
  111116. });
  111117. Object.defineProperty(PhysicsImpostor.prototype, "mass", {
  111118. /**
  111119. * Gets the mass of the physics imposter
  111120. */
  111121. get: function () {
  111122. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0;
  111123. },
  111124. set: function (value) {
  111125. this.setMass(value);
  111126. },
  111127. enumerable: true,
  111128. configurable: true
  111129. });
  111130. Object.defineProperty(PhysicsImpostor.prototype, "friction", {
  111131. /**
  111132. * Gets the coefficient of friction
  111133. */
  111134. get: function () {
  111135. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0;
  111136. },
  111137. /**
  111138. * Sets the coefficient of friction
  111139. */
  111140. set: function (value) {
  111141. if (!this._physicsEngine) {
  111142. return;
  111143. }
  111144. this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, value);
  111145. },
  111146. enumerable: true,
  111147. configurable: true
  111148. });
  111149. Object.defineProperty(PhysicsImpostor.prototype, "restitution", {
  111150. /**
  111151. * Gets the coefficient of restitution
  111152. */
  111153. get: function () {
  111154. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0;
  111155. },
  111156. /**
  111157. * Sets the coefficient of restitution
  111158. */
  111159. set: function (value) {
  111160. if (!this._physicsEngine) {
  111161. return;
  111162. }
  111163. this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, value);
  111164. },
  111165. enumerable: true,
  111166. configurable: true
  111167. });
  111168. /**
  111169. * This function will completly initialize this impostor.
  111170. * It will create a new body - but only if this mesh has no parent.
  111171. * If it has, this impostor will not be used other than to define the impostor
  111172. * of the child mesh.
  111173. * @hidden
  111174. */
  111175. PhysicsImpostor.prototype._init = function () {
  111176. if (!this._physicsEngine) {
  111177. return;
  111178. }
  111179. this._physicsEngine.removeImpostor(this);
  111180. this.physicsBody = null;
  111181. this._parent = this._parent || this._getPhysicsParent();
  111182. if (!this._isDisposed && (!this.parent || this._options.ignoreParent)) {
  111183. this._physicsEngine.addImpostor(this);
  111184. }
  111185. };
  111186. PhysicsImpostor.prototype._getPhysicsParent = function () {
  111187. if (this.object.parent instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]) {
  111188. var parentMesh = this.object.parent;
  111189. return parentMesh.physicsImpostor;
  111190. }
  111191. return null;
  111192. };
  111193. /**
  111194. * Should a new body be generated.
  111195. * @returns boolean specifying if body initialization is required
  111196. */
  111197. PhysicsImpostor.prototype.isBodyInitRequired = function () {
  111198. return this._bodyUpdateRequired || (!this._physicsBody && !this._parent);
  111199. };
  111200. /**
  111201. * Sets the updated scaling
  111202. * @param updated Specifies if the scaling is updated
  111203. */
  111204. PhysicsImpostor.prototype.setScalingUpdated = function () {
  111205. this.forceUpdate();
  111206. };
  111207. /**
  111208. * Force a regeneration of this or the parent's impostor's body.
  111209. * Use under cautious - This will remove all joints already implemented.
  111210. */
  111211. PhysicsImpostor.prototype.forceUpdate = function () {
  111212. this._init();
  111213. if (this.parent && !this._options.ignoreParent) {
  111214. this.parent.forceUpdate();
  111215. }
  111216. };
  111217. Object.defineProperty(PhysicsImpostor.prototype, "physicsBody", {
  111218. /*public get mesh(): AbstractMesh {
  111219. return this._mesh;
  111220. }*/
  111221. /**
  111222. * Gets the body that holds this impostor. Either its own, or its parent.
  111223. */
  111224. get: function () {
  111225. return (this._parent && !this._options.ignoreParent) ? this._parent.physicsBody : this._physicsBody;
  111226. },
  111227. /**
  111228. * Set the physics body. Used mainly by the physics engine/plugin
  111229. */
  111230. set: function (physicsBody) {
  111231. if (this._physicsBody && this._physicsEngine) {
  111232. this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this);
  111233. }
  111234. this._physicsBody = physicsBody;
  111235. this.resetUpdateFlags();
  111236. },
  111237. enumerable: true,
  111238. configurable: true
  111239. });
  111240. Object.defineProperty(PhysicsImpostor.prototype, "parent", {
  111241. /**
  111242. * Get the parent of the physics imposter
  111243. * @returns Physics imposter or null
  111244. */
  111245. get: function () {
  111246. return !this._options.ignoreParent && this._parent ? this._parent : null;
  111247. },
  111248. /**
  111249. * Sets the parent of the physics imposter
  111250. */
  111251. set: function (value) {
  111252. this._parent = value;
  111253. },
  111254. enumerable: true,
  111255. configurable: true
  111256. });
  111257. /**
  111258. * Resets the update flags
  111259. */
  111260. PhysicsImpostor.prototype.resetUpdateFlags = function () {
  111261. this._bodyUpdateRequired = false;
  111262. };
  111263. /**
  111264. * Gets the object extend size
  111265. * @returns the object extend size
  111266. */
  111267. PhysicsImpostor.prototype.getObjectExtendSize = function () {
  111268. if (this.object.getBoundingInfo) {
  111269. var q = this.object.rotationQuaternion;
  111270. //reset rotation
  111271. this.object.rotationQuaternion = PhysicsImpostor.IDENTITY_QUATERNION;
  111272. //calculate the world matrix with no rotation
  111273. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  111274. var boundingInfo = this.object.getBoundingInfo();
  111275. var size = boundingInfo.boundingBox.extendSizeWorld.scale(2);
  111276. //bring back the rotation
  111277. this.object.rotationQuaternion = q;
  111278. //calculate the world matrix with the new rotation
  111279. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  111280. return size;
  111281. }
  111282. else {
  111283. return PhysicsImpostor.DEFAULT_OBJECT_SIZE;
  111284. }
  111285. };
  111286. /**
  111287. * Gets the object center
  111288. * @returns The object center
  111289. */
  111290. PhysicsImpostor.prototype.getObjectCenter = function () {
  111291. if (this.object.getBoundingInfo) {
  111292. var boundingInfo = this.object.getBoundingInfo();
  111293. return boundingInfo.boundingBox.centerWorld;
  111294. }
  111295. else {
  111296. return this.object.position;
  111297. }
  111298. };
  111299. /**
  111300. * Get a specific parametes from the options parameter
  111301. * @param paramName The object parameter name
  111302. * @returns The object parameter
  111303. */
  111304. PhysicsImpostor.prototype.getParam = function (paramName) {
  111305. return this._options[paramName];
  111306. };
  111307. /**
  111308. * Sets a specific parameter in the options given to the physics plugin
  111309. * @param paramName The parameter name
  111310. * @param value The value of the parameter
  111311. */
  111312. PhysicsImpostor.prototype.setParam = function (paramName, value) {
  111313. this._options[paramName] = value;
  111314. this._bodyUpdateRequired = true;
  111315. };
  111316. /**
  111317. * Specifically change the body's mass option. Won't recreate the physics body object
  111318. * @param mass The mass of the physics imposter
  111319. */
  111320. PhysicsImpostor.prototype.setMass = function (mass) {
  111321. if (this.getParam("mass") !== mass) {
  111322. this.setParam("mass", mass);
  111323. }
  111324. if (this._physicsEngine) {
  111325. this._physicsEngine.getPhysicsPlugin().setBodyMass(this, mass);
  111326. }
  111327. };
  111328. /**
  111329. * Gets the linear velocity
  111330. * @returns linear velocity or null
  111331. */
  111332. PhysicsImpostor.prototype.getLinearVelocity = function () {
  111333. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  111334. };
  111335. /**
  111336. * Sets the linear velocity
  111337. * @param velocity linear velocity or null
  111338. */
  111339. PhysicsImpostor.prototype.setLinearVelocity = function (velocity) {
  111340. if (this._physicsEngine) {
  111341. this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, velocity);
  111342. }
  111343. };
  111344. /**
  111345. * Gets the angular velocity
  111346. * @returns angular velocity or null
  111347. */
  111348. PhysicsImpostor.prototype.getAngularVelocity = function () {
  111349. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  111350. };
  111351. /**
  111352. * Sets the angular velocity
  111353. * @param velocity The velocity or null
  111354. */
  111355. PhysicsImpostor.prototype.setAngularVelocity = function (velocity) {
  111356. if (this._physicsEngine) {
  111357. this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, velocity);
  111358. }
  111359. };
  111360. /**
  111361. * Execute a function with the physics plugin native code
  111362. * Provide a function the will have two variables - the world object and the physics body object
  111363. * @param func The function to execute with the physics plugin native code
  111364. */
  111365. PhysicsImpostor.prototype.executeNativeFunction = function (func) {
  111366. if (this._physicsEngine) {
  111367. func(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody);
  111368. }
  111369. };
  111370. /**
  111371. * Register a function that will be executed before the physics world is stepping forward
  111372. * @param func The function to execute before the physics world is stepped forward
  111373. */
  111374. PhysicsImpostor.prototype.registerBeforePhysicsStep = function (func) {
  111375. this._onBeforePhysicsStepCallbacks.push(func);
  111376. };
  111377. /**
  111378. * Unregister a function that will be executed before the physics world is stepping forward
  111379. * @param func The function to execute before the physics world is stepped forward
  111380. */
  111381. PhysicsImpostor.prototype.unregisterBeforePhysicsStep = function (func) {
  111382. var index = this._onBeforePhysicsStepCallbacks.indexOf(func);
  111383. if (index > -1) {
  111384. this._onBeforePhysicsStepCallbacks.splice(index, 1);
  111385. }
  111386. else {
  111387. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  111388. }
  111389. };
  111390. /**
  111391. * Register a function that will be executed after the physics step
  111392. * @param func The function to execute after physics step
  111393. */
  111394. PhysicsImpostor.prototype.registerAfterPhysicsStep = function (func) {
  111395. this._onAfterPhysicsStepCallbacks.push(func);
  111396. };
  111397. /**
  111398. * Unregisters a function that will be executed after the physics step
  111399. * @param func The function to execute after physics step
  111400. */
  111401. PhysicsImpostor.prototype.unregisterAfterPhysicsStep = function (func) {
  111402. var index = this._onAfterPhysicsStepCallbacks.indexOf(func);
  111403. if (index > -1) {
  111404. this._onAfterPhysicsStepCallbacks.splice(index, 1);
  111405. }
  111406. else {
  111407. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  111408. }
  111409. };
  111410. /**
  111411. * register a function that will be executed when this impostor collides against a different body
  111412. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  111413. * @param func Callback that is executed on collision
  111414. */
  111415. PhysicsImpostor.prototype.registerOnPhysicsCollide = function (collideAgainst, func) {
  111416. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  111417. this._onPhysicsCollideCallbacks.push({ callback: func, otherImpostors: collidedAgainstList });
  111418. };
  111419. /**
  111420. * Unregisters the physics imposter on contact
  111421. * @param collideAgainst The physics object to collide against
  111422. * @param func Callback to execute on collision
  111423. */
  111424. PhysicsImpostor.prototype.unregisterOnPhysicsCollide = function (collideAgainst, func) {
  111425. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  111426. var index = -1;
  111427. var found = this._onPhysicsCollideCallbacks.some(function (cbDef, idx) {
  111428. if (cbDef.callback === func && cbDef.otherImpostors.length === collidedAgainstList.length) {
  111429. // chcek the arrays match
  111430. var sameList = cbDef.otherImpostors.every(function (impostor) {
  111431. return collidedAgainstList.indexOf(impostor) > -1;
  111432. });
  111433. if (sameList) {
  111434. index = idx;
  111435. }
  111436. return sameList;
  111437. }
  111438. return false;
  111439. });
  111440. if (found) {
  111441. this._onPhysicsCollideCallbacks.splice(index, 1);
  111442. }
  111443. else {
  111444. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  111445. }
  111446. };
  111447. /**
  111448. * Get the parent rotation
  111449. * @returns The parent rotation
  111450. */
  111451. PhysicsImpostor.prototype.getParentsRotation = function () {
  111452. var parent = this.object.parent;
  111453. this._tmpQuat.copyFromFloats(0, 0, 0, 1);
  111454. while (parent) {
  111455. if (parent.rotationQuaternion) {
  111456. this._tmpQuat2.copyFrom(parent.rotationQuaternion);
  111457. }
  111458. else {
  111459. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(parent.rotation.y, parent.rotation.x, parent.rotation.z, this._tmpQuat2);
  111460. }
  111461. this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat);
  111462. parent = parent.parent;
  111463. }
  111464. return this._tmpQuat;
  111465. };
  111466. /**
  111467. * Apply a force
  111468. * @param force The force to apply
  111469. * @param contactPoint The contact point for the force
  111470. * @returns The physics imposter
  111471. */
  111472. PhysicsImpostor.prototype.applyForce = function (force, contactPoint) {
  111473. if (this._physicsEngine) {
  111474. this._physicsEngine.getPhysicsPlugin().applyForce(this, force, contactPoint);
  111475. }
  111476. return this;
  111477. };
  111478. /**
  111479. * Apply an impulse
  111480. * @param force The impulse force
  111481. * @param contactPoint The contact point for the impulse force
  111482. * @returns The physics imposter
  111483. */
  111484. PhysicsImpostor.prototype.applyImpulse = function (force, contactPoint) {
  111485. if (this._physicsEngine) {
  111486. this._physicsEngine.getPhysicsPlugin().applyImpulse(this, force, contactPoint);
  111487. }
  111488. return this;
  111489. };
  111490. /**
  111491. * A help function to create a joint
  111492. * @param otherImpostor A physics imposter used to create a joint
  111493. * @param jointType The type of joint
  111494. * @param jointData The data for the joint
  111495. * @returns The physics imposter
  111496. */
  111497. PhysicsImpostor.prototype.createJoint = function (otherImpostor, jointType, jointData) {
  111498. var joint = new _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"](jointType, jointData);
  111499. this.addJoint(otherImpostor, joint);
  111500. return this;
  111501. };
  111502. /**
  111503. * Add a joint to this impostor with a different impostor
  111504. * @param otherImpostor A physics imposter used to add a joint
  111505. * @param joint The joint to add
  111506. * @returns The physics imposter
  111507. */
  111508. PhysicsImpostor.prototype.addJoint = function (otherImpostor, joint) {
  111509. this._joints.push({
  111510. otherImpostor: otherImpostor,
  111511. joint: joint
  111512. });
  111513. if (this._physicsEngine) {
  111514. this._physicsEngine.addJoint(this, otherImpostor, joint);
  111515. }
  111516. return this;
  111517. };
  111518. /**
  111519. * Will keep this body still, in a sleep mode.
  111520. * @returns the physics imposter
  111521. */
  111522. PhysicsImpostor.prototype.sleep = function () {
  111523. if (this._physicsEngine) {
  111524. this._physicsEngine.getPhysicsPlugin().sleepBody(this);
  111525. }
  111526. return this;
  111527. };
  111528. /**
  111529. * Wake the body up.
  111530. * @returns The physics imposter
  111531. */
  111532. PhysicsImpostor.prototype.wakeUp = function () {
  111533. if (this._physicsEngine) {
  111534. this._physicsEngine.getPhysicsPlugin().wakeUpBody(this);
  111535. }
  111536. return this;
  111537. };
  111538. /**
  111539. * Clones the physics imposter
  111540. * @param newObject The physics imposter clones to this physics-enabled object
  111541. * @returns A nullable physics imposter
  111542. */
  111543. PhysicsImpostor.prototype.clone = function (newObject) {
  111544. if (!newObject) {
  111545. return null;
  111546. }
  111547. return new PhysicsImpostor(newObject, this.type, this._options, this._scene);
  111548. };
  111549. /**
  111550. * Disposes the physics imposter
  111551. */
  111552. PhysicsImpostor.prototype.dispose = function ( /*disposeChildren: boolean = true*/) {
  111553. var _this = this;
  111554. //no dispose if no physics engine is available.
  111555. if (!this._physicsEngine) {
  111556. return;
  111557. }
  111558. this._joints.forEach(function (j) {
  111559. if (_this._physicsEngine) {
  111560. _this._physicsEngine.removeJoint(_this, j.otherImpostor, j.joint);
  111561. }
  111562. });
  111563. //dispose the physics body
  111564. this._physicsEngine.removeImpostor(this);
  111565. if (this.parent) {
  111566. this.parent.forceUpdate();
  111567. }
  111568. else {
  111569. /*this._object.getChildMeshes().forEach(function(mesh) {
  111570. if (mesh.physicsImpostor) {
  111571. if (disposeChildren) {
  111572. mesh.physicsImpostor.dispose();
  111573. mesh.physicsImpostor = null;
  111574. }
  111575. }
  111576. })*/
  111577. }
  111578. this._isDisposed = true;
  111579. };
  111580. /**
  111581. * Sets the delta position
  111582. * @param position The delta position amount
  111583. */
  111584. PhysicsImpostor.prototype.setDeltaPosition = function (position) {
  111585. this._deltaPosition.copyFrom(position);
  111586. };
  111587. /**
  111588. * Sets the delta rotation
  111589. * @param rotation The delta rotation amount
  111590. */
  111591. PhysicsImpostor.prototype.setDeltaRotation = function (rotation) {
  111592. if (!this._deltaRotation) {
  111593. this._deltaRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  111594. }
  111595. this._deltaRotation.copyFrom(rotation);
  111596. this._deltaRotationConjugated = this._deltaRotation.conjugate();
  111597. };
  111598. /**
  111599. * Gets the box size of the physics imposter and stores the result in the input parameter
  111600. * @param result Stores the box size
  111601. * @returns The physics imposter
  111602. */
  111603. PhysicsImpostor.prototype.getBoxSizeToRef = function (result) {
  111604. if (this._physicsEngine) {
  111605. this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, result);
  111606. }
  111607. return this;
  111608. };
  111609. /**
  111610. * Gets the radius of the physics imposter
  111611. * @returns Radius of the physics imposter
  111612. */
  111613. PhysicsImpostor.prototype.getRadius = function () {
  111614. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0;
  111615. };
  111616. /**
  111617. * Sync a bone with this impostor
  111618. * @param bone The bone to sync to the impostor.
  111619. * @param boneMesh The mesh that the bone is influencing.
  111620. * @param jointPivot The pivot of the joint / bone in local space.
  111621. * @param distToJoint Optional distance from the impostor to the joint.
  111622. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  111623. */
  111624. PhysicsImpostor.prototype.syncBoneWithImpostor = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation) {
  111625. var tempVec = PhysicsImpostor._tmpVecs[0];
  111626. var mesh = this.object;
  111627. if (mesh.rotationQuaternion) {
  111628. if (adjustRotation) {
  111629. var tempQuat = PhysicsImpostor._tmpQuat;
  111630. mesh.rotationQuaternion.multiplyToRef(adjustRotation, tempQuat);
  111631. bone.setRotationQuaternion(tempQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  111632. }
  111633. else {
  111634. bone.setRotationQuaternion(mesh.rotationQuaternion, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  111635. }
  111636. }
  111637. tempVec.x = 0;
  111638. tempVec.y = 0;
  111639. tempVec.z = 0;
  111640. if (jointPivot) {
  111641. tempVec.x = jointPivot.x;
  111642. tempVec.y = jointPivot.y;
  111643. tempVec.z = jointPivot.z;
  111644. bone.getDirectionToRef(tempVec, boneMesh, tempVec);
  111645. if (distToJoint === undefined || distToJoint === null) {
  111646. distToJoint = jointPivot.length();
  111647. }
  111648. tempVec.x *= distToJoint;
  111649. tempVec.y *= distToJoint;
  111650. tempVec.z *= distToJoint;
  111651. }
  111652. if (bone.getParent()) {
  111653. tempVec.addInPlace(mesh.getAbsolutePosition());
  111654. bone.setAbsolutePosition(tempVec, boneMesh);
  111655. }
  111656. else {
  111657. boneMesh.setAbsolutePosition(mesh.getAbsolutePosition());
  111658. boneMesh.position.x -= tempVec.x;
  111659. boneMesh.position.y -= tempVec.y;
  111660. boneMesh.position.z -= tempVec.z;
  111661. }
  111662. };
  111663. /**
  111664. * Sync impostor to a bone
  111665. * @param bone The bone that the impostor will be synced to.
  111666. * @param boneMesh The mesh that the bone is influencing.
  111667. * @param jointPivot The pivot of the joint / bone in local space.
  111668. * @param distToJoint Optional distance from the impostor to the joint.
  111669. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  111670. * @param boneAxis Optional vector3 axis the bone is aligned with
  111671. */
  111672. PhysicsImpostor.prototype.syncImpostorWithBone = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation, boneAxis) {
  111673. var mesh = this.object;
  111674. if (mesh.rotationQuaternion) {
  111675. if (adjustRotation) {
  111676. var tempQuat = PhysicsImpostor._tmpQuat;
  111677. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, tempQuat);
  111678. tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);
  111679. }
  111680. else {
  111681. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, mesh.rotationQuaternion);
  111682. }
  111683. }
  111684. var pos = PhysicsImpostor._tmpVecs[0];
  111685. var boneDir = PhysicsImpostor._tmpVecs[1];
  111686. if (!boneAxis) {
  111687. boneAxis = PhysicsImpostor._tmpVecs[2];
  111688. boneAxis.x = 0;
  111689. boneAxis.y = 1;
  111690. boneAxis.z = 0;
  111691. }
  111692. bone.getDirectionToRef(boneAxis, boneMesh, boneDir);
  111693. bone.getAbsolutePositionToRef(boneMesh, pos);
  111694. if ((distToJoint === undefined || distToJoint === null) && jointPivot) {
  111695. distToJoint = jointPivot.length();
  111696. }
  111697. if (distToJoint !== undefined && distToJoint !== null) {
  111698. pos.x += boneDir.x * distToJoint;
  111699. pos.y += boneDir.y * distToJoint;
  111700. pos.z += boneDir.z * distToJoint;
  111701. }
  111702. mesh.setAbsolutePosition(pos);
  111703. };
  111704. /**
  111705. * The default object size of the imposter
  111706. */
  111707. PhysicsImpostor.DEFAULT_OBJECT_SIZE = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  111708. /**
  111709. * The identity quaternion of the imposter
  111710. */
  111711. PhysicsImpostor.IDENTITY_QUATERNION = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  111712. PhysicsImpostor._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero);
  111713. PhysicsImpostor._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  111714. //Impostor types
  111715. /**
  111716. * No-Imposter type
  111717. */
  111718. PhysicsImpostor.NoImpostor = 0;
  111719. /**
  111720. * Sphere-Imposter type
  111721. */
  111722. PhysicsImpostor.SphereImpostor = 1;
  111723. /**
  111724. * Box-Imposter type
  111725. */
  111726. PhysicsImpostor.BoxImpostor = 2;
  111727. /**
  111728. * Plane-Imposter type
  111729. */
  111730. PhysicsImpostor.PlaneImpostor = 3;
  111731. /**
  111732. * Mesh-imposter type
  111733. */
  111734. PhysicsImpostor.MeshImpostor = 4;
  111735. /**
  111736. * Cylinder-Imposter type
  111737. */
  111738. PhysicsImpostor.CylinderImpostor = 7;
  111739. /**
  111740. * Particle-Imposter type
  111741. */
  111742. PhysicsImpostor.ParticleImpostor = 8;
  111743. /**
  111744. * Heightmap-Imposter type
  111745. */
  111746. PhysicsImpostor.HeightmapImpostor = 9;
  111747. return PhysicsImpostor;
  111748. }());
  111749. /***/ }),
  111750. /***/ "./Physics/physicsJoint.ts":
  111751. /*!*********************************!*\
  111752. !*** ./Physics/physicsJoint.ts ***!
  111753. \*********************************/
  111754. /*! exports provided: PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint */
  111755. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111756. "use strict";
  111757. __webpack_require__.r(__webpack_exports__);
  111758. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return PhysicsJoint; });
  111759. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return DistanceJoint; });
  111760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return MotorEnabledJoint; });
  111761. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return HingeJoint; });
  111762. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return Hinge2Joint; });
  111763. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  111764. /**
  111765. * This is a holder class for the physics joint created by the physics plugin
  111766. * It holds a set of functions to control the underlying joint
  111767. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111768. */
  111769. var PhysicsJoint = /** @class */ (function () {
  111770. /**
  111771. * Initializes the physics joint
  111772. * @param type The type of the physics joint
  111773. * @param jointData The data for the physics joint
  111774. */
  111775. function PhysicsJoint(
  111776. /**
  111777. * The type of the physics joint
  111778. */
  111779. type,
  111780. /**
  111781. * The data for the physics joint
  111782. */
  111783. jointData) {
  111784. this.type = type;
  111785. this.jointData = jointData;
  111786. jointData.nativeParams = jointData.nativeParams || {};
  111787. }
  111788. Object.defineProperty(PhysicsJoint.prototype, "physicsJoint", {
  111789. /**
  111790. * Gets the physics joint
  111791. */
  111792. get: function () {
  111793. return this._physicsJoint;
  111794. },
  111795. /**
  111796. * Sets the physics joint
  111797. */
  111798. set: function (newJoint) {
  111799. if (this._physicsJoint) {
  111800. //remove from the wolrd
  111801. }
  111802. this._physicsJoint = newJoint;
  111803. },
  111804. enumerable: true,
  111805. configurable: true
  111806. });
  111807. Object.defineProperty(PhysicsJoint.prototype, "physicsPlugin", {
  111808. /**
  111809. * Sets the physics plugin
  111810. */
  111811. set: function (physicsPlugin) {
  111812. this._physicsPlugin = physicsPlugin;
  111813. },
  111814. enumerable: true,
  111815. configurable: true
  111816. });
  111817. /**
  111818. * Execute a function that is physics-plugin specific.
  111819. * @param {Function} func the function that will be executed.
  111820. * It accepts two parameters: the physics world and the physics joint
  111821. */
  111822. PhysicsJoint.prototype.executeNativeFunction = function (func) {
  111823. func(this._physicsPlugin.world, this._physicsJoint);
  111824. };
  111825. //TODO check if the native joints are the same
  111826. //Joint Types
  111827. /**
  111828. * Distance-Joint type
  111829. */
  111830. PhysicsJoint.DistanceJoint = 0;
  111831. /**
  111832. * Hinge-Joint type
  111833. */
  111834. PhysicsJoint.HingeJoint = 1;
  111835. /**
  111836. * Ball-and-Socket joint type
  111837. */
  111838. PhysicsJoint.BallAndSocketJoint = 2;
  111839. /**
  111840. * Wheel-Joint type
  111841. */
  111842. PhysicsJoint.WheelJoint = 3;
  111843. /**
  111844. * Slider-Joint type
  111845. */
  111846. PhysicsJoint.SliderJoint = 4;
  111847. //OIMO
  111848. /**
  111849. * Prismatic-Joint type
  111850. */
  111851. PhysicsJoint.PrismaticJoint = 5;
  111852. //
  111853. /**
  111854. * Universal-Joint type
  111855. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  111856. */
  111857. PhysicsJoint.UniversalJoint = 6;
  111858. /**
  111859. * Hinge-Joint 2 type
  111860. */
  111861. PhysicsJoint.Hinge2Joint = PhysicsJoint.WheelJoint;
  111862. //Cannon
  111863. /**
  111864. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  111865. */
  111866. PhysicsJoint.PointToPointJoint = 8;
  111867. //Cannon only at the moment
  111868. /**
  111869. * Spring-Joint type
  111870. */
  111871. PhysicsJoint.SpringJoint = 9;
  111872. /**
  111873. * Lock-Joint type
  111874. */
  111875. PhysicsJoint.LockJoint = 10;
  111876. return PhysicsJoint;
  111877. }());
  111878. /**
  111879. * A class representing a physics distance joint
  111880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111881. */
  111882. var DistanceJoint = /** @class */ (function (_super) {
  111883. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DistanceJoint, _super);
  111884. /**
  111885. *
  111886. * @param jointData The data for the Distance-Joint
  111887. */
  111888. function DistanceJoint(jointData) {
  111889. return _super.call(this, PhysicsJoint.DistanceJoint, jointData) || this;
  111890. }
  111891. /**
  111892. * Update the predefined distance.
  111893. * @param maxDistance The maximum preferred distance
  111894. * @param minDistance The minimum preferred distance
  111895. */
  111896. DistanceJoint.prototype.updateDistance = function (maxDistance, minDistance) {
  111897. this._physicsPlugin.updateDistanceJoint(this, maxDistance, minDistance);
  111898. };
  111899. return DistanceJoint;
  111900. }(PhysicsJoint));
  111901. /**
  111902. * Represents a Motor-Enabled Joint
  111903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111904. */
  111905. var MotorEnabledJoint = /** @class */ (function (_super) {
  111906. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotorEnabledJoint, _super);
  111907. /**
  111908. * Initializes the Motor-Enabled Joint
  111909. * @param type The type of the joint
  111910. * @param jointData The physica joint data for the joint
  111911. */
  111912. function MotorEnabledJoint(type, jointData) {
  111913. return _super.call(this, type, jointData) || this;
  111914. }
  111915. /**
  111916. * Set the motor values.
  111917. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111918. * @param force the force to apply
  111919. * @param maxForce max force for this motor.
  111920. */
  111921. MotorEnabledJoint.prototype.setMotor = function (force, maxForce) {
  111922. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  111923. };
  111924. /**
  111925. * Set the motor's limits.
  111926. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111927. * @param upperLimit The upper limit of the motor
  111928. * @param lowerLimit The lower limit of the motor
  111929. */
  111930. MotorEnabledJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  111931. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  111932. };
  111933. return MotorEnabledJoint;
  111934. }(PhysicsJoint));
  111935. /**
  111936. * This class represents a single physics Hinge-Joint
  111937. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111938. */
  111939. var HingeJoint = /** @class */ (function (_super) {
  111940. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HingeJoint, _super);
  111941. /**
  111942. * Initializes the Hinge-Joint
  111943. * @param jointData The joint data for the Hinge-Joint
  111944. */
  111945. function HingeJoint(jointData) {
  111946. return _super.call(this, PhysicsJoint.HingeJoint, jointData) || this;
  111947. }
  111948. /**
  111949. * Set the motor values.
  111950. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111951. * @param {number} force the force to apply
  111952. * @param {number} maxForce max force for this motor.
  111953. */
  111954. HingeJoint.prototype.setMotor = function (force, maxForce) {
  111955. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  111956. };
  111957. /**
  111958. * Set the motor's limits.
  111959. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111960. * @param upperLimit The upper limit of the motor
  111961. * @param lowerLimit The lower limit of the motor
  111962. */
  111963. HingeJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  111964. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  111965. };
  111966. return HingeJoint;
  111967. }(MotorEnabledJoint));
  111968. /**
  111969. * This class represents a dual hinge physics joint (same as wheel joint)
  111970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111971. */
  111972. var Hinge2Joint = /** @class */ (function (_super) {
  111973. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Hinge2Joint, _super);
  111974. /**
  111975. * Initializes the Hinge2-Joint
  111976. * @param jointData The joint data for the Hinge2-Joint
  111977. */
  111978. function Hinge2Joint(jointData) {
  111979. return _super.call(this, PhysicsJoint.Hinge2Joint, jointData) || this;
  111980. }
  111981. /**
  111982. * Set the motor values.
  111983. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111984. * @param {number} force the force to apply
  111985. * @param {number} maxForce max force for this motor.
  111986. * @param {motorIndex} the motor's index, 0 or 1.
  111987. */
  111988. Hinge2Joint.prototype.setMotor = function (force, maxForce, motorIndex) {
  111989. if (motorIndex === void 0) { motorIndex = 0; }
  111990. this._physicsPlugin.setMotor(this, force || 0, maxForce, motorIndex);
  111991. };
  111992. /**
  111993. * Set the motor limits.
  111994. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111995. * @param {number} upperLimit the upper limit
  111996. * @param {number} lowerLimit lower limit
  111997. * @param {motorIndex} the motor's index, 0 or 1.
  111998. */
  111999. Hinge2Joint.prototype.setLimit = function (upperLimit, lowerLimit, motorIndex) {
  112000. if (motorIndex === void 0) { motorIndex = 0; }
  112001. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit, motorIndex);
  112002. };
  112003. return Hinge2Joint;
  112004. }(MotorEnabledJoint));
  112005. /***/ }),
  112006. /***/ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts":
  112007. /*!****************************************************************************!*\
  112008. !*** ./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts ***!
  112009. \****************************************************************************/
  112010. /*! exports provided: DefaultRenderingPipeline */
  112011. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112012. "use strict";
  112013. __webpack_require__.r(__webpack_exports__);
  112014. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return DefaultRenderingPipeline; });
  112015. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  112016. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  112017. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  112018. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  112019. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  112020. /* harmony import */ var _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Layers/glowLayer */ "./Layers/glowLayer.ts");
  112021. /* harmony import */ var _PostProcesses_sharpenPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  112022. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  112023. /* harmony import */ var _PostProcesses_chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  112024. /* harmony import */ var _PostProcesses_grainPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  112025. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  112026. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  112027. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  112028. /* harmony import */ var _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../PostProcesses/depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  112029. /* harmony import */ var _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../PostProcesses/bloomEffect */ "./PostProcesses/bloomEffect.ts");
  112030. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  112031. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  112032. /**
  112033. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  112034. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  112035. */
  112036. var DefaultRenderingPipeline = /** @class */ (function (_super) {
  112037. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DefaultRenderingPipeline, _super);
  112038. /**
  112039. * @constructor
  112040. * @param name - The rendering pipeline name (default: "")
  112041. * @param hdr - If high dynamic range textures should be used (default: true)
  112042. * @param scene - The scene linked to this pipeline (default: the last created scene)
  112043. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  112044. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  112045. */
  112046. function DefaultRenderingPipeline(name, hdr, scene, cameras, automaticBuild) {
  112047. if (name === void 0) { name = ""; }
  112048. if (hdr === void 0) { hdr = true; }
  112049. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene; }
  112050. if (automaticBuild === void 0) { automaticBuild = true; }
  112051. var _this = _super.call(this, scene.getEngine(), name) || this;
  112052. _this._camerasToBeAttached = [];
  112053. /**
  112054. * ID of the sharpen post process,
  112055. */
  112056. _this.SharpenPostProcessId = "SharpenPostProcessEffect";
  112057. /**
  112058. * @ignore
  112059. * ID of the image processing post process;
  112060. */
  112061. _this.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect";
  112062. /**
  112063. * @ignore
  112064. * ID of the Fast Approximate Anti-Aliasing post process;
  112065. */
  112066. _this.FxaaPostProcessId = "FxaaPostProcessEffect";
  112067. /**
  112068. * ID of the chromatic aberration post process,
  112069. */
  112070. _this.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect";
  112071. /**
  112072. * ID of the grain post process
  112073. */
  112074. _this.GrainPostProcessId = "GrainPostProcessEffect";
  112075. /**
  112076. * Glow post process which adds a glow to emmisive areas of the image
  112077. */
  112078. _this._glowLayer = null;
  112079. /**
  112080. * Animations which can be used to tweak settings over a period of time
  112081. */
  112082. _this.animations = [];
  112083. _this._imageProcessingConfigurationObserver = null;
  112084. // Values
  112085. _this._sharpenEnabled = false;
  112086. _this._bloomEnabled = false;
  112087. _this._depthOfFieldEnabled = false;
  112088. _this._depthOfFieldBlurLevel = _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffectBlurLevel"].Low;
  112089. _this._fxaaEnabled = false;
  112090. _this._imageProcessingEnabled = true;
  112091. _this._bloomScale = 0.5;
  112092. _this._chromaticAberrationEnabled = false;
  112093. _this._grainEnabled = false;
  112094. _this._buildAllowed = true;
  112095. _this._resizeObserver = null;
  112096. _this._hardwareScaleLevel = 1.0;
  112097. _this._bloomKernel = 64;
  112098. /**
  112099. * Specifies the weight of the bloom in the final rendering
  112100. */
  112101. _this._bloomWeight = 0.15;
  112102. /**
  112103. * Specifies the luma threshold for the area that will be blurred by the bloom
  112104. */
  112105. _this._bloomThreshold = 0.9;
  112106. _this._samples = 1;
  112107. _this._hasCleared = false;
  112108. _this._prevPostProcess = null;
  112109. _this._prevPrevPostProcess = null;
  112110. _this._depthOfFieldSceneObserver = null;
  112111. _this._cameras = cameras || scene.cameras;
  112112. _this._cameras = _this._cameras.slice();
  112113. _this._camerasToBeAttached = _this._cameras.slice();
  112114. _this._buildAllowed = automaticBuild;
  112115. // Initialize
  112116. _this._scene = scene;
  112117. var caps = _this._scene.getEngine().getCaps();
  112118. _this._hdr = hdr && (caps.textureHalfFloatRender || caps.textureFloatRender);
  112119. // Misc
  112120. if (_this._hdr) {
  112121. if (caps.textureHalfFloatRender) {
  112122. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_HALF_FLOAT;
  112123. }
  112124. else if (caps.textureFloatRender) {
  112125. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_FLOAT;
  112126. }
  112127. }
  112128. else {
  112129. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  112130. }
  112131. // Attach
  112132. scene.postProcessRenderPipelineManager.addPipeline(_this);
  112133. var engine = _this._scene.getEngine();
  112134. // Create post processes before hand so they can be modified before enabled.
  112135. // Block compilation flag is set to true to avoid compilation prior to use, these will be updated on first use in build pipeline.
  112136. _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);
  112137. _this._sharpenEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.SharpenPostProcessId, function () { return _this.sharpen; }, true);
  112138. _this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](_this._scene, null, _this._depthOfFieldBlurLevel, _this._defaultPipelineTextureType, true);
  112139. _this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](_this._scene, _this._bloomScale, _this._bloomWeight, _this.bloomKernel, _this._defaultPipelineTextureType, true);
  112140. _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);
  112141. _this._chromaticAberrationEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.ChromaticAberrationPostProcessId, function () { return _this.chromaticAberration; }, true);
  112142. _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);
  112143. _this._grainEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.GrainPostProcessId, function () { return _this.grain; }, true);
  112144. _this._resizeObserver = engine.onResizeObservable.add(function () {
  112145. _this._hardwareScaleLevel = engine.getHardwareScalingLevel();
  112146. _this.bloomKernel = _this.bloomKernel;
  112147. });
  112148. _this._imageProcessingConfigurationObserver = _this._scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  112149. _this.bloom._downscale._exposure = _this._scene.imageProcessingConfiguration.exposure;
  112150. });
  112151. _this._buildPipeline();
  112152. return _this;
  112153. }
  112154. Object.defineProperty(DefaultRenderingPipeline.prototype, "sharpenEnabled", {
  112155. get: function () {
  112156. return this._sharpenEnabled;
  112157. },
  112158. /**
  112159. * Enable or disable the sharpen process from the pipeline
  112160. */
  112161. set: function (enabled) {
  112162. if (this._sharpenEnabled === enabled) {
  112163. return;
  112164. }
  112165. this._sharpenEnabled = enabled;
  112166. this._buildPipeline();
  112167. },
  112168. enumerable: true,
  112169. configurable: true
  112170. });
  112171. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomKernel", {
  112172. /**
  112173. * Specifies the size of the bloom blur kernel, relative to the final output size
  112174. */
  112175. get: function () {
  112176. return this._bloomKernel;
  112177. },
  112178. set: function (value) {
  112179. this._bloomKernel = value;
  112180. this.bloom.kernel = value / this._hardwareScaleLevel;
  112181. },
  112182. enumerable: true,
  112183. configurable: true
  112184. });
  112185. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomWeight", {
  112186. get: function () {
  112187. return this._bloomWeight;
  112188. },
  112189. /**
  112190. * The strength of the bloom.
  112191. */
  112192. set: function (value) {
  112193. if (this._bloomWeight === value) {
  112194. return;
  112195. }
  112196. this.bloom.weight = value;
  112197. this._bloomWeight = value;
  112198. },
  112199. enumerable: true,
  112200. configurable: true
  112201. });
  112202. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomThreshold", {
  112203. get: function () {
  112204. return this._bloomThreshold;
  112205. },
  112206. /**
  112207. * The strength of the bloom.
  112208. */
  112209. set: function (value) {
  112210. if (this._bloomThreshold === value) {
  112211. return;
  112212. }
  112213. this.bloom.threshold = value;
  112214. this._bloomThreshold = value;
  112215. },
  112216. enumerable: true,
  112217. configurable: true
  112218. });
  112219. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomScale", {
  112220. get: function () {
  112221. return this._bloomScale;
  112222. },
  112223. /**
  112224. * The scale of the bloom, lower value will provide better performance.
  112225. */
  112226. set: function (value) {
  112227. if (this._bloomScale === value) {
  112228. return;
  112229. }
  112230. this._bloomScale = value;
  112231. // recreate bloom and dispose old as this setting is not dynamic
  112232. this._rebuildBloom();
  112233. this._buildPipeline();
  112234. },
  112235. enumerable: true,
  112236. configurable: true
  112237. });
  112238. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomEnabled", {
  112239. get: function () {
  112240. return this._bloomEnabled;
  112241. },
  112242. /**
  112243. * Enable or disable the bloom from the pipeline
  112244. */
  112245. set: function (enabled) {
  112246. if (this._bloomEnabled === enabled) {
  112247. return;
  112248. }
  112249. this._bloomEnabled = enabled;
  112250. this._buildPipeline();
  112251. },
  112252. enumerable: true,
  112253. configurable: true
  112254. });
  112255. DefaultRenderingPipeline.prototype._rebuildBloom = function () {
  112256. // recreate bloom and dispose old as this setting is not dynamic
  112257. var oldBloom = this.bloom;
  112258. this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](this._scene, this.bloomScale, this._bloomWeight, this.bloomKernel, this._defaultPipelineTextureType, false);
  112259. this.bloom.threshold = oldBloom.threshold;
  112260. for (var i = 0; i < this._cameras.length; i++) {
  112261. oldBloom.disposeEffects(this._cameras[i]);
  112262. }
  112263. };
  112264. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", {
  112265. /**
  112266. * If the depth of field is enabled.
  112267. */
  112268. get: function () {
  112269. return this._depthOfFieldEnabled;
  112270. },
  112271. set: function (enabled) {
  112272. if (this._depthOfFieldEnabled === enabled) {
  112273. return;
  112274. }
  112275. this._depthOfFieldEnabled = enabled;
  112276. this._buildPipeline();
  112277. },
  112278. enumerable: true,
  112279. configurable: true
  112280. });
  112281. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", {
  112282. /**
  112283. * Blur level of the depth of field effect. (Higher blur will effect performance)
  112284. */
  112285. get: function () {
  112286. return this._depthOfFieldBlurLevel;
  112287. },
  112288. set: function (value) {
  112289. if (this._depthOfFieldBlurLevel === value) {
  112290. return;
  112291. }
  112292. this._depthOfFieldBlurLevel = value;
  112293. // recreate dof and dispose old as this setting is not dynamic
  112294. var oldDof = this.depthOfField;
  112295. this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](this._scene, null, this._depthOfFieldBlurLevel, this._defaultPipelineTextureType, false);
  112296. this.depthOfField.focalLength = oldDof.focalLength;
  112297. this.depthOfField.focusDistance = oldDof.focusDistance;
  112298. this.depthOfField.fStop = oldDof.fStop;
  112299. this.depthOfField.lensSize = oldDof.lensSize;
  112300. for (var i = 0; i < this._cameras.length; i++) {
  112301. oldDof.disposeEffects(this._cameras[i]);
  112302. }
  112303. this._buildPipeline();
  112304. },
  112305. enumerable: true,
  112306. configurable: true
  112307. });
  112308. Object.defineProperty(DefaultRenderingPipeline.prototype, "fxaaEnabled", {
  112309. get: function () {
  112310. return this._fxaaEnabled;
  112311. },
  112312. /**
  112313. * If the anti aliasing is enabled.
  112314. */
  112315. set: function (enabled) {
  112316. if (this._fxaaEnabled === enabled) {
  112317. return;
  112318. }
  112319. this._fxaaEnabled = enabled;
  112320. this._buildPipeline();
  112321. },
  112322. enumerable: true,
  112323. configurable: true
  112324. });
  112325. Object.defineProperty(DefaultRenderingPipeline.prototype, "samples", {
  112326. get: function () {
  112327. return this._samples;
  112328. },
  112329. /**
  112330. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  112331. */
  112332. set: function (sampleCount) {
  112333. if (this._samples === sampleCount) {
  112334. return;
  112335. }
  112336. this._samples = sampleCount;
  112337. this._buildPipeline();
  112338. },
  112339. enumerable: true,
  112340. configurable: true
  112341. });
  112342. Object.defineProperty(DefaultRenderingPipeline.prototype, "imageProcessingEnabled", {
  112343. get: function () {
  112344. return this._imageProcessingEnabled;
  112345. },
  112346. /**
  112347. * If image processing is enabled.
  112348. */
  112349. set: function (enabled) {
  112350. if (this._imageProcessingEnabled === enabled) {
  112351. return;
  112352. }
  112353. this._imageProcessingEnabled = enabled;
  112354. this._buildPipeline();
  112355. },
  112356. enumerable: true,
  112357. configurable: true
  112358. });
  112359. Object.defineProperty(DefaultRenderingPipeline.prototype, "glowLayerEnabled", {
  112360. get: function () {
  112361. return this._glowLayer == null;
  112362. },
  112363. /**
  112364. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  112365. */
  112366. set: function (enabled) {
  112367. if (enabled && !this._glowLayer) {
  112368. this._glowLayer = new _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__["GlowLayer"]("", this._scene);
  112369. }
  112370. else if (!enabled && this._glowLayer) {
  112371. this._glowLayer.dispose();
  112372. this._glowLayer = null;
  112373. }
  112374. },
  112375. enumerable: true,
  112376. configurable: true
  112377. });
  112378. Object.defineProperty(DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", {
  112379. get: function () {
  112380. return this._chromaticAberrationEnabled;
  112381. },
  112382. /**
  112383. * Enable or disable the chromaticAberration process from the pipeline
  112384. */
  112385. set: function (enabled) {
  112386. if (this._chromaticAberrationEnabled === enabled) {
  112387. return;
  112388. }
  112389. this._chromaticAberrationEnabled = enabled;
  112390. this._buildPipeline();
  112391. },
  112392. enumerable: true,
  112393. configurable: true
  112394. });
  112395. Object.defineProperty(DefaultRenderingPipeline.prototype, "grainEnabled", {
  112396. get: function () {
  112397. return this._grainEnabled;
  112398. },
  112399. /**
  112400. * Enable or disable the grain process from the pipeline
  112401. */
  112402. set: function (enabled) {
  112403. if (this._grainEnabled === enabled) {
  112404. return;
  112405. }
  112406. this._grainEnabled = enabled;
  112407. this._buildPipeline();
  112408. },
  112409. enumerable: true,
  112410. configurable: true
  112411. });
  112412. /**
  112413. * Force the compilation of the entire pipeline.
  112414. */
  112415. DefaultRenderingPipeline.prototype.prepare = function () {
  112416. var previousState = this._buildAllowed;
  112417. this._buildAllowed = true;
  112418. this._buildPipeline();
  112419. this._buildAllowed = previousState;
  112420. };
  112421. DefaultRenderingPipeline.prototype._setAutoClearAndTextureSharing = function (postProcess, skipTextureSharing) {
  112422. if (skipTextureSharing === void 0) { skipTextureSharing = false; }
  112423. if (this._hasCleared) {
  112424. postProcess.autoClear = false;
  112425. }
  112426. else {
  112427. postProcess.autoClear = true;
  112428. this._scene.autoClear = false;
  112429. this._hasCleared = true;
  112430. }
  112431. if (!skipTextureSharing) {
  112432. if (this._prevPrevPostProcess) {
  112433. postProcess.shareOutputWith(this._prevPrevPostProcess);
  112434. }
  112435. else {
  112436. postProcess.useOwnOutput();
  112437. }
  112438. if (this._prevPostProcess) {
  112439. this._prevPrevPostProcess = this._prevPostProcess;
  112440. }
  112441. this._prevPostProcess = postProcess;
  112442. }
  112443. };
  112444. DefaultRenderingPipeline.prototype._buildPipeline = function () {
  112445. var _this = this;
  112446. if (!this._buildAllowed) {
  112447. return;
  112448. }
  112449. this._scene.autoClear = true;
  112450. var engine = this._scene.getEngine();
  112451. this._disposePostProcesses();
  112452. if (this._cameras !== null) {
  112453. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  112454. // get back cameras to be used to reattach pipeline
  112455. this._cameras = this._camerasToBeAttached.slice();
  112456. }
  112457. this._reset();
  112458. this._prevPostProcess = null;
  112459. this._prevPrevPostProcess = null;
  112460. this._hasCleared = false;
  112461. if (this.depthOfFieldEnabled) {
  112462. // Multi camera suport
  112463. if (this._cameras.length > 1) {
  112464. for (var _i = 0, _a = this._cameras; _i < _a.length; _i++) {
  112465. var camera = _a[_i];
  112466. var depthRenderer = this._scene.enableDepthRenderer(camera);
  112467. depthRenderer.useOnlyInActiveCamera = true;
  112468. }
  112469. this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add(function (scene) {
  112470. if (_this._cameras.indexOf(scene.activeCamera) > -1) {
  112471. _this.depthOfField.depthTexture = scene.enableDepthRenderer(scene.activeCamera).getDepthMap();
  112472. }
  112473. });
  112474. }
  112475. else {
  112476. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  112477. var depthRenderer = this._scene.enableDepthRenderer(this._cameras[0]);
  112478. this.depthOfField.depthTexture = depthRenderer.getDepthMap();
  112479. }
  112480. if (!this.depthOfField._isReady()) {
  112481. this.depthOfField._updateEffects();
  112482. }
  112483. this.addEffect(this.depthOfField);
  112484. this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], true);
  112485. }
  112486. else {
  112487. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  112488. }
  112489. if (this.bloomEnabled) {
  112490. if (!this.bloom._isReady()) {
  112491. this.bloom._updateEffects();
  112492. }
  112493. this.addEffect(this.bloom);
  112494. this._setAutoClearAndTextureSharing(this.bloom._effects[0], true);
  112495. }
  112496. if (this._imageProcessingEnabled) {
  112497. 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);
  112498. if (this._hdr) {
  112499. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.ImageProcessingPostProcessId, function () { return _this.imageProcessing; }, true));
  112500. this._setAutoClearAndTextureSharing(this.imageProcessing);
  112501. }
  112502. else {
  112503. this._scene.imageProcessingConfiguration.applyByPostProcess = false;
  112504. }
  112505. }
  112506. if (this.sharpenEnabled) {
  112507. if (!this.sharpen.isReady()) {
  112508. this.sharpen.updateEffect();
  112509. }
  112510. this.addEffect(this._sharpenEffect);
  112511. this._setAutoClearAndTextureSharing(this.sharpen);
  112512. }
  112513. if (this.grainEnabled) {
  112514. if (!this.grain.isReady()) {
  112515. this.grain.updateEffect();
  112516. }
  112517. this.addEffect(this._grainEffect);
  112518. this._setAutoClearAndTextureSharing(this.grain);
  112519. }
  112520. if (this.chromaticAberrationEnabled) {
  112521. if (!this.chromaticAberration.isReady()) {
  112522. this.chromaticAberration.updateEffect();
  112523. }
  112524. this.addEffect(this._chromaticAberrationEffect);
  112525. this._setAutoClearAndTextureSharing(this.chromaticAberration);
  112526. }
  112527. if (this.fxaaEnabled) {
  112528. 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);
  112529. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.FxaaPostProcessId, function () { return _this.fxaa; }, true));
  112530. this._setAutoClearAndTextureSharing(this.fxaa, true);
  112531. }
  112532. if (this._cameras !== null) {
  112533. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  112534. }
  112535. if (!this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1) {
  112536. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  112537. }
  112538. };
  112539. DefaultRenderingPipeline.prototype._disposePostProcesses = function (disposeNonRecreated) {
  112540. if (disposeNonRecreated === void 0) { disposeNonRecreated = false; }
  112541. for (var i = 0; i < this._cameras.length; i++) {
  112542. var camera = this._cameras[i];
  112543. if (this.imageProcessing) {
  112544. this.imageProcessing.dispose(camera);
  112545. }
  112546. if (this.fxaa) {
  112547. this.fxaa.dispose(camera);
  112548. }
  112549. // These are created in the constructor and should not be disposed on every pipeline change
  112550. if (disposeNonRecreated) {
  112551. if (this.sharpen) {
  112552. this.sharpen.dispose(camera);
  112553. }
  112554. if (this.depthOfField) {
  112555. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  112556. this.depthOfField.disposeEffects(camera);
  112557. }
  112558. if (this.bloom) {
  112559. this.bloom.disposeEffects(camera);
  112560. }
  112561. if (this.chromaticAberration) {
  112562. this.chromaticAberration.dispose(camera);
  112563. }
  112564. if (this.grain) {
  112565. this.grain.dispose(camera);
  112566. }
  112567. if (this._glowLayer) {
  112568. this._glowLayer.dispose();
  112569. }
  112570. }
  112571. }
  112572. this.imageProcessing = null;
  112573. this.fxaa = null;
  112574. if (disposeNonRecreated) {
  112575. this.sharpen = null;
  112576. this._sharpenEffect = null;
  112577. this.depthOfField = null;
  112578. this.bloom = null;
  112579. this.chromaticAberration = null;
  112580. this._chromaticAberrationEffect = null;
  112581. this.grain = null;
  112582. this._grainEffect = null;
  112583. this._glowLayer = null;
  112584. }
  112585. };
  112586. /**
  112587. * Adds a camera to the pipeline
  112588. * @param camera the camera to be added
  112589. */
  112590. DefaultRenderingPipeline.prototype.addCamera = function (camera) {
  112591. this._camerasToBeAttached.push(camera);
  112592. this._buildPipeline();
  112593. };
  112594. /**
  112595. * Removes a camera from the pipeline
  112596. * @param camera the camera to remove
  112597. */
  112598. DefaultRenderingPipeline.prototype.removeCamera = function (camera) {
  112599. var index = this._camerasToBeAttached.indexOf(camera);
  112600. this._camerasToBeAttached.splice(index, 1);
  112601. this._buildPipeline();
  112602. };
  112603. /**
  112604. * Dispose of the pipeline and stop all post processes
  112605. */
  112606. DefaultRenderingPipeline.prototype.dispose = function () {
  112607. this._disposePostProcesses(true);
  112608. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  112609. this._scene.autoClear = true;
  112610. if (this._resizeObserver) {
  112611. this._scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  112612. this._resizeObserver = null;
  112613. }
  112614. this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver);
  112615. _super.prototype.dispose.call(this);
  112616. };
  112617. /**
  112618. * Serialize the rendering pipeline (Used when exporting)
  112619. * @returns the serialized object
  112620. */
  112621. DefaultRenderingPipeline.prototype.serialize = function () {
  112622. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  112623. serializationObject.customType = "DefaultRenderingPipeline";
  112624. return serializationObject;
  112625. };
  112626. /**
  112627. * Parse the serialized pipeline
  112628. * @param source Source pipeline.
  112629. * @param scene The scene to load the pipeline to.
  112630. * @param rootUrl The URL of the serialized pipeline.
  112631. * @returns An instantiated pipeline from the serialized object.
  112632. */
  112633. DefaultRenderingPipeline.Parse = function (source, scene, rootUrl) {
  112634. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new DefaultRenderingPipeline(source._name, source._name._hdr, scene); }, source, scene, rootUrl);
  112635. };
  112636. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112637. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112638. ], DefaultRenderingPipeline.prototype, "sharpenEnabled", null);
  112639. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112640. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112641. ], DefaultRenderingPipeline.prototype, "bloomKernel", null);
  112642. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112643. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112644. ], DefaultRenderingPipeline.prototype, "_bloomWeight", void 0);
  112645. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112646. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112647. ], DefaultRenderingPipeline.prototype, "_bloomThreshold", void 0);
  112648. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112649. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112650. ], DefaultRenderingPipeline.prototype, "_hdr", void 0);
  112651. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112652. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112653. ], DefaultRenderingPipeline.prototype, "bloomWeight", null);
  112654. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112655. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112656. ], DefaultRenderingPipeline.prototype, "bloomThreshold", null);
  112657. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112658. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112659. ], DefaultRenderingPipeline.prototype, "bloomScale", null);
  112660. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112661. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112662. ], DefaultRenderingPipeline.prototype, "bloomEnabled", null);
  112663. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112664. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112665. ], DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", null);
  112666. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112667. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112668. ], DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", null);
  112669. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112670. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112671. ], DefaultRenderingPipeline.prototype, "fxaaEnabled", null);
  112672. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112673. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112674. ], DefaultRenderingPipeline.prototype, "samples", null);
  112675. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112676. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112677. ], DefaultRenderingPipeline.prototype, "imageProcessingEnabled", null);
  112678. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112679. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112680. ], DefaultRenderingPipeline.prototype, "glowLayerEnabled", null);
  112681. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112682. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112683. ], DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", null);
  112684. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112685. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112686. ], DefaultRenderingPipeline.prototype, "grainEnabled", null);
  112687. return DefaultRenderingPipeline;
  112688. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__["PostProcessRenderPipeline"]));
  112689. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__["_TypeStore"].RegisteredTypes["BABYLON.DefaultRenderingPipeline"] = DefaultRenderingPipeline;
  112690. /***/ }),
  112691. /***/ "./PostProcesses/RenderPipeline/Pipelines/index.ts":
  112692. /*!*********************************************************!*\
  112693. !*** ./PostProcesses/RenderPipeline/Pipelines/index.ts ***!
  112694. \*********************************************************/
  112695. /*! exports provided: DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  112696. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112697. "use strict";
  112698. __webpack_require__.r(__webpack_exports__);
  112699. /* harmony import */ var _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts");
  112700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  112701. /* harmony import */ var _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts");
  112702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__["LensRenderingPipeline"]; });
  112703. /* harmony import */ var _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ssao2RenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts");
  112704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__["SSAO2RenderingPipeline"]; });
  112705. /* harmony import */ var _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ssaoRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts");
  112706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__["SSAORenderingPipeline"]; });
  112707. /* harmony import */ var _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./standardRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts");
  112708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__["StandardRenderingPipeline"]; });
  112709. /***/ }),
  112710. /***/ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts":
  112711. /*!*************************************************************************!*\
  112712. !*** ./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts ***!
  112713. \*************************************************************************/
  112714. /*! exports provided: LensRenderingPipeline */
  112715. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112716. "use strict";
  112717. __webpack_require__.r(__webpack_exports__);
  112718. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return LensRenderingPipeline; });
  112719. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  112720. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  112721. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  112722. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  112723. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  112724. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  112725. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  112726. /* harmony import */ var _Shaders_lensHighlights_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Shaders/lensHighlights.fragment */ "./Shaders/lensHighlights.fragment.ts");
  112727. /* harmony import */ var _Shaders_depthOfField_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../Shaders/depthOfField.fragment */ "./Shaders/depthOfField.fragment.ts");
  112728. /**
  112729. * BABYLON.JS Chromatic Aberration GLSL Shader
  112730. * Author: Olivier Guyot
  112731. * Separates very slightly R, G and B colors on the edges of the screen
  112732. * Inspired by Francois Tarlier & Martins Upitis
  112733. */
  112734. var LensRenderingPipeline = /** @class */ (function (_super) {
  112735. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensRenderingPipeline, _super);
  112736. /**
  112737. * @constructor
  112738. *
  112739. * Effect parameters are as follow:
  112740. * {
  112741. * chromatic_aberration: number; // from 0 to x (1 for realism)
  112742. * edge_blur: number; // from 0 to x (1 for realism)
  112743. * distortion: number; // from 0 to x (1 for realism)
  112744. * grain_amount: number; // from 0 to 1
  112745. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  112746. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  112747. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  112748. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  112749. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  112750. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  112751. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  112752. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  112753. * }
  112754. * Note: if an effect parameter is unset, effect is disabled
  112755. *
  112756. * @param name The rendering pipeline name
  112757. * @param parameters - An object containing all parameters (see above)
  112758. * @param scene The scene linked to this pipeline
  112759. * @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)
  112760. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112761. */
  112762. function LensRenderingPipeline(name, parameters, scene, ratio, cameras) {
  112763. if (ratio === void 0) { ratio = 1.0; }
  112764. var _this = _super.call(this, scene.getEngine(), name) || this;
  112765. // Lens effects can be of the following:
  112766. // - chromatic aberration (slight shift of RGB colors)
  112767. // - blur on the edge of the lens
  112768. // - lens distortion
  112769. // - depth-of-field blur & highlights enhancing
  112770. // - depth-of-field 'bokeh' effect (shapes appearing in blurred areas)
  112771. // - grain effect (noise or custom texture)
  112772. // Two additional texture samplers are needed:
  112773. // - depth map (for depth-of-field)
  112774. // - grain texture
  112775. /**
  112776. * @ignore
  112777. * The chromatic aberration PostProcess id in the pipeline
  112778. */
  112779. _this.LensChromaticAberrationEffect = "LensChromaticAberrationEffect";
  112780. /**
  112781. * @ignore
  112782. * The highlights enhancing PostProcess id in the pipeline
  112783. */
  112784. _this.HighlightsEnhancingEffect = "HighlightsEnhancingEffect";
  112785. /**
  112786. * @ignore
  112787. * The depth-of-field PostProcess id in the pipeline
  112788. */
  112789. _this.LensDepthOfFieldEffect = "LensDepthOfFieldEffect";
  112790. _this._scene = scene;
  112791. // Fetch texture samplers
  112792. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  112793. if (parameters.grain_texture) {
  112794. _this._grainTexture = parameters.grain_texture;
  112795. }
  112796. else {
  112797. _this._createGrainTexture();
  112798. }
  112799. // save parameters
  112800. _this._edgeBlur = parameters.edge_blur ? parameters.edge_blur : 0;
  112801. _this._grainAmount = parameters.grain_amount ? parameters.grain_amount : 0;
  112802. _this._chromaticAberration = parameters.chromatic_aberration ? parameters.chromatic_aberration : 0;
  112803. _this._distortion = parameters.distortion ? parameters.distortion : 0;
  112804. _this._highlightsGain = parameters.dof_gain !== undefined ? parameters.dof_gain : -1;
  112805. _this._highlightsThreshold = parameters.dof_threshold ? parameters.dof_threshold : 1;
  112806. _this._dofDistance = parameters.dof_focus_distance !== undefined ? parameters.dof_focus_distance : -1;
  112807. _this._dofAperture = parameters.dof_aperture ? parameters.dof_aperture : 1;
  112808. _this._dofDarken = parameters.dof_darken ? parameters.dof_darken : 0;
  112809. _this._dofPentagon = parameters.dof_pentagon !== undefined ? parameters.dof_pentagon : true;
  112810. _this._blurNoise = parameters.blur_noise !== undefined ? parameters.blur_noise : true;
  112811. // Create effects
  112812. _this._createChromaticAberrationPostProcess(ratio);
  112813. _this._createHighlightsPostProcess(ratio);
  112814. _this._createDepthOfFieldPostProcess(ratio / 4);
  112815. // Set up pipeline
  112816. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensChromaticAberrationEffect, function () { return _this._chromaticAberrationPostProcess; }, true));
  112817. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.HighlightsEnhancingEffect, function () { return _this._highlightsPostProcess; }, true));
  112818. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensDepthOfFieldEffect, function () { return _this._depthOfFieldPostProcess; }, true));
  112819. if (_this._highlightsGain === -1) {
  112820. _this._disableEffect(_this.HighlightsEnhancingEffect, null);
  112821. }
  112822. // Finish
  112823. scene.postProcessRenderPipelineManager.addPipeline(_this);
  112824. if (cameras) {
  112825. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  112826. }
  112827. return _this;
  112828. }
  112829. // public methods (self explanatory)
  112830. /**
  112831. * Sets the amount of blur at the edges
  112832. * @param amount blur amount
  112833. */
  112834. LensRenderingPipeline.prototype.setEdgeBlur = function (amount) { this._edgeBlur = amount; };
  112835. /**
  112836. * Sets edge blur to 0
  112837. */
  112838. LensRenderingPipeline.prototype.disableEdgeBlur = function () { this._edgeBlur = 0; };
  112839. /**
  112840. * Sets the amout of grain
  112841. * @param amount Amount of grain
  112842. */
  112843. LensRenderingPipeline.prototype.setGrainAmount = function (amount) { this._grainAmount = amount; };
  112844. /**
  112845. * Set grain amount to 0
  112846. */
  112847. LensRenderingPipeline.prototype.disableGrain = function () { this._grainAmount = 0; };
  112848. /**
  112849. * Sets the chromatic aberration amount
  112850. * @param amount amount of chromatic aberration
  112851. */
  112852. LensRenderingPipeline.prototype.setChromaticAberration = function (amount) { this._chromaticAberration = amount; };
  112853. /**
  112854. * Sets chromatic aberration amount to 0
  112855. */
  112856. LensRenderingPipeline.prototype.disableChromaticAberration = function () { this._chromaticAberration = 0; };
  112857. /**
  112858. * Sets the EdgeDistortion amount
  112859. * @param amount amount of EdgeDistortion
  112860. */
  112861. LensRenderingPipeline.prototype.setEdgeDistortion = function (amount) { this._distortion = amount; };
  112862. /**
  112863. * Sets edge distortion to 0
  112864. */
  112865. LensRenderingPipeline.prototype.disableEdgeDistortion = function () { this._distortion = 0; };
  112866. /**
  112867. * Sets the FocusDistance amount
  112868. * @param amount amount of FocusDistance
  112869. */
  112870. LensRenderingPipeline.prototype.setFocusDistance = function (amount) { this._dofDistance = amount; };
  112871. /**
  112872. * Disables depth of field
  112873. */
  112874. LensRenderingPipeline.prototype.disableDepthOfField = function () { this._dofDistance = -1; };
  112875. /**
  112876. * Sets the Aperture amount
  112877. * @param amount amount of Aperture
  112878. */
  112879. LensRenderingPipeline.prototype.setAperture = function (amount) { this._dofAperture = amount; };
  112880. /**
  112881. * Sets the DarkenOutOfFocus amount
  112882. * @param amount amount of DarkenOutOfFocus
  112883. */
  112884. LensRenderingPipeline.prototype.setDarkenOutOfFocus = function (amount) { this._dofDarken = amount; };
  112885. /**
  112886. * Creates a pentagon bokeh effect
  112887. */
  112888. LensRenderingPipeline.prototype.enablePentagonBokeh = function () {
  112889. this._highlightsPostProcess.updateEffect("#define PENTAGON\n");
  112890. };
  112891. /**
  112892. * Disables the pentagon bokeh effect
  112893. */
  112894. LensRenderingPipeline.prototype.disablePentagonBokeh = function () {
  112895. this._highlightsPostProcess.updateEffect();
  112896. };
  112897. /**
  112898. * Enables noise blur
  112899. */
  112900. LensRenderingPipeline.prototype.enableNoiseBlur = function () { this._blurNoise = true; };
  112901. /**
  112902. * Disables noise blur
  112903. */
  112904. LensRenderingPipeline.prototype.disableNoiseBlur = function () { this._blurNoise = false; };
  112905. /**
  112906. * Sets the HighlightsGain amount
  112907. * @param amount amount of HighlightsGain
  112908. */
  112909. LensRenderingPipeline.prototype.setHighlightsGain = function (amount) {
  112910. this._highlightsGain = amount;
  112911. };
  112912. /**
  112913. * Sets the HighlightsThreshold amount
  112914. * @param amount amount of HighlightsThreshold
  112915. */
  112916. LensRenderingPipeline.prototype.setHighlightsThreshold = function (amount) {
  112917. if (this._highlightsGain === -1) {
  112918. this._highlightsGain = 1.0;
  112919. }
  112920. this._highlightsThreshold = amount;
  112921. };
  112922. /**
  112923. * Disables highlights
  112924. */
  112925. LensRenderingPipeline.prototype.disableHighlights = function () {
  112926. this._highlightsGain = -1;
  112927. };
  112928. /**
  112929. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  112930. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  112931. */
  112932. LensRenderingPipeline.prototype.dispose = function (disableDepthRender) {
  112933. if (disableDepthRender === void 0) { disableDepthRender = false; }
  112934. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  112935. this._chromaticAberrationPostProcess = null;
  112936. this._highlightsPostProcess = null;
  112937. this._depthOfFieldPostProcess = null;
  112938. this._grainTexture.dispose();
  112939. if (disableDepthRender) {
  112940. this._scene.disableDepthRenderer();
  112941. }
  112942. };
  112943. // colors shifting and distortion
  112944. LensRenderingPipeline.prototype._createChromaticAberrationPostProcess = function (ratio) {
  112945. var _this = this;
  112946. this._chromaticAberrationPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensChromaticAberration", "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], // uniforms
  112947. [], // samplers
  112948. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  112949. this._chromaticAberrationPostProcess.onApply = function (effect) {
  112950. effect.setFloat('chromatic_aberration', _this._chromaticAberration);
  112951. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  112952. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  112953. effect.setFloat('radialIntensity', 1);
  112954. effect.setFloat2('direction', 17, 17);
  112955. effect.setFloat2('centerPosition', 0.5, 0.5);
  112956. };
  112957. };
  112958. // highlights enhancing
  112959. LensRenderingPipeline.prototype._createHighlightsPostProcess = function (ratio) {
  112960. var _this = this;
  112961. this._highlightsPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensHighlights", "lensHighlights", ["gain", "threshold", "screen_width", "screen_height"], // uniforms
  112962. [], // samplers
  112963. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, this._dofPentagon ? "#define PENTAGON\n" : "");
  112964. this._highlightsPostProcess.onApply = function (effect) {
  112965. effect.setFloat('gain', _this._highlightsGain);
  112966. effect.setFloat('threshold', _this._highlightsThreshold);
  112967. effect.setTextureFromPostProcess("textureSampler", _this._chromaticAberrationPostProcess);
  112968. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  112969. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  112970. };
  112971. };
  112972. // colors shifting and distortion
  112973. LensRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (ratio) {
  112974. var _this = this;
  112975. this._depthOfFieldPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensDepthOfField", "depthOfField", [
  112976. "grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled",
  112977. "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"
  112978. ], ["depthSampler", "grainSampler", "highlightsSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  112979. this._depthOfFieldPostProcess.onApply = function (effect) {
  112980. effect.setTexture("depthSampler", _this._depthTexture);
  112981. effect.setTexture("grainSampler", _this._grainTexture);
  112982. effect.setTextureFromPostProcess("textureSampler", _this._highlightsPostProcess);
  112983. effect.setTextureFromPostProcess("highlightsSampler", _this._depthOfFieldPostProcess);
  112984. effect.setFloat('grain_amount', _this._grainAmount);
  112985. effect.setBool('blur_noise', _this._blurNoise);
  112986. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  112987. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  112988. effect.setFloat('distortion', _this._distortion);
  112989. effect.setBool('dof_enabled', (_this._dofDistance !== -1));
  112990. effect.setFloat('screen_distance', 1.0 / (0.1 - 1.0 / _this._dofDistance));
  112991. effect.setFloat('aperture', _this._dofAperture);
  112992. effect.setFloat('darken', _this._dofDarken);
  112993. effect.setFloat('edge_blur', _this._edgeBlur);
  112994. effect.setBool('highlights', (_this._highlightsGain !== -1));
  112995. if (_this._scene.activeCamera) {
  112996. effect.setFloat('near', _this._scene.activeCamera.minZ);
  112997. effect.setFloat('far', _this._scene.activeCamera.maxZ);
  112998. }
  112999. };
  113000. };
  113001. // creates a black and white random noise texture, 512x512
  113002. LensRenderingPipeline.prototype._createGrainTexture = function () {
  113003. var size = 512;
  113004. 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);
  113005. this._grainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  113006. this._grainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  113007. var context = this._grainTexture.getContext();
  113008. var rand = function (min, max) {
  113009. return Math.random() * (max - min) + min;
  113010. };
  113011. var value;
  113012. for (var x = 0; x < size; x++) {
  113013. for (var y = 0; y < size; y++) {
  113014. value = Math.floor(rand(0.42, 0.58) * 255);
  113015. context.fillStyle = 'rgb(' + value + ', ' + value + ', ' + value + ')';
  113016. context.fillRect(x, y, 1, 1);
  113017. }
  113018. }
  113019. this._grainTexture.update(false);
  113020. };
  113021. return LensRenderingPipeline;
  113022. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipeline"]));
  113023. /***/ }),
  113024. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts":
  113025. /*!**************************************************************************!*\
  113026. !*** ./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts ***!
  113027. \**************************************************************************/
  113028. /*! exports provided: SSAO2RenderingPipeline */
  113029. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113030. "use strict";
  113031. __webpack_require__.r(__webpack_exports__);
  113032. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return SSAO2RenderingPipeline; });
  113033. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  113034. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  113035. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  113036. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  113037. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  113038. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  113039. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  113040. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  113041. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  113042. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  113043. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  113044. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  113045. /* harmony import */ var _Shaders_ssao2_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssao2.fragment */ "./Shaders/ssao2.fragment.ts");
  113046. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  113047. /**
  113048. * Render pipeline to produce ssao effect
  113049. */
  113050. var SSAO2RenderingPipeline = /** @class */ (function (_super) {
  113051. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAO2RenderingPipeline, _super);
  113052. /**
  113053. * @constructor
  113054. * @param name The rendering pipeline name
  113055. * @param scene The scene linked to this pipeline
  113056. * @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 }
  113057. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113058. */
  113059. function SSAO2RenderingPipeline(name, scene, ratio, cameras) {
  113060. var _this = _super.call(this, scene.getEngine(), name) || this;
  113061. // Members
  113062. /**
  113063. * @ignore
  113064. * The PassPostProcess id in the pipeline that contains the original scene color
  113065. */
  113066. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  113067. /**
  113068. * @ignore
  113069. * The SSAO PostProcess id in the pipeline
  113070. */
  113071. _this.SSAORenderEffect = "SSAORenderEffect";
  113072. /**
  113073. * @ignore
  113074. * The horizontal blur PostProcess id in the pipeline
  113075. */
  113076. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  113077. /**
  113078. * @ignore
  113079. * The vertical blur PostProcess id in the pipeline
  113080. */
  113081. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  113082. /**
  113083. * @ignore
  113084. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113085. */
  113086. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  113087. /**
  113088. * The output strength of the SSAO post-process. Default value is 1.0.
  113089. */
  113090. _this.totalStrength = 1.0;
  113091. /**
  113092. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  113093. */
  113094. _this.maxZ = 100.0;
  113095. /**
  113096. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  113097. */
  113098. _this.minZAspect = 0.2;
  113099. _this._samples = 8;
  113100. _this._textureSamples = 1;
  113101. _this._expensiveBlur = true;
  113102. /**
  113103. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  113104. */
  113105. _this.radius = 2.0;
  113106. /**
  113107. * The base color of the SSAO post-process
  113108. * The final result is "base + ssao" between [0, 1]
  113109. */
  113110. _this.base = 0;
  113111. _this._firstUpdate = true;
  113112. _this._bits = new Uint32Array(1);
  113113. _this._scene = scene;
  113114. _this._ratio = ratio;
  113115. if (!_this.isSupported) {
  113116. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("SSAO 2 needs WebGL 2 support.");
  113117. return _this;
  113118. }
  113119. var ssaoRatio = _this._ratio.ssaoRatio || ratio;
  113120. var blurRatio = _this._ratio.blurRatio || ratio;
  113121. // Set up assets
  113122. var geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  113123. _this._createRandomTexture();
  113124. _this._depthTexture = geometryBufferRenderer.getGBuffer().textures[0];
  113125. _this._normalTexture = geometryBufferRenderer.getGBuffer().textures[1];
  113126. _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);
  113127. _this._originalColorPostProcess.samples = _this.textureSamples;
  113128. _this._createSSAOPostProcess(1.0);
  113129. _this._createBlurPostProcess(ssaoRatio, blurRatio);
  113130. _this._createSSAOCombinePostProcess(blurRatio);
  113131. // Set up pipeline
  113132. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  113133. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  113134. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  113135. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  113136. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  113137. // Finish
  113138. scene.postProcessRenderPipelineManager.addPipeline(_this);
  113139. if (cameras) {
  113140. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  113141. }
  113142. return _this;
  113143. }
  113144. Object.defineProperty(SSAO2RenderingPipeline.prototype, "samples", {
  113145. get: function () {
  113146. return this._samples;
  113147. },
  113148. /**
  113149. * Number of samples used for the SSAO calculations. Default value is 8
  113150. */
  113151. set: function (n) {
  113152. this._ssaoPostProcess.updateEffect("#define SAMPLES " + n + "\n#define SSAO");
  113153. this._samples = n;
  113154. this._sampleSphere = this._generateHemisphere();
  113155. this._firstUpdate = true;
  113156. },
  113157. enumerable: true,
  113158. configurable: true
  113159. });
  113160. Object.defineProperty(SSAO2RenderingPipeline.prototype, "textureSamples", {
  113161. get: function () {
  113162. return this._textureSamples;
  113163. },
  113164. /**
  113165. * Number of samples to use for antialiasing
  113166. */
  113167. set: function (n) {
  113168. this._textureSamples = n;
  113169. this._originalColorPostProcess.samples = n;
  113170. this._blurHPostProcess.samples = n;
  113171. this._blurVPostProcess.samples = n;
  113172. this._ssaoPostProcess.samples = n;
  113173. this._ssaoCombinePostProcess.samples = n;
  113174. },
  113175. enumerable: true,
  113176. configurable: true
  113177. });
  113178. Object.defineProperty(SSAO2RenderingPipeline.prototype, "expensiveBlur", {
  113179. get: function () {
  113180. return this._expensiveBlur;
  113181. },
  113182. /**
  113183. * If bilateral blur should be used
  113184. */
  113185. set: function (b) {
  113186. 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"]);
  113187. this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE " + (b ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]);
  113188. this._expensiveBlur = b;
  113189. this._firstUpdate = true;
  113190. },
  113191. enumerable: true,
  113192. configurable: true
  113193. });
  113194. Object.defineProperty(SSAO2RenderingPipeline, "IsSupported", {
  113195. /**
  113196. * Support test.
  113197. */
  113198. get: function () {
  113199. var engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__["EngineStore"].LastCreatedEngine;
  113200. if (!engine) {
  113201. return false;
  113202. }
  113203. return engine.getCaps().drawBuffersExtension;
  113204. },
  113205. enumerable: true,
  113206. configurable: true
  113207. });
  113208. // Public Methods
  113209. /**
  113210. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113211. */
  113212. SSAO2RenderingPipeline.prototype.dispose = function (disableGeometryBufferRenderer) {
  113213. if (disableGeometryBufferRenderer === void 0) { disableGeometryBufferRenderer = false; }
  113214. for (var i = 0; i < this._scene.cameras.length; i++) {
  113215. var camera = this._scene.cameras[i];
  113216. this._originalColorPostProcess.dispose(camera);
  113217. this._ssaoPostProcess.dispose(camera);
  113218. this._blurHPostProcess.dispose(camera);
  113219. this._blurVPostProcess.dispose(camera);
  113220. this._ssaoCombinePostProcess.dispose(camera);
  113221. }
  113222. this._randomTexture.dispose();
  113223. if (disableGeometryBufferRenderer) {
  113224. this._scene.disableGeometryBufferRenderer();
  113225. }
  113226. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  113227. _super.prototype.dispose.call(this);
  113228. };
  113229. // Private Methods
  113230. SSAO2RenderingPipeline.prototype._createBlurPostProcess = function (ssaoRatio, blurRatio) {
  113231. var _this = this;
  113232. this._samplerOffsets = [];
  113233. var expensive = this.expensiveBlur;
  113234. for (var i = -8; i < 8; i++) {
  113235. this._samplerOffsets.push(i * 2 + 0.5);
  113236. }
  113237. 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");
  113238. this._blurHPostProcess.onApply = function (effect) {
  113239. if (!_this._scene.activeCamera) {
  113240. return;
  113241. }
  113242. effect.setFloat("outSize", _this._ssaoCombinePostProcess.width > 0 ? _this._ssaoCombinePostProcess.width : _this._originalColorPostProcess.width);
  113243. effect.setFloat("near", _this._scene.activeCamera.minZ);
  113244. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  113245. effect.setFloat("radius", _this.radius);
  113246. effect.setTexture("depthSampler", _this._depthTexture);
  113247. if (_this._firstUpdate) {
  113248. effect.setArray("samplerOffsets", _this._samplerOffsets);
  113249. }
  113250. };
  113251. 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");
  113252. this._blurVPostProcess.onApply = function (effect) {
  113253. if (!_this._scene.activeCamera) {
  113254. return;
  113255. }
  113256. effect.setFloat("outSize", _this._ssaoCombinePostProcess.height > 0 ? _this._ssaoCombinePostProcess.height : _this._originalColorPostProcess.height);
  113257. effect.setFloat("near", _this._scene.activeCamera.minZ);
  113258. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  113259. effect.setFloat("radius", _this.radius);
  113260. effect.setTexture("depthSampler", _this._depthTexture);
  113261. if (_this._firstUpdate) {
  113262. effect.setArray("samplerOffsets", _this._samplerOffsets);
  113263. _this._firstUpdate = false;
  113264. }
  113265. };
  113266. this._blurHPostProcess.samples = this.textureSamples;
  113267. this._blurVPostProcess.samples = this.textureSamples;
  113268. };
  113269. /** @hidden */
  113270. SSAO2RenderingPipeline.prototype._rebuild = function () {
  113271. this._firstUpdate = true;
  113272. _super.prototype._rebuild.call(this);
  113273. };
  113274. //Van der Corput radical inverse
  113275. SSAO2RenderingPipeline.prototype._radicalInverse_VdC = function (i) {
  113276. this._bits[0] = i;
  113277. this._bits[0] = ((this._bits[0] << 16) | (this._bits[0] >> 16)) >>> 0;
  113278. this._bits[0] = ((this._bits[0] & 0x55555555) << 1) | ((this._bits[0] & 0xAAAAAAAA) >>> 1) >>> 0;
  113279. this._bits[0] = ((this._bits[0] & 0x33333333) << 2) | ((this._bits[0] & 0xCCCCCCCC) >>> 2) >>> 0;
  113280. this._bits[0] = ((this._bits[0] & 0x0F0F0F0F) << 4) | ((this._bits[0] & 0xF0F0F0F0) >>> 4) >>> 0;
  113281. this._bits[0] = ((this._bits[0] & 0x00FF00FF) << 8) | ((this._bits[0] & 0xFF00FF00) >>> 8) >>> 0;
  113282. return this._bits[0] * 2.3283064365386963e-10; // / 0x100000000 or / 4294967296
  113283. };
  113284. SSAO2RenderingPipeline.prototype._hammersley = function (i, n) {
  113285. return [i / n, this._radicalInverse_VdC(i)];
  113286. };
  113287. SSAO2RenderingPipeline.prototype._hemisphereSample_uniform = function (u, v) {
  113288. var phi = v * 2.0 * Math.PI;
  113289. // rejecting samples that are close to tangent plane to avoid z-fighting artifacts
  113290. var cosTheta = 1.0 - (u * 0.85 + 0.15);
  113291. var sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta);
  113292. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.cos(phi) * sinTheta, Math.sin(phi) * sinTheta, cosTheta);
  113293. };
  113294. SSAO2RenderingPipeline.prototype._generateHemisphere = function () {
  113295. var numSamples = this.samples;
  113296. var result = [];
  113297. var vector;
  113298. var i = 0;
  113299. while (i < numSamples) {
  113300. if (numSamples < 16) {
  113301. vector = this._hemisphereSample_uniform(Math.random(), Math.random());
  113302. }
  113303. else {
  113304. var rand = this._hammersley(i, numSamples);
  113305. vector = this._hemisphereSample_uniform(rand[0], rand[1]);
  113306. }
  113307. result.push(vector.x, vector.y, vector.z);
  113308. i++;
  113309. }
  113310. return result;
  113311. };
  113312. SSAO2RenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  113313. var _this = this;
  113314. var numSamples = this.samples;
  113315. this._sampleSphere = this._generateHemisphere();
  113316. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("ssao2", "ssao2", [
  113317. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  113318. "base", "range", "projection", "near", "far", "texelSize",
  113319. "xViewport", "yViewport", "maxZ", "minZAspect"
  113320. ], ["randomSampler", "normalSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  113321. this._ssaoPostProcess.onApply = function (effect) {
  113322. if (_this._firstUpdate) {
  113323. effect.setArray3("sampleSphere", _this._sampleSphere);
  113324. effect.setFloat("randTextureTiles", 32.0);
  113325. }
  113326. if (!_this._scene.activeCamera) {
  113327. return;
  113328. }
  113329. effect.setFloat("samplesFactor", 1 / _this.samples);
  113330. effect.setFloat("totalStrength", _this.totalStrength);
  113331. effect.setFloat2("texelSize", 1 / _this._ssaoPostProcess.width, 1 / _this._ssaoPostProcess.height);
  113332. effect.setFloat("radius", _this.radius);
  113333. effect.setFloat("maxZ", _this.maxZ);
  113334. effect.setFloat("minZAspect", _this.minZAspect);
  113335. effect.setFloat("base", _this.base);
  113336. effect.setFloat("near", _this._scene.activeCamera.minZ);
  113337. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  113338. effect.setFloat("xViewport", Math.tan(_this._scene.activeCamera.fov / 2) * _this._scene.getEngine().getAspectRatio(_this._scene.activeCamera, true));
  113339. effect.setFloat("yViewport", Math.tan(_this._scene.activeCamera.fov / 2));
  113340. effect.setMatrix("projection", _this._scene.getProjectionMatrix());
  113341. effect.setTexture("textureSampler", _this._depthTexture);
  113342. effect.setTexture("normalSampler", _this._normalTexture);
  113343. effect.setTexture("randomSampler", _this._randomTexture);
  113344. };
  113345. this._ssaoPostProcess.samples = this.textureSamples;
  113346. };
  113347. SSAO2RenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  113348. var _this = this;
  113349. 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);
  113350. this._ssaoCombinePostProcess.onApply = function (effect) {
  113351. var viewport = _this._scene.activeCamera.viewport;
  113352. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector4[0].copyFromFloats(viewport.x, viewport.y, viewport.width, viewport.height));
  113353. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  113354. };
  113355. this._ssaoCombinePostProcess.samples = this.textureSamples;
  113356. };
  113357. SSAO2RenderingPipeline.prototype._createRandomTexture = function () {
  113358. var size = 128;
  113359. 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);
  113360. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  113361. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  113362. var context = this._randomTexture.getContext();
  113363. var rand = function (min, max) {
  113364. return Math.random() * (max - min) + min;
  113365. };
  113366. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  113367. for (var x = 0; x < size; x++) {
  113368. for (var y = 0; y < size; y++) {
  113369. randVector.x = rand(0.0, 1.0);
  113370. randVector.y = rand(0.0, 1.0);
  113371. randVector.z = 0.0;
  113372. randVector.normalize();
  113373. randVector.scaleInPlace(255);
  113374. randVector.x = Math.floor(randVector.x);
  113375. randVector.y = Math.floor(randVector.y);
  113376. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  113377. context.fillRect(x, y, 1, 1);
  113378. }
  113379. }
  113380. this._randomTexture.update(false);
  113381. };
  113382. /**
  113383. * Serialize the rendering pipeline (Used when exporting)
  113384. * @returns the serialized object
  113385. */
  113386. SSAO2RenderingPipeline.prototype.serialize = function () {
  113387. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Serialize(this);
  113388. serializationObject.customType = "SSAO2RenderingPipeline";
  113389. return serializationObject;
  113390. };
  113391. /**
  113392. * Parse the serialized pipeline
  113393. * @param source Source pipeline.
  113394. * @param scene The scene to load the pipeline to.
  113395. * @param rootUrl The URL of the serialized pipeline.
  113396. * @returns An instantiated pipeline from the serialized object.
  113397. */
  113398. SSAO2RenderingPipeline.Parse = function (source, scene, rootUrl) {
  113399. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Parse(function () { return new SSAO2RenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  113400. };
  113401. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113402. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  113403. ], SSAO2RenderingPipeline.prototype, "totalStrength", void 0);
  113404. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113405. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  113406. ], SSAO2RenderingPipeline.prototype, "maxZ", void 0);
  113407. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113408. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  113409. ], SSAO2RenderingPipeline.prototype, "minZAspect", void 0);
  113410. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113411. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("samples")
  113412. ], SSAO2RenderingPipeline.prototype, "_samples", void 0);
  113413. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113414. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("textureSamples")
  113415. ], SSAO2RenderingPipeline.prototype, "_textureSamples", void 0);
  113416. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113417. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  113418. ], SSAO2RenderingPipeline.prototype, "_ratio", void 0);
  113419. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113420. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("expensiveBlur")
  113421. ], SSAO2RenderingPipeline.prototype, "_expensiveBlur", void 0);
  113422. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113423. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  113424. ], SSAO2RenderingPipeline.prototype, "radius", void 0);
  113425. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113426. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  113427. ], SSAO2RenderingPipeline.prototype, "base", void 0);
  113428. return SSAO2RenderingPipeline;
  113429. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  113430. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__["_TypeStore"].RegisteredTypes["BABYLON.SSAO2RenderingPipeline"] = SSAO2RenderingPipeline;
  113431. /***/ }),
  113432. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts":
  113433. /*!*************************************************************************!*\
  113434. !*** ./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts ***!
  113435. \*************************************************************************/
  113436. /*! exports provided: SSAORenderingPipeline */
  113437. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113438. "use strict";
  113439. __webpack_require__.r(__webpack_exports__);
  113440. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return SSAORenderingPipeline; });
  113441. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  113442. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  113443. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  113444. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  113445. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  113446. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  113447. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  113448. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  113449. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  113450. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  113451. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  113452. /* harmony import */ var _Shaders_ssao_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Shaders/ssao.fragment */ "./Shaders/ssao.fragment.ts");
  113453. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  113454. /**
  113455. * Render pipeline to produce ssao effect
  113456. */
  113457. var SSAORenderingPipeline = /** @class */ (function (_super) {
  113458. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAORenderingPipeline, _super);
  113459. /**
  113460. * @constructor
  113461. * @param name - The rendering pipeline name
  113462. * @param scene - The scene linked to this pipeline
  113463. * @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 }
  113464. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  113465. */
  113466. function SSAORenderingPipeline(name, scene, ratio, cameras) {
  113467. var _this = _super.call(this, scene.getEngine(), name) || this;
  113468. // Members
  113469. /**
  113470. * @ignore
  113471. * The PassPostProcess id in the pipeline that contains the original scene color
  113472. */
  113473. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  113474. /**
  113475. * @ignore
  113476. * The SSAO PostProcess id in the pipeline
  113477. */
  113478. _this.SSAORenderEffect = "SSAORenderEffect";
  113479. /**
  113480. * @ignore
  113481. * The horizontal blur PostProcess id in the pipeline
  113482. */
  113483. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  113484. /**
  113485. * @ignore
  113486. * The vertical blur PostProcess id in the pipeline
  113487. */
  113488. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  113489. /**
  113490. * @ignore
  113491. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113492. */
  113493. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  113494. /**
  113495. * The output strength of the SSAO post-process. Default value is 1.0.
  113496. */
  113497. _this.totalStrength = 1.0;
  113498. /**
  113499. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  113500. */
  113501. _this.radius = 0.0001;
  113502. /**
  113503. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  113504. * Must not be equal to fallOff and superior to fallOff.
  113505. * Default value is 0.975
  113506. */
  113507. _this.area = 0.0075;
  113508. /**
  113509. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  113510. * Must not be equal to area and inferior to area.
  113511. * Default value is 0.0
  113512. */
  113513. _this.fallOff = 0.000001;
  113514. /**
  113515. * The base color of the SSAO post-process
  113516. * The final result is "base + ssao" between [0, 1]
  113517. */
  113518. _this.base = 0.5;
  113519. _this._firstUpdate = true;
  113520. _this._scene = scene;
  113521. // Set up assets
  113522. _this._createRandomTexture();
  113523. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  113524. var ssaoRatio = ratio.ssaoRatio || ratio;
  113525. var combineRatio = ratio.combineRatio || ratio;
  113526. _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);
  113527. _this._createSSAOPostProcess(ssaoRatio);
  113528. _this._createBlurPostProcess(ssaoRatio);
  113529. _this._createSSAOCombinePostProcess(combineRatio);
  113530. // Set up pipeline
  113531. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  113532. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  113533. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  113534. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  113535. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  113536. // Finish
  113537. scene.postProcessRenderPipelineManager.addPipeline(_this);
  113538. if (cameras) {
  113539. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  113540. }
  113541. return _this;
  113542. }
  113543. // Public Methods
  113544. /**
  113545. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113546. */
  113547. SSAORenderingPipeline.prototype.dispose = function (disableDepthRender) {
  113548. if (disableDepthRender === void 0) { disableDepthRender = false; }
  113549. for (var i = 0; i < this._scene.cameras.length; i++) {
  113550. var camera = this._scene.cameras[i];
  113551. this._originalColorPostProcess.dispose(camera);
  113552. this._ssaoPostProcess.dispose(camera);
  113553. this._blurHPostProcess.dispose(camera);
  113554. this._blurVPostProcess.dispose(camera);
  113555. this._ssaoCombinePostProcess.dispose(camera);
  113556. }
  113557. this._randomTexture.dispose();
  113558. if (disableDepthRender) {
  113559. this._scene.disableDepthRenderer();
  113560. }
  113561. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  113562. _super.prototype.dispose.call(this);
  113563. };
  113564. // Private Methods
  113565. SSAORenderingPipeline.prototype._createBlurPostProcess = function (ratio) {
  113566. var _this = this;
  113567. var size = 16;
  113568. 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);
  113569. 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);
  113570. this._blurHPostProcess.onActivateObservable.add(function () {
  113571. var dw = _this._blurHPostProcess.width / _this._scene.getEngine().getRenderWidth();
  113572. _this._blurHPostProcess.kernel = size * dw;
  113573. });
  113574. this._blurVPostProcess.onActivateObservable.add(function () {
  113575. var dw = _this._blurVPostProcess.height / _this._scene.getEngine().getRenderHeight();
  113576. _this._blurVPostProcess.kernel = size * dw;
  113577. });
  113578. };
  113579. /** @hidden */
  113580. SSAORenderingPipeline.prototype._rebuild = function () {
  113581. this._firstUpdate = true;
  113582. _super.prototype._rebuild.call(this);
  113583. };
  113584. SSAORenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  113585. var _this = this;
  113586. var numSamples = 16;
  113587. var sampleSphere = [
  113588. 0.5381, 0.1856, -0.4319,
  113589. 0.1379, 0.2486, 0.4430,
  113590. 0.3371, 0.5679, -0.0057,
  113591. -0.6999, -0.0451, -0.0019,
  113592. 0.0689, -0.1598, -0.8547,
  113593. 0.0560, 0.0069, -0.1843,
  113594. -0.0146, 0.1402, 0.0762,
  113595. 0.0100, -0.1924, -0.0344,
  113596. -0.3577, -0.5301, -0.4358,
  113597. -0.3169, 0.1063, 0.0158,
  113598. 0.0103, -0.5869, 0.0046,
  113599. -0.0897, -0.4940, 0.3287,
  113600. 0.7119, -0.0154, -0.0918,
  113601. -0.0533, 0.0596, -0.5411,
  113602. 0.0352, -0.0631, 0.5460,
  113603. -0.4776, 0.2847, -0.0271
  113604. ];
  113605. var samplesFactor = 1.0 / numSamples;
  113606. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__["PostProcess"]("ssao", "ssao", [
  113607. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  113608. "area", "fallOff", "base", "range", "viewport"
  113609. ], ["randomSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  113610. this._ssaoPostProcess.onApply = function (effect) {
  113611. if (_this._firstUpdate) {
  113612. effect.setArray3("sampleSphere", sampleSphere);
  113613. effect.setFloat("samplesFactor", samplesFactor);
  113614. effect.setFloat("randTextureTiles", 4.0);
  113615. }
  113616. effect.setFloat("totalStrength", _this.totalStrength);
  113617. effect.setFloat("radius", _this.radius);
  113618. effect.setFloat("area", _this.area);
  113619. effect.setFloat("fallOff", _this.fallOff);
  113620. effect.setFloat("base", _this.base);
  113621. effect.setTexture("textureSampler", _this._depthTexture);
  113622. effect.setTexture("randomSampler", _this._randomTexture);
  113623. };
  113624. };
  113625. SSAORenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  113626. var _this = this;
  113627. 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);
  113628. this._ssaoCombinePostProcess.onApply = function (effect) {
  113629. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector4[0].copyFromFloats(0, 0, 1.0, 1.0));
  113630. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  113631. };
  113632. };
  113633. SSAORenderingPipeline.prototype._createRandomTexture = function () {
  113634. var size = 512;
  113635. 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);
  113636. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  113637. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  113638. var context = this._randomTexture.getContext();
  113639. var rand = function (min, max) {
  113640. return Math.random() * (max - min) + min;
  113641. };
  113642. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  113643. for (var x = 0; x < size; x++) {
  113644. for (var y = 0; y < size; y++) {
  113645. randVector.x = Math.floor(rand(-1.0, 1.0) * 255);
  113646. randVector.y = Math.floor(rand(-1.0, 1.0) * 255);
  113647. randVector.z = Math.floor(rand(-1.0, 1.0) * 255);
  113648. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  113649. context.fillRect(x, y, 1, 1);
  113650. }
  113651. }
  113652. this._randomTexture.update(false);
  113653. };
  113654. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113655. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  113656. ], SSAORenderingPipeline.prototype, "totalStrength", void 0);
  113657. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113658. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  113659. ], SSAORenderingPipeline.prototype, "radius", void 0);
  113660. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113661. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  113662. ], SSAORenderingPipeline.prototype, "area", void 0);
  113663. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113664. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  113665. ], SSAORenderingPipeline.prototype, "fallOff", void 0);
  113666. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113667. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  113668. ], SSAORenderingPipeline.prototype, "base", void 0);
  113669. return SSAORenderingPipeline;
  113670. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderPipeline"]));
  113671. /***/ }),
  113672. /***/ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts":
  113673. /*!*****************************************************************************!*\
  113674. !*** ./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts ***!
  113675. \*****************************************************************************/
  113676. /*! exports provided: StandardRenderingPipeline */
  113677. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113678. "use strict";
  113679. __webpack_require__.r(__webpack_exports__);
  113680. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return StandardRenderingPipeline; });
  113681. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  113682. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  113683. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  113684. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  113685. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  113686. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  113687. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  113688. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  113689. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  113690. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  113691. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  113692. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  113693. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  113694. /* harmony import */ var _Shaders_standard_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/standard.fragment */ "./Shaders/standard.fragment.ts");
  113695. /**
  113696. * Standard rendering pipeline
  113697. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113698. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  113699. */
  113700. var StandardRenderingPipeline = /** @class */ (function (_super) {
  113701. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardRenderingPipeline, _super);
  113702. /**
  113703. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113704. * @constructor
  113705. * @param name The rendering pipeline name
  113706. * @param scene The scene linked to this pipeline
  113707. * @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)
  113708. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  113709. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113710. */
  113711. function StandardRenderingPipeline(name, scene, ratio, originalPostProcess, cameras) {
  113712. if (originalPostProcess === void 0) { originalPostProcess = null; }
  113713. var _this = _super.call(this, scene.getEngine(), name) || this;
  113714. /**
  113715. * Post-process used to down scale an image x4
  113716. */
  113717. _this.downSampleX4PostProcess = null;
  113718. /**
  113719. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  113720. */
  113721. _this.brightPassPostProcess = null;
  113722. /**
  113723. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  113724. */
  113725. _this.blurHPostProcesses = [];
  113726. /**
  113727. * Post-process array storing all the vertical blur post-processes used by the pipeline
  113728. */
  113729. _this.blurVPostProcesses = [];
  113730. /**
  113731. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  113732. */
  113733. _this.textureAdderPostProcess = null;
  113734. /**
  113735. * Post-process used to create volumetric lighting effect
  113736. */
  113737. _this.volumetricLightPostProcess = null;
  113738. /**
  113739. * Post-process used to smooth the previous volumetric light post-process on the X axis
  113740. */
  113741. _this.volumetricLightSmoothXPostProcess = null;
  113742. /**
  113743. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  113744. */
  113745. _this.volumetricLightSmoothYPostProcess = null;
  113746. /**
  113747. * Post-process used to merge the volumetric light effect and the real scene color
  113748. */
  113749. _this.volumetricLightMergePostProces = null;
  113750. /**
  113751. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  113752. */
  113753. _this.volumetricLightFinalPostProcess = null;
  113754. /**
  113755. * Base post-process used to calculate the average luminance of the final image for HDR
  113756. */
  113757. _this.luminancePostProcess = null;
  113758. /**
  113759. * Post-processes used to create down sample post-processes in order to get
  113760. * the average luminance of the final image for HDR
  113761. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  113762. */
  113763. _this.luminanceDownSamplePostProcesses = [];
  113764. /**
  113765. * Post-process used to create a HDR effect (light adaptation)
  113766. */
  113767. _this.hdrPostProcess = null;
  113768. /**
  113769. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  113770. */
  113771. _this.textureAdderFinalPostProcess = null;
  113772. /**
  113773. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  113774. */
  113775. _this.lensFlareFinalPostProcess = null;
  113776. /**
  113777. * Post-process used to merge the final HDR post-process and the real scene color
  113778. */
  113779. _this.hdrFinalPostProcess = null;
  113780. /**
  113781. * Post-process used to create a lens flare effect
  113782. */
  113783. _this.lensFlarePostProcess = null;
  113784. /**
  113785. * Post-process that merges the result of the lens flare post-process and the real scene color
  113786. */
  113787. _this.lensFlareComposePostProcess = null;
  113788. /**
  113789. * Post-process used to create a motion blur effect
  113790. */
  113791. _this.motionBlurPostProcess = null;
  113792. /**
  113793. * Post-process used to create a depth of field effect
  113794. */
  113795. _this.depthOfFieldPostProcess = null;
  113796. /**
  113797. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113798. */
  113799. _this.fxaaPostProcess = null;
  113800. // Values
  113801. /**
  113802. * Represents the brightness threshold in order to configure the illuminated surfaces
  113803. */
  113804. _this.brightThreshold = 1.0;
  113805. /**
  113806. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  113807. */
  113808. _this.blurWidth = 512.0;
  113809. /**
  113810. * Sets if the blur for highlighted surfaces must be only horizontal
  113811. */
  113812. _this.horizontalBlur = false;
  113813. /**
  113814. * Sets the overall exposure used by the pipeline
  113815. */
  113816. _this.exposure = 1.0;
  113817. /**
  113818. * Texture used typically to simulate "dirty" on camera lens
  113819. */
  113820. _this.lensTexture = null;
  113821. /**
  113822. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  113823. */
  113824. _this.volumetricLightCoefficient = 0.2;
  113825. /**
  113826. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  113827. */
  113828. _this.volumetricLightPower = 4.0;
  113829. /**
  113830. * Used the set the blur intensity to smooth the volumetric lights
  113831. */
  113832. _this.volumetricLightBlurScale = 64.0;
  113833. /**
  113834. * Light (spot or directional) used to generate the volumetric lights rays
  113835. * The source light must have a shadow generate so the pipeline can get its
  113836. * depth map
  113837. */
  113838. _this.sourceLight = null;
  113839. /**
  113840. * For eye adaptation, represents the minimum luminance the eye can see
  113841. */
  113842. _this.hdrMinimumLuminance = 1.0;
  113843. /**
  113844. * For eye adaptation, represents the decrease luminance speed
  113845. */
  113846. _this.hdrDecreaseRate = 0.5;
  113847. /**
  113848. * For eye adaptation, represents the increase luminance speed
  113849. */
  113850. _this.hdrIncreaseRate = 0.5;
  113851. /**
  113852. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  113853. */
  113854. _this.lensColorTexture = null;
  113855. /**
  113856. * The overall strengh for the lens flare effect
  113857. */
  113858. _this.lensFlareStrength = 20.0;
  113859. /**
  113860. * Dispersion coefficient for lens flare ghosts
  113861. */
  113862. _this.lensFlareGhostDispersal = 1.4;
  113863. /**
  113864. * Main lens flare halo width
  113865. */
  113866. _this.lensFlareHaloWidth = 0.7;
  113867. /**
  113868. * Based on the lens distortion effect, defines how much the lens flare result
  113869. * is distorted
  113870. */
  113871. _this.lensFlareDistortionStrength = 16.0;
  113872. /**
  113873. * Lens star texture must be used to simulate rays on the flares and is available
  113874. * in the documentation
  113875. */
  113876. _this.lensStarTexture = null;
  113877. /**
  113878. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  113879. * flare effect by taking account of the dirt texture
  113880. */
  113881. _this.lensFlareDirtTexture = null;
  113882. /**
  113883. * Represents the focal length for the depth of field effect
  113884. */
  113885. _this.depthOfFieldDistance = 10.0;
  113886. /**
  113887. * Represents the blur intensity for the blurred part of the depth of field effect
  113888. */
  113889. _this.depthOfFieldBlurWidth = 64.0;
  113890. /**
  113891. * For motion blur, defines how much the image is blurred by the movement
  113892. */
  113893. _this.motionStrength = 1.0;
  113894. /**
  113895. * List of animations for the pipeline (IAnimatable implementation)
  113896. */
  113897. _this.animations = [];
  113898. _this._currentDepthOfFieldSource = null;
  113899. _this._hdrCurrentLuminance = 1.0;
  113900. // Getters and setters
  113901. _this._bloomEnabled = false;
  113902. _this._depthOfFieldEnabled = false;
  113903. _this._vlsEnabled = false;
  113904. _this._lensFlareEnabled = false;
  113905. _this._hdrEnabled = false;
  113906. _this._motionBlurEnabled = false;
  113907. _this._fxaaEnabled = false;
  113908. _this._motionBlurSamples = 64.0;
  113909. _this._volumetricLightStepsCount = 50.0;
  113910. _this._samples = 1;
  113911. _this._cameras = cameras || [];
  113912. // Initialize
  113913. _this._scene = scene;
  113914. _this._basePostProcess = originalPostProcess;
  113915. _this._ratio = ratio;
  113916. // Misc
  113917. _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;
  113918. // Finish
  113919. scene.postProcessRenderPipelineManager.addPipeline(_this);
  113920. _this._buildPipeline();
  113921. return _this;
  113922. }
  113923. Object.defineProperty(StandardRenderingPipeline.prototype, "BloomEnabled", {
  113924. /**
  113925. * @ignore
  113926. * Specifies if the bloom pipeline is enabled
  113927. */
  113928. get: function () {
  113929. return this._bloomEnabled;
  113930. },
  113931. set: function (enabled) {
  113932. if (this._bloomEnabled === enabled) {
  113933. return;
  113934. }
  113935. this._bloomEnabled = enabled;
  113936. this._buildPipeline();
  113937. },
  113938. enumerable: true,
  113939. configurable: true
  113940. });
  113941. Object.defineProperty(StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", {
  113942. /**
  113943. * @ignore
  113944. * Specifies if the depth of field pipeline is enabed
  113945. */
  113946. get: function () {
  113947. return this._depthOfFieldEnabled;
  113948. },
  113949. set: function (enabled) {
  113950. if (this._depthOfFieldEnabled === enabled) {
  113951. return;
  113952. }
  113953. this._depthOfFieldEnabled = enabled;
  113954. this._buildPipeline();
  113955. },
  113956. enumerable: true,
  113957. configurable: true
  113958. });
  113959. Object.defineProperty(StandardRenderingPipeline.prototype, "LensFlareEnabled", {
  113960. /**
  113961. * @ignore
  113962. * Specifies if the lens flare pipeline is enabed
  113963. */
  113964. get: function () {
  113965. return this._lensFlareEnabled;
  113966. },
  113967. set: function (enabled) {
  113968. if (this._lensFlareEnabled === enabled) {
  113969. return;
  113970. }
  113971. this._lensFlareEnabled = enabled;
  113972. this._buildPipeline();
  113973. },
  113974. enumerable: true,
  113975. configurable: true
  113976. });
  113977. Object.defineProperty(StandardRenderingPipeline.prototype, "HDREnabled", {
  113978. /**
  113979. * @ignore
  113980. * Specifies if the HDR pipeline is enabled
  113981. */
  113982. get: function () {
  113983. return this._hdrEnabled;
  113984. },
  113985. set: function (enabled) {
  113986. if (this._hdrEnabled === enabled) {
  113987. return;
  113988. }
  113989. this._hdrEnabled = enabled;
  113990. this._buildPipeline();
  113991. },
  113992. enumerable: true,
  113993. configurable: true
  113994. });
  113995. Object.defineProperty(StandardRenderingPipeline.prototype, "VLSEnabled", {
  113996. /**
  113997. * @ignore
  113998. * Specifies if the volumetric lights scattering effect is enabled
  113999. */
  114000. get: function () {
  114001. return this._vlsEnabled;
  114002. },
  114003. set: function (enabled) {
  114004. if (this._vlsEnabled === enabled) {
  114005. return;
  114006. }
  114007. if (enabled) {
  114008. var geometry = this._scene.enableGeometryBufferRenderer();
  114009. if (!geometry) {
  114010. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
  114011. return;
  114012. }
  114013. }
  114014. this._vlsEnabled = enabled;
  114015. this._buildPipeline();
  114016. },
  114017. enumerable: true,
  114018. configurable: true
  114019. });
  114020. Object.defineProperty(StandardRenderingPipeline.prototype, "MotionBlurEnabled", {
  114021. /**
  114022. * @ignore
  114023. * Specifies if the motion blur effect is enabled
  114024. */
  114025. get: function () {
  114026. return this._motionBlurEnabled;
  114027. },
  114028. set: function (enabled) {
  114029. if (this._motionBlurEnabled === enabled) {
  114030. return;
  114031. }
  114032. this._motionBlurEnabled = enabled;
  114033. this._buildPipeline();
  114034. },
  114035. enumerable: true,
  114036. configurable: true
  114037. });
  114038. Object.defineProperty(StandardRenderingPipeline.prototype, "fxaaEnabled", {
  114039. /**
  114040. * Specifies if anti-aliasing is enabled
  114041. */
  114042. get: function () {
  114043. return this._fxaaEnabled;
  114044. },
  114045. set: function (enabled) {
  114046. if (this._fxaaEnabled === enabled) {
  114047. return;
  114048. }
  114049. this._fxaaEnabled = enabled;
  114050. this._buildPipeline();
  114051. },
  114052. enumerable: true,
  114053. configurable: true
  114054. });
  114055. Object.defineProperty(StandardRenderingPipeline.prototype, "volumetricLightStepsCount", {
  114056. /**
  114057. * Specifies the number of steps used to calculate the volumetric lights
  114058. * Typically in interval [50, 200]
  114059. */
  114060. get: function () {
  114061. return this._volumetricLightStepsCount;
  114062. },
  114063. set: function (count) {
  114064. if (this.volumetricLightPostProcess) {
  114065. this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS " + count.toFixed(1));
  114066. }
  114067. this._volumetricLightStepsCount = count;
  114068. },
  114069. enumerable: true,
  114070. configurable: true
  114071. });
  114072. Object.defineProperty(StandardRenderingPipeline.prototype, "motionBlurSamples", {
  114073. /**
  114074. * Specifies the number of samples used for the motion blur effect
  114075. * Typically in interval [16, 64]
  114076. */
  114077. get: function () {
  114078. return this._motionBlurSamples;
  114079. },
  114080. set: function (samples) {
  114081. if (this.motionBlurPostProcess) {
  114082. this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + samples.toFixed(1));
  114083. }
  114084. this._motionBlurSamples = samples;
  114085. },
  114086. enumerable: true,
  114087. configurable: true
  114088. });
  114089. Object.defineProperty(StandardRenderingPipeline.prototype, "samples", {
  114090. /**
  114091. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  114092. */
  114093. get: function () {
  114094. return this._samples;
  114095. },
  114096. set: function (sampleCount) {
  114097. if (this._samples === sampleCount) {
  114098. return;
  114099. }
  114100. this._samples = sampleCount;
  114101. this._buildPipeline();
  114102. },
  114103. enumerable: true,
  114104. configurable: true
  114105. });
  114106. StandardRenderingPipeline.prototype._buildPipeline = function () {
  114107. var _this = this;
  114108. var ratio = this._ratio;
  114109. var scene = this._scene;
  114110. this._disposePostProcesses();
  114111. this._reset();
  114112. // Create pass post-process
  114113. if (!this._basePostProcess) {
  114114. 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);
  114115. this.originalPostProcess.onApply = function () {
  114116. _this._currentDepthOfFieldSource = _this.originalPostProcess;
  114117. };
  114118. }
  114119. else {
  114120. this.originalPostProcess = this._basePostProcess;
  114121. }
  114122. if (this._bloomEnabled || this._vlsEnabled || this._lensFlareEnabled || this._depthOfFieldEnabled || this._motionBlurEnabled) {
  114123. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPassPostProcess", function () { return _this.originalPostProcess; }, true));
  114124. }
  114125. this._currentDepthOfFieldSource = this.originalPostProcess;
  114126. if (this._bloomEnabled) {
  114127. // Create down sample X4 post-process
  114128. this._createDownSampleX4PostProcess(scene, ratio / 2);
  114129. // Create bright pass post-process
  114130. this._createBrightPassPostProcess(scene, ratio / 2);
  114131. // Create gaussian blur post-processes (down sampling blurs)
  114132. this._createBlurPostProcesses(scene, ratio / 4, 1);
  114133. // Create texture adder post-process
  114134. this._createTextureAdderPostProcess(scene, ratio);
  114135. // Create depth-of-field source post-process
  114136. 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);
  114137. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBaseDepthOfFieldSource", function () { return _this.textureAdderFinalPostProcess; }, true));
  114138. }
  114139. if (this._vlsEnabled) {
  114140. // Create volumetric light
  114141. this._createVolumetricLightPostProcess(scene, ratio);
  114142. // Create volumetric light final post-process
  114143. 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);
  114144. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSFinal", function () { return _this.volumetricLightFinalPostProcess; }, true));
  114145. }
  114146. if (this._lensFlareEnabled) {
  114147. // Create lens flare post-process
  114148. this._createLensFlarePostProcess(scene, ratio);
  114149. // Create depth-of-field source post-process post lens-flare and disable it now
  114150. 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);
  114151. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostLensFlareDepthOfFieldSource", function () { return _this.lensFlareFinalPostProcess; }, true));
  114152. }
  114153. if (this._hdrEnabled) {
  114154. // Create luminance
  114155. this._createLuminancePostProcesses(scene, this._floatTextureType);
  114156. // Create HDR
  114157. this._createHdrPostProcess(scene, ratio);
  114158. // Create depth-of-field source post-process post hdr and disable it now
  114159. 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);
  114160. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostHDReDepthOfFieldSource", function () { return _this.hdrFinalPostProcess; }, true));
  114161. }
  114162. if (this._depthOfFieldEnabled) {
  114163. // Create gaussian blur used by depth-of-field
  114164. this._createBlurPostProcesses(scene, ratio / 2, 3, "depthOfFieldBlurWidth");
  114165. // Create depth-of-field post-process
  114166. this._createDepthOfFieldPostProcess(scene, ratio);
  114167. }
  114168. if (this._motionBlurEnabled) {
  114169. // Create motion blur post-process
  114170. this._createMotionBlurPostProcess(scene, ratio);
  114171. }
  114172. if (this._fxaaEnabled) {
  114173. // Create fxaa post-process
  114174. 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);
  114175. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRFxaa", function () { return _this.fxaaPostProcess; }, true));
  114176. }
  114177. if (this._cameras !== null) {
  114178. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  114179. }
  114180. if (!this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1) {
  114181. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  114182. }
  114183. };
  114184. // Down Sample X4 Post-Processs
  114185. StandardRenderingPipeline.prototype._createDownSampleX4PostProcess = function (scene, ratio) {
  114186. var _this = this;
  114187. var downSampleX4Offsets = new Array(32);
  114188. 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);
  114189. this.downSampleX4PostProcess.onApply = function (effect) {
  114190. var id = 0;
  114191. var width = _this.downSampleX4PostProcess.width;
  114192. var height = _this.downSampleX4PostProcess.height;
  114193. for (var i = -2; i < 2; i++) {
  114194. for (var j = -2; j < 2; j++) {
  114195. downSampleX4Offsets[id] = (i + 0.5) * (1.0 / width);
  114196. downSampleX4Offsets[id + 1] = (j + 0.5) * (1.0 / height);
  114197. id += 2;
  114198. }
  114199. }
  114200. effect.setArray2("dsOffsets", downSampleX4Offsets);
  114201. };
  114202. // Add to pipeline
  114203. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDownSampleX4", function () { return _this.downSampleX4PostProcess; }, true));
  114204. };
  114205. // Brightpass Post-Process
  114206. StandardRenderingPipeline.prototype._createBrightPassPostProcess = function (scene, ratio) {
  114207. var _this = this;
  114208. var brightOffsets = new Array(8);
  114209. 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);
  114210. this.brightPassPostProcess.onApply = function (effect) {
  114211. var sU = (1.0 / _this.brightPassPostProcess.width);
  114212. var sV = (1.0 / _this.brightPassPostProcess.height);
  114213. brightOffsets[0] = -0.5 * sU;
  114214. brightOffsets[1] = 0.5 * sV;
  114215. brightOffsets[2] = 0.5 * sU;
  114216. brightOffsets[3] = 0.5 * sV;
  114217. brightOffsets[4] = -0.5 * sU;
  114218. brightOffsets[5] = -0.5 * sV;
  114219. brightOffsets[6] = 0.5 * sU;
  114220. brightOffsets[7] = -0.5 * sV;
  114221. effect.setArray2("dsOffsets", brightOffsets);
  114222. effect.setFloat("brightThreshold", _this.brightThreshold);
  114223. };
  114224. // Add to pipeline
  114225. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBrightPass", function () { return _this.brightPassPostProcess; }, true));
  114226. };
  114227. // Create blur H&V post-processes
  114228. StandardRenderingPipeline.prototype._createBlurPostProcesses = function (scene, ratio, indice, blurWidthKey) {
  114229. var _this = this;
  114230. if (blurWidthKey === void 0) { blurWidthKey = "blurWidth"; }
  114231. var engine = scene.getEngine();
  114232. 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);
  114233. 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);
  114234. blurX.onActivateObservable.add(function () {
  114235. var dw = blurX.width / engine.getRenderWidth();
  114236. blurX.kernel = _this[blurWidthKey] * dw;
  114237. });
  114238. blurY.onActivateObservable.add(function () {
  114239. var dw = blurY.height / engine.getRenderHeight();
  114240. blurY.kernel = _this.horizontalBlur ? 64 * dw : _this[blurWidthKey] * dw;
  114241. });
  114242. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurH" + indice, function () { return blurX; }, true));
  114243. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurV" + indice, function () { return blurY; }, true));
  114244. this.blurHPostProcesses.push(blurX);
  114245. this.blurVPostProcesses.push(blurY);
  114246. };
  114247. // Create texture adder post-process
  114248. StandardRenderingPipeline.prototype._createTextureAdderPostProcess = function (scene, ratio) {
  114249. var _this = this;
  114250. 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);
  114251. this.textureAdderPostProcess.onApply = function (effect) {
  114252. effect.setTextureFromPostProcess("otherSampler", _this._vlsEnabled ? _this._currentDepthOfFieldSource : _this.originalPostProcess);
  114253. effect.setTexture("lensSampler", _this.lensTexture);
  114254. effect.setFloat("exposure", _this.exposure);
  114255. _this._currentDepthOfFieldSource = _this.textureAdderFinalPostProcess;
  114256. };
  114257. // Add to pipeline
  114258. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRTextureAdder", function () { return _this.textureAdderPostProcess; }, true));
  114259. };
  114260. StandardRenderingPipeline.prototype._createVolumetricLightPostProcess = function (scene, ratio) {
  114261. var _this = this;
  114262. var geometryRenderer = scene.enableGeometryBufferRenderer();
  114263. geometryRenderer.enablePosition = true;
  114264. var geometry = geometryRenderer.getGBuffer();
  114265. // Base post-process
  114266. 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));
  114267. var depthValues = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  114268. this.volumetricLightPostProcess.onApply = function (effect) {
  114269. if (_this.sourceLight && _this.sourceLight.getShadowGenerator() && _this._scene.activeCamera) {
  114270. var generator = _this.sourceLight.getShadowGenerator();
  114271. effect.setTexture("shadowMapSampler", generator.getShadowMap());
  114272. effect.setTexture("positionSampler", geometry.textures[2]);
  114273. effect.setColor3("sunColor", _this.sourceLight.diffuse);
  114274. effect.setVector3("sunDirection", _this.sourceLight.getShadowDirection());
  114275. effect.setVector3("cameraPosition", _this._scene.activeCamera.globalPosition);
  114276. effect.setMatrix("shadowViewProjection", generator.getTransformMatrix());
  114277. effect.setFloat("scatteringCoefficient", _this.volumetricLightCoefficient);
  114278. effect.setFloat("scatteringPower", _this.volumetricLightPower);
  114279. depthValues.x = _this.sourceLight.getDepthMinZ(_this._scene.activeCamera);
  114280. depthValues.y = _this.sourceLight.getDepthMaxZ(_this._scene.activeCamera);
  114281. effect.setVector2("depthValues", depthValues);
  114282. }
  114283. };
  114284. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLS", function () { return _this.volumetricLightPostProcess; }, true));
  114285. // Smooth
  114286. this._createBlurPostProcesses(scene, ratio / 4, 0, "volumetricLightBlurScale");
  114287. // Merge
  114288. 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");
  114289. this.volumetricLightMergePostProces.onApply = function (effect) {
  114290. effect.setTextureFromPostProcess("originalSampler", _this._bloomEnabled ? _this.textureAdderFinalPostProcess : _this.originalPostProcess);
  114291. _this._currentDepthOfFieldSource = _this.volumetricLightFinalPostProcess;
  114292. };
  114293. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSMerge", function () { return _this.volumetricLightMergePostProces; }, true));
  114294. };
  114295. // Create luminance
  114296. StandardRenderingPipeline.prototype._createLuminancePostProcesses = function (scene, textureType) {
  114297. var _this = this;
  114298. // Create luminance
  114299. var size = Math.pow(3, StandardRenderingPipeline.LuminanceSteps);
  114300. 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);
  114301. var offsets = [];
  114302. this.luminancePostProcess.onApply = function (effect) {
  114303. var sU = (1.0 / _this.luminancePostProcess.width);
  114304. var sV = (1.0 / _this.luminancePostProcess.height);
  114305. offsets[0] = -0.5 * sU;
  114306. offsets[1] = 0.5 * sV;
  114307. offsets[2] = 0.5 * sU;
  114308. offsets[3] = 0.5 * sV;
  114309. offsets[4] = -0.5 * sU;
  114310. offsets[5] = -0.5 * sV;
  114311. offsets[6] = 0.5 * sU;
  114312. offsets[7] = -0.5 * sV;
  114313. effect.setArray2("lumOffsets", offsets);
  114314. };
  114315. // Add to pipeline
  114316. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminance", function () { return _this.luminancePostProcess; }, true));
  114317. // Create down sample luminance
  114318. for (var i = StandardRenderingPipeline.LuminanceSteps - 1; i >= 0; i--) {
  114319. var size = Math.pow(3, i);
  114320. var defines = "#define LUMINANCE_DOWN_SAMPLE\n";
  114321. if (i === 0) {
  114322. defines += "#define FINAL_DOWN_SAMPLER";
  114323. }
  114324. 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);
  114325. this.luminanceDownSamplePostProcesses.push(postProcess);
  114326. }
  114327. // Create callbacks and add effects
  114328. var lastLuminance = this.luminancePostProcess;
  114329. this.luminanceDownSamplePostProcesses.forEach(function (pp, index) {
  114330. var downSampleOffsets = new Array(18);
  114331. pp.onApply = function (effect) {
  114332. if (!lastLuminance) {
  114333. return;
  114334. }
  114335. var id = 0;
  114336. for (var x = -1; x < 2; x++) {
  114337. for (var y = -1; y < 2; y++) {
  114338. downSampleOffsets[id] = x / lastLuminance.width;
  114339. downSampleOffsets[id + 1] = y / lastLuminance.height;
  114340. id += 2;
  114341. }
  114342. }
  114343. effect.setArray2("dsOffsets", downSampleOffsets);
  114344. effect.setFloat("halfDestPixelSize", 0.5 / lastLuminance.width);
  114345. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  114346. lastLuminance = _this.luminancePostProcess;
  114347. }
  114348. else {
  114349. lastLuminance = pp;
  114350. }
  114351. };
  114352. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  114353. pp.onAfterRender = function () {
  114354. var pixel = scene.getEngine().readPixels(0, 0, 1, 1);
  114355. 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);
  114356. _this._hdrCurrentLuminance = (pixel[0] * bit_shift.x + pixel[1] * bit_shift.y + pixel[2] * bit_shift.z + pixel[3] * bit_shift.w) / 100.0;
  114357. };
  114358. }
  114359. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminanceDownSample" + index, function () { return pp; }, true));
  114360. });
  114361. };
  114362. // Create HDR post-process
  114363. StandardRenderingPipeline.prototype._createHdrPostProcess = function (scene, ratio) {
  114364. var _this = this;
  114365. 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);
  114366. var outputLiminance = 1;
  114367. var time = 0;
  114368. var lastTime = 0;
  114369. this.hdrPostProcess.onApply = function (effect) {
  114370. effect.setTextureFromPostProcess("textureAdderSampler", _this._currentDepthOfFieldSource);
  114371. time += scene.getEngine().getDeltaTime();
  114372. if (outputLiminance < 0) {
  114373. outputLiminance = _this._hdrCurrentLuminance;
  114374. }
  114375. else {
  114376. var dt = (lastTime - time) / 1000.0;
  114377. if (_this._hdrCurrentLuminance < outputLiminance + _this.hdrDecreaseRate * dt) {
  114378. outputLiminance += _this.hdrDecreaseRate * dt;
  114379. }
  114380. else if (_this._hdrCurrentLuminance > outputLiminance - _this.hdrIncreaseRate * dt) {
  114381. outputLiminance -= _this.hdrIncreaseRate * dt;
  114382. }
  114383. else {
  114384. outputLiminance = _this._hdrCurrentLuminance;
  114385. }
  114386. }
  114387. outputLiminance = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(outputLiminance, _this.hdrMinimumLuminance, 1e20);
  114388. effect.setFloat("averageLuminance", outputLiminance);
  114389. lastTime = time;
  114390. _this._currentDepthOfFieldSource = _this.hdrFinalPostProcess;
  114391. };
  114392. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDR", function () { return _this.hdrPostProcess; }, true));
  114393. };
  114394. // Create lens flare post-process
  114395. StandardRenderingPipeline.prototype._createLensFlarePostProcess = function (scene, ratio) {
  114396. var _this = this;
  114397. 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);
  114398. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlare", function () { return _this.lensFlarePostProcess; }, true));
  114399. this._createBlurPostProcesses(scene, ratio / 4, 2);
  114400. 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);
  114401. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlareCompose", function () { return _this.lensFlareComposePostProcess; }, true));
  114402. var resolution = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  114403. // Lens flare
  114404. this.lensFlarePostProcess.onApply = function (effect) {
  114405. effect.setTextureFromPostProcess("textureSampler", _this._bloomEnabled ? _this.blurHPostProcesses[0] : _this.originalPostProcess);
  114406. effect.setTexture("lensColorSampler", _this.lensColorTexture);
  114407. effect.setFloat("strength", _this.lensFlareStrength);
  114408. effect.setFloat("ghostDispersal", _this.lensFlareGhostDispersal);
  114409. effect.setFloat("haloWidth", _this.lensFlareHaloWidth);
  114410. // Shift
  114411. resolution.x = _this.lensFlarePostProcess.width;
  114412. resolution.y = _this.lensFlarePostProcess.height;
  114413. effect.setVector2("resolution", resolution);
  114414. effect.setFloat("distortionStrength", _this.lensFlareDistortionStrength);
  114415. };
  114416. // Compose
  114417. 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);
  114418. 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);
  114419. this.lensFlareComposePostProcess.onApply = function (effect) {
  114420. if (!_this._scene.activeCamera) {
  114421. return;
  114422. }
  114423. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  114424. effect.setTexture("lensDirtSampler", _this.lensFlareDirtTexture);
  114425. effect.setTexture("lensStarSampler", _this.lensStarTexture);
  114426. // Lens start rotation matrix
  114427. var camerax = _this._scene.activeCamera.getViewMatrix().getRow(0);
  114428. var cameraz = _this._scene.activeCamera.getViewMatrix().getRow(2);
  114429. 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));
  114430. camRot *= 4.0;
  114431. 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);
  114432. var lensStarMatrix = scaleBias2.multiply(starRotation).multiply(scaleBias1);
  114433. effect.setMatrix("lensStarMatrix", lensStarMatrix);
  114434. _this._currentDepthOfFieldSource = _this.lensFlareFinalPostProcess;
  114435. };
  114436. };
  114437. // Create depth-of-field post-process
  114438. StandardRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (scene, ratio) {
  114439. var _this = this;
  114440. 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);
  114441. this.depthOfFieldPostProcess.onApply = function (effect) {
  114442. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  114443. effect.setTexture("depthSampler", _this._getDepthTexture());
  114444. effect.setFloat("distance", _this.depthOfFieldDistance);
  114445. };
  114446. // Add to pipeline
  114447. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDepthOfField", function () { return _this.depthOfFieldPostProcess; }, true));
  114448. };
  114449. // Create motion blur post-process
  114450. StandardRenderingPipeline.prototype._createMotionBlurPostProcess = function (scene, ratio) {
  114451. var _this = this;
  114452. 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);
  114453. var motionScale = 0;
  114454. var prevViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  114455. var invViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  114456. var viewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  114457. var screenSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  114458. this.motionBlurPostProcess.onApply = function (effect) {
  114459. viewProjection = scene.getProjectionMatrix().multiply(scene.getViewMatrix());
  114460. viewProjection.invertToRef(invViewProjection);
  114461. effect.setMatrix("inverseViewProjection", invViewProjection);
  114462. effect.setMatrix("prevViewProjection", prevViewProjection);
  114463. prevViewProjection = viewProjection;
  114464. screenSize.x = _this.motionBlurPostProcess.width;
  114465. screenSize.y = _this.motionBlurPostProcess.height;
  114466. effect.setVector2("screenSize", screenSize);
  114467. motionScale = scene.getEngine().getFps() / 60.0;
  114468. effect.setFloat("motionScale", motionScale);
  114469. effect.setFloat("motionStrength", _this.motionStrength);
  114470. effect.setTexture("depthSampler", _this._getDepthTexture());
  114471. };
  114472. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRMotionBlur", function () { return _this.motionBlurPostProcess; }, true));
  114473. };
  114474. StandardRenderingPipeline.prototype._getDepthTexture = function () {
  114475. if (this._scene.getEngine().getCaps().drawBuffersExtension) {
  114476. var renderer = this._scene.enableGeometryBufferRenderer();
  114477. return renderer.getGBuffer().textures[0];
  114478. }
  114479. return this._scene.enableDepthRenderer().getDepthMap();
  114480. };
  114481. StandardRenderingPipeline.prototype._disposePostProcesses = function () {
  114482. for (var i = 0; i < this._cameras.length; i++) {
  114483. var camera = this._cameras[i];
  114484. if (this.originalPostProcess) {
  114485. this.originalPostProcess.dispose(camera);
  114486. }
  114487. if (this.downSampleX4PostProcess) {
  114488. this.downSampleX4PostProcess.dispose(camera);
  114489. }
  114490. if (this.brightPassPostProcess) {
  114491. this.brightPassPostProcess.dispose(camera);
  114492. }
  114493. if (this.textureAdderPostProcess) {
  114494. this.textureAdderPostProcess.dispose(camera);
  114495. }
  114496. if (this.textureAdderFinalPostProcess) {
  114497. this.textureAdderFinalPostProcess.dispose(camera);
  114498. }
  114499. if (this.volumetricLightPostProcess) {
  114500. this.volumetricLightPostProcess.dispose(camera);
  114501. }
  114502. if (this.volumetricLightSmoothXPostProcess) {
  114503. this.volumetricLightSmoothXPostProcess.dispose(camera);
  114504. }
  114505. if (this.volumetricLightSmoothYPostProcess) {
  114506. this.volumetricLightSmoothYPostProcess.dispose(camera);
  114507. }
  114508. if (this.volumetricLightMergePostProces) {
  114509. this.volumetricLightMergePostProces.dispose(camera);
  114510. }
  114511. if (this.volumetricLightFinalPostProcess) {
  114512. this.volumetricLightFinalPostProcess.dispose(camera);
  114513. }
  114514. if (this.lensFlarePostProcess) {
  114515. this.lensFlarePostProcess.dispose(camera);
  114516. }
  114517. if (this.lensFlareComposePostProcess) {
  114518. this.lensFlareComposePostProcess.dispose(camera);
  114519. }
  114520. for (var j = 0; j < this.luminanceDownSamplePostProcesses.length; j++) {
  114521. this.luminanceDownSamplePostProcesses[j].dispose(camera);
  114522. }
  114523. if (this.luminancePostProcess) {
  114524. this.luminancePostProcess.dispose(camera);
  114525. }
  114526. if (this.hdrPostProcess) {
  114527. this.hdrPostProcess.dispose(camera);
  114528. }
  114529. if (this.hdrFinalPostProcess) {
  114530. this.hdrFinalPostProcess.dispose(camera);
  114531. }
  114532. if (this.depthOfFieldPostProcess) {
  114533. this.depthOfFieldPostProcess.dispose(camera);
  114534. }
  114535. if (this.motionBlurPostProcess) {
  114536. this.motionBlurPostProcess.dispose(camera);
  114537. }
  114538. if (this.fxaaPostProcess) {
  114539. this.fxaaPostProcess.dispose(camera);
  114540. }
  114541. for (var j = 0; j < this.blurHPostProcesses.length; j++) {
  114542. this.blurHPostProcesses[j].dispose(camera);
  114543. }
  114544. for (var j = 0; j < this.blurVPostProcesses.length; j++) {
  114545. this.blurVPostProcesses[j].dispose(camera);
  114546. }
  114547. }
  114548. this.originalPostProcess = null;
  114549. this.downSampleX4PostProcess = null;
  114550. this.brightPassPostProcess = null;
  114551. this.textureAdderPostProcess = null;
  114552. this.textureAdderFinalPostProcess = null;
  114553. this.volumetricLightPostProcess = null;
  114554. this.volumetricLightSmoothXPostProcess = null;
  114555. this.volumetricLightSmoothYPostProcess = null;
  114556. this.volumetricLightMergePostProces = null;
  114557. this.volumetricLightFinalPostProcess = null;
  114558. this.lensFlarePostProcess = null;
  114559. this.lensFlareComposePostProcess = null;
  114560. this.luminancePostProcess = null;
  114561. this.hdrPostProcess = null;
  114562. this.hdrFinalPostProcess = null;
  114563. this.depthOfFieldPostProcess = null;
  114564. this.motionBlurPostProcess = null;
  114565. this.fxaaPostProcess = null;
  114566. this.luminanceDownSamplePostProcesses = [];
  114567. this.blurHPostProcesses = [];
  114568. this.blurVPostProcesses = [];
  114569. };
  114570. /**
  114571. * Dispose of the pipeline and stop all post processes
  114572. */
  114573. StandardRenderingPipeline.prototype.dispose = function () {
  114574. this._disposePostProcesses();
  114575. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  114576. _super.prototype.dispose.call(this);
  114577. };
  114578. /**
  114579. * Serialize the rendering pipeline (Used when exporting)
  114580. * @returns the serialized object
  114581. */
  114582. StandardRenderingPipeline.prototype.serialize = function () {
  114583. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  114584. if (this.sourceLight) {
  114585. serializationObject.sourceLightId = this.sourceLight.id;
  114586. }
  114587. serializationObject.customType = "StandardRenderingPipeline";
  114588. return serializationObject;
  114589. };
  114590. /**
  114591. * Parse the serialized pipeline
  114592. * @param source Source pipeline.
  114593. * @param scene The scene to load the pipeline to.
  114594. * @param rootUrl The URL of the serialized pipeline.
  114595. * @returns An instantiated pipeline from the serialized object.
  114596. */
  114597. StandardRenderingPipeline.Parse = function (source, scene, rootUrl) {
  114598. var p = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardRenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  114599. if (source.sourceLightId) {
  114600. p.sourceLight = scene.getLightByID(source.sourceLightId);
  114601. }
  114602. return p;
  114603. };
  114604. /**
  114605. * Luminance steps
  114606. */
  114607. StandardRenderingPipeline.LuminanceSteps = 6;
  114608. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114609. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114610. ], StandardRenderingPipeline.prototype, "brightThreshold", void 0);
  114611. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114612. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114613. ], StandardRenderingPipeline.prototype, "blurWidth", void 0);
  114614. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114615. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114616. ], StandardRenderingPipeline.prototype, "horizontalBlur", void 0);
  114617. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114618. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114619. ], StandardRenderingPipeline.prototype, "exposure", void 0);
  114620. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114621. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensTexture")
  114622. ], StandardRenderingPipeline.prototype, "lensTexture", void 0);
  114623. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114624. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114625. ], StandardRenderingPipeline.prototype, "volumetricLightCoefficient", void 0);
  114626. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114627. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114628. ], StandardRenderingPipeline.prototype, "volumetricLightPower", void 0);
  114629. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114630. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114631. ], StandardRenderingPipeline.prototype, "volumetricLightBlurScale", void 0);
  114632. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114633. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114634. ], StandardRenderingPipeline.prototype, "hdrMinimumLuminance", void 0);
  114635. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114636. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114637. ], StandardRenderingPipeline.prototype, "hdrDecreaseRate", void 0);
  114638. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114639. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114640. ], StandardRenderingPipeline.prototype, "hdrIncreaseRate", void 0);
  114641. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114642. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensColorTexture")
  114643. ], StandardRenderingPipeline.prototype, "lensColorTexture", void 0);
  114644. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114645. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114646. ], StandardRenderingPipeline.prototype, "lensFlareStrength", void 0);
  114647. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114648. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114649. ], StandardRenderingPipeline.prototype, "lensFlareGhostDispersal", void 0);
  114650. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114651. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114652. ], StandardRenderingPipeline.prototype, "lensFlareHaloWidth", void 0);
  114653. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114654. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114655. ], StandardRenderingPipeline.prototype, "lensFlareDistortionStrength", void 0);
  114656. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114657. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensStarTexture")
  114658. ], StandardRenderingPipeline.prototype, "lensStarTexture", void 0);
  114659. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114660. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensFlareDirtTexture")
  114661. ], StandardRenderingPipeline.prototype, "lensFlareDirtTexture", void 0);
  114662. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114663. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114664. ], StandardRenderingPipeline.prototype, "depthOfFieldDistance", void 0);
  114665. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114666. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114667. ], StandardRenderingPipeline.prototype, "depthOfFieldBlurWidth", void 0);
  114668. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114669. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114670. ], StandardRenderingPipeline.prototype, "motionStrength", void 0);
  114671. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114672. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114673. ], StandardRenderingPipeline.prototype, "_ratio", void 0);
  114674. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114675. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114676. ], StandardRenderingPipeline.prototype, "BloomEnabled", null);
  114677. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114678. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114679. ], StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", null);
  114680. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114681. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114682. ], StandardRenderingPipeline.prototype, "LensFlareEnabled", null);
  114683. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114684. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114685. ], StandardRenderingPipeline.prototype, "HDREnabled", null);
  114686. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114687. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114688. ], StandardRenderingPipeline.prototype, "VLSEnabled", null);
  114689. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114690. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114691. ], StandardRenderingPipeline.prototype, "MotionBlurEnabled", null);
  114692. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114693. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114694. ], StandardRenderingPipeline.prototype, "fxaaEnabled", null);
  114695. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114696. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114697. ], StandardRenderingPipeline.prototype, "volumetricLightStepsCount", null);
  114698. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114699. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114700. ], StandardRenderingPipeline.prototype, "motionBlurSamples", null);
  114701. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114702. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114703. ], StandardRenderingPipeline.prototype, "samples", null);
  114704. return StandardRenderingPipeline;
  114705. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  114706. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardRenderingPipeline"] = StandardRenderingPipeline;
  114707. /***/ }),
  114708. /***/ "./PostProcesses/RenderPipeline/index.ts":
  114709. /*!***********************************************!*\
  114710. !*** ./PostProcesses/RenderPipeline/index.ts ***!
  114711. \***********************************************/
  114712. /*! exports provided: PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  114713. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114714. "use strict";
  114715. __webpack_require__.r(__webpack_exports__);
  114716. /* harmony import */ var _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Pipelines/index */ "./PostProcesses/RenderPipeline/Pipelines/index.ts");
  114717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  114718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  114719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  114720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  114721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  114722. /* harmony import */ var _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  114723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]; });
  114724. /* harmony import */ var _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  114725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__["PostProcessRenderPipeline"]; });
  114726. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  114727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderPipelineManager"]; });
  114728. /* harmony import */ var _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  114729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipelineManagerSceneComponent"]; });
  114730. /***/ }),
  114731. /***/ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts":
  114732. /*!*****************************************************************!*\
  114733. !*** ./PostProcesses/RenderPipeline/postProcessRenderEffect.ts ***!
  114734. \*****************************************************************/
  114735. /*! exports provided: PostProcessRenderEffect */
  114736. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114737. "use strict";
  114738. __webpack_require__.r(__webpack_exports__);
  114739. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return PostProcessRenderEffect; });
  114740. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  114741. /**
  114742. * This represents a set of one or more post processes in Babylon.
  114743. * A post process can be used to apply a shader to a texture after it is rendered.
  114744. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  114745. */
  114746. var PostProcessRenderEffect = /** @class */ (function () {
  114747. /**
  114748. * Instantiates a post process render effect.
  114749. * A post process can be used to apply a shader to a texture after it is rendered.
  114750. * @param engine The engine the effect is tied to
  114751. * @param name The name of the effect
  114752. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  114753. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  114754. */
  114755. function PostProcessRenderEffect(engine, name, getPostProcesses, singleInstance) {
  114756. this._name = name;
  114757. this._singleInstance = singleInstance || true;
  114758. this._getPostProcesses = getPostProcesses;
  114759. this._cameras = {};
  114760. this._indicesForCamera = {};
  114761. this._postProcesses = {};
  114762. }
  114763. Object.defineProperty(PostProcessRenderEffect.prototype, "isSupported", {
  114764. /**
  114765. * Checks if all the post processes in the effect are supported.
  114766. */
  114767. get: function () {
  114768. for (var index in this._postProcesses) {
  114769. if (this._postProcesses.hasOwnProperty(index)) {
  114770. var pps = this._postProcesses[index];
  114771. for (var ppIndex = 0; ppIndex < pps.length; ppIndex++) {
  114772. if (!pps[ppIndex].isSupported) {
  114773. return false;
  114774. }
  114775. }
  114776. }
  114777. }
  114778. return true;
  114779. },
  114780. enumerable: true,
  114781. configurable: true
  114782. });
  114783. /**
  114784. * Updates the current state of the effect
  114785. * @hidden
  114786. */
  114787. PostProcessRenderEffect.prototype._update = function () {
  114788. };
  114789. /**
  114790. * Attaches the effect on cameras
  114791. * @param cameras The camera to attach to.
  114792. * @hidden
  114793. */
  114794. PostProcessRenderEffect.prototype._attachCameras = function (cameras) {
  114795. var _this = this;
  114796. var cameraKey;
  114797. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  114798. if (!cams) {
  114799. return;
  114800. }
  114801. for (var i = 0; i < cams.length; i++) {
  114802. var camera = cams[i];
  114803. var cameraName = camera.name;
  114804. if (this._singleInstance) {
  114805. cameraKey = 0;
  114806. }
  114807. else {
  114808. cameraKey = cameraName;
  114809. }
  114810. if (!this._postProcesses[cameraKey]) {
  114811. var postProcess = this._getPostProcesses();
  114812. if (postProcess) {
  114813. this._postProcesses[cameraKey] = Array.isArray(postProcess) ? postProcess : [postProcess];
  114814. }
  114815. }
  114816. if (!this._indicesForCamera[cameraName]) {
  114817. this._indicesForCamera[cameraName] = [];
  114818. }
  114819. this._postProcesses[cameraKey].forEach(function (postProcess) {
  114820. var index = camera.attachPostProcess(postProcess);
  114821. _this._indicesForCamera[cameraName].push(index);
  114822. });
  114823. if (!this._cameras[cameraName]) {
  114824. this._cameras[cameraName] = camera;
  114825. }
  114826. }
  114827. };
  114828. /**
  114829. * Detatches the effect on cameras
  114830. * @param cameras The camera to detatch from.
  114831. * @hidden
  114832. */
  114833. PostProcessRenderEffect.prototype._detachCameras = function (cameras) {
  114834. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  114835. if (!cams) {
  114836. return;
  114837. }
  114838. for (var i = 0; i < cams.length; i++) {
  114839. var camera = cams[i];
  114840. var cameraName = camera.name;
  114841. var postProcesses = this._postProcesses[this._singleInstance ? 0 : cameraName];
  114842. if (postProcesses) {
  114843. postProcesses.forEach(function (postProcess) {
  114844. camera.detachPostProcess(postProcess);
  114845. });
  114846. }
  114847. if (this._cameras[cameraName]) {
  114848. this._cameras[cameraName] = null;
  114849. }
  114850. }
  114851. };
  114852. /**
  114853. * Enables the effect on given cameras
  114854. * @param cameras The camera to enable.
  114855. * @hidden
  114856. */
  114857. PostProcessRenderEffect.prototype._enable = function (cameras) {
  114858. var _this = this;
  114859. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  114860. if (!cams) {
  114861. return;
  114862. }
  114863. for (var i = 0; i < cams.length; i++) {
  114864. var camera = cams[i];
  114865. var cameraName = camera.name;
  114866. for (var j = 0; j < this._indicesForCamera[cameraName].length; j++) {
  114867. if (camera._postProcesses[this._indicesForCamera[cameraName][j]] === undefined || camera._postProcesses[this._indicesForCamera[cameraName][j]] === null) {
  114868. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  114869. cams[i].attachPostProcess(postProcess, _this._indicesForCamera[cameraName][j]);
  114870. });
  114871. }
  114872. }
  114873. }
  114874. };
  114875. /**
  114876. * Disables the effect on the given cameras
  114877. * @param cameras The camera to disable.
  114878. * @hidden
  114879. */
  114880. PostProcessRenderEffect.prototype._disable = function (cameras) {
  114881. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  114882. if (!cams) {
  114883. return;
  114884. }
  114885. for (var i = 0; i < cams.length; i++) {
  114886. var camera = cams[i];
  114887. var cameraName = camera.name;
  114888. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  114889. camera.detachPostProcess(postProcess);
  114890. });
  114891. }
  114892. };
  114893. /**
  114894. * Gets a list of the post processes contained in the effect.
  114895. * @param camera The camera to get the post processes on.
  114896. * @returns The list of the post processes in the effect.
  114897. */
  114898. PostProcessRenderEffect.prototype.getPostProcesses = function (camera) {
  114899. if (this._singleInstance) {
  114900. return this._postProcesses[0];
  114901. }
  114902. else {
  114903. if (!camera) {
  114904. return null;
  114905. }
  114906. return this._postProcesses[camera.name];
  114907. }
  114908. };
  114909. return PostProcessRenderEffect;
  114910. }());
  114911. /***/ }),
  114912. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts":
  114913. /*!*******************************************************************!*\
  114914. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts ***!
  114915. \*******************************************************************/
  114916. /*! exports provided: PostProcessRenderPipeline */
  114917. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114918. "use strict";
  114919. __webpack_require__.r(__webpack_exports__);
  114920. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return PostProcessRenderPipeline; });
  114921. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114922. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  114923. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  114924. /**
  114925. * PostProcessRenderPipeline
  114926. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  114927. */
  114928. var PostProcessRenderPipeline = /** @class */ (function () {
  114929. /**
  114930. * Initializes a PostProcessRenderPipeline
  114931. * @param engine engine to add the pipeline to
  114932. * @param name name of the pipeline
  114933. */
  114934. function PostProcessRenderPipeline(engine, name) {
  114935. this.engine = engine;
  114936. this._name = name;
  114937. this._renderEffects = {};
  114938. this._renderEffectsForIsolatedPass = new Array();
  114939. this._cameras = [];
  114940. }
  114941. /**
  114942. * "PostProcessRenderPipeline"
  114943. * @returns "PostProcessRenderPipeline"
  114944. */
  114945. PostProcessRenderPipeline.prototype.getClassName = function () {
  114946. return "PostProcessRenderPipeline";
  114947. };
  114948. Object.defineProperty(PostProcessRenderPipeline.prototype, "isSupported", {
  114949. /**
  114950. * If all the render effects in the pipeline are support
  114951. */
  114952. get: function () {
  114953. for (var renderEffectName in this._renderEffects) {
  114954. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  114955. if (!this._renderEffects[renderEffectName].isSupported) {
  114956. return false;
  114957. }
  114958. }
  114959. }
  114960. return true;
  114961. },
  114962. enumerable: true,
  114963. configurable: true
  114964. });
  114965. /**
  114966. * Adds an effect to the pipeline
  114967. * @param renderEffect the effect to add
  114968. */
  114969. PostProcessRenderPipeline.prototype.addEffect = function (renderEffect) {
  114970. this._renderEffects[renderEffect._name] = renderEffect;
  114971. };
  114972. // private
  114973. /** @hidden */
  114974. PostProcessRenderPipeline.prototype._rebuild = function () {
  114975. };
  114976. /** @hidden */
  114977. PostProcessRenderPipeline.prototype._enableEffect = function (renderEffectName, cameras) {
  114978. var renderEffects = this._renderEffects[renderEffectName];
  114979. if (!renderEffects) {
  114980. return;
  114981. }
  114982. renderEffects._enable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  114983. };
  114984. /** @hidden */
  114985. PostProcessRenderPipeline.prototype._disableEffect = function (renderEffectName, cameras) {
  114986. var renderEffects = this._renderEffects[renderEffectName];
  114987. if (!renderEffects) {
  114988. return;
  114989. }
  114990. renderEffects._disable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  114991. };
  114992. /** @hidden */
  114993. PostProcessRenderPipeline.prototype._attachCameras = function (cameras, unique) {
  114994. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  114995. if (!cams) {
  114996. return;
  114997. }
  114998. var indicesToDelete = [];
  114999. var i;
  115000. for (i = 0; i < cams.length; i++) {
  115001. var camera = cams[i];
  115002. var cameraName = camera.name;
  115003. if (this._cameras.indexOf(camera) === -1) {
  115004. this._cameras[cameraName] = camera;
  115005. }
  115006. else if (unique) {
  115007. indicesToDelete.push(i);
  115008. }
  115009. }
  115010. for (i = 0; i < indicesToDelete.length; i++) {
  115011. cameras.splice(indicesToDelete[i], 1);
  115012. }
  115013. for (var renderEffectName in this._renderEffects) {
  115014. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  115015. this._renderEffects[renderEffectName]._attachCameras(cams);
  115016. }
  115017. }
  115018. };
  115019. /** @hidden */
  115020. PostProcessRenderPipeline.prototype._detachCameras = function (cameras) {
  115021. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  115022. if (!cams) {
  115023. return;
  115024. }
  115025. for (var renderEffectName in this._renderEffects) {
  115026. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  115027. this._renderEffects[renderEffectName]._detachCameras(cams);
  115028. }
  115029. }
  115030. for (var i = 0; i < cams.length; i++) {
  115031. this._cameras.splice(this._cameras.indexOf(cams[i]), 1);
  115032. }
  115033. };
  115034. /** @hidden */
  115035. PostProcessRenderPipeline.prototype._update = function () {
  115036. for (var renderEffectName in this._renderEffects) {
  115037. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  115038. this._renderEffects[renderEffectName]._update();
  115039. }
  115040. }
  115041. for (var i = 0; i < this._cameras.length; i++) {
  115042. var cameraName = this._cameras[i].name;
  115043. if (this._renderEffectsForIsolatedPass[cameraName]) {
  115044. this._renderEffectsForIsolatedPass[cameraName]._update();
  115045. }
  115046. }
  115047. };
  115048. /** @hidden */
  115049. PostProcessRenderPipeline.prototype._reset = function () {
  115050. this._renderEffects = {};
  115051. this._renderEffectsForIsolatedPass = new Array();
  115052. };
  115053. PostProcessRenderPipeline.prototype._enableMSAAOnFirstPostProcess = function (sampleCount) {
  115054. // 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)
  115055. var effectKeys = Object.keys(this._renderEffects);
  115056. if (this.engine.webGLVersion >= 2 && effectKeys.length > 0) {
  115057. var postProcesses = this._renderEffects[effectKeys[0]].getPostProcesses();
  115058. if (postProcesses) {
  115059. postProcesses[0].samples = sampleCount;
  115060. return true;
  115061. }
  115062. }
  115063. return false;
  115064. };
  115065. /**
  115066. * Disposes of the pipeline
  115067. */
  115068. PostProcessRenderPipeline.prototype.dispose = function () {
  115069. // Must be implemented by children
  115070. };
  115071. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115072. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  115073. ], PostProcessRenderPipeline.prototype, "_name", void 0);
  115074. return PostProcessRenderPipeline;
  115075. }());
  115076. /***/ }),
  115077. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts":
  115078. /*!**************************************************************************!*\
  115079. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts ***!
  115080. \**************************************************************************/
  115081. /*! exports provided: PostProcessRenderPipelineManager */
  115082. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115083. "use strict";
  115084. __webpack_require__.r(__webpack_exports__);
  115085. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return PostProcessRenderPipelineManager; });
  115086. /**
  115087. * PostProcessRenderPipelineManager class
  115088. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  115089. */
  115090. var PostProcessRenderPipelineManager = /** @class */ (function () {
  115091. /**
  115092. * Initializes a PostProcessRenderPipelineManager
  115093. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  115094. */
  115095. function PostProcessRenderPipelineManager() {
  115096. this._renderPipelines = {};
  115097. }
  115098. /**
  115099. * Adds a pipeline to the manager
  115100. * @param renderPipeline The pipeline to add
  115101. */
  115102. PostProcessRenderPipelineManager.prototype.addPipeline = function (renderPipeline) {
  115103. this._renderPipelines[renderPipeline._name] = renderPipeline;
  115104. };
  115105. /**
  115106. * Attaches a camera to the pipeline
  115107. * @param renderPipelineName The name of the pipeline to attach to
  115108. * @param cameras the camera to attach
  115109. * @param unique if the camera can be attached multiple times to the pipeline
  115110. */
  115111. PostProcessRenderPipelineManager.prototype.attachCamerasToRenderPipeline = function (renderPipelineName, cameras, unique) {
  115112. if (unique === void 0) { unique = false; }
  115113. var renderPipeline = this._renderPipelines[renderPipelineName];
  115114. if (!renderPipeline) {
  115115. return;
  115116. }
  115117. renderPipeline._attachCameras(cameras, unique);
  115118. };
  115119. /**
  115120. * Detaches a camera from the pipeline
  115121. * @param renderPipelineName The name of the pipeline to detach from
  115122. * @param cameras the camera to detach
  115123. */
  115124. PostProcessRenderPipelineManager.prototype.detachCamerasFromRenderPipeline = function (renderPipelineName, cameras) {
  115125. var renderPipeline = this._renderPipelines[renderPipelineName];
  115126. if (!renderPipeline) {
  115127. return;
  115128. }
  115129. renderPipeline._detachCameras(cameras);
  115130. };
  115131. /**
  115132. * Enables an effect by name on a pipeline
  115133. * @param renderPipelineName the name of the pipeline to enable the effect in
  115134. * @param renderEffectName the name of the effect to enable
  115135. * @param cameras the cameras that the effect should be enabled on
  115136. */
  115137. PostProcessRenderPipelineManager.prototype.enableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  115138. var renderPipeline = this._renderPipelines[renderPipelineName];
  115139. if (!renderPipeline) {
  115140. return;
  115141. }
  115142. renderPipeline._enableEffect(renderEffectName, cameras);
  115143. };
  115144. /**
  115145. * Disables an effect by name on a pipeline
  115146. * @param renderPipelineName the name of the pipeline to disable the effect in
  115147. * @param renderEffectName the name of the effect to disable
  115148. * @param cameras the cameras that the effect should be disabled on
  115149. */
  115150. PostProcessRenderPipelineManager.prototype.disableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  115151. var renderPipeline = this._renderPipelines[renderPipelineName];
  115152. if (!renderPipeline) {
  115153. return;
  115154. }
  115155. renderPipeline._disableEffect(renderEffectName, cameras);
  115156. };
  115157. /**
  115158. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  115159. */
  115160. PostProcessRenderPipelineManager.prototype.update = function () {
  115161. for (var renderPipelineName in this._renderPipelines) {
  115162. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  115163. var pipeline = this._renderPipelines[renderPipelineName];
  115164. if (!pipeline.isSupported) {
  115165. pipeline.dispose();
  115166. delete this._renderPipelines[renderPipelineName];
  115167. }
  115168. else {
  115169. pipeline._update();
  115170. }
  115171. }
  115172. }
  115173. };
  115174. /** @hidden */
  115175. PostProcessRenderPipelineManager.prototype._rebuild = function () {
  115176. for (var renderPipelineName in this._renderPipelines) {
  115177. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  115178. var pipeline = this._renderPipelines[renderPipelineName];
  115179. pipeline._rebuild();
  115180. }
  115181. }
  115182. };
  115183. /**
  115184. * Disposes of the manager and pipelines
  115185. */
  115186. PostProcessRenderPipelineManager.prototype.dispose = function () {
  115187. for (var renderPipelineName in this._renderPipelines) {
  115188. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  115189. var pipeline = this._renderPipelines[renderPipelineName];
  115190. pipeline.dispose();
  115191. }
  115192. }
  115193. };
  115194. return PostProcessRenderPipelineManager;
  115195. }());
  115196. /***/ }),
  115197. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts":
  115198. /*!****************************************************************************************!*\
  115199. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts ***!
  115200. \****************************************************************************************/
  115201. /*! exports provided: PostProcessRenderPipelineManagerSceneComponent */
  115202. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115203. "use strict";
  115204. __webpack_require__.r(__webpack_exports__);
  115205. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return PostProcessRenderPipelineManagerSceneComponent; });
  115206. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  115207. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  115208. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  115209. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype, "postProcessRenderPipelineManager", {
  115210. get: function () {
  115211. if (!this._postProcessRenderPipelineManager) {
  115212. // Register the G Buffer component to the scene.
  115213. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER);
  115214. if (!component) {
  115215. component = new PostProcessRenderPipelineManagerSceneComponent(this);
  115216. this._addComponent(component);
  115217. }
  115218. this._postProcessRenderPipelineManager = new _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderPipelineManager"]();
  115219. }
  115220. return this._postProcessRenderPipelineManager;
  115221. },
  115222. enumerable: true,
  115223. configurable: true
  115224. });
  115225. /**
  115226. * Defines the Render Pipeline scene component responsible to rendering pipelines
  115227. */
  115228. var PostProcessRenderPipelineManagerSceneComponent = /** @class */ (function () {
  115229. /**
  115230. * Creates a new instance of the component for the given scene
  115231. * @param scene Defines the scene to register the component in
  115232. */
  115233. function PostProcessRenderPipelineManagerSceneComponent(scene) {
  115234. /**
  115235. * The component name helpfull to identify the component in the list of scene components.
  115236. */
  115237. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER;
  115238. this.scene = scene;
  115239. }
  115240. /**
  115241. * Registers the component in a given scene
  115242. */
  115243. PostProcessRenderPipelineManagerSceneComponent.prototype.register = function () {
  115244. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets);
  115245. };
  115246. /**
  115247. * Rebuilds the elements related to this component in case of
  115248. * context lost for instance.
  115249. */
  115250. PostProcessRenderPipelineManagerSceneComponent.prototype.rebuild = function () {
  115251. if (this.scene._postProcessRenderPipelineManager) {
  115252. this.scene._postProcessRenderPipelineManager._rebuild();
  115253. }
  115254. };
  115255. /**
  115256. * Disposes the component and the associated ressources
  115257. */
  115258. PostProcessRenderPipelineManagerSceneComponent.prototype.dispose = function () {
  115259. if (this.scene._postProcessRenderPipelineManager) {
  115260. this.scene._postProcessRenderPipelineManager.dispose();
  115261. }
  115262. };
  115263. PostProcessRenderPipelineManagerSceneComponent.prototype._gatherRenderTargets = function () {
  115264. if (this.scene._postProcessRenderPipelineManager) {
  115265. this.scene._postProcessRenderPipelineManager.update();
  115266. }
  115267. };
  115268. return PostProcessRenderPipelineManagerSceneComponent;
  115269. }());
  115270. /***/ }),
  115271. /***/ "./PostProcesses/anaglyphPostProcess.ts":
  115272. /*!**********************************************!*\
  115273. !*** ./PostProcesses/anaglyphPostProcess.ts ***!
  115274. \**********************************************/
  115275. /*! exports provided: AnaglyphPostProcess */
  115276. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115277. "use strict";
  115278. __webpack_require__.r(__webpack_exports__);
  115279. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return AnaglyphPostProcess; });
  115280. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115281. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115282. /* harmony import */ var _Shaders_anaglyph_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/anaglyph.fragment */ "./Shaders/anaglyph.fragment.ts");
  115283. /**
  115284. * Postprocess used to generate anaglyphic rendering
  115285. */
  115286. var AnaglyphPostProcess = /** @class */ (function (_super) {
  115287. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphPostProcess, _super);
  115288. /**
  115289. * Creates a new AnaglyphPostProcess
  115290. * @param name defines postprocess name
  115291. * @param options defines creation options or target ratio scale
  115292. * @param rigCameras defines cameras using this postprocess
  115293. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  115294. * @param engine defines hosting engine
  115295. * @param reusable defines if the postprocess will be reused multiple times per frame
  115296. */
  115297. function AnaglyphPostProcess(name, options, rigCameras, samplingMode, engine, reusable) {
  115298. var _this = _super.call(this, name, "anaglyph", null, ["leftSampler"], options, rigCameras[1], samplingMode, engine, reusable) || this;
  115299. _this._passedProcess = rigCameras[0]._rigPostProcess;
  115300. _this.onApplyObservable.add(function (effect) {
  115301. effect.setTextureFromPostProcess("leftSampler", _this._passedProcess);
  115302. });
  115303. return _this;
  115304. }
  115305. return AnaglyphPostProcess;
  115306. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  115307. /***/ }),
  115308. /***/ "./PostProcesses/blackAndWhitePostProcess.ts":
  115309. /*!***************************************************!*\
  115310. !*** ./PostProcesses/blackAndWhitePostProcess.ts ***!
  115311. \***************************************************/
  115312. /*! exports provided: BlackAndWhitePostProcess */
  115313. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115314. "use strict";
  115315. __webpack_require__.r(__webpack_exports__);
  115316. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return BlackAndWhitePostProcess; });
  115317. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115318. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115319. /* harmony import */ var _Shaders_blackAndWhite_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/blackAndWhite.fragment */ "./Shaders/blackAndWhite.fragment.ts");
  115320. /**
  115321. * Post process used to render in black and white
  115322. */
  115323. var BlackAndWhitePostProcess = /** @class */ (function (_super) {
  115324. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlackAndWhitePostProcess, _super);
  115325. /**
  115326. * Creates a black and white post process
  115327. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  115328. * @param name The name of the effect.
  115329. * @param options The required width/height ratio to downsize to before computing the render pass.
  115330. * @param camera The camera to apply the render pass to.
  115331. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115332. * @param engine The engine which the post process will be applied. (default: current engine)
  115333. * @param reusable If the post process can be reused on the same frame. (default: false)
  115334. */
  115335. function BlackAndWhitePostProcess(name, options, camera, samplingMode, engine, reusable) {
  115336. var _this = _super.call(this, name, "blackAndWhite", ["degree"], null, options, camera, samplingMode, engine, reusable) || this;
  115337. /**
  115338. * Linear about to convert he result to black and white (default: 1)
  115339. */
  115340. _this.degree = 1;
  115341. _this.onApplyObservable.add(function (effect) {
  115342. effect.setFloat("degree", _this.degree);
  115343. });
  115344. return _this;
  115345. }
  115346. return BlackAndWhitePostProcess;
  115347. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  115348. /***/ }),
  115349. /***/ "./PostProcesses/bloomEffect.ts":
  115350. /*!**************************************!*\
  115351. !*** ./PostProcesses/bloomEffect.ts ***!
  115352. \**************************************/
  115353. /*! exports provided: BloomEffect */
  115354. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115355. "use strict";
  115356. __webpack_require__.r(__webpack_exports__);
  115357. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return BloomEffect; });
  115358. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115359. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  115360. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  115361. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  115362. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  115363. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  115364. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  115365. /**
  115366. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  115367. */
  115368. var BloomEffect = /** @class */ (function (_super) {
  115369. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomEffect, _super);
  115370. /**
  115371. * Creates a new instance of @see BloomEffect
  115372. * @param scene The scene the effect belongs to.
  115373. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  115374. * @param bloomKernel The size of the kernel to be used when applying the blur.
  115375. * @param bloomWeight The the strength of bloom.
  115376. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  115377. * @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)
  115378. */
  115379. function BloomEffect(scene, bloomScale, bloomWeight, bloomKernel, pipelineTextureType, blockCompilation) {
  115380. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  115381. if (blockCompilation === void 0) { blockCompilation = false; }
  115382. var _this = _super.call(this, scene.getEngine(), "bloom", function () {
  115383. return _this._effects;
  115384. }, true) || this;
  115385. _this.bloomScale = bloomScale;
  115386. /**
  115387. * @hidden Internal
  115388. */
  115389. _this._effects = [];
  115390. _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);
  115391. _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);
  115392. _this._blurX.alwaysForcePOT = true;
  115393. _this._blurX.autoClear = false;
  115394. _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);
  115395. _this._blurY.alwaysForcePOT = true;
  115396. _this._blurY.autoClear = false;
  115397. _this.kernel = bloomKernel;
  115398. _this._effects = [_this._downscale, _this._blurX, _this._blurY];
  115399. _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);
  115400. _this._merge.autoClear = false;
  115401. _this._effects.push(_this._merge);
  115402. return _this;
  115403. }
  115404. Object.defineProperty(BloomEffect.prototype, "threshold", {
  115405. /**
  115406. * The luminance threshold to find bright areas of the image to bloom.
  115407. */
  115408. get: function () {
  115409. return this._downscale.threshold;
  115410. },
  115411. set: function (value) {
  115412. this._downscale.threshold = value;
  115413. },
  115414. enumerable: true,
  115415. configurable: true
  115416. });
  115417. Object.defineProperty(BloomEffect.prototype, "weight", {
  115418. /**
  115419. * The strength of the bloom.
  115420. */
  115421. get: function () {
  115422. return this._merge.weight;
  115423. },
  115424. set: function (value) {
  115425. this._merge.weight = value;
  115426. },
  115427. enumerable: true,
  115428. configurable: true
  115429. });
  115430. Object.defineProperty(BloomEffect.prototype, "kernel", {
  115431. /**
  115432. * Specifies the size of the bloom blur kernel, relative to the final output size
  115433. */
  115434. get: function () {
  115435. return this._blurX.kernel / this.bloomScale;
  115436. },
  115437. set: function (value) {
  115438. this._blurX.kernel = value * this.bloomScale;
  115439. this._blurY.kernel = value * this.bloomScale;
  115440. },
  115441. enumerable: true,
  115442. configurable: true
  115443. });
  115444. /**
  115445. * Disposes each of the internal effects for a given camera.
  115446. * @param camera The camera to dispose the effect on.
  115447. */
  115448. BloomEffect.prototype.disposeEffects = function (camera) {
  115449. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  115450. this._effects[effectIndex].dispose(camera);
  115451. }
  115452. };
  115453. /**
  115454. * @hidden Internal
  115455. */
  115456. BloomEffect.prototype._updateEffects = function () {
  115457. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  115458. this._effects[effectIndex].updateEffect();
  115459. }
  115460. };
  115461. /**
  115462. * Internal
  115463. * @returns if all the contained post processes are ready.
  115464. * @hidden
  115465. */
  115466. BloomEffect.prototype._isReady = function () {
  115467. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  115468. if (!this._effects[effectIndex].isReady()) {
  115469. return false;
  115470. }
  115471. }
  115472. return true;
  115473. };
  115474. return BloomEffect;
  115475. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]));
  115476. /***/ }),
  115477. /***/ "./PostProcesses/bloomMergePostProcess.ts":
  115478. /*!************************************************!*\
  115479. !*** ./PostProcesses/bloomMergePostProcess.ts ***!
  115480. \************************************************/
  115481. /*! exports provided: BloomMergePostProcess */
  115482. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115483. "use strict";
  115484. __webpack_require__.r(__webpack_exports__);
  115485. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return BloomMergePostProcess; });
  115486. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115487. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115488. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  115489. /* harmony import */ var _Shaders_bloomMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/bloomMerge.fragment */ "./Shaders/bloomMerge.fragment.ts");
  115490. /**
  115491. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  115492. */
  115493. var BloomMergePostProcess = /** @class */ (function (_super) {
  115494. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomMergePostProcess, _super);
  115495. /**
  115496. * Creates a new instance of @see BloomMergePostProcess
  115497. * @param name The name of the effect.
  115498. * @param originalFromInput Post process which's input will be used for the merge.
  115499. * @param blurred Blurred highlights post process which's output will be used.
  115500. * @param weight Weight of the bloom to be added to the original input.
  115501. * @param options The required width/height ratio to downsize to before computing the render pass.
  115502. * @param camera The camera to apply the render pass to.
  115503. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115504. * @param engine The engine which the post process will be applied. (default: current engine)
  115505. * @param reusable If the post process can be reused on the same frame. (default: false)
  115506. * @param textureType Type of textures used when performing the post process. (default: 0)
  115507. * @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)
  115508. */
  115509. function BloomMergePostProcess(name, originalFromInput, blurred,
  115510. /** Weight of the bloom to be added to the original input. */
  115511. weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  115512. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  115513. if (blockCompilation === void 0) { blockCompilation = false; }
  115514. var _this = _super.call(this, name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  115515. _this.weight = weight;
  115516. _this.onApplyObservable.add(function (effect) {
  115517. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  115518. effect.setTextureFromPostProcessOutput("bloomBlur", blurred);
  115519. effect.setFloat("bloomWeight", _this.weight);
  115520. });
  115521. if (!blockCompilation) {
  115522. _this.updateEffect();
  115523. }
  115524. return _this;
  115525. }
  115526. return BloomMergePostProcess;
  115527. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  115528. /***/ }),
  115529. /***/ "./PostProcesses/blurPostProcess.ts":
  115530. /*!******************************************!*\
  115531. !*** ./PostProcesses/blurPostProcess.ts ***!
  115532. \******************************************/
  115533. /*! exports provided: BlurPostProcess */
  115534. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115535. "use strict";
  115536. __webpack_require__.r(__webpack_exports__);
  115537. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return BlurPostProcess; });
  115538. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115539. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115540. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  115541. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  115542. /* harmony import */ var _Shaders_kernelBlur_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/kernelBlur.fragment */ "./Shaders/kernelBlur.fragment.ts");
  115543. /* harmony import */ var _Shaders_kernelBlur_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/kernelBlur.vertex */ "./Shaders/kernelBlur.vertex.ts");
  115544. /**
  115545. * The Blur Post Process which blurs an image based on a kernel and direction.
  115546. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  115547. */
  115548. var BlurPostProcess = /** @class */ (function (_super) {
  115549. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlurPostProcess, _super);
  115550. /**
  115551. * Creates a new instance BlurPostProcess
  115552. * @param name The name of the effect.
  115553. * @param direction The direction in which to blur the image.
  115554. * @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.
  115555. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  115556. * @param camera The camera to apply the render pass to.
  115557. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115558. * @param engine The engine which the post process will be applied. (default: current engine)
  115559. * @param reusable If the post process can be reused on the same frame. (default: false)
  115560. * @param textureType Type of textures used when performing the post process. (default: 0)
  115561. * @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)
  115562. */
  115563. function BlurPostProcess(name,
  115564. /** The direction in which to blur the image. */
  115565. direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
  115566. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  115567. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  115568. if (defines === void 0) { defines = ""; }
  115569. if (blockCompilation === void 0) { blockCompilation = false; }
  115570. 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;
  115571. _this.direction = direction;
  115572. _this.blockCompilation = blockCompilation;
  115573. _this._packedFloat = false;
  115574. _this._staticDefines = "";
  115575. _this._staticDefines = defines;
  115576. _this.onApplyObservable.add(function (effect) {
  115577. if (_this._outputTexture) {
  115578. effect.setFloat2('delta', (1 / _this._outputTexture.width) * _this.direction.x, (1 / _this._outputTexture.height) * _this.direction.y);
  115579. }
  115580. else {
  115581. effect.setFloat2('delta', (1 / _this.width) * _this.direction.x, (1 / _this.height) * _this.direction.y);
  115582. }
  115583. });
  115584. _this.kernel = kernel;
  115585. return _this;
  115586. }
  115587. Object.defineProperty(BlurPostProcess.prototype, "kernel", {
  115588. /**
  115589. * Gets the length in pixels of the blur sample region
  115590. */
  115591. get: function () {
  115592. return this._idealKernel;
  115593. },
  115594. /**
  115595. * Sets the length in pixels of the blur sample region
  115596. */
  115597. set: function (v) {
  115598. if (this._idealKernel === v) {
  115599. return;
  115600. }
  115601. v = Math.max(v, 1);
  115602. this._idealKernel = v;
  115603. this._kernel = this._nearestBestKernel(v);
  115604. if (!this.blockCompilation) {
  115605. this._updateParameters();
  115606. }
  115607. },
  115608. enumerable: true,
  115609. configurable: true
  115610. });
  115611. Object.defineProperty(BlurPostProcess.prototype, "packedFloat", {
  115612. /**
  115613. * Gets wether or not the blur is unpacking/repacking floats
  115614. */
  115615. get: function () {
  115616. return this._packedFloat;
  115617. },
  115618. /**
  115619. * Sets wether or not the blur needs to unpack/repack floats
  115620. */
  115621. set: function (v) {
  115622. if (this._packedFloat === v) {
  115623. return;
  115624. }
  115625. this._packedFloat = v;
  115626. if (!this.blockCompilation) {
  115627. this._updateParameters();
  115628. }
  115629. },
  115630. enumerable: true,
  115631. configurable: true
  115632. });
  115633. /**
  115634. * Updates the effect with the current post process compile time values and recompiles the shader.
  115635. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  115636. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  115637. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  115638. * @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
  115639. * @param onCompiled Called when the shader has been compiled.
  115640. * @param onError Called if there is an error when compiling a shader.
  115641. */
  115642. BlurPostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  115643. if (defines === void 0) { defines = null; }
  115644. if (uniforms === void 0) { uniforms = null; }
  115645. if (samplers === void 0) { samplers = null; }
  115646. this._updateParameters(onCompiled, onError);
  115647. };
  115648. BlurPostProcess.prototype._updateParameters = function (onCompiled, onError) {
  115649. // Generate sampling offsets and weights
  115650. var N = this._kernel;
  115651. var centerIndex = (N - 1) / 2;
  115652. // Generate Gaussian sampling weights over kernel
  115653. var offsets = [];
  115654. var weights = [];
  115655. var totalWeight = 0;
  115656. for (var i = 0; i < N; i++) {
  115657. var u = i / (N - 1);
  115658. var w = this._gaussianWeight(u * 2.0 - 1);
  115659. offsets[i] = (i - centerIndex);
  115660. weights[i] = w;
  115661. totalWeight += w;
  115662. }
  115663. // Normalize weights
  115664. for (var i = 0; i < weights.length; i++) {
  115665. weights[i] /= totalWeight;
  115666. }
  115667. // Optimize: combine samples to take advantage of hardware linear sampling
  115668. // Walk from left to center, combining pairs (symmetrically)
  115669. var linearSamplingWeights = [];
  115670. var linearSamplingOffsets = [];
  115671. var linearSamplingMap = [];
  115672. for (var i = 0; i <= centerIndex; i += 2) {
  115673. var j = Math.min(i + 1, Math.floor(centerIndex));
  115674. var singleCenterSample = i === j;
  115675. if (singleCenterSample) {
  115676. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  115677. }
  115678. else {
  115679. var sharedCell = j === centerIndex;
  115680. var weightLinear = (weights[i] + weights[j] * (sharedCell ? .5 : 1.));
  115681. var offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);
  115682. if (offsetLinear === 0) {
  115683. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  115684. linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });
  115685. }
  115686. else {
  115687. linearSamplingMap.push({ o: offsetLinear, w: weightLinear });
  115688. linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });
  115689. }
  115690. }
  115691. }
  115692. for (var i = 0; i < linearSamplingMap.length; i++) {
  115693. linearSamplingOffsets[i] = linearSamplingMap[i].o;
  115694. linearSamplingWeights[i] = linearSamplingMap[i].w;
  115695. }
  115696. // Replace with optimized
  115697. offsets = linearSamplingOffsets;
  115698. weights = linearSamplingWeights;
  115699. // Generate shaders
  115700. var maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors;
  115701. var freeVaryingVec2 = Math.max(maxVaryingRows, 0.) - 1; // Because of sampleCenter
  115702. var varyingCount = Math.min(offsets.length, freeVaryingVec2);
  115703. var defines = "";
  115704. defines += this._staticDefines;
  115705. // The DOF fragment should ignore the center pixel when looping as it is handled manualy in the fragment shader.
  115706. if (this._staticDefines.indexOf("DOF") != -1) {
  115707. defines += "#define CENTER_WEIGHT " + this._glslFloat(weights[varyingCount - 1]) + "\r\n";
  115708. varyingCount--;
  115709. }
  115710. for (var i = 0; i < varyingCount; i++) {
  115711. defines += "#define KERNEL_OFFSET" + i + " " + this._glslFloat(offsets[i]) + "\r\n";
  115712. defines += "#define KERNEL_WEIGHT" + i + " " + this._glslFloat(weights[i]) + "\r\n";
  115713. }
  115714. var depCount = 0;
  115715. for (var i = freeVaryingVec2; i < offsets.length; i++) {
  115716. defines += "#define KERNEL_DEP_OFFSET" + depCount + " " + this._glslFloat(offsets[i]) + "\r\n";
  115717. defines += "#define KERNEL_DEP_WEIGHT" + depCount + " " + this._glslFloat(weights[i]) + "\r\n";
  115718. depCount++;
  115719. }
  115720. if (this.packedFloat) {
  115721. defines += "#define PACKEDFLOAT 1";
  115722. }
  115723. this.blockCompilation = false;
  115724. _super.prototype.updateEffect.call(this, defines, null, null, {
  115725. varyingCount: varyingCount,
  115726. depCount: depCount
  115727. }, onCompiled, onError);
  115728. };
  115729. /**
  115730. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  115731. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  115732. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  115733. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  115734. * The gaps between physical kernels are compensated for in the weighting of the samples
  115735. * @param idealKernel Ideal blur kernel.
  115736. * @return Nearest best kernel.
  115737. */
  115738. BlurPostProcess.prototype._nearestBestKernel = function (idealKernel) {
  115739. var v = Math.round(idealKernel);
  115740. for (var _i = 0, _a = [v, v - 1, v + 1, v - 2, v + 2]; _i < _a.length; _i++) {
  115741. var k = _a[_i];
  115742. if (((k % 2) !== 0) && ((Math.floor(k / 2) % 2) === 0) && k > 0) {
  115743. return Math.max(k, 3);
  115744. }
  115745. }
  115746. return Math.max(v, 3);
  115747. };
  115748. /**
  115749. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  115750. * @param x The point on the Gaussian distribution to sample.
  115751. * @return the value of the Gaussian function at x.
  115752. */
  115753. BlurPostProcess.prototype._gaussianWeight = function (x) {
  115754. //reference: Engines/ImageProcessingBlur.cpp #dcc760
  115755. // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],
  115756. // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.
  115757. // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is
  115758. // truncated at around 1.3% of peak strength.
  115759. //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size
  115760. var sigma = (1 / 3);
  115761. var denominator = Math.sqrt(2.0 * Math.PI) * sigma;
  115762. var exponent = -((x * x) / (2.0 * sigma * sigma));
  115763. var weight = (1.0 / denominator) * Math.exp(exponent);
  115764. return weight;
  115765. };
  115766. /**
  115767. * Generates a string that can be used as a floating point number in GLSL.
  115768. * @param x Value to print.
  115769. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  115770. * @return GLSL float string.
  115771. */
  115772. BlurPostProcess.prototype._glslFloat = function (x, decimalFigures) {
  115773. if (decimalFigures === void 0) { decimalFigures = 8; }
  115774. return x.toFixed(decimalFigures).replace(/0+$/, '');
  115775. };
  115776. return BlurPostProcess;
  115777. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  115778. /***/ }),
  115779. /***/ "./PostProcesses/chromaticAberrationPostProcess.ts":
  115780. /*!*********************************************************!*\
  115781. !*** ./PostProcesses/chromaticAberrationPostProcess.ts ***!
  115782. \*********************************************************/
  115783. /*! exports provided: ChromaticAberrationPostProcess */
  115784. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115785. "use strict";
  115786. __webpack_require__.r(__webpack_exports__);
  115787. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return ChromaticAberrationPostProcess; });
  115788. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115789. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  115790. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115791. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  115792. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  115793. /**
  115794. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  115795. */
  115796. var ChromaticAberrationPostProcess = /** @class */ (function (_super) {
  115797. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ChromaticAberrationPostProcess, _super);
  115798. /**
  115799. * Creates a new instance ChromaticAberrationPostProcess
  115800. * @param name The name of the effect.
  115801. * @param screenWidth The width of the screen to apply the effect on.
  115802. * @param screenHeight The height of the screen to apply the effect on.
  115803. * @param options The required width/height ratio to downsize to before computing the render pass.
  115804. * @param camera The camera to apply the render pass to.
  115805. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115806. * @param engine The engine which the post process will be applied. (default: current engine)
  115807. * @param reusable If the post process can be reused on the same frame. (default: false)
  115808. * @param textureType Type of textures used when performing the post process. (default: 0)
  115809. * @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)
  115810. */
  115811. function ChromaticAberrationPostProcess(name, screenWidth, screenHeight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  115812. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  115813. if (blockCompilation === void 0) { blockCompilation = false; }
  115814. 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;
  115815. /**
  115816. * The amount of seperation of rgb channels (default: 30)
  115817. */
  115818. _this.aberrationAmount = 30;
  115819. /**
  115820. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  115821. */
  115822. _this.radialIntensity = 0;
  115823. /**
  115824. * 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))
  115825. */
  115826. _this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.707, 0.707);
  115827. /**
  115828. * 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))
  115829. */
  115830. _this.centerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.5, 0.5);
  115831. _this.onApplyObservable.add(function (effect) {
  115832. effect.setFloat('chromatic_aberration', _this.aberrationAmount);
  115833. effect.setFloat('screen_width', screenWidth);
  115834. effect.setFloat('screen_height', screenHeight);
  115835. effect.setFloat('radialIntensity', _this.radialIntensity);
  115836. effect.setFloat2('direction', _this.direction.x, _this.direction.y);
  115837. effect.setFloat2('centerPosition', _this.centerPosition.x, _this.centerPosition.y);
  115838. });
  115839. return _this;
  115840. }
  115841. return ChromaticAberrationPostProcess;
  115842. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  115843. /***/ }),
  115844. /***/ "./PostProcesses/circleOfConfusionPostProcess.ts":
  115845. /*!*******************************************************!*\
  115846. !*** ./PostProcesses/circleOfConfusionPostProcess.ts ***!
  115847. \*******************************************************/
  115848. /*! exports provided: CircleOfConfusionPostProcess */
  115849. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115850. "use strict";
  115851. __webpack_require__.r(__webpack_exports__);
  115852. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return CircleOfConfusionPostProcess; });
  115853. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115854. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115855. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  115856. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  115857. /* harmony import */ var _Shaders_circleOfConfusion_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/circleOfConfusion.fragment */ "./Shaders/circleOfConfusion.fragment.ts");
  115858. /**
  115859. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  115860. */
  115861. var CircleOfConfusionPostProcess = /** @class */ (function (_super) {
  115862. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleOfConfusionPostProcess, _super);
  115863. /**
  115864. * Creates a new instance CircleOfConfusionPostProcess
  115865. * @param name The name of the effect.
  115866. * @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.
  115867. * @param options The required width/height ratio to downsize to before computing the render pass.
  115868. * @param camera The camera to apply the render pass to.
  115869. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115870. * @param engine The engine which the post process will be applied. (default: current engine)
  115871. * @param reusable If the post process can be reused on the same frame. (default: false)
  115872. * @param textureType Type of textures used when performing the post process. (default: 0)
  115873. * @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)
  115874. */
  115875. function CircleOfConfusionPostProcess(name, depthTexture, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  115876. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  115877. if (blockCompilation === void 0) { blockCompilation = false; }
  115878. var _this = _super.call(this, name, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  115879. /**
  115880. * 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.
  115881. */
  115882. _this.lensSize = 50;
  115883. /**
  115884. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  115885. */
  115886. _this.fStop = 1.4;
  115887. /**
  115888. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  115889. */
  115890. _this.focusDistance = 2000;
  115891. /**
  115892. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  115893. */
  115894. _this.focalLength = 50;
  115895. _this._depthTexture = null;
  115896. _this._depthTexture = depthTexture;
  115897. _this.onApplyObservable.add(function (effect) {
  115898. if (!_this._depthTexture) {
  115899. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("No depth texture set on CircleOfConfusionPostProcess");
  115900. return;
  115901. }
  115902. effect.setTexture("depthSampler", _this._depthTexture);
  115903. // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html
  115904. var aperture = _this.lensSize / _this.fStop;
  115905. var cocPrecalculation = ((aperture * _this.focalLength) / ((_this.focusDistance - _this.focalLength))); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]
  115906. effect.setFloat('focusDistance', _this.focusDistance);
  115907. effect.setFloat('cocPrecalculation', cocPrecalculation);
  115908. effect.setFloat2('cameraMinMaxZ', _this._depthTexture.activeCamera.minZ, _this._depthTexture.activeCamera.maxZ);
  115909. });
  115910. return _this;
  115911. }
  115912. Object.defineProperty(CircleOfConfusionPostProcess.prototype, "depthTexture", {
  115913. /**
  115914. * 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.
  115915. */
  115916. set: function (value) {
  115917. this._depthTexture = value;
  115918. },
  115919. enumerable: true,
  115920. configurable: true
  115921. });
  115922. return CircleOfConfusionPostProcess;
  115923. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  115924. /***/ }),
  115925. /***/ "./PostProcesses/colorCorrectionPostProcess.ts":
  115926. /*!*****************************************************!*\
  115927. !*** ./PostProcesses/colorCorrectionPostProcess.ts ***!
  115928. \*****************************************************/
  115929. /*! exports provided: ColorCorrectionPostProcess */
  115930. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115931. "use strict";
  115932. __webpack_require__.r(__webpack_exports__);
  115933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return ColorCorrectionPostProcess; });
  115934. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115935. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115936. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  115937. /* harmony import */ var _Shaders_colorCorrection_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/colorCorrection.fragment */ "./Shaders/colorCorrection.fragment.ts");
  115938. /**
  115939. *
  115940. * This post-process allows the modification of rendered colors by using
  115941. * a 'look-up table' (LUT). This effect is also called Color Grading.
  115942. *
  115943. * The object needs to be provided an url to a texture containing the color
  115944. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  115945. * Use an image editing software to tweak the LUT to match your needs.
  115946. *
  115947. * For an example of a color LUT, see here:
  115948. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  115949. * For explanations on color grading, see here:
  115950. * @see http://udn.epicgames.com/Three/ColorGrading.html
  115951. *
  115952. */
  115953. var ColorCorrectionPostProcess = /** @class */ (function (_super) {
  115954. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorCorrectionPostProcess, _super);
  115955. function ColorCorrectionPostProcess(name, colorTableUrl, options, camera, samplingMode, engine, reusable) {
  115956. var _this = _super.call(this, name, 'colorCorrection', null, ['colorTable'], options, camera, samplingMode, engine, reusable) || this;
  115957. _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);
  115958. _this._colorTableTexture.anisotropicFilteringLevel = 1;
  115959. _this._colorTableTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  115960. _this._colorTableTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  115961. _this.onApply = function (effect) {
  115962. effect.setTexture("colorTable", _this._colorTableTexture);
  115963. };
  115964. return _this;
  115965. }
  115966. return ColorCorrectionPostProcess;
  115967. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  115968. /***/ }),
  115969. /***/ "./PostProcesses/convolutionPostProcess.ts":
  115970. /*!*************************************************!*\
  115971. !*** ./PostProcesses/convolutionPostProcess.ts ***!
  115972. \*************************************************/
  115973. /*! exports provided: ConvolutionPostProcess */
  115974. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115975. "use strict";
  115976. __webpack_require__.r(__webpack_exports__);
  115977. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return ConvolutionPostProcess; });
  115978. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115979. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115980. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  115981. /* harmony import */ var _Shaders_convolution_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/convolution.fragment */ "./Shaders/convolution.fragment.ts");
  115982. /**
  115983. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  115984. * input texture to perform effects such as edge detection or sharpening
  115985. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  115986. */
  115987. var ConvolutionPostProcess = /** @class */ (function (_super) {
  115988. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ConvolutionPostProcess, _super);
  115989. /**
  115990. * Creates a new instance ConvolutionPostProcess
  115991. * @param name The name of the effect.
  115992. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  115993. * @param options The required width/height ratio to downsize to before computing the render pass.
  115994. * @param camera The camera to apply the render pass to.
  115995. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115996. * @param engine The engine which the post process will be applied. (default: current engine)
  115997. * @param reusable If the post process can be reused on the same frame. (default: false)
  115998. * @param textureType Type of textures used when performing the post process. (default: 0)
  115999. */
  116000. function ConvolutionPostProcess(name,
  116001. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  116002. kernel, options, camera, samplingMode, engine, reusable, textureType) {
  116003. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116004. var _this = _super.call(this, name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  116005. _this.kernel = kernel;
  116006. _this.onApply = function (effect) {
  116007. effect.setFloat2("screenSize", _this.width, _this.height);
  116008. effect.setArray("kernel", _this.kernel);
  116009. };
  116010. return _this;
  116011. }
  116012. // Statics
  116013. /**
  116014. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116015. */
  116016. ConvolutionPostProcess.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
  116017. /**
  116018. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116019. */
  116020. ConvolutionPostProcess.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
  116021. /**
  116022. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116023. */
  116024. ConvolutionPostProcess.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
  116025. /**
  116026. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116027. */
  116028. ConvolutionPostProcess.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
  116029. /**
  116030. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116031. */
  116032. ConvolutionPostProcess.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
  116033. /**
  116034. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116035. */
  116036. ConvolutionPostProcess.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
  116037. return ConvolutionPostProcess;
  116038. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116039. /***/ }),
  116040. /***/ "./PostProcesses/depthOfFieldBlurPostProcess.ts":
  116041. /*!******************************************************!*\
  116042. !*** ./PostProcesses/depthOfFieldBlurPostProcess.ts ***!
  116043. \******************************************************/
  116044. /*! exports provided: DepthOfFieldBlurPostProcess */
  116045. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116046. "use strict";
  116047. __webpack_require__.r(__webpack_exports__);
  116048. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return DepthOfFieldBlurPostProcess; });
  116049. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116050. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116051. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  116052. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116053. /**
  116054. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  116055. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  116056. * based on samples that have a large difference in distance than the center pixel.
  116057. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  116058. */
  116059. var DepthOfFieldBlurPostProcess = /** @class */ (function (_super) {
  116060. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldBlurPostProcess, _super);
  116061. /**
  116062. * Creates a new instance CircleOfConfusionPostProcess
  116063. * @param name The name of the effect.
  116064. * @param scene The scene the effect belongs to.
  116065. * @param direction The direction the blur should be applied.
  116066. * @param kernel The size of the kernel used to blur.
  116067. * @param options The required width/height ratio to downsize to before computing the render pass.
  116068. * @param camera The camera to apply the render pass to.
  116069. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  116070. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  116071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116072. * @param engine The engine which the post process will be applied. (default: current engine)
  116073. * @param reusable If the post process can be reused on the same frame. (default: false)
  116074. * @param textureType Type of textures used when performing the post process. (default: 0)
  116075. * @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)
  116076. */
  116077. function DepthOfFieldBlurPostProcess(name, scene, direction, kernel, options, camera, circleOfConfusion, imageToBlur, samplingMode, engine, reusable, textureType, blockCompilation) {
  116078. if (imageToBlur === void 0) { imageToBlur = null; }
  116079. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  116080. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116081. if (blockCompilation === void 0) { blockCompilation = false; }
  116082. 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;
  116083. _this.direction = direction;
  116084. _this.onApplyObservable.add(function (effect) {
  116085. if (imageToBlur != null) {
  116086. effect.setTextureFromPostProcess("textureSampler", imageToBlur);
  116087. }
  116088. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  116089. if (scene.activeCamera) {
  116090. effect.setFloat2('cameraMinMaxZ', scene.activeCamera.minZ, scene.activeCamera.maxZ);
  116091. }
  116092. });
  116093. return _this;
  116094. }
  116095. return DepthOfFieldBlurPostProcess;
  116096. }(_blurPostProcess__WEBPACK_IMPORTED_MODULE_2__["BlurPostProcess"]));
  116097. /***/ }),
  116098. /***/ "./PostProcesses/depthOfFieldEffect.ts":
  116099. /*!*********************************************!*\
  116100. !*** ./PostProcesses/depthOfFieldEffect.ts ***!
  116101. \*********************************************/
  116102. /*! exports provided: DepthOfFieldEffectBlurLevel, DepthOfFieldEffect */
  116103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116104. "use strict";
  116105. __webpack_require__.r(__webpack_exports__);
  116106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return DepthOfFieldEffectBlurLevel; });
  116107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return DepthOfFieldEffect; });
  116108. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116109. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116110. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116111. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  116112. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  116113. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  116114. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  116115. /**
  116116. * Specifies the level of max blur that should be applied when using the depth of field effect
  116117. */
  116118. var DepthOfFieldEffectBlurLevel;
  116119. (function (DepthOfFieldEffectBlurLevel) {
  116120. /**
  116121. * Subtle blur
  116122. */
  116123. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Low"] = 0] = "Low";
  116124. /**
  116125. * Medium blur
  116126. */
  116127. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Medium"] = 1] = "Medium";
  116128. /**
  116129. * Large blur
  116130. */
  116131. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["High"] = 2] = "High";
  116132. })(DepthOfFieldEffectBlurLevel || (DepthOfFieldEffectBlurLevel = {}));
  116133. /**
  116134. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  116135. */
  116136. var DepthOfFieldEffect = /** @class */ (function (_super) {
  116137. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldEffect, _super);
  116138. /**
  116139. * Creates a new instance DepthOfFieldEffect
  116140. * @param scene The scene the effect belongs to.
  116141. * @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.
  116142. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  116143. * @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)
  116144. */
  116145. function DepthOfFieldEffect(scene, depthTexture, blurLevel, pipelineTextureType, blockCompilation) {
  116146. if (blurLevel === void 0) { blurLevel = DepthOfFieldEffectBlurLevel.Low; }
  116147. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  116148. if (blockCompilation === void 0) { blockCompilation = false; }
  116149. var _this = _super.call(this, scene.getEngine(), "depth of field", function () {
  116150. return _this._effects;
  116151. }, true) || this;
  116152. /**
  116153. * @hidden Internal post processes in depth of field effect
  116154. */
  116155. _this._effects = [];
  116156. // Circle of confusion value for each pixel is used to determine how much to blur that pixel
  116157. _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);
  116158. // 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)
  116159. // Blur the image but do not blur on sharp far to near distance changes to avoid bleeding artifacts
  116160. // See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  116161. _this._depthOfFieldBlurY = [];
  116162. _this._depthOfFieldBlurX = [];
  116163. var blurCount = 1;
  116164. var kernelSize = 15;
  116165. switch (blurLevel) {
  116166. case DepthOfFieldEffectBlurLevel.High: {
  116167. blurCount = 3;
  116168. kernelSize = 51;
  116169. break;
  116170. }
  116171. case DepthOfFieldEffectBlurLevel.Medium: {
  116172. blurCount = 2;
  116173. kernelSize = 31;
  116174. break;
  116175. }
  116176. default: {
  116177. kernelSize = 15;
  116178. blurCount = 1;
  116179. break;
  116180. }
  116181. }
  116182. var adjustedKernelSize = kernelSize / Math.pow(2, blurCount - 1);
  116183. var ratio = 1.0;
  116184. for (var i = 0; i < blurCount; i++) {
  116185. 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);
  116186. blurY.autoClear = false;
  116187. ratio = 0.75 / Math.pow(2, i);
  116188. 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);
  116189. blurX.autoClear = false;
  116190. _this._depthOfFieldBlurY.push(blurY);
  116191. _this._depthOfFieldBlurX.push(blurX);
  116192. }
  116193. // Set all post processes on the effect.
  116194. _this._effects = [_this._circleOfConfusion];
  116195. for (var i = 0; i < _this._depthOfFieldBlurX.length; i++) {
  116196. _this._effects.push(_this._depthOfFieldBlurY[i]);
  116197. _this._effects.push(_this._depthOfFieldBlurX[i]);
  116198. }
  116199. // Merge blurred images with original image based on circleOfConfusion
  116200. _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);
  116201. _this._dofMerge.autoClear = false;
  116202. _this._effects.push(_this._dofMerge);
  116203. return _this;
  116204. }
  116205. Object.defineProperty(DepthOfFieldEffect.prototype, "focalLength", {
  116206. get: function () {
  116207. return this._circleOfConfusion.focalLength;
  116208. },
  116209. /**
  116210. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  116211. */
  116212. set: function (value) {
  116213. this._circleOfConfusion.focalLength = value;
  116214. },
  116215. enumerable: true,
  116216. configurable: true
  116217. });
  116218. Object.defineProperty(DepthOfFieldEffect.prototype, "fStop", {
  116219. get: function () {
  116220. return this._circleOfConfusion.fStop;
  116221. },
  116222. /**
  116223. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  116224. */
  116225. set: function (value) {
  116226. this._circleOfConfusion.fStop = value;
  116227. },
  116228. enumerable: true,
  116229. configurable: true
  116230. });
  116231. Object.defineProperty(DepthOfFieldEffect.prototype, "focusDistance", {
  116232. get: function () {
  116233. return this._circleOfConfusion.focusDistance;
  116234. },
  116235. /**
  116236. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  116237. */
  116238. set: function (value) {
  116239. this._circleOfConfusion.focusDistance = value;
  116240. },
  116241. enumerable: true,
  116242. configurable: true
  116243. });
  116244. Object.defineProperty(DepthOfFieldEffect.prototype, "lensSize", {
  116245. get: function () {
  116246. return this._circleOfConfusion.lensSize;
  116247. },
  116248. /**
  116249. * 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.
  116250. */
  116251. set: function (value) {
  116252. this._circleOfConfusion.lensSize = value;
  116253. },
  116254. enumerable: true,
  116255. configurable: true
  116256. });
  116257. Object.defineProperty(DepthOfFieldEffect.prototype, "depthTexture", {
  116258. /**
  116259. * 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.
  116260. */
  116261. set: function (value) {
  116262. this._circleOfConfusion.depthTexture = value;
  116263. },
  116264. enumerable: true,
  116265. configurable: true
  116266. });
  116267. /**
  116268. * Disposes each of the internal effects for a given camera.
  116269. * @param camera The camera to dispose the effect on.
  116270. */
  116271. DepthOfFieldEffect.prototype.disposeEffects = function (camera) {
  116272. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116273. this._effects[effectIndex].dispose(camera);
  116274. }
  116275. };
  116276. /**
  116277. * @hidden Internal
  116278. */
  116279. DepthOfFieldEffect.prototype._updateEffects = function () {
  116280. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116281. this._effects[effectIndex].updateEffect();
  116282. }
  116283. };
  116284. /**
  116285. * Internal
  116286. * @returns if all the contained post processes are ready.
  116287. * @hidden
  116288. */
  116289. DepthOfFieldEffect.prototype._isReady = function () {
  116290. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116291. if (!this._effects[effectIndex].isReady()) {
  116292. return false;
  116293. }
  116294. }
  116295. return true;
  116296. };
  116297. return DepthOfFieldEffect;
  116298. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderEffect"]));
  116299. /***/ }),
  116300. /***/ "./PostProcesses/depthOfFieldMergePostProcess.ts":
  116301. /*!*******************************************************!*\
  116302. !*** ./PostProcesses/depthOfFieldMergePostProcess.ts ***!
  116303. \*******************************************************/
  116304. /*! exports provided: DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess */
  116305. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116306. "use strict";
  116307. __webpack_require__.r(__webpack_exports__);
  116308. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return DepthOfFieldMergePostProcessOptions; });
  116309. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return DepthOfFieldMergePostProcess; });
  116310. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116311. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116312. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116313. /* harmony import */ var _Shaders_depthOfFieldMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/depthOfFieldMerge.fragment */ "./Shaders/depthOfFieldMerge.fragment.ts");
  116314. /**
  116315. * Options to be set when merging outputs from the default pipeline.
  116316. */
  116317. var DepthOfFieldMergePostProcessOptions = /** @class */ (function () {
  116318. function DepthOfFieldMergePostProcessOptions() {
  116319. }
  116320. return DepthOfFieldMergePostProcessOptions;
  116321. }());
  116322. /**
  116323. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  116324. */
  116325. var DepthOfFieldMergePostProcess = /** @class */ (function (_super) {
  116326. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldMergePostProcess, _super);
  116327. /**
  116328. * Creates a new instance of DepthOfFieldMergePostProcess
  116329. * @param name The name of the effect.
  116330. * @param originalFromInput Post process which's input will be used for the merge.
  116331. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  116332. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  116333. * @param options The required width/height ratio to downsize to before computing the render pass.
  116334. * @param camera The camera to apply the render pass to.
  116335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116336. * @param engine The engine which the post process will be applied. (default: current engine)
  116337. * @param reusable If the post process can be reused on the same frame. (default: false)
  116338. * @param textureType Type of textures used when performing the post process. (default: 0)
  116339. * @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)
  116340. */
  116341. function DepthOfFieldMergePostProcess(name, originalFromInput, circleOfConfusion, blurSteps, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116342. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116343. if (blockCompilation === void 0) { blockCompilation = false; }
  116344. var _this = _super.call(this, name, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  116345. _this.blurSteps = blurSteps;
  116346. _this.onApplyObservable.add(function (effect) {
  116347. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  116348. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  116349. blurSteps.forEach(function (step, index) {
  116350. effect.setTextureFromPostProcessOutput("blurStep" + (blurSteps.length - index - 1), step);
  116351. });
  116352. });
  116353. if (!blockCompilation) {
  116354. _this.updateEffect();
  116355. }
  116356. return _this;
  116357. }
  116358. /**
  116359. * Updates the effect with the current post process compile time values and recompiles the shader.
  116360. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  116361. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  116362. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  116363. * @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
  116364. * @param onCompiled Called when the shader has been compiled.
  116365. * @param onError Called if there is an error when compiling a shader.
  116366. */
  116367. DepthOfFieldMergePostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  116368. if (defines === void 0) { defines = null; }
  116369. if (uniforms === void 0) { uniforms = null; }
  116370. if (samplers === void 0) { samplers = null; }
  116371. if (!defines) {
  116372. defines = "";
  116373. defines += "#define BLUR_LEVEL " + (this.blurSteps.length - 1) + "\n";
  116374. }
  116375. _super.prototype.updateEffect.call(this, defines, uniforms, samplers, indexParameters, onCompiled, onError);
  116376. };
  116377. return DepthOfFieldMergePostProcess;
  116378. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116379. /***/ }),
  116380. /***/ "./PostProcesses/displayPassPostProcess.ts":
  116381. /*!*************************************************!*\
  116382. !*** ./PostProcesses/displayPassPostProcess.ts ***!
  116383. \*************************************************/
  116384. /*! exports provided: DisplayPassPostProcess */
  116385. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116386. "use strict";
  116387. __webpack_require__.r(__webpack_exports__);
  116388. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return DisplayPassPostProcess; });
  116389. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116390. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116391. /* harmony import */ var _Shaders_displayPass_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/displayPass.fragment */ "./Shaders/displayPass.fragment.ts");
  116392. /**
  116393. * DisplayPassPostProcess which produces an output the same as it's input
  116394. */
  116395. var DisplayPassPostProcess = /** @class */ (function (_super) {
  116396. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayPassPostProcess, _super);
  116397. /**
  116398. * Creates the DisplayPassPostProcess
  116399. * @param name The name of the effect.
  116400. * @param options The required width/height ratio to downsize to before computing the render pass.
  116401. * @param camera The camera to apply the render pass to.
  116402. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116403. * @param engine The engine which the post process will be applied. (default: current engine)
  116404. * @param reusable If the post process can be reused on the same frame. (default: false)
  116405. */
  116406. function DisplayPassPostProcess(name, options, camera, samplingMode, engine, reusable) {
  116407. return _super.call(this, name, "displayPass", ["passSampler"], ["passSampler"], options, camera, samplingMode, engine, reusable) || this;
  116408. }
  116409. return DisplayPassPostProcess;
  116410. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116411. /***/ }),
  116412. /***/ "./PostProcesses/extractHighlightsPostProcess.ts":
  116413. /*!*******************************************************!*\
  116414. !*** ./PostProcesses/extractHighlightsPostProcess.ts ***!
  116415. \*******************************************************/
  116416. /*! exports provided: ExtractHighlightsPostProcess */
  116417. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116418. "use strict";
  116419. __webpack_require__.r(__webpack_exports__);
  116420. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return ExtractHighlightsPostProcess; });
  116421. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116422. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116423. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116424. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116425. /* harmony import */ var _Shaders_extractHighlights_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/extractHighlights.fragment */ "./Shaders/extractHighlights.fragment.ts");
  116426. /**
  116427. * 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.
  116428. */
  116429. var ExtractHighlightsPostProcess = /** @class */ (function (_super) {
  116430. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExtractHighlightsPostProcess, _super);
  116431. function ExtractHighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116432. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116433. if (blockCompilation === void 0) { blockCompilation = false; }
  116434. var _this = _super.call(this, name, "extractHighlights", ["threshold", "exposure"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  116435. /**
  116436. * The luminance threshold, pixels below this value will be set to black.
  116437. */
  116438. _this.threshold = 0.9;
  116439. /** @hidden */
  116440. _this._exposure = 1;
  116441. /**
  116442. * Post process which has the input texture to be used when performing highlight extraction
  116443. * @hidden
  116444. */
  116445. _this._inputPostProcess = null;
  116446. _this.onApplyObservable.add(function (effect) {
  116447. if (_this._inputPostProcess) {
  116448. effect.setTextureFromPostProcess("textureSampler", _this._inputPostProcess);
  116449. }
  116450. effect.setFloat('threshold', Math.pow(_this.threshold, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["ToGammaSpace"]));
  116451. effect.setFloat('exposure', _this._exposure);
  116452. });
  116453. return _this;
  116454. }
  116455. return ExtractHighlightsPostProcess;
  116456. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116457. /***/ }),
  116458. /***/ "./PostProcesses/filterPostProcess.ts":
  116459. /*!********************************************!*\
  116460. !*** ./PostProcesses/filterPostProcess.ts ***!
  116461. \********************************************/
  116462. /*! exports provided: FilterPostProcess */
  116463. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116464. "use strict";
  116465. __webpack_require__.r(__webpack_exports__);
  116466. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return FilterPostProcess; });
  116467. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116468. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116469. /* harmony import */ var _Shaders_filter_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/filter.fragment */ "./Shaders/filter.fragment.ts");
  116470. /**
  116471. * Applies a kernel filter to the image
  116472. */
  116473. var FilterPostProcess = /** @class */ (function (_super) {
  116474. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FilterPostProcess, _super);
  116475. /**
  116476. *
  116477. * @param name The name of the effect.
  116478. * @param kernelMatrix The matrix to be applied to the image
  116479. * @param options The required width/height ratio to downsize to before computing the render pass.
  116480. * @param camera The camera to apply the render pass to.
  116481. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116482. * @param engine The engine which the post process will be applied. (default: current engine)
  116483. * @param reusable If the post process can be reused on the same frame. (default: false)
  116484. */
  116485. function FilterPostProcess(name,
  116486. /** The matrix to be applied to the image */
  116487. kernelMatrix, options, camera, samplingMode, engine, reusable) {
  116488. var _this = _super.call(this, name, "filter", ["kernelMatrix"], null, options, camera, samplingMode, engine, reusable) || this;
  116489. _this.kernelMatrix = kernelMatrix;
  116490. _this.onApply = function (effect) {
  116491. effect.setMatrix("kernelMatrix", _this.kernelMatrix);
  116492. };
  116493. return _this;
  116494. }
  116495. return FilterPostProcess;
  116496. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116497. /***/ }),
  116498. /***/ "./PostProcesses/fxaaPostProcess.ts":
  116499. /*!******************************************!*\
  116500. !*** ./PostProcesses/fxaaPostProcess.ts ***!
  116501. \******************************************/
  116502. /*! exports provided: FxaaPostProcess */
  116503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116504. "use strict";
  116505. __webpack_require__.r(__webpack_exports__);
  116506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return FxaaPostProcess; });
  116507. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116508. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116509. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116510. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116511. /* harmony import */ var _Shaders_fxaa_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/fxaa.fragment */ "./Shaders/fxaa.fragment.ts");
  116512. /* harmony import */ var _Shaders_fxaa_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/fxaa.vertex */ "./Shaders/fxaa.vertex.ts");
  116513. /**
  116514. * Fxaa post process
  116515. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  116516. */
  116517. var FxaaPostProcess = /** @class */ (function (_super) {
  116518. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FxaaPostProcess, _super);
  116519. function FxaaPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  116520. if (camera === void 0) { camera = null; }
  116521. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116522. 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;
  116523. var defines = _this._getDefines();
  116524. _this.updateEffect(defines);
  116525. _this.onApplyObservable.add(function (effect) {
  116526. var texelSize = _this.texelSize;
  116527. effect.setFloat2("texelSize", texelSize.x, texelSize.y);
  116528. });
  116529. return _this;
  116530. }
  116531. FxaaPostProcess.prototype._getDefines = function () {
  116532. var engine = this.getEngine();
  116533. if (!engine) {
  116534. return null;
  116535. }
  116536. var glInfo = engine.getGlInfo();
  116537. if (glInfo && glInfo.renderer && glInfo.renderer.toLowerCase().indexOf("mali") > -1) {
  116538. return "#define MALI 1\n";
  116539. }
  116540. return null;
  116541. };
  116542. return FxaaPostProcess;
  116543. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  116544. /***/ }),
  116545. /***/ "./PostProcesses/grainPostProcess.ts":
  116546. /*!*******************************************!*\
  116547. !*** ./PostProcesses/grainPostProcess.ts ***!
  116548. \*******************************************/
  116549. /*! exports provided: GrainPostProcess */
  116550. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116551. "use strict";
  116552. __webpack_require__.r(__webpack_exports__);
  116553. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return GrainPostProcess; });
  116554. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116555. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116556. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116557. /* harmony import */ var _Shaders_grain_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/grain.fragment */ "./Shaders/grain.fragment.ts");
  116558. /**
  116559. * The GrainPostProcess adds noise to the image at mid luminance levels
  116560. */
  116561. var GrainPostProcess = /** @class */ (function (_super) {
  116562. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GrainPostProcess, _super);
  116563. /**
  116564. * Creates a new instance of @see GrainPostProcess
  116565. * @param name The name of the effect.
  116566. * @param options The required width/height ratio to downsize to before computing the render pass.
  116567. * @param camera The camera to apply the render pass to.
  116568. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116569. * @param engine The engine which the post process will be applied. (default: current engine)
  116570. * @param reusable If the post process can be reused on the same frame. (default: false)
  116571. * @param textureType Type of textures used when performing the post process. (default: 0)
  116572. * @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)
  116573. */
  116574. function GrainPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116575. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116576. if (blockCompilation === void 0) { blockCompilation = false; }
  116577. var _this = _super.call(this, name, "grain", ["intensity", "animatedSeed"], [], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  116578. /**
  116579. * The intensity of the grain added (default: 30)
  116580. */
  116581. _this.intensity = 30;
  116582. /**
  116583. * If the grain should be randomized on every frame
  116584. */
  116585. _this.animated = false;
  116586. _this.onApplyObservable.add(function (effect) {
  116587. effect.setFloat('intensity', _this.intensity);
  116588. effect.setFloat('animatedSeed', _this.animated ? Math.random() + 1 : 1);
  116589. });
  116590. return _this;
  116591. }
  116592. return GrainPostProcess;
  116593. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116594. /***/ }),
  116595. /***/ "./PostProcesses/highlightsPostProcess.ts":
  116596. /*!************************************************!*\
  116597. !*** ./PostProcesses/highlightsPostProcess.ts ***!
  116598. \************************************************/
  116599. /*! exports provided: HighlightsPostProcess */
  116600. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116601. "use strict";
  116602. __webpack_require__.r(__webpack_exports__);
  116603. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return HighlightsPostProcess; });
  116604. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116605. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116606. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116607. /* harmony import */ var _Shaders_highlights_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/highlights.fragment */ "./Shaders/highlights.fragment.ts");
  116608. /**
  116609. * Extracts highlights from the image
  116610. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  116611. */
  116612. var HighlightsPostProcess = /** @class */ (function (_super) {
  116613. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightsPostProcess, _super);
  116614. /**
  116615. * Extracts highlights from the image
  116616. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  116617. * @param name The name of the effect.
  116618. * @param options The required width/height ratio to downsize to before computing the render pass.
  116619. * @param camera The camera to apply the render pass to.
  116620. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116621. * @param engine The engine which the post process will be applied. (default: current engine)
  116622. * @param reusable If the post process can be reused on the same frame. (default: false)
  116623. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  116624. */
  116625. function HighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  116626. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116627. return _super.call(this, name, "highlights", null, null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  116628. }
  116629. return HighlightsPostProcess;
  116630. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116631. /***/ }),
  116632. /***/ "./PostProcesses/imageProcessingPostProcess.ts":
  116633. /*!*****************************************************!*\
  116634. !*** ./PostProcesses/imageProcessingPostProcess.ts ***!
  116635. \*****************************************************/
  116636. /*! exports provided: ImageProcessingPostProcess */
  116637. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116638. "use strict";
  116639. __webpack_require__.r(__webpack_exports__);
  116640. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return ImageProcessingPostProcess; });
  116641. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116642. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  116643. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  116644. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116645. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  116646. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116647. /* harmony import */ var _Shaders_imageProcessing_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/imageProcessing.fragment */ "./Shaders/imageProcessing.fragment.ts");
  116648. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  116649. /**
  116650. * ImageProcessingPostProcess
  116651. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  116652. */
  116653. var ImageProcessingPostProcess = /** @class */ (function (_super) {
  116654. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingPostProcess, _super);
  116655. function ImageProcessingPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, imageProcessingConfiguration) {
  116656. if (camera === void 0) { camera = null; }
  116657. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116658. var _this = _super.call(this, name, "imageProcessing", [], [], options, camera, samplingMode, engine, reusable, null, textureType, "postprocess", null, true) || this;
  116659. _this._fromLinearSpace = true;
  116660. /**
  116661. * Defines cache preventing GC.
  116662. */
  116663. _this._defines = {
  116664. IMAGEPROCESSING: false,
  116665. VIGNETTE: false,
  116666. VIGNETTEBLENDMODEMULTIPLY: false,
  116667. VIGNETTEBLENDMODEOPAQUE: false,
  116668. TONEMAPPING: false,
  116669. TONEMAPPING_ACES: false,
  116670. CONTRAST: false,
  116671. COLORCURVES: false,
  116672. COLORGRADING: false,
  116673. COLORGRADING3D: false,
  116674. FROMLINEARSPACE: false,
  116675. SAMPLER3DGREENDEPTH: false,
  116676. SAMPLER3DBGRMAP: false,
  116677. IMAGEPROCESSINGPOSTPROCESS: false,
  116678. EXPOSURE: false,
  116679. };
  116680. // Setup the configuration as forced by the constructor. This would then not force the
  116681. // scene materials output in linear space and let untouched the default forward pass.
  116682. if (imageProcessingConfiguration) {
  116683. imageProcessingConfiguration.applyByPostProcess = true;
  116684. _this._attachImageProcessingConfiguration(imageProcessingConfiguration, true);
  116685. // This will cause the shader to be compiled
  116686. _this.fromLinearSpace = false;
  116687. }
  116688. // Setup the default processing configuration to the scene.
  116689. else {
  116690. _this._attachImageProcessingConfiguration(null, true);
  116691. _this.imageProcessingConfiguration.applyByPostProcess = true;
  116692. }
  116693. _this.onApply = function (effect) {
  116694. _this.imageProcessingConfiguration.bind(effect, _this.aspectRatio);
  116695. };
  116696. return _this;
  116697. }
  116698. Object.defineProperty(ImageProcessingPostProcess.prototype, "imageProcessingConfiguration", {
  116699. /**
  116700. * Gets the image processing configuration used either in this material.
  116701. */
  116702. get: function () {
  116703. return this._imageProcessingConfiguration;
  116704. },
  116705. /**
  116706. * Sets the Default image processing configuration used either in the this material.
  116707. *
  116708. * If sets to null, the scene one is in use.
  116709. */
  116710. set: function (value) {
  116711. this._attachImageProcessingConfiguration(value);
  116712. },
  116713. enumerable: true,
  116714. configurable: true
  116715. });
  116716. /**
  116717. * Attaches a new image processing configuration to the PBR Material.
  116718. * @param configuration
  116719. */
  116720. ImageProcessingPostProcess.prototype._attachImageProcessingConfiguration = function (configuration, doNotBuild) {
  116721. var _this = this;
  116722. if (doNotBuild === void 0) { doNotBuild = false; }
  116723. if (configuration === this._imageProcessingConfiguration) {
  116724. return;
  116725. }
  116726. // Detaches observer.
  116727. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  116728. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  116729. }
  116730. // Pick the scene configuration if needed.
  116731. if (!configuration) {
  116732. var scene = null;
  116733. var engine = this.getEngine();
  116734. var camera = this.getCamera();
  116735. if (camera) {
  116736. scene = camera.getScene();
  116737. }
  116738. else if (engine && engine.scenes) {
  116739. var scenes = engine.scenes;
  116740. scene = scenes[scenes.length - 1];
  116741. }
  116742. else {
  116743. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  116744. }
  116745. this._imageProcessingConfiguration = scene.imageProcessingConfiguration;
  116746. }
  116747. else {
  116748. this._imageProcessingConfiguration = configuration;
  116749. }
  116750. // Attaches observer.
  116751. if (this._imageProcessingConfiguration) {
  116752. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  116753. _this._updateParameters();
  116754. });
  116755. }
  116756. // Ensure the effect will be rebuilt.
  116757. if (!doNotBuild) {
  116758. this._updateParameters();
  116759. }
  116760. };
  116761. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurves", {
  116762. /**
  116763. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  116764. */
  116765. get: function () {
  116766. return this.imageProcessingConfiguration.colorCurves;
  116767. },
  116768. /**
  116769. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  116770. */
  116771. set: function (value) {
  116772. this.imageProcessingConfiguration.colorCurves = value;
  116773. },
  116774. enumerable: true,
  116775. configurable: true
  116776. });
  116777. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurvesEnabled", {
  116778. /**
  116779. * Gets wether the color curves effect is enabled.
  116780. */
  116781. get: function () {
  116782. return this.imageProcessingConfiguration.colorCurvesEnabled;
  116783. },
  116784. /**
  116785. * Sets wether the color curves effect is enabled.
  116786. */
  116787. set: function (value) {
  116788. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  116789. },
  116790. enumerable: true,
  116791. configurable: true
  116792. });
  116793. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingTexture", {
  116794. /**
  116795. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  116796. */
  116797. get: function () {
  116798. return this.imageProcessingConfiguration.colorGradingTexture;
  116799. },
  116800. /**
  116801. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  116802. */
  116803. set: function (value) {
  116804. this.imageProcessingConfiguration.colorGradingTexture = value;
  116805. },
  116806. enumerable: true,
  116807. configurable: true
  116808. });
  116809. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingEnabled", {
  116810. /**
  116811. * Gets wether the color grading effect is enabled.
  116812. */
  116813. get: function () {
  116814. return this.imageProcessingConfiguration.colorGradingEnabled;
  116815. },
  116816. /**
  116817. * Gets wether the color grading effect is enabled.
  116818. */
  116819. set: function (value) {
  116820. this.imageProcessingConfiguration.colorGradingEnabled = value;
  116821. },
  116822. enumerable: true,
  116823. configurable: true
  116824. });
  116825. Object.defineProperty(ImageProcessingPostProcess.prototype, "exposure", {
  116826. /**
  116827. * Gets exposure used in the effect.
  116828. */
  116829. get: function () {
  116830. return this.imageProcessingConfiguration.exposure;
  116831. },
  116832. /**
  116833. * Sets exposure used in the effect.
  116834. */
  116835. set: function (value) {
  116836. this.imageProcessingConfiguration.exposure = value;
  116837. },
  116838. enumerable: true,
  116839. configurable: true
  116840. });
  116841. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingEnabled", {
  116842. /**
  116843. * Gets wether tonemapping is enabled or not.
  116844. */
  116845. get: function () {
  116846. return this._imageProcessingConfiguration.toneMappingEnabled;
  116847. },
  116848. /**
  116849. * Sets wether tonemapping is enabled or not
  116850. */
  116851. set: function (value) {
  116852. this._imageProcessingConfiguration.toneMappingEnabled = value;
  116853. },
  116854. enumerable: true,
  116855. configurable: true
  116856. });
  116857. Object.defineProperty(ImageProcessingPostProcess.prototype, "contrast", {
  116858. /**
  116859. * Gets contrast used in the effect.
  116860. */
  116861. get: function () {
  116862. return this.imageProcessingConfiguration.contrast;
  116863. },
  116864. /**
  116865. * Sets contrast used in the effect.
  116866. */
  116867. set: function (value) {
  116868. this.imageProcessingConfiguration.contrast = value;
  116869. },
  116870. enumerable: true,
  116871. configurable: true
  116872. });
  116873. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteStretch", {
  116874. /**
  116875. * Gets Vignette stretch size.
  116876. */
  116877. get: function () {
  116878. return this.imageProcessingConfiguration.vignetteStretch;
  116879. },
  116880. /**
  116881. * Sets Vignette stretch size.
  116882. */
  116883. set: function (value) {
  116884. this.imageProcessingConfiguration.vignetteStretch = value;
  116885. },
  116886. enumerable: true,
  116887. configurable: true
  116888. });
  116889. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreX", {
  116890. /**
  116891. * Gets Vignette centre X Offset.
  116892. */
  116893. get: function () {
  116894. return this.imageProcessingConfiguration.vignetteCentreX;
  116895. },
  116896. /**
  116897. * Sets Vignette centre X Offset.
  116898. */
  116899. set: function (value) {
  116900. this.imageProcessingConfiguration.vignetteCentreX = value;
  116901. },
  116902. enumerable: true,
  116903. configurable: true
  116904. });
  116905. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreY", {
  116906. /**
  116907. * Gets Vignette centre Y Offset.
  116908. */
  116909. get: function () {
  116910. return this.imageProcessingConfiguration.vignetteCentreY;
  116911. },
  116912. /**
  116913. * Sets Vignette centre Y Offset.
  116914. */
  116915. set: function (value) {
  116916. this.imageProcessingConfiguration.vignetteCentreY = value;
  116917. },
  116918. enumerable: true,
  116919. configurable: true
  116920. });
  116921. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteWeight", {
  116922. /**
  116923. * Gets Vignette weight or intensity of the vignette effect.
  116924. */
  116925. get: function () {
  116926. return this.imageProcessingConfiguration.vignetteWeight;
  116927. },
  116928. /**
  116929. * Sets Vignette weight or intensity of the vignette effect.
  116930. */
  116931. set: function (value) {
  116932. this.imageProcessingConfiguration.vignetteWeight = value;
  116933. },
  116934. enumerable: true,
  116935. configurable: true
  116936. });
  116937. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteColor", {
  116938. /**
  116939. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116940. * if vignetteEnabled is set to true.
  116941. */
  116942. get: function () {
  116943. return this.imageProcessingConfiguration.vignetteColor;
  116944. },
  116945. /**
  116946. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116947. * if vignetteEnabled is set to true.
  116948. */
  116949. set: function (value) {
  116950. this.imageProcessingConfiguration.vignetteColor = value;
  116951. },
  116952. enumerable: true,
  116953. configurable: true
  116954. });
  116955. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCameraFov", {
  116956. /**
  116957. * Gets Camera field of view used by the Vignette effect.
  116958. */
  116959. get: function () {
  116960. return this.imageProcessingConfiguration.vignetteCameraFov;
  116961. },
  116962. /**
  116963. * Sets Camera field of view used by the Vignette effect.
  116964. */
  116965. set: function (value) {
  116966. this.imageProcessingConfiguration.vignetteCameraFov = value;
  116967. },
  116968. enumerable: true,
  116969. configurable: true
  116970. });
  116971. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteBlendMode", {
  116972. /**
  116973. * Gets the vignette blend mode allowing different kind of effect.
  116974. */
  116975. get: function () {
  116976. return this.imageProcessingConfiguration.vignetteBlendMode;
  116977. },
  116978. /**
  116979. * Sets the vignette blend mode allowing different kind of effect.
  116980. */
  116981. set: function (value) {
  116982. this.imageProcessingConfiguration.vignetteBlendMode = value;
  116983. },
  116984. enumerable: true,
  116985. configurable: true
  116986. });
  116987. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteEnabled", {
  116988. /**
  116989. * Gets wether the vignette effect is enabled.
  116990. */
  116991. get: function () {
  116992. return this.imageProcessingConfiguration.vignetteEnabled;
  116993. },
  116994. /**
  116995. * Sets wether the vignette effect is enabled.
  116996. */
  116997. set: function (value) {
  116998. this.imageProcessingConfiguration.vignetteEnabled = value;
  116999. },
  117000. enumerable: true,
  117001. configurable: true
  117002. });
  117003. Object.defineProperty(ImageProcessingPostProcess.prototype, "fromLinearSpace", {
  117004. /**
  117005. * Gets wether the input of the processing is in Gamma or Linear Space.
  117006. */
  117007. get: function () {
  117008. return this._fromLinearSpace;
  117009. },
  117010. /**
  117011. * Sets wether the input of the processing is in Gamma or Linear Space.
  117012. */
  117013. set: function (value) {
  117014. if (this._fromLinearSpace === value) {
  117015. return;
  117016. }
  117017. this._fromLinearSpace = value;
  117018. this._updateParameters();
  117019. },
  117020. enumerable: true,
  117021. configurable: true
  117022. });
  117023. /**
  117024. * "ImageProcessingPostProcess"
  117025. * @returns "ImageProcessingPostProcess"
  117026. */
  117027. ImageProcessingPostProcess.prototype.getClassName = function () {
  117028. return "ImageProcessingPostProcess";
  117029. };
  117030. ImageProcessingPostProcess.prototype._updateParameters = function () {
  117031. this._defines.FROMLINEARSPACE = this._fromLinearSpace;
  117032. this.imageProcessingConfiguration.prepareDefines(this._defines, true);
  117033. var defines = "";
  117034. for (var define in this._defines) {
  117035. if (this._defines[define]) {
  117036. defines += "#define " + define + ";\r\n";
  117037. }
  117038. }
  117039. var samplers = ["textureSampler"];
  117040. var uniforms = ["scale"];
  117041. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"]) {
  117042. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._defines);
  117043. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._defines);
  117044. }
  117045. this.updateEffect(defines, uniforms, samplers);
  117046. };
  117047. ImageProcessingPostProcess.prototype.dispose = function (camera) {
  117048. _super.prototype.dispose.call(this, camera);
  117049. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  117050. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  117051. }
  117052. if (this._imageProcessingConfiguration) {
  117053. this.imageProcessingConfiguration.applyByPostProcess = false;
  117054. }
  117055. };
  117056. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117057. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117058. ], ImageProcessingPostProcess.prototype, "_fromLinearSpace", void 0);
  117059. return ImageProcessingPostProcess;
  117060. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  117061. /***/ }),
  117062. /***/ "./PostProcesses/index.ts":
  117063. /*!********************************!*\
  117064. !*** ./PostProcesses/index.ts ***!
  117065. \********************************/
  117066. /*! 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 */
  117067. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117068. "use strict";
  117069. __webpack_require__.r(__webpack_exports__);
  117070. /* harmony import */ var _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  117071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  117072. /* harmony import */ var _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./blackAndWhitePostProcess */ "./PostProcesses/blackAndWhitePostProcess.ts");
  117073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__["BlackAndWhitePostProcess"]; });
  117074. /* harmony import */ var _bloomEffect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bloomEffect */ "./PostProcesses/bloomEffect.ts");
  117075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _bloomEffect__WEBPACK_IMPORTED_MODULE_2__["BloomEffect"]; });
  117076. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  117077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__["BloomMergePostProcess"]; });
  117078. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  117079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]; });
  117080. /* harmony import */ var _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  117081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__["ChromaticAberrationPostProcess"]; });
  117082. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  117083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__["CircleOfConfusionPostProcess"]; });
  117084. /* harmony import */ var _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./colorCorrectionPostProcess */ "./PostProcesses/colorCorrectionPostProcess.ts");
  117085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__["ColorCorrectionPostProcess"]; });
  117086. /* harmony import */ var _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./convolutionPostProcess */ "./PostProcesses/convolutionPostProcess.ts");
  117087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__["ConvolutionPostProcess"]; });
  117088. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  117089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__["DepthOfFieldBlurPostProcess"]; });
  117090. /* harmony import */ var _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  117091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffectBlurLevel"]; });
  117092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffect"]; });
  117093. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  117094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcessOptions"]; });
  117095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcess"]; });
  117096. /* harmony import */ var _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./displayPassPostProcess */ "./PostProcesses/displayPassPostProcess.ts");
  117097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__["DisplayPassPostProcess"]; });
  117098. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  117099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__["ExtractHighlightsPostProcess"]; });
  117100. /* harmony import */ var _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./filterPostProcess */ "./PostProcesses/filterPostProcess.ts");
  117101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__["FilterPostProcess"]; });
  117102. /* harmony import */ var _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  117103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__["FxaaPostProcess"]; });
  117104. /* harmony import */ var _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  117105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__["GrainPostProcess"]; });
  117106. /* harmony import */ var _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./highlightsPostProcess */ "./PostProcesses/highlightsPostProcess.ts");
  117107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__["HighlightsPostProcess"]; });
  117108. /* harmony import */ var _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  117109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__["ImageProcessingPostProcess"]; });
  117110. /* harmony import */ var _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./motionBlurPostProcess */ "./PostProcesses/motionBlurPostProcess.ts");
  117111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__["MotionBlurPostProcess"]; });
  117112. /* harmony import */ var _passPostProcess__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./passPostProcess */ "./PostProcesses/passPostProcess.ts");
  117113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassPostProcess"]; });
  117114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassCubePostProcess"]; });
  117115. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _postProcess__WEBPACK_IMPORTED_MODULE_21__["PostProcess"]; });
  117117. /* harmony import */ var _postProcessManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./postProcessManager */ "./PostProcesses/postProcessManager.ts");
  117118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"]; });
  117119. /* harmony import */ var _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./refractionPostProcess */ "./PostProcesses/refractionPostProcess.ts");
  117120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__["RefractionPostProcess"]; });
  117121. /* harmony import */ var _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./RenderPipeline/index */ "./PostProcesses/RenderPipeline/index.ts");
  117122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderEffect"]; });
  117123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipeline"]; });
  117124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManager"]; });
  117125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManagerSceneComponent"]; });
  117126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["DefaultRenderingPipeline"]; });
  117127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["LensRenderingPipeline"]; });
  117128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAO2RenderingPipeline"]; });
  117129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAORenderingPipeline"]; });
  117130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["StandardRenderingPipeline"]; });
  117131. /* harmony import */ var _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  117132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__["SharpenPostProcess"]; });
  117133. /* harmony import */ var _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  117134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__["StereoscopicInterlacePostProcess"]; });
  117135. /* harmony import */ var _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./tonemapPostProcess */ "./PostProcesses/tonemapPostProcess.ts");
  117136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemappingOperator"]; });
  117137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemapPostProcess"]; });
  117138. /* harmony import */ var _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./volumetricLightScatteringPostProcess */ "./PostProcesses/volumetricLightScatteringPostProcess.ts");
  117139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__["VolumetricLightScatteringPostProcess"]; });
  117140. /* harmony import */ var _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  117141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  117142. /***/ }),
  117143. /***/ "./PostProcesses/motionBlurPostProcess.ts":
  117144. /*!************************************************!*\
  117145. !*** ./PostProcesses/motionBlurPostProcess.ts ***!
  117146. \************************************************/
  117147. /*! exports provided: MotionBlurPostProcess */
  117148. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117149. "use strict";
  117150. __webpack_require__.r(__webpack_exports__);
  117151. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return MotionBlurPostProcess; });
  117152. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117153. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  117154. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117155. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117156. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117157. /* harmony import */ var _Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Rendering/geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  117158. /* harmony import */ var _Shaders_motionBlur_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/motionBlur.fragment */ "./Shaders/motionBlur.fragment.ts");
  117159. /**
  117160. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  117161. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  117162. * As an example, all you have to do is to create the post-process:
  117163. * var mb = new BABYLON.MotionBlurPostProcess(
  117164. * 'mb', // The name of the effect.
  117165. * scene, // The scene containing the objects to blur according to their velocity.
  117166. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  117167. * camera // The camera to apply the render pass to.
  117168. * );
  117169. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  117170. */
  117171. var MotionBlurPostProcess = /** @class */ (function (_super) {
  117172. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotionBlurPostProcess, _super);
  117173. /**
  117174. * Creates a new instance MotionBlurPostProcess
  117175. * @param name The name of the effect.
  117176. * @param scene The scene containing the objects to blur according to their velocity.
  117177. * @param options The required width/height ratio to downsize to before computing the render pass.
  117178. * @param camera The camera to apply the render pass to.
  117179. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117180. * @param engine The engine which the post process will be applied. (default: current engine)
  117181. * @param reusable If the post process can be reused on the same frame. (default: false)
  117182. * @param textureType Type of textures used when performing the post process. (default: 0)
  117183. * @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)
  117184. */
  117185. function MotionBlurPostProcess(name, scene, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117186. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117187. if (blockCompilation === void 0) { blockCompilation = false; }
  117188. 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;
  117189. /**
  117190. * Defines how much the image is blurred by the movement. Default value is equal to 1
  117191. */
  117192. _this.motionStrength = 1;
  117193. _this._motionBlurSamples = 32;
  117194. _this._geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  117195. if (!_this._geometryBufferRenderer) {
  117196. // Geometry buffer renderer is not supported. So, work as a passthrough.
  117197. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Multiple Render Target support needed to compute object based motion blur");
  117198. _this.updateEffect();
  117199. }
  117200. else {
  117201. // Geometry buffer renderer is supported.
  117202. _this._geometryBufferRenderer.enableVelocity = true;
  117203. _this.onApply = function (effect) {
  117204. effect.setVector2("screenSize", new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](_this.width, _this.height));
  117205. effect.setFloat("motionScale", scene.getAnimationRatio());
  117206. effect.setFloat("motionStrength", _this.motionStrength);
  117207. if (_this._geometryBufferRenderer) {
  117208. var velocityIndex = _this._geometryBufferRenderer.getTextureIndex(_Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRenderer"].VELOCITY_TEXTURE_TYPE);
  117209. effect.setTexture("velocitySampler", _this._geometryBufferRenderer.getGBuffer().textures[velocityIndex]);
  117210. }
  117211. };
  117212. }
  117213. return _this;
  117214. }
  117215. Object.defineProperty(MotionBlurPostProcess.prototype, "motionBlurSamples", {
  117216. /**
  117217. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  117218. */
  117219. get: function () {
  117220. return this._motionBlurSamples;
  117221. },
  117222. /**
  117223. * Sets the number of iterations to be used for motion blur quality
  117224. */
  117225. set: function (samples) {
  117226. this._motionBlurSamples = samples;
  117227. if (this._geometryBufferRenderer) {
  117228. this.updateEffect("#define GEOMETRY_SUPPORTED\n#define SAMPLES " + samples.toFixed(1));
  117229. }
  117230. },
  117231. enumerable: true,
  117232. configurable: true
  117233. });
  117234. /**
  117235. * Disposes the post process.
  117236. * @param camera The camera to dispose the post process on.
  117237. */
  117238. MotionBlurPostProcess.prototype.dispose = function (camera) {
  117239. if (this._geometryBufferRenderer) {
  117240. // Clear previous transformation matrices dictionary used to compute objects velocities
  117241. this._geometryBufferRenderer._previousTransformationMatrices = {};
  117242. }
  117243. _super.prototype.dispose.call(this, camera);
  117244. };
  117245. return MotionBlurPostProcess;
  117246. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  117247. /***/ }),
  117248. /***/ "./PostProcesses/passPostProcess.ts":
  117249. /*!******************************************!*\
  117250. !*** ./PostProcesses/passPostProcess.ts ***!
  117251. \******************************************/
  117252. /*! exports provided: PassPostProcess, PassCubePostProcess */
  117253. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117254. "use strict";
  117255. __webpack_require__.r(__webpack_exports__);
  117256. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return PassPostProcess; });
  117257. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return PassCubePostProcess; });
  117258. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117259. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117260. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117261. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  117262. /* harmony import */ var _Shaders_pass_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/pass.fragment */ "./Shaders/pass.fragment.ts");
  117263. /* harmony import */ var _Shaders_passCube_fragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/passCube.fragment */ "./Shaders/passCube.fragment.ts");
  117264. /**
  117265. * PassPostProcess which produces an output the same as it's input
  117266. */
  117267. var PassPostProcess = /** @class */ (function (_super) {
  117268. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassPostProcess, _super);
  117269. /**
  117270. * Creates the PassPostProcess
  117271. * @param name The name of the effect.
  117272. * @param options The required width/height ratio to downsize to before computing the render pass.
  117273. * @param camera The camera to apply the render pass to.
  117274. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117275. * @param engine The engine which the post process will be applied. (default: current engine)
  117276. * @param reusable If the post process can be reused on the same frame. (default: false)
  117277. * @param textureType The type of texture to be used when performing the post processing.
  117278. * @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)
  117279. */
  117280. function PassPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117281. if (camera === void 0) { camera = null; }
  117282. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117283. if (blockCompilation === void 0) { blockCompilation = false; }
  117284. return _super.call(this, name, "pass", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation) || this;
  117285. }
  117286. return PassPostProcess;
  117287. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  117288. /**
  117289. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  117290. */
  117291. var PassCubePostProcess = /** @class */ (function (_super) {
  117292. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassCubePostProcess, _super);
  117293. /**
  117294. * Creates the PassCubePostProcess
  117295. * @param name The name of the effect.
  117296. * @param options The required width/height ratio to downsize to before computing the render pass.
  117297. * @param camera The camera to apply the render pass to.
  117298. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117299. * @param engine The engine which the post process will be applied. (default: current engine)
  117300. * @param reusable If the post process can be reused on the same frame. (default: false)
  117301. * @param textureType The type of texture to be used when performing the post processing.
  117302. * @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)
  117303. */
  117304. function PassCubePostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117305. if (camera === void 0) { camera = null; }
  117306. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117307. if (blockCompilation === void 0) { blockCompilation = false; }
  117308. var _this = _super.call(this, name, "passCube", null, null, options, camera, samplingMode, engine, reusable, "#define POSITIVEX", textureType, undefined, null, blockCompilation) || this;
  117309. _this._face = 0;
  117310. return _this;
  117311. }
  117312. Object.defineProperty(PassCubePostProcess.prototype, "face", {
  117313. /**
  117314. * Gets or sets the cube face to display.
  117315. * * 0 is +X
  117316. * * 1 is -X
  117317. * * 2 is +Y
  117318. * * 3 is -Y
  117319. * * 4 is +Z
  117320. * * 5 is -Z
  117321. */
  117322. get: function () {
  117323. return this._face;
  117324. },
  117325. set: function (value) {
  117326. if (value < 0 || value > 5) {
  117327. return;
  117328. }
  117329. this._face = value;
  117330. switch (this._face) {
  117331. case 0:
  117332. this.updateEffect("#define POSITIVEX");
  117333. break;
  117334. case 1:
  117335. this.updateEffect("#define NEGATIVEX");
  117336. break;
  117337. case 2:
  117338. this.updateEffect("#define POSITIVEY");
  117339. break;
  117340. case 3:
  117341. this.updateEffect("#define NEGATIVEY");
  117342. break;
  117343. case 4:
  117344. this.updateEffect("#define POSITIVEZ");
  117345. break;
  117346. case 5:
  117347. this.updateEffect("#define NEGATIVEZ");
  117348. break;
  117349. }
  117350. },
  117351. enumerable: true,
  117352. configurable: true
  117353. });
  117354. return PassCubePostProcess;
  117355. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  117356. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"]._RescalePostProcessFactory = function (engine) {
  117357. 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);
  117358. };
  117359. /***/ }),
  117360. /***/ "./PostProcesses/postProcess.ts":
  117361. /*!**************************************!*\
  117362. !*** ./PostProcesses/postProcess.ts ***!
  117363. \**************************************/
  117364. /*! exports provided: PostProcess */
  117365. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117366. "use strict";
  117367. __webpack_require__.r(__webpack_exports__);
  117368. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return PostProcess; });
  117369. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  117370. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  117371. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  117372. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117373. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117374. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  117375. /**
  117376. * PostProcess can be used to apply a shader to a texture after it has been rendered
  117377. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117378. */
  117379. var PostProcess = /** @class */ (function () {
  117380. /**
  117381. * Creates a new instance PostProcess
  117382. * @param name The name of the PostProcess.
  117383. * @param fragmentUrl The url of the fragment shader to be used.
  117384. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  117385. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  117386. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  117387. * @param camera The camera to apply the render pass to.
  117388. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117389. * @param engine The engine which the post process will be applied. (default: current engine)
  117390. * @param reusable If the post process can be reused on the same frame. (default: false)
  117391. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  117392. * @param textureType Type of textures used when performing the post process. (default: 0)
  117393. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  117394. * @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
  117395. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  117396. */
  117397. function PostProcess(
  117398. /** Name of the PostProcess. */
  117399. name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
  117400. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE; }
  117401. if (defines === void 0) { defines = null; }
  117402. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117403. if (vertexUrl === void 0) { vertexUrl = "postprocess"; }
  117404. if (blockCompilation === void 0) { blockCompilation = false; }
  117405. this.name = name;
  117406. /**
  117407. * Width of the texture to apply the post process on
  117408. */
  117409. this.width = -1;
  117410. /**
  117411. * Height of the texture to apply the post process on
  117412. */
  117413. this.height = -1;
  117414. /**
  117415. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  117416. * @hidden
  117417. */
  117418. this._outputTexture = null;
  117419. /**
  117420. * If the buffer needs to be cleared before applying the post process. (default: true)
  117421. * Should be set to false if shader will overwrite all previous pixels.
  117422. */
  117423. this.autoClear = true;
  117424. /**
  117425. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  117426. */
  117427. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE;
  117428. /**
  117429. * Animations to be used for the post processing
  117430. */
  117431. this.animations = new Array();
  117432. /**
  117433. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  117434. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  117435. */
  117436. this.enablePixelPerfectMode = false;
  117437. /**
  117438. * Force the postprocess to be applied without taking in account viewport
  117439. */
  117440. this.forceFullscreenViewport = true;
  117441. /**
  117442. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  117443. *
  117444. * | Value | Type | Description |
  117445. * | ----- | ----------------------------------- | ----------- |
  117446. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  117447. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  117448. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  117449. *
  117450. */
  117451. this.scaleMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].SCALEMODE_FLOOR;
  117452. /**
  117453. * Force textures to be a power of two (default: false)
  117454. */
  117455. this.alwaysForcePOT = false;
  117456. this._samples = 1;
  117457. /**
  117458. * Modify the scale of the post process to be the same as the viewport (default: false)
  117459. */
  117460. this.adaptScaleToCurrentViewport = false;
  117461. this._reusable = false;
  117462. /**
  117463. * Smart array of input and output textures for the post process.
  117464. * @hidden
  117465. */
  117466. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  117467. /**
  117468. * The index in _textures that corresponds to the output texture.
  117469. * @hidden
  117470. */
  117471. this._currentRenderTextureInd = 0;
  117472. this._scaleRatio = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 1);
  117473. this._texelSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  117474. // Events
  117475. /**
  117476. * An event triggered when the postprocess is activated.
  117477. */
  117478. this.onActivateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  117479. /**
  117480. * An event triggered when the postprocess changes its size.
  117481. */
  117482. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  117483. /**
  117484. * An event triggered when the postprocess applies its effect.
  117485. */
  117486. this.onApplyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  117487. /**
  117488. * An event triggered before rendering the postprocess
  117489. */
  117490. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  117491. /**
  117492. * An event triggered after rendering the postprocess
  117493. */
  117494. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  117495. if (camera != null) {
  117496. this._camera = camera;
  117497. this._scene = camera.getScene();
  117498. camera.attachPostProcess(this);
  117499. this._engine = this._scene.getEngine();
  117500. this._scene.postProcesses.push(this);
  117501. }
  117502. else if (engine) {
  117503. this._engine = engine;
  117504. this._engine.postProcesses.push(this);
  117505. }
  117506. this._options = options;
  117507. this.renderTargetSamplingMode = samplingMode ? samplingMode : _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  117508. this._reusable = reusable || false;
  117509. this._textureType = textureType;
  117510. this._samplers = samplers || [];
  117511. this._samplers.push("textureSampler");
  117512. this._fragmentUrl = fragmentUrl;
  117513. this._vertexUrl = vertexUrl;
  117514. this._parameters = parameters || [];
  117515. this._parameters.push("scale");
  117516. this._indexParameters = indexParameters;
  117517. if (!blockCompilation) {
  117518. this.updateEffect(defines);
  117519. }
  117520. }
  117521. Object.defineProperty(PostProcess.prototype, "samples", {
  117522. /**
  117523. * Number of sample textures (default: 1)
  117524. */
  117525. get: function () {
  117526. return this._samples;
  117527. },
  117528. set: function (n) {
  117529. var _this = this;
  117530. this._samples = n;
  117531. this._textures.forEach(function (texture) {
  117532. if (texture.samples !== _this._samples) {
  117533. _this._engine.updateRenderTargetTextureSampleCount(texture, _this._samples);
  117534. }
  117535. });
  117536. },
  117537. enumerable: true,
  117538. configurable: true
  117539. });
  117540. /**
  117541. * Returns the fragment url or shader name used in the post process.
  117542. * @returns the fragment url or name in the shader store.
  117543. */
  117544. PostProcess.prototype.getEffectName = function () {
  117545. return this._fragmentUrl;
  117546. };
  117547. Object.defineProperty(PostProcess.prototype, "onActivate", {
  117548. /**
  117549. * A function that is added to the onActivateObservable
  117550. */
  117551. set: function (callback) {
  117552. if (this._onActivateObserver) {
  117553. this.onActivateObservable.remove(this._onActivateObserver);
  117554. }
  117555. if (callback) {
  117556. this._onActivateObserver = this.onActivateObservable.add(callback);
  117557. }
  117558. },
  117559. enumerable: true,
  117560. configurable: true
  117561. });
  117562. Object.defineProperty(PostProcess.prototype, "onSizeChanged", {
  117563. /**
  117564. * A function that is added to the onSizeChangedObservable
  117565. */
  117566. set: function (callback) {
  117567. if (this._onSizeChangedObserver) {
  117568. this.onSizeChangedObservable.remove(this._onSizeChangedObserver);
  117569. }
  117570. this._onSizeChangedObserver = this.onSizeChangedObservable.add(callback);
  117571. },
  117572. enumerable: true,
  117573. configurable: true
  117574. });
  117575. Object.defineProperty(PostProcess.prototype, "onApply", {
  117576. /**
  117577. * A function that is added to the onApplyObservable
  117578. */
  117579. set: function (callback) {
  117580. if (this._onApplyObserver) {
  117581. this.onApplyObservable.remove(this._onApplyObserver);
  117582. }
  117583. this._onApplyObserver = this.onApplyObservable.add(callback);
  117584. },
  117585. enumerable: true,
  117586. configurable: true
  117587. });
  117588. Object.defineProperty(PostProcess.prototype, "onBeforeRender", {
  117589. /**
  117590. * A function that is added to the onBeforeRenderObservable
  117591. */
  117592. set: function (callback) {
  117593. if (this._onBeforeRenderObserver) {
  117594. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  117595. }
  117596. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  117597. },
  117598. enumerable: true,
  117599. configurable: true
  117600. });
  117601. Object.defineProperty(PostProcess.prototype, "onAfterRender", {
  117602. /**
  117603. * A function that is added to the onAfterRenderObservable
  117604. */
  117605. set: function (callback) {
  117606. if (this._onAfterRenderObserver) {
  117607. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  117608. }
  117609. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  117610. },
  117611. enumerable: true,
  117612. configurable: true
  117613. });
  117614. Object.defineProperty(PostProcess.prototype, "inputTexture", {
  117615. /**
  117616. * 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
  117617. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  117618. */
  117619. get: function () {
  117620. return this._textures.data[this._currentRenderTextureInd];
  117621. },
  117622. set: function (value) {
  117623. this._forcedOutputTexture = value;
  117624. },
  117625. enumerable: true,
  117626. configurable: true
  117627. });
  117628. /**
  117629. * Gets the camera which post process is applied to.
  117630. * @returns The camera the post process is applied to.
  117631. */
  117632. PostProcess.prototype.getCamera = function () {
  117633. return this._camera;
  117634. };
  117635. Object.defineProperty(PostProcess.prototype, "texelSize", {
  117636. /**
  117637. * Gets the texel size of the postprocess.
  117638. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  117639. */
  117640. get: function () {
  117641. if (this._shareOutputWithPostProcess) {
  117642. return this._shareOutputWithPostProcess.texelSize;
  117643. }
  117644. if (this._forcedOutputTexture) {
  117645. this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture.width, 1.0 / this._forcedOutputTexture.height);
  117646. }
  117647. return this._texelSize;
  117648. },
  117649. enumerable: true,
  117650. configurable: true
  117651. });
  117652. /**
  117653. * Gets the engine which this post process belongs to.
  117654. * @returns The engine the post process was enabled with.
  117655. */
  117656. PostProcess.prototype.getEngine = function () {
  117657. return this._engine;
  117658. };
  117659. /**
  117660. * The effect that is created when initializing the post process.
  117661. * @returns The created effect corrisponding the the postprocess.
  117662. */
  117663. PostProcess.prototype.getEffect = function () {
  117664. return this._effect;
  117665. };
  117666. /**
  117667. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  117668. * @param postProcess The post process to share the output with.
  117669. * @returns This post process.
  117670. */
  117671. PostProcess.prototype.shareOutputWith = function (postProcess) {
  117672. this._disposeTextures();
  117673. this._shareOutputWithPostProcess = postProcess;
  117674. return this;
  117675. };
  117676. /**
  117677. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  117678. * This should be called if the post process that shares output with this post process is disabled/disposed.
  117679. */
  117680. PostProcess.prototype.useOwnOutput = function () {
  117681. if (this._textures.length == 0) {
  117682. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  117683. }
  117684. this._shareOutputWithPostProcess = null;
  117685. };
  117686. /**
  117687. * Updates the effect with the current post process compile time values and recompiles the shader.
  117688. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  117689. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  117690. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  117691. * @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
  117692. * @param onCompiled Called when the shader has been compiled.
  117693. * @param onError Called if there is an error when compiling a shader.
  117694. */
  117695. PostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  117696. if (defines === void 0) { defines = null; }
  117697. if (uniforms === void 0) { uniforms = null; }
  117698. if (samplers === void 0) { samplers = null; }
  117699. 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);
  117700. };
  117701. /**
  117702. * The post process is reusable if it can be used multiple times within one frame.
  117703. * @returns If the post process is reusable
  117704. */
  117705. PostProcess.prototype.isReusable = function () {
  117706. return this._reusable;
  117707. };
  117708. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  117709. PostProcess.prototype.markTextureDirty = function () {
  117710. this.width = -1;
  117711. };
  117712. /**
  117713. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  117714. * 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.
  117715. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  117716. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  117717. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  117718. * @returns The target texture that was bound to be written to.
  117719. */
  117720. PostProcess.prototype.activate = function (camera, sourceTexture, forceDepthStencil) {
  117721. var _this = this;
  117722. if (sourceTexture === void 0) { sourceTexture = null; }
  117723. camera = camera || this._camera;
  117724. var scene = camera.getScene();
  117725. var engine = scene.getEngine();
  117726. var maxSize = engine.getCaps().maxTextureSize;
  117727. var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * this._options) | 0;
  117728. var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * this._options) | 0;
  117729. // 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
  117730. var webVRCamera = camera.parent;
  117731. if (webVRCamera && (webVRCamera.leftCamera == camera || webVRCamera.rightCamera == camera)) {
  117732. requiredWidth /= 2;
  117733. }
  117734. var desiredWidth = (this._options.width || requiredWidth);
  117735. var desiredHeight = this._options.height || requiredHeight;
  117736. if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
  117737. if (this.adaptScaleToCurrentViewport) {
  117738. var currentViewport = engine.currentViewport;
  117739. if (currentViewport) {
  117740. desiredWidth *= currentViewport.width;
  117741. desiredHeight *= currentViewport.height;
  117742. }
  117743. }
  117744. if (this.renderTargetSamplingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE || this.alwaysForcePOT) {
  117745. if (!this._options.width) {
  117746. desiredWidth = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredWidth, maxSize, this.scaleMode) : desiredWidth;
  117747. }
  117748. if (!this._options.height) {
  117749. desiredHeight = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredHeight, maxSize, this.scaleMode) : desiredHeight;
  117750. }
  117751. }
  117752. if (this.width !== desiredWidth || this.height !== desiredHeight) {
  117753. if (this._textures.length > 0) {
  117754. for (var i = 0; i < this._textures.length; i++) {
  117755. this._engine._releaseTexture(this._textures.data[i]);
  117756. }
  117757. this._textures.reset();
  117758. }
  117759. this.width = desiredWidth;
  117760. this.height = desiredHeight;
  117761. var textureSize = { width: this.width, height: this.height };
  117762. var textureOptions = {
  117763. generateMipMaps: false,
  117764. generateDepthBuffer: forceDepthStencil || camera._postProcesses.indexOf(this) === 0,
  117765. generateStencilBuffer: (forceDepthStencil || camera._postProcesses.indexOf(this) === 0) && this._engine.isStencilEnable,
  117766. samplingMode: this.renderTargetSamplingMode,
  117767. type: this._textureType
  117768. };
  117769. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  117770. if (this._reusable) {
  117771. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  117772. }
  117773. this._texelSize.copyFromFloats(1.0 / this.width, 1.0 / this.height);
  117774. this.onSizeChangedObservable.notifyObservers(this);
  117775. }
  117776. this._textures.forEach(function (texture) {
  117777. if (texture.samples !== _this.samples) {
  117778. _this._engine.updateRenderTargetTextureSampleCount(texture, _this.samples);
  117779. }
  117780. });
  117781. }
  117782. var target;
  117783. if (this._shareOutputWithPostProcess) {
  117784. target = this._shareOutputWithPostProcess.inputTexture;
  117785. }
  117786. else if (this._forcedOutputTexture) {
  117787. target = this._forcedOutputTexture;
  117788. this.width = this._forcedOutputTexture.width;
  117789. this.height = this._forcedOutputTexture.height;
  117790. }
  117791. else {
  117792. target = this.inputTexture;
  117793. }
  117794. // Bind the input of this post process to be used as the output of the previous post process.
  117795. if (this.enablePixelPerfectMode) {
  117796. this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
  117797. this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, this.forceFullscreenViewport);
  117798. }
  117799. else {
  117800. this._scaleRatio.copyFromFloats(1, 1);
  117801. this._engine.bindFramebuffer(target, 0, undefined, undefined, this.forceFullscreenViewport);
  117802. }
  117803. this.onActivateObservable.notifyObservers(camera);
  117804. // Clear
  117805. if (this.autoClear && this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE) {
  117806. this._engine.clear(this.clearColor ? this.clearColor : scene.clearColor, scene._allowPostProcessClearColor, true, true);
  117807. }
  117808. if (this._reusable) {
  117809. this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
  117810. }
  117811. return target;
  117812. };
  117813. Object.defineProperty(PostProcess.prototype, "isSupported", {
  117814. /**
  117815. * If the post process is supported.
  117816. */
  117817. get: function () {
  117818. return this._effect.isSupported;
  117819. },
  117820. enumerable: true,
  117821. configurable: true
  117822. });
  117823. Object.defineProperty(PostProcess.prototype, "aspectRatio", {
  117824. /**
  117825. * The aspect ratio of the output texture.
  117826. */
  117827. get: function () {
  117828. if (this._shareOutputWithPostProcess) {
  117829. return this._shareOutputWithPostProcess.aspectRatio;
  117830. }
  117831. if (this._forcedOutputTexture) {
  117832. return this._forcedOutputTexture.width / this._forcedOutputTexture.height;
  117833. }
  117834. return this.width / this.height;
  117835. },
  117836. enumerable: true,
  117837. configurable: true
  117838. });
  117839. /**
  117840. * Get a value indicating if the post-process is ready to be used
  117841. * @returns true if the post-process is ready (shader is compiled)
  117842. */
  117843. PostProcess.prototype.isReady = function () {
  117844. return this._effect && this._effect.isReady();
  117845. };
  117846. /**
  117847. * Binds all textures and uniforms to the shader, this will be run on every pass.
  117848. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  117849. */
  117850. PostProcess.prototype.apply = function () {
  117851. // Check
  117852. if (!this._effect || !this._effect.isReady()) {
  117853. return null;
  117854. }
  117855. // States
  117856. this._engine.enableEffect(this._effect);
  117857. this._engine.setState(false);
  117858. this._engine.setDepthBuffer(false);
  117859. this._engine.setDepthWrite(false);
  117860. // Alpha
  117861. this._engine.setAlphaMode(this.alphaMode);
  117862. if (this.alphaConstants) {
  117863. this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
  117864. }
  117865. // Bind the output texture of the preivous post process as the input to this post process.
  117866. var source;
  117867. if (this._shareOutputWithPostProcess) {
  117868. source = this._shareOutputWithPostProcess.inputTexture;
  117869. }
  117870. else if (this._forcedOutputTexture) {
  117871. source = this._forcedOutputTexture;
  117872. }
  117873. else {
  117874. source = this.inputTexture;
  117875. }
  117876. this._effect._bindTexture("textureSampler", source);
  117877. // Parameters
  117878. this._effect.setVector2("scale", this._scaleRatio);
  117879. this.onApplyObservable.notifyObservers(this._effect);
  117880. return this._effect;
  117881. };
  117882. PostProcess.prototype._disposeTextures = function () {
  117883. if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {
  117884. return;
  117885. }
  117886. if (this._textures.length > 0) {
  117887. for (var i = 0; i < this._textures.length; i++) {
  117888. this._engine._releaseTexture(this._textures.data[i]);
  117889. }
  117890. }
  117891. this._textures.dispose();
  117892. };
  117893. /**
  117894. * Disposes the post process.
  117895. * @param camera The camera to dispose the post process on.
  117896. */
  117897. PostProcess.prototype.dispose = function (camera) {
  117898. camera = camera || this._camera;
  117899. this._disposeTextures();
  117900. if (this._scene) {
  117901. var index_1 = this._scene.postProcesses.indexOf(this);
  117902. if (index_1 !== -1) {
  117903. this._scene.postProcesses.splice(index_1, 1);
  117904. }
  117905. }
  117906. else {
  117907. var index_2 = this._engine.postProcesses.indexOf(this);
  117908. if (index_2 !== -1) {
  117909. this._engine.postProcesses.splice(index_2, 1);
  117910. }
  117911. }
  117912. if (!camera) {
  117913. return;
  117914. }
  117915. camera.detachPostProcess(this);
  117916. var index = camera._postProcesses.indexOf(this);
  117917. if (index === 0 && camera._postProcesses.length > 0) {
  117918. var firstPostProcess = this._camera._getFirstPostProcess();
  117919. if (firstPostProcess) {
  117920. firstPostProcess.markTextureDirty();
  117921. }
  117922. }
  117923. this.onActivateObservable.clear();
  117924. this.onAfterRenderObservable.clear();
  117925. this.onApplyObservable.clear();
  117926. this.onBeforeRenderObservable.clear();
  117927. this.onSizeChangedObservable.clear();
  117928. };
  117929. return PostProcess;
  117930. }());
  117931. /***/ }),
  117932. /***/ "./PostProcesses/postProcessManager.ts":
  117933. /*!*********************************************!*\
  117934. !*** ./PostProcesses/postProcessManager.ts ***!
  117935. \*********************************************/
  117936. /*! exports provided: PostProcessManager */
  117937. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117938. "use strict";
  117939. __webpack_require__.r(__webpack_exports__);
  117940. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return PostProcessManager; });
  117941. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  117942. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  117943. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117944. /**
  117945. * PostProcessManager is used to manage one or more post processes or post process pipelines
  117946. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117947. */
  117948. var PostProcessManager = /** @class */ (function () {
  117949. /**
  117950. * Creates a new instance PostProcess
  117951. * @param scene The scene that the post process is associated with.
  117952. */
  117953. function PostProcessManager(scene) {
  117954. this._vertexBuffers = {};
  117955. this._scene = scene;
  117956. }
  117957. PostProcessManager.prototype._prepareBuffers = function () {
  117958. if (this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind]) {
  117959. return;
  117960. }
  117961. // VBO
  117962. var vertices = [];
  117963. vertices.push(1, 1);
  117964. vertices.push(-1, 1);
  117965. vertices.push(-1, -1);
  117966. vertices.push(1, -1);
  117967. 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);
  117968. this._buildIndexBuffer();
  117969. };
  117970. PostProcessManager.prototype._buildIndexBuffer = function () {
  117971. // Indices
  117972. var indices = [];
  117973. indices.push(0);
  117974. indices.push(1);
  117975. indices.push(2);
  117976. indices.push(0);
  117977. indices.push(2);
  117978. indices.push(3);
  117979. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  117980. };
  117981. /**
  117982. * Rebuilds the vertex buffers of the manager.
  117983. * @hidden
  117984. */
  117985. PostProcessManager.prototype._rebuild = function () {
  117986. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  117987. if (!vb) {
  117988. return;
  117989. }
  117990. vb._rebuild();
  117991. this._buildIndexBuffer();
  117992. };
  117993. // Methods
  117994. /**
  117995. * Prepares a frame to be run through a post process.
  117996. * @param sourceTexture The input texture to the post procesess. (default: null)
  117997. * @param postProcesses An array of post processes to be run. (default: null)
  117998. * @returns True if the post processes were able to be run.
  117999. * @hidden
  118000. */
  118001. PostProcessManager.prototype._prepareFrame = function (sourceTexture, postProcesses) {
  118002. if (sourceTexture === void 0) { sourceTexture = null; }
  118003. if (postProcesses === void 0) { postProcesses = null; }
  118004. var camera = this._scene.activeCamera;
  118005. if (!camera) {
  118006. return false;
  118007. }
  118008. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  118009. if (!postProcesses || postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  118010. return false;
  118011. }
  118012. postProcesses[0].activate(camera, sourceTexture, postProcesses !== null && postProcesses !== undefined);
  118013. return true;
  118014. };
  118015. /**
  118016. * Manually render a set of post processes to a texture.
  118017. * @param postProcesses An array of post processes to be run.
  118018. * @param targetTexture The target texture to render to.
  118019. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  118020. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  118021. * @param lodLevel defines which lod of the texture to render to
  118022. */
  118023. PostProcessManager.prototype.directRender = function (postProcesses, targetTexture, forceFullscreenViewport, faceIndex, lodLevel) {
  118024. if (targetTexture === void 0) { targetTexture = null; }
  118025. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  118026. if (faceIndex === void 0) { faceIndex = 0; }
  118027. if (lodLevel === void 0) { lodLevel = 0; }
  118028. var engine = this._scene.getEngine();
  118029. for (var index = 0; index < postProcesses.length; index++) {
  118030. if (index < postProcesses.length - 1) {
  118031. postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture);
  118032. }
  118033. else {
  118034. if (targetTexture) {
  118035. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport, undefined, lodLevel);
  118036. }
  118037. else {
  118038. engine.restoreDefaultFramebuffer();
  118039. }
  118040. }
  118041. var pp = postProcesses[index];
  118042. var effect = pp.apply();
  118043. if (effect) {
  118044. pp.onBeforeRenderObservable.notifyObservers(effect);
  118045. // VBOs
  118046. this._prepareBuffers();
  118047. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  118048. // Draw order
  118049. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  118050. pp.onAfterRenderObservable.notifyObservers(effect);
  118051. }
  118052. }
  118053. // Restore depth buffer
  118054. engine.setDepthBuffer(true);
  118055. engine.setDepthWrite(true);
  118056. };
  118057. /**
  118058. * Finalize the result of the output of the postprocesses.
  118059. * @param doNotPresent If true the result will not be displayed to the screen.
  118060. * @param targetTexture The target texture to render to.
  118061. * @param faceIndex The index of the face to bind the target texture to.
  118062. * @param postProcesses The array of post processes to render.
  118063. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  118064. * @hidden
  118065. */
  118066. PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, faceIndex, postProcesses, forceFullscreenViewport) {
  118067. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  118068. var camera = this._scene.activeCamera;
  118069. if (!camera) {
  118070. return;
  118071. }
  118072. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  118073. if (postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  118074. return;
  118075. }
  118076. var engine = this._scene.getEngine();
  118077. for (var index = 0, len = postProcesses.length; index < len; index++) {
  118078. var pp = postProcesses[index];
  118079. if (index < len - 1) {
  118080. pp._outputTexture = postProcesses[index + 1].activate(camera, targetTexture);
  118081. }
  118082. else {
  118083. if (targetTexture) {
  118084. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport);
  118085. pp._outputTexture = targetTexture;
  118086. }
  118087. else {
  118088. engine.restoreDefaultFramebuffer();
  118089. pp._outputTexture = null;
  118090. }
  118091. }
  118092. if (doNotPresent) {
  118093. break;
  118094. }
  118095. var effect = pp.apply();
  118096. if (effect) {
  118097. pp.onBeforeRenderObservable.notifyObservers(effect);
  118098. // VBOs
  118099. this._prepareBuffers();
  118100. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  118101. // Draw order
  118102. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  118103. pp.onAfterRenderObservable.notifyObservers(effect);
  118104. }
  118105. }
  118106. // Restore states
  118107. engine.setDepthBuffer(true);
  118108. engine.setDepthWrite(true);
  118109. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  118110. };
  118111. /**
  118112. * Disposes of the post process manager.
  118113. */
  118114. PostProcessManager.prototype.dispose = function () {
  118115. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  118116. if (buffer) {
  118117. buffer.dispose();
  118118. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  118119. }
  118120. if (this._indexBuffer) {
  118121. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  118122. this._indexBuffer = null;
  118123. }
  118124. };
  118125. return PostProcessManager;
  118126. }());
  118127. /***/ }),
  118128. /***/ "./PostProcesses/refractionPostProcess.ts":
  118129. /*!************************************************!*\
  118130. !*** ./PostProcesses/refractionPostProcess.ts ***!
  118131. \************************************************/
  118132. /*! exports provided: RefractionPostProcess */
  118133. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118134. "use strict";
  118135. __webpack_require__.r(__webpack_exports__);
  118136. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return RefractionPostProcess; });
  118137. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118138. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118139. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118140. /* harmony import */ var _Shaders_refraction_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/refraction.fragment */ "./Shaders/refraction.fragment.ts");
  118141. /**
  118142. * Post process which applies a refractin texture
  118143. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118144. */
  118145. var RefractionPostProcess = /** @class */ (function (_super) {
  118146. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionPostProcess, _super);
  118147. /**
  118148. * Initializes the RefractionPostProcess
  118149. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118150. * @param name The name of the effect.
  118151. * @param refractionTextureUrl Url of the refraction texture to use
  118152. * @param color the base color of the refraction (used to taint the rendering)
  118153. * @param depth simulated refraction depth
  118154. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  118155. * @param camera The camera to apply the render pass to.
  118156. * @param options The required width/height ratio to downsize to before computing the render pass.
  118157. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118158. * @param engine The engine which the post process will be applied. (default: current engine)
  118159. * @param reusable If the post process can be reused on the same frame. (default: false)
  118160. */
  118161. function RefractionPostProcess(name, refractionTextureUrl,
  118162. /** the base color of the refraction (used to taint the rendering) */
  118163. color,
  118164. /** simulated refraction depth */
  118165. depth,
  118166. /** the coefficient of the base color (0 to remove base color tainting) */
  118167. colorLevel, options, camera, samplingMode, engine, reusable) {
  118168. var _this = _super.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], options, camera, samplingMode, engine, reusable) || this;
  118169. _this.color = color;
  118170. _this.depth = depth;
  118171. _this.colorLevel = colorLevel;
  118172. _this._ownRefractionTexture = true;
  118173. _this.onActivateObservable.add(function (cam) {
  118174. _this._refTexture = _this._refTexture || new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](refractionTextureUrl, cam.getScene());
  118175. });
  118176. _this.onApplyObservable.add(function (effect) {
  118177. effect.setColor3("baseColor", _this.color);
  118178. effect.setFloat("depth", _this.depth);
  118179. effect.setFloat("colorLevel", _this.colorLevel);
  118180. effect.setTexture("refractionSampler", _this._refTexture);
  118181. });
  118182. return _this;
  118183. }
  118184. Object.defineProperty(RefractionPostProcess.prototype, "refractionTexture", {
  118185. /**
  118186. * Gets or sets the refraction texture
  118187. * Please note that you are responsible for disposing the texture if you set it manually
  118188. */
  118189. get: function () {
  118190. return this._refTexture;
  118191. },
  118192. set: function (value) {
  118193. if (this._refTexture && this._ownRefractionTexture) {
  118194. this._refTexture.dispose();
  118195. }
  118196. this._refTexture = value;
  118197. this._ownRefractionTexture = false;
  118198. },
  118199. enumerable: true,
  118200. configurable: true
  118201. });
  118202. // Methods
  118203. /**
  118204. * Disposes of the post process
  118205. * @param camera Camera to dispose post process on
  118206. */
  118207. RefractionPostProcess.prototype.dispose = function (camera) {
  118208. if (this._refTexture && this._ownRefractionTexture) {
  118209. this._refTexture.dispose();
  118210. this._refTexture = null;
  118211. }
  118212. _super.prototype.dispose.call(this, camera);
  118213. };
  118214. return RefractionPostProcess;
  118215. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  118216. /***/ }),
  118217. /***/ "./PostProcesses/sharpenPostProcess.ts":
  118218. /*!*********************************************!*\
  118219. !*** ./PostProcesses/sharpenPostProcess.ts ***!
  118220. \*********************************************/
  118221. /*! exports provided: SharpenPostProcess */
  118222. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118223. "use strict";
  118224. __webpack_require__.r(__webpack_exports__);
  118225. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return SharpenPostProcess; });
  118226. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118227. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118228. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118229. /* harmony import */ var _Shaders_sharpen_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/sharpen.fragment */ "./Shaders/sharpen.fragment.ts");
  118230. /**
  118231. * The SharpenPostProcess applies a sharpen kernel to every pixel
  118232. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118233. */
  118234. var SharpenPostProcess = /** @class */ (function (_super) {
  118235. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SharpenPostProcess, _super);
  118236. /**
  118237. * Creates a new instance ConvolutionPostProcess
  118238. * @param name The name of the effect.
  118239. * @param options The required width/height ratio to downsize to before computing the render pass.
  118240. * @param camera The camera to apply the render pass to.
  118241. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118242. * @param engine The engine which the post process will be applied. (default: current engine)
  118243. * @param reusable If the post process can be reused on the same frame. (default: false)
  118244. * @param textureType Type of textures used when performing the post process. (default: 0)
  118245. * @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)
  118246. */
  118247. function SharpenPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118248. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118249. if (blockCompilation === void 0) { blockCompilation = false; }
  118250. var _this = _super.call(this, name, "sharpen", ["sharpnessAmounts", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  118251. /**
  118252. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  118253. */
  118254. _this.colorAmount = 1.0;
  118255. /**
  118256. * How much sharpness should be applied (default: 0.3)
  118257. */
  118258. _this.edgeAmount = 0.3;
  118259. _this.onApply = function (effect) {
  118260. effect.setFloat2("screenSize", _this.width, _this.height);
  118261. effect.setFloat2("sharpnessAmounts", _this.edgeAmount, _this.colorAmount);
  118262. };
  118263. return _this;
  118264. }
  118265. return SharpenPostProcess;
  118266. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  118267. /***/ }),
  118268. /***/ "./PostProcesses/stereoscopicInterlacePostProcess.ts":
  118269. /*!***********************************************************!*\
  118270. !*** ./PostProcesses/stereoscopicInterlacePostProcess.ts ***!
  118271. \***********************************************************/
  118272. /*! exports provided: StereoscopicInterlacePostProcess */
  118273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118274. "use strict";
  118275. __webpack_require__.r(__webpack_exports__);
  118276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return StereoscopicInterlacePostProcess; });
  118277. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118278. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118279. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118280. /* harmony import */ var _Shaders_stereoscopicInterlace_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/stereoscopicInterlace.fragment */ "./Shaders/stereoscopicInterlace.fragment.ts");
  118281. /**
  118282. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  118283. */
  118284. var StereoscopicInterlacePostProcess = /** @class */ (function (_super) {
  118285. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicInterlacePostProcess, _super);
  118286. /**
  118287. * Initializes a StereoscopicInterlacePostProcess
  118288. * @param name The name of the effect.
  118289. * @param rigCameras The rig cameras to be appled to the post process
  118290. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  118291. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118292. * @param engine The engine which the post process will be applied. (default: current engine)
  118293. * @param reusable If the post process can be reused on the same frame. (default: false)
  118294. */
  118295. function StereoscopicInterlacePostProcess(name, rigCameras, isStereoscopicHoriz, samplingMode, engine, reusable) {
  118296. var _this = _super.call(this, name, "stereoscopicInterlace", ['stepSize'], ['camASampler'], 1, rigCameras[1], samplingMode, engine, reusable, isStereoscopicHoriz ? "#define IS_STEREOSCOPIC_HORIZ 1" : undefined) || this;
  118297. _this._passedProcess = rigCameras[0]._rigPostProcess;
  118298. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  118299. _this.onSizeChangedObservable.add(function () {
  118300. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  118301. });
  118302. _this.onApplyObservable.add(function (effect) {
  118303. effect.setTextureFromPostProcess("camASampler", _this._passedProcess);
  118304. effect.setFloat2("stepSize", _this._stepSize.x, _this._stepSize.y);
  118305. });
  118306. return _this;
  118307. }
  118308. return StereoscopicInterlacePostProcess;
  118309. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  118310. /***/ }),
  118311. /***/ "./PostProcesses/tonemapPostProcess.ts":
  118312. /*!*********************************************!*\
  118313. !*** ./PostProcesses/tonemapPostProcess.ts ***!
  118314. \*********************************************/
  118315. /*! exports provided: TonemappingOperator, TonemapPostProcess */
  118316. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118317. "use strict";
  118318. __webpack_require__.r(__webpack_exports__);
  118319. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return TonemappingOperator; });
  118320. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return TonemapPostProcess; });
  118321. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118322. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118323. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118324. /* harmony import */ var _Shaders_tonemap_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/tonemap.fragment */ "./Shaders/tonemap.fragment.ts");
  118325. /** Defines operator used for tonemapping */
  118326. var TonemappingOperator;
  118327. (function (TonemappingOperator) {
  118328. /** Hable */
  118329. TonemappingOperator[TonemappingOperator["Hable"] = 0] = "Hable";
  118330. /** Reinhard */
  118331. TonemappingOperator[TonemappingOperator["Reinhard"] = 1] = "Reinhard";
  118332. /** HejiDawson */
  118333. TonemappingOperator[TonemappingOperator["HejiDawson"] = 2] = "HejiDawson";
  118334. /** Photographic */
  118335. TonemappingOperator[TonemappingOperator["Photographic"] = 3] = "Photographic";
  118336. })(TonemappingOperator || (TonemappingOperator = {}));
  118337. /**
  118338. * Defines a post process to apply tone mapping
  118339. */
  118340. var TonemapPostProcess = /** @class */ (function (_super) {
  118341. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TonemapPostProcess, _super);
  118342. /**
  118343. * Creates a new TonemapPostProcess
  118344. * @param name defines the name of the postprocess
  118345. * @param _operator defines the operator to use
  118346. * @param exposureAdjustment defines the required exposure adjustement
  118347. * @param camera defines the camera to use (can be null)
  118348. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  118349. * @param engine defines the hosting engine (can be ignore if camera is set)
  118350. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  118351. */
  118352. function TonemapPostProcess(name, _operator,
  118353. /** Defines the required exposure adjustement */
  118354. exposureAdjustment, camera, samplingMode, engine, textureFormat) {
  118355. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE; }
  118356. if (textureFormat === void 0) { textureFormat = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118357. var _this = _super.call(this, name, "tonemap", ["_ExposureAdjustment"], null, 1.0, camera, samplingMode, engine, true, null, textureFormat) || this;
  118358. _this._operator = _operator;
  118359. _this.exposureAdjustment = exposureAdjustment;
  118360. var defines = "#define ";
  118361. if (_this._operator === TonemappingOperator.Hable) {
  118362. defines += "HABLE_TONEMAPPING";
  118363. }
  118364. else if (_this._operator === TonemappingOperator.Reinhard) {
  118365. defines += "REINHARD_TONEMAPPING";
  118366. }
  118367. else if (_this._operator === TonemappingOperator.HejiDawson) {
  118368. defines += "OPTIMIZED_HEJIDAWSON_TONEMAPPING";
  118369. }
  118370. else if (_this._operator === TonemappingOperator.Photographic) {
  118371. defines += "PHOTOGRAPHIC_TONEMAPPING";
  118372. }
  118373. //sadly a second call to create the effect.
  118374. _this.updateEffect(defines);
  118375. _this.onApply = function (effect) {
  118376. effect.setFloat("_ExposureAdjustment", _this.exposureAdjustment);
  118377. };
  118378. return _this;
  118379. }
  118380. return TonemapPostProcess;
  118381. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  118382. /***/ }),
  118383. /***/ "./PostProcesses/volumetricLightScatteringPostProcess.ts":
  118384. /*!***************************************************************!*\
  118385. !*** ./PostProcesses/volumetricLightScatteringPostProcess.ts ***!
  118386. \***************************************************************/
  118387. /*! exports provided: VolumetricLightScatteringPostProcess */
  118388. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118389. "use strict";
  118390. __webpack_require__.r(__webpack_exports__);
  118391. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return VolumetricLightScatteringPostProcess; });
  118392. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118393. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  118394. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  118395. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118396. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  118397. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  118398. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  118399. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  118400. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  118401. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118402. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  118403. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118404. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118405. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  118406. /* harmony import */ var _Shaders_volumetricLightScattering_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/volumetricLightScattering.fragment */ "./Shaders/volumetricLightScattering.fragment.ts");
  118407. /* harmony import */ var _Shaders_volumetricLightScatteringPass_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/volumetricLightScatteringPass.fragment */ "./Shaders/volumetricLightScatteringPass.fragment.ts");
  118408. /**
  118409. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  118410. */
  118411. var VolumetricLightScatteringPostProcess = /** @class */ (function (_super) {
  118412. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumetricLightScatteringPostProcess, _super);
  118413. /**
  118414. * @constructor
  118415. * @param name The post-process name
  118416. * @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)
  118417. * @param camera The camera that the post-process will be attached to
  118418. * @param mesh The mesh used to create the light scattering
  118419. * @param samples The post-process quality, default 100
  118420. * @param samplingModeThe post-process filtering mode
  118421. * @param engine The babylon engine
  118422. * @param reusable If the post-process is reusable
  118423. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  118424. */
  118425. function VolumetricLightScatteringPostProcess(name, ratio, camera, mesh, samples, samplingMode, engine, reusable, scene) {
  118426. if (samples === void 0) { samples = 100; }
  118427. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].BILINEAR_SAMPLINGMODE; }
  118428. 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;
  118429. _this._screenCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  118430. /**
  118431. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  118432. */
  118433. _this.customMeshPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  118434. /**
  118435. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  118436. */
  118437. _this.useCustomMeshPosition = false;
  118438. /**
  118439. * If the post-process should inverse the light scattering direction
  118440. */
  118441. _this.invert = true;
  118442. /**
  118443. * Array containing the excluded meshes not rendered in the internal pass
  118444. */
  118445. _this.excludedMeshes = new Array();
  118446. /**
  118447. * Controls the overall intensity of the post-process
  118448. */
  118449. _this.exposure = 0.3;
  118450. /**
  118451. * Dissipates each sample's contribution in range [0, 1]
  118452. */
  118453. _this.decay = 0.96815;
  118454. /**
  118455. * Controls the overall intensity of each sample
  118456. */
  118457. _this.weight = 0.58767;
  118458. /**
  118459. * Controls the density of each sample
  118460. */
  118461. _this.density = 0.926;
  118462. scene = ((camera === null) ? scene : camera.getScene()); // parameter "scene" can be null.
  118463. engine = scene.getEngine();
  118464. _this._viewPort = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Viewport"](0, 0, 1, 1).toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  118465. // Configure mesh
  118466. _this.mesh = ((mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene));
  118467. // Configure
  118468. _this._createPass(scene, ratio.passRatio || ratio);
  118469. _this.onActivate = function (camera) {
  118470. if (!_this.isSupported) {
  118471. _this.dispose(camera);
  118472. }
  118473. _this.onActivate = null;
  118474. };
  118475. _this.onApplyObservable.add(function (effect) {
  118476. _this._updateMeshScreenCoordinates(scene);
  118477. effect.setTexture("lightScatteringSampler", _this._volumetricLightScatteringRTT);
  118478. effect.setFloat("exposure", _this.exposure);
  118479. effect.setFloat("decay", _this.decay);
  118480. effect.setFloat("weight", _this.weight);
  118481. effect.setFloat("density", _this.density);
  118482. effect.setVector2("meshPositionOnScreen", _this._screenCoordinates);
  118483. });
  118484. return _this;
  118485. }
  118486. Object.defineProperty(VolumetricLightScatteringPostProcess.prototype, "useDiffuseColor", {
  118487. /**
  118488. * @hidden
  118489. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  118490. */
  118491. get: function () {
  118492. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  118493. return false;
  118494. },
  118495. set: function (useDiffuseColor) {
  118496. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  118497. },
  118498. enumerable: true,
  118499. configurable: true
  118500. });
  118501. /**
  118502. * Returns the string "VolumetricLightScatteringPostProcess"
  118503. * @returns "VolumetricLightScatteringPostProcess"
  118504. */
  118505. VolumetricLightScatteringPostProcess.prototype.getClassName = function () {
  118506. return "VolumetricLightScatteringPostProcess";
  118507. };
  118508. VolumetricLightScatteringPostProcess.prototype._isReady = function (subMesh, useInstances) {
  118509. var mesh = subMesh.getMesh();
  118510. // Render this.mesh as default
  118511. if (mesh === this.mesh && mesh.material) {
  118512. return mesh.material.isReady(mesh);
  118513. }
  118514. var defines = [];
  118515. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  118516. var material = subMesh.getMaterial();
  118517. // Alpha test
  118518. if (material) {
  118519. if (material.needAlphaTesting()) {
  118520. defines.push("#define ALPHATEST");
  118521. }
  118522. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind)) {
  118523. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  118524. defines.push("#define UV1");
  118525. }
  118526. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind)) {
  118527. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  118528. defines.push("#define UV2");
  118529. }
  118530. }
  118531. // Bones
  118532. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  118533. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  118534. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  118535. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  118536. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  118537. }
  118538. else {
  118539. defines.push("#define NUM_BONE_INFLUENCERS 0");
  118540. }
  118541. // Instances
  118542. if (useInstances) {
  118543. defines.push("#define INSTANCES");
  118544. attribs.push("world0");
  118545. attribs.push("world1");
  118546. attribs.push("world2");
  118547. attribs.push("world3");
  118548. }
  118549. // Get correct effect
  118550. var join = defines.join("\n");
  118551. if (this._cachedDefines !== join) {
  118552. this._cachedDefines = join;
  118553. this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect({ vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" }, attribs, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], join);
  118554. }
  118555. return this._volumetricLightScatteringPass.isReady();
  118556. };
  118557. /**
  118558. * Sets the new light position for light scattering effect
  118559. * @param position The new custom light position
  118560. */
  118561. VolumetricLightScatteringPostProcess.prototype.setCustomMeshPosition = function (position) {
  118562. this.customMeshPosition = position;
  118563. };
  118564. /**
  118565. * Returns the light position for light scattering effect
  118566. * @return Vector3 The custom light position
  118567. */
  118568. VolumetricLightScatteringPostProcess.prototype.getCustomMeshPosition = function () {
  118569. return this.customMeshPosition;
  118570. };
  118571. /**
  118572. * Disposes the internal assets and detaches the post-process from the camera
  118573. */
  118574. VolumetricLightScatteringPostProcess.prototype.dispose = function (camera) {
  118575. var rttIndex = camera.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);
  118576. if (rttIndex !== -1) {
  118577. camera.getScene().customRenderTargets.splice(rttIndex, 1);
  118578. }
  118579. this._volumetricLightScatteringRTT.dispose();
  118580. _super.prototype.dispose.call(this, camera);
  118581. };
  118582. /**
  118583. * Returns the render target texture used by the post-process
  118584. * @return the render target texture used by the post-process
  118585. */
  118586. VolumetricLightScatteringPostProcess.prototype.getPass = function () {
  118587. return this._volumetricLightScatteringRTT;
  118588. };
  118589. // Private methods
  118590. VolumetricLightScatteringPostProcess.prototype._meshExcluded = function (mesh) {
  118591. if (this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  118592. return true;
  118593. }
  118594. return false;
  118595. };
  118596. VolumetricLightScatteringPostProcess.prototype._createPass = function (scene, ratio) {
  118597. var _this = this;
  118598. var engine = scene.getEngine();
  118599. 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);
  118600. this._volumetricLightScatteringRTT.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  118601. this._volumetricLightScatteringRTT.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  118602. this._volumetricLightScatteringRTT.renderList = null;
  118603. this._volumetricLightScatteringRTT.renderParticles = false;
  118604. this._volumetricLightScatteringRTT.ignoreCameraViewport = true;
  118605. var camera = this.getCamera();
  118606. if (camera) {
  118607. camera.customRenderTargets.push(this._volumetricLightScatteringRTT);
  118608. }
  118609. else {
  118610. scene.customRenderTargets.push(this._volumetricLightScatteringRTT);
  118611. }
  118612. // Custom render function for submeshes
  118613. var renderSubMesh = function (subMesh) {
  118614. var mesh = subMesh.getRenderingMesh();
  118615. if (_this._meshExcluded(mesh)) {
  118616. return;
  118617. }
  118618. var material = subMesh.getMaterial();
  118619. if (!material) {
  118620. return;
  118621. }
  118622. var scene = mesh.getScene();
  118623. var engine = scene.getEngine();
  118624. // Culling
  118625. engine.setState(material.backFaceCulling);
  118626. // Managing instances
  118627. var batch = mesh._getInstancesRenderList(subMesh._id);
  118628. if (batch.mustReturn) {
  118629. return;
  118630. }
  118631. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  118632. if (_this._isReady(subMesh, hardwareInstancedRendering)) {
  118633. var effect = _this._volumetricLightScatteringPass;
  118634. if (mesh === _this.mesh) {
  118635. if (subMesh.effect) {
  118636. effect = subMesh.effect;
  118637. }
  118638. else {
  118639. effect = material.getEffect();
  118640. }
  118641. }
  118642. engine.enableEffect(effect);
  118643. mesh._bind(subMesh, effect, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode);
  118644. if (mesh === _this.mesh) {
  118645. material.bind(mesh.getWorldMatrix(), mesh);
  118646. }
  118647. else {
  118648. _this._volumetricLightScatteringPass.setMatrix("viewProjection", scene.getTransformMatrix());
  118649. // Alpha test
  118650. if (material && material.needAlphaTesting()) {
  118651. var alphaTexture = material.getAlphaTestTexture();
  118652. _this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
  118653. if (alphaTexture) {
  118654. _this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  118655. }
  118656. }
  118657. // Bones
  118658. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  118659. _this._volumetricLightScatteringPass.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  118660. }
  118661. }
  118662. // Draw
  118663. mesh._processRendering(subMesh, _this._volumetricLightScatteringPass, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return effect.setMatrix("world", world); });
  118664. }
  118665. };
  118666. // Render target texture callbacks
  118667. var savedSceneClearColor;
  118668. var sceneClearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0.0, 0.0, 0.0, 1.0);
  118669. this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function () {
  118670. savedSceneClearColor = scene.clearColor;
  118671. scene.clearColor = sceneClearColor;
  118672. });
  118673. this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function () {
  118674. scene.clearColor = savedSceneClearColor;
  118675. });
  118676. this._volumetricLightScatteringRTT.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  118677. var engine = scene.getEngine();
  118678. var index;
  118679. if (depthOnlySubMeshes.length) {
  118680. engine.setColorWrite(false);
  118681. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  118682. renderSubMesh(depthOnlySubMeshes.data[index]);
  118683. }
  118684. engine.setColorWrite(true);
  118685. }
  118686. for (index = 0; index < opaqueSubMeshes.length; index++) {
  118687. renderSubMesh(opaqueSubMeshes.data[index]);
  118688. }
  118689. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  118690. renderSubMesh(alphaTestSubMeshes.data[index]);
  118691. }
  118692. if (transparentSubMeshes.length) {
  118693. // Sort sub meshes
  118694. for (index = 0; index < transparentSubMeshes.length; index++) {
  118695. var submesh = transparentSubMeshes.data[index];
  118696. var boundingInfo = submesh.getBoundingInfo();
  118697. if (boundingInfo && scene.activeCamera) {
  118698. submesh._alphaIndex = submesh.getMesh().alphaIndex;
  118699. submesh._distanceToCamera = boundingInfo.boundingSphere.centerWorld.subtract(scene.activeCamera.position).length();
  118700. }
  118701. }
  118702. var sortedArray = transparentSubMeshes.data.slice(0, transparentSubMeshes.length);
  118703. sortedArray.sort(function (a, b) {
  118704. // Alpha index first
  118705. if (a._alphaIndex > b._alphaIndex) {
  118706. return 1;
  118707. }
  118708. if (a._alphaIndex < b._alphaIndex) {
  118709. return -1;
  118710. }
  118711. // Then distance to camera
  118712. if (a._distanceToCamera < b._distanceToCamera) {
  118713. return 1;
  118714. }
  118715. if (a._distanceToCamera > b._distanceToCamera) {
  118716. return -1;
  118717. }
  118718. return 0;
  118719. });
  118720. // Render sub meshes
  118721. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_COMBINE);
  118722. for (index = 0; index < sortedArray.length; index++) {
  118723. renderSubMesh(sortedArray[index]);
  118724. }
  118725. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_DISABLE);
  118726. }
  118727. };
  118728. };
  118729. VolumetricLightScatteringPostProcess.prototype._updateMeshScreenCoordinates = function (scene) {
  118730. var transform = scene.getTransformMatrix();
  118731. var meshPosition;
  118732. if (this.useCustomMeshPosition) {
  118733. meshPosition = this.customMeshPosition;
  118734. }
  118735. else if (this.attachedNode) {
  118736. meshPosition = this.attachedNode.position;
  118737. }
  118738. else {
  118739. meshPosition = this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position;
  118740. }
  118741. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Project(meshPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity(), transform, this._viewPort);
  118742. this._screenCoordinates.x = pos.x / this._viewPort.width;
  118743. this._screenCoordinates.y = pos.y / this._viewPort.height;
  118744. if (this.invert) {
  118745. this._screenCoordinates.y = 1.0 - this._screenCoordinates.y;
  118746. }
  118747. };
  118748. // Static methods
  118749. /**
  118750. * Creates a default mesh for the Volumeric Light Scattering post-process
  118751. * @param name The mesh name
  118752. * @param scene The scene where to create the mesh
  118753. * @return the default mesh
  118754. */
  118755. VolumetricLightScatteringPostProcess.CreateDefaultMesh = function (name, scene) {
  118756. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__["Mesh"].CreatePlane(name, 1, scene);
  118757. mesh.billboardMode = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__["AbstractMesh"].BILLBOARDMODE_ALL;
  118758. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"](name + "Material", scene);
  118759. material.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  118760. mesh.material = material;
  118761. return mesh;
  118762. };
  118763. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118764. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  118765. ], VolumetricLightScatteringPostProcess.prototype, "customMeshPosition", void 0);
  118766. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118767. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118768. ], VolumetricLightScatteringPostProcess.prototype, "useCustomMeshPosition", void 0);
  118769. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118770. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118771. ], VolumetricLightScatteringPostProcess.prototype, "invert", void 0);
  118772. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118773. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  118774. ], VolumetricLightScatteringPostProcess.prototype, "mesh", void 0);
  118775. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118776. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118777. ], VolumetricLightScatteringPostProcess.prototype, "excludedMeshes", void 0);
  118778. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118779. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118780. ], VolumetricLightScatteringPostProcess.prototype, "exposure", void 0);
  118781. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118782. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118783. ], VolumetricLightScatteringPostProcess.prototype, "decay", void 0);
  118784. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118785. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118786. ], VolumetricLightScatteringPostProcess.prototype, "weight", void 0);
  118787. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118788. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118789. ], VolumetricLightScatteringPostProcess.prototype, "density", void 0);
  118790. return VolumetricLightScatteringPostProcess;
  118791. }(_postProcess__WEBPACK_IMPORTED_MODULE_11__["PostProcess"]));
  118792. /***/ }),
  118793. /***/ "./PostProcesses/vrDistortionCorrectionPostProcess.ts":
  118794. /*!************************************************************!*\
  118795. !*** ./PostProcesses/vrDistortionCorrectionPostProcess.ts ***!
  118796. \************************************************************/
  118797. /*! exports provided: VRDistortionCorrectionPostProcess */
  118798. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118799. "use strict";
  118800. __webpack_require__.r(__webpack_exports__);
  118801. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return VRDistortionCorrectionPostProcess; });
  118802. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118803. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118804. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118805. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118806. /* harmony import */ var _Shaders_vrDistortionCorrection_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/vrDistortionCorrection.fragment */ "./Shaders/vrDistortionCorrection.fragment.ts");
  118807. /**
  118808. * VRDistortionCorrectionPostProcess used for mobile VR
  118809. */
  118810. var VRDistortionCorrectionPostProcess = /** @class */ (function (_super) {
  118811. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDistortionCorrectionPostProcess, _super);
  118812. /**
  118813. * Initializes the VRDistortionCorrectionPostProcess
  118814. * @param name The name of the effect.
  118815. * @param camera The camera to apply the render pass to.
  118816. * @param isRightEye If this is for the right eye distortion
  118817. * @param vrMetrics All the required metrics for the VR camera
  118818. */
  118819. function VRDistortionCorrectionPostProcess(name, camera, isRightEye, vrMetrics) {
  118820. var _this = _super.call(this, name, "vrDistortionCorrection", [
  118821. 'LensCenter',
  118822. 'Scale',
  118823. 'ScaleIn',
  118824. 'HmdWarpParam'
  118825. ], null, vrMetrics.postProcessScaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  118826. _this._isRightEye = isRightEye;
  118827. _this._distortionFactors = vrMetrics.distortionK;
  118828. _this._postProcessScaleFactor = vrMetrics.postProcessScaleFactor;
  118829. _this._lensCenterOffset = vrMetrics.lensCenterOffset;
  118830. _this.adaptScaleToCurrentViewport = true;
  118831. _this.onSizeChangedObservable.add(function () {
  118832. _this._scaleIn = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](2, 2 / _this.aspectRatio);
  118833. _this._scaleFactor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](.5 * (1 / _this._postProcessScaleFactor), .5 * (1 / _this._postProcessScaleFactor) * _this.aspectRatio);
  118834. _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);
  118835. });
  118836. _this.onApplyObservable.add(function (effect) {
  118837. effect.setFloat2("LensCenter", _this._lensCenter.x, _this._lensCenter.y);
  118838. effect.setFloat2("Scale", _this._scaleFactor.x, _this._scaleFactor.y);
  118839. effect.setFloat2("ScaleIn", _this._scaleIn.x, _this._scaleIn.y);
  118840. effect.setFloat4("HmdWarpParam", _this._distortionFactors[0], _this._distortionFactors[1], _this._distortionFactors[2], _this._distortionFactors[3]);
  118841. });
  118842. return _this;
  118843. }
  118844. return VRDistortionCorrectionPostProcess;
  118845. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  118846. /***/ }),
  118847. /***/ "./Probes/index.ts":
  118848. /*!*************************!*\
  118849. !*** ./Probes/index.ts ***!
  118850. \*************************/
  118851. /*! exports provided: ReflectionProbe */
  118852. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118853. "use strict";
  118854. __webpack_require__.r(__webpack_exports__);
  118855. /* harmony import */ var _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./reflectionProbe */ "./Probes/reflectionProbe.ts");
  118856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  118857. /***/ }),
  118858. /***/ "./Probes/reflectionProbe.ts":
  118859. /*!***********************************!*\
  118860. !*** ./Probes/reflectionProbe.ts ***!
  118861. \***********************************/
  118862. /*! exports provided: ReflectionProbe */
  118863. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118864. "use strict";
  118865. __webpack_require__.r(__webpack_exports__);
  118866. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return ReflectionProbe; });
  118867. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118868. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  118869. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  118870. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118871. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  118872. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118873. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.removeReflectionProbe = function (toRemove) {
  118874. if (!this.reflectionProbes) {
  118875. return -1;
  118876. }
  118877. var index = this.reflectionProbes.indexOf(toRemove);
  118878. if (index !== -1) {
  118879. this.reflectionProbes.splice(index, 1);
  118880. }
  118881. return index;
  118882. };
  118883. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.addReflectionProbe = function (newReflectionProbe) {
  118884. if (!this.reflectionProbes) {
  118885. this.reflectionProbes = [];
  118886. }
  118887. this.reflectionProbes.push(newReflectionProbe);
  118888. };
  118889. /**
  118890. * Class used to generate realtime reflection / refraction cube textures
  118891. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118892. */
  118893. var ReflectionProbe = /** @class */ (function () {
  118894. /**
  118895. * Creates a new reflection probe
  118896. * @param name defines the name of the probe
  118897. * @param size defines the texture resolution (for each face)
  118898. * @param scene defines the hosting scene
  118899. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  118900. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  118901. */
  118902. function ReflectionProbe(
  118903. /** defines the name of the probe */
  118904. name, size, scene, generateMipMaps, useFloat) {
  118905. if (generateMipMaps === void 0) { generateMipMaps = true; }
  118906. if (useFloat === void 0) { useFloat = false; }
  118907. var _this = this;
  118908. this.name = name;
  118909. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  118910. this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  118911. this._add = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  118912. this._invertYAxis = false;
  118913. /** Gets or sets probe position (center of the cube map) */
  118914. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  118915. this._scene = scene;
  118916. // Create the scene field if not exist.
  118917. if (!this._scene.reflectionProbes) {
  118918. this._scene.reflectionProbes = new Array();
  118919. }
  118920. this._scene.reflectionProbes.push(this);
  118921. 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);
  118922. this._renderTargetTexture.onBeforeRenderObservable.add(function (faceIndex) {
  118923. switch (faceIndex) {
  118924. case 0:
  118925. _this._add.copyFromFloats(1, 0, 0);
  118926. break;
  118927. case 1:
  118928. _this._add.copyFromFloats(-1, 0, 0);
  118929. break;
  118930. case 2:
  118931. _this._add.copyFromFloats(0, _this._invertYAxis ? 1 : -1, 0);
  118932. break;
  118933. case 3:
  118934. _this._add.copyFromFloats(0, _this._invertYAxis ? -1 : 1, 0);
  118935. break;
  118936. case 4:
  118937. _this._add.copyFromFloats(0, 0, 1);
  118938. break;
  118939. case 5:
  118940. _this._add.copyFromFloats(0, 0, -1);
  118941. break;
  118942. }
  118943. if (_this._attachedMesh) {
  118944. _this.position.copyFrom(_this._attachedMesh.getAbsolutePosition());
  118945. }
  118946. _this.position.addToRef(_this._add, _this._target);
  118947. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(_this.position, _this._target, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), _this._viewMatrix);
  118948. if (scene.activeCamera) {
  118949. _this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
  118950. scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
  118951. }
  118952. scene._forcedViewPosition = _this.position;
  118953. });
  118954. this._renderTargetTexture.onAfterUnbindObservable.add(function () {
  118955. scene._forcedViewPosition = null;
  118956. scene.updateTransformMatrix(true);
  118957. });
  118958. }
  118959. Object.defineProperty(ReflectionProbe.prototype, "samples", {
  118960. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  118961. get: function () {
  118962. return this._renderTargetTexture.samples;
  118963. },
  118964. set: function (value) {
  118965. this._renderTargetTexture.samples = value;
  118966. },
  118967. enumerable: true,
  118968. configurable: true
  118969. });
  118970. Object.defineProperty(ReflectionProbe.prototype, "refreshRate", {
  118971. /** Gets or sets the refresh rate to use (on every frame by default) */
  118972. get: function () {
  118973. return this._renderTargetTexture.refreshRate;
  118974. },
  118975. set: function (value) {
  118976. this._renderTargetTexture.refreshRate = value;
  118977. },
  118978. enumerable: true,
  118979. configurable: true
  118980. });
  118981. /**
  118982. * Gets the hosting scene
  118983. * @returns a Scene
  118984. */
  118985. ReflectionProbe.prototype.getScene = function () {
  118986. return this._scene;
  118987. };
  118988. Object.defineProperty(ReflectionProbe.prototype, "cubeTexture", {
  118989. /** Gets the internal CubeTexture used to render to */
  118990. get: function () {
  118991. return this._renderTargetTexture;
  118992. },
  118993. enumerable: true,
  118994. configurable: true
  118995. });
  118996. Object.defineProperty(ReflectionProbe.prototype, "renderList", {
  118997. /** Gets the list of meshes to render */
  118998. get: function () {
  118999. return this._renderTargetTexture.renderList;
  119000. },
  119001. enumerable: true,
  119002. configurable: true
  119003. });
  119004. /**
  119005. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  119006. * @param mesh defines the mesh to attach to
  119007. */
  119008. ReflectionProbe.prototype.attachToMesh = function (mesh) {
  119009. this._attachedMesh = mesh;
  119010. };
  119011. /**
  119012. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  119013. * @param renderingGroupId The rendering group id corresponding to its index
  119014. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  119015. */
  119016. ReflectionProbe.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  119017. this._renderTargetTexture.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  119018. };
  119019. /**
  119020. * Clean all associated resources
  119021. */
  119022. ReflectionProbe.prototype.dispose = function () {
  119023. var index = this._scene.reflectionProbes.indexOf(this);
  119024. if (index !== -1) {
  119025. // Remove from the scene if found
  119026. this._scene.reflectionProbes.splice(index, 1);
  119027. }
  119028. if (this._renderTargetTexture) {
  119029. this._renderTargetTexture.dispose();
  119030. this._renderTargetTexture = null;
  119031. }
  119032. };
  119033. /**
  119034. * Converts the reflection probe information to a readable string for debug purpose.
  119035. * @param fullDetails Supports for multiple levels of logging within scene loading
  119036. * @returns the human readable reflection probe info
  119037. */
  119038. ReflectionProbe.prototype.toString = function (fullDetails) {
  119039. var ret = "Name: " + this.name;
  119040. if (fullDetails) {
  119041. ret += ", position: " + this.position.toString();
  119042. if (this._attachedMesh) {
  119043. ret += ", attached mesh: " + this._attachedMesh.name;
  119044. }
  119045. }
  119046. return ret;
  119047. };
  119048. /**
  119049. * Get the class name of the relfection probe.
  119050. * @returns "ReflectionProbe"
  119051. */
  119052. ReflectionProbe.prototype.getClassName = function () {
  119053. return "ReflectionProbe";
  119054. };
  119055. /**
  119056. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  119057. * @returns The JSON representation of the texture
  119058. */
  119059. ReflectionProbe.prototype.serialize = function () {
  119060. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, this._renderTargetTexture.serialize());
  119061. serializationObject.isReflectionProbe = true;
  119062. return serializationObject;
  119063. };
  119064. /**
  119065. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  119066. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  119067. * @param scene Define the scene the parsed reflection probe should be instantiated in
  119068. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  119069. * @returns The parsed reflection probe if successful
  119070. */
  119071. ReflectionProbe.Parse = function (parsedReflectionProbe, scene, rootUrl) {
  119072. var reflectionProbe = null;
  119073. if (scene.reflectionProbes) {
  119074. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  119075. var rp = scene.reflectionProbes[index];
  119076. if (rp.name === parsedReflectionProbe.name) {
  119077. reflectionProbe = rp;
  119078. break;
  119079. }
  119080. }
  119081. }
  119082. reflectionProbe = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return reflectionProbe || new ReflectionProbe(parsedReflectionProbe.name, parsedReflectionProbe.renderTargetSize, scene, parsedReflectionProbe._generateMipMaps); }, parsedReflectionProbe, scene, rootUrl);
  119083. reflectionProbe.cubeTexture._waitingRenderList = parsedReflectionProbe.renderList;
  119084. if (parsedReflectionProbe._attachedMesh) {
  119085. reflectionProbe.attachToMesh(scene.getMeshByID(parsedReflectionProbe._attachedMesh));
  119086. }
  119087. return reflectionProbe;
  119088. };
  119089. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119090. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  119091. ], ReflectionProbe.prototype, "_attachedMesh", void 0);
  119092. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119093. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  119094. ], ReflectionProbe.prototype, "position", void 0);
  119095. return ReflectionProbe;
  119096. }());
  119097. /***/ }),
  119098. /***/ "./Rendering/boundingBoxRenderer.ts":
  119099. /*!******************************************!*\
  119100. !*** ./Rendering/boundingBoxRenderer.ts ***!
  119101. \******************************************/
  119102. /*! exports provided: BoundingBoxRenderer */
  119103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119104. "use strict";
  119105. __webpack_require__.r(__webpack_exports__);
  119106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return BoundingBoxRenderer; });
  119107. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  119108. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  119109. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  119110. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  119111. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119112. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  119113. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  119114. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  119115. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  119116. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  119117. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  119118. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "forceShowBoundingBoxes", {
  119119. get: function () {
  119120. return this._forceShowBoundingBoxes || false;
  119121. },
  119122. set: function (value) {
  119123. this._forceShowBoundingBoxes = value;
  119124. // Lazyly creates a BB renderer if needed.
  119125. if (value) {
  119126. this.getBoundingBoxRenderer();
  119127. }
  119128. },
  119129. enumerable: true,
  119130. configurable: true
  119131. });
  119132. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.getBoundingBoxRenderer = function () {
  119133. if (!this._boundingBoxRenderer) {
  119134. this._boundingBoxRenderer = new BoundingBoxRenderer(this);
  119135. }
  119136. return this._boundingBoxRenderer;
  119137. };
  119138. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "showBoundingBox", {
  119139. get: function () {
  119140. return this._showBoundingBox || false;
  119141. },
  119142. set: function (value) {
  119143. this._showBoundingBox = value;
  119144. // Lazyly creates a BB renderer if needed.
  119145. if (value) {
  119146. this.getScene().getBoundingBoxRenderer();
  119147. }
  119148. },
  119149. enumerable: true,
  119150. configurable: true
  119151. });
  119152. /**
  119153. * Component responsible of rendering the bounding box of the meshes in a scene.
  119154. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  119155. */
  119156. var BoundingBoxRenderer = /** @class */ (function () {
  119157. /**
  119158. * Instantiates a new bounding box renderer in a scene.
  119159. * @param scene the scene the renderer renders in
  119160. */
  119161. function BoundingBoxRenderer(scene) {
  119162. /**
  119163. * The component name helpfull to identify the component in the list of scene components.
  119164. */
  119165. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_BOUNDINGBOXRENDERER;
  119166. /**
  119167. * Color of the bounding box lines placed in front of an object
  119168. */
  119169. this.frontColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  119170. /**
  119171. * Color of the bounding box lines placed behind an object
  119172. */
  119173. this.backColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0.1, 0.1, 0.1);
  119174. /**
  119175. * Defines if the renderer should show the back lines or not
  119176. */
  119177. this.showBackLines = true;
  119178. /**
  119179. * @hidden
  119180. */
  119181. this.renderList = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__["SmartArray"](32);
  119182. this._vertexBuffers = {};
  119183. this.scene = scene;
  119184. scene._addComponent(this);
  119185. }
  119186. /**
  119187. * Registers the component in a given scene
  119188. */
  119189. BoundingBoxRenderer.prototype.register = function () {
  119190. this.scene._beforeEvaluateActiveMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset);
  119191. this.scene._activeMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_ACTIVEMESH_BOUNDINGBOXRENDERER, this, this._activeMesh);
  119192. this.scene._evaluateSubMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh);
  119193. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render);
  119194. };
  119195. BoundingBoxRenderer.prototype._evaluateSubMesh = function (mesh, subMesh) {
  119196. if (mesh.showSubMeshesBoundingBox) {
  119197. var boundingInfo = subMesh.getBoundingInfo();
  119198. if (boundingInfo !== null && boundingInfo !== undefined) {
  119199. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  119200. this.renderList.push(boundingInfo.boundingBox);
  119201. }
  119202. }
  119203. };
  119204. BoundingBoxRenderer.prototype._activeMesh = function (sourceMesh, mesh) {
  119205. if (sourceMesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {
  119206. var boundingInfo = sourceMesh.getBoundingInfo();
  119207. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  119208. this.renderList.push(boundingInfo.boundingBox);
  119209. }
  119210. };
  119211. BoundingBoxRenderer.prototype._prepareRessources = function () {
  119212. if (this._colorShader) {
  119213. return;
  119214. }
  119215. this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__["ShaderMaterial"]("colorShader", this.scene, "color", {
  119216. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind],
  119217. uniforms: ["world", "viewProjection", "color"]
  119218. });
  119219. var engine = this.scene.getEngine();
  119220. var boxdata = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateBox({ size: 1.0 });
  119221. 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);
  119222. this._createIndexBuffer();
  119223. };
  119224. BoundingBoxRenderer.prototype._createIndexBuffer = function () {
  119225. var engine = this.scene.getEngine();
  119226. 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]);
  119227. };
  119228. /**
  119229. * Rebuilds the elements related to this component in case of
  119230. * context lost for instance.
  119231. */
  119232. BoundingBoxRenderer.prototype.rebuild = function () {
  119233. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  119234. if (vb) {
  119235. vb._rebuild();
  119236. }
  119237. this._createIndexBuffer();
  119238. };
  119239. /**
  119240. * @hidden
  119241. */
  119242. BoundingBoxRenderer.prototype.reset = function () {
  119243. this.renderList.reset();
  119244. };
  119245. /**
  119246. * Render the bounding boxes of a specific rendering group
  119247. * @param renderingGroupId defines the rendering group to render
  119248. */
  119249. BoundingBoxRenderer.prototype.render = function (renderingGroupId) {
  119250. if (this.renderList.length === 0) {
  119251. return;
  119252. }
  119253. this._prepareRessources();
  119254. if (!this._colorShader.isReady()) {
  119255. return;
  119256. }
  119257. var engine = this.scene.getEngine();
  119258. engine.setDepthWrite(false);
  119259. this._colorShader._preBind();
  119260. for (var boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {
  119261. var boundingBox = this.renderList.data[boundingBoxIndex];
  119262. if (boundingBox._tag !== renderingGroupId) {
  119263. continue;
  119264. }
  119265. var min = boundingBox.minimum;
  119266. var max = boundingBox.maximum;
  119267. var diff = max.subtract(min);
  119268. var median = min.add(diff.scale(0.5));
  119269. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  119270. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  119271. .multiply(boundingBox.getWorldMatrix());
  119272. // VBOs
  119273. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  119274. if (this.showBackLines) {
  119275. // Back
  119276. engine.setDepthFunctionToGreaterOrEqual();
  119277. this.scene.resetCachedMaterial();
  119278. this._colorShader.setColor4("color", this.backColor.toColor4());
  119279. this._colorShader.bind(worldMatrix);
  119280. // Draw order
  119281. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  119282. }
  119283. // Front
  119284. engine.setDepthFunctionToLess();
  119285. this.scene.resetCachedMaterial();
  119286. this._colorShader.setColor4("color", this.frontColor.toColor4());
  119287. this._colorShader.bind(worldMatrix);
  119288. // Draw order
  119289. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  119290. }
  119291. this._colorShader.unbind();
  119292. engine.setDepthFunctionToLessOrEqual();
  119293. engine.setDepthWrite(true);
  119294. };
  119295. /**
  119296. * In case of occlusion queries, we can render the occlusion bounding box through this method
  119297. * @param mesh Define the mesh to render the occlusion bounding box for
  119298. */
  119299. BoundingBoxRenderer.prototype.renderOcclusionBoundingBox = function (mesh) {
  119300. this._prepareRessources();
  119301. if (!this._colorShader.isReady() || !mesh._boundingInfo) {
  119302. return;
  119303. }
  119304. var engine = this.scene.getEngine();
  119305. engine.setDepthWrite(false);
  119306. engine.setColorWrite(false);
  119307. this._colorShader._preBind();
  119308. var boundingBox = mesh._boundingInfo.boundingBox;
  119309. var min = boundingBox.minimum;
  119310. var max = boundingBox.maximum;
  119311. var diff = max.subtract(min);
  119312. var median = min.add(diff.scale(0.5));
  119313. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  119314. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  119315. .multiply(boundingBox.getWorldMatrix());
  119316. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  119317. engine.setDepthFunctionToLess();
  119318. this.scene.resetCachedMaterial();
  119319. this._colorShader.bind(worldMatrix);
  119320. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  119321. this._colorShader.unbind();
  119322. engine.setDepthFunctionToLessOrEqual();
  119323. engine.setDepthWrite(true);
  119324. engine.setColorWrite(true);
  119325. };
  119326. /**
  119327. * Dispose and release the resources attached to this renderer.
  119328. */
  119329. BoundingBoxRenderer.prototype.dispose = function () {
  119330. if (!this._colorShader) {
  119331. return;
  119332. }
  119333. this.renderList.dispose();
  119334. this._colorShader.dispose();
  119335. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  119336. if (buffer) {
  119337. buffer.dispose();
  119338. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  119339. }
  119340. this.scene.getEngine()._releaseBuffer(this._indexBuffer);
  119341. };
  119342. return BoundingBoxRenderer;
  119343. }());
  119344. /***/ }),
  119345. /***/ "./Rendering/depthRenderer.ts":
  119346. /*!************************************!*\
  119347. !*** ./Rendering/depthRenderer.ts ***!
  119348. \************************************/
  119349. /*! exports provided: DepthRenderer */
  119350. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119351. "use strict";
  119352. __webpack_require__.r(__webpack_exports__);
  119353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return DepthRenderer; });
  119354. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119355. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  119356. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119357. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  119358. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  119359. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119360. /* harmony import */ var _Shaders_depth_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/depth.fragment */ "./Shaders/depth.fragment.ts");
  119361. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  119362. /**
  119363. * This represents a depth renderer in Babylon.
  119364. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  119365. */
  119366. var DepthRenderer = /** @class */ (function () {
  119367. /**
  119368. * Instantiates a depth renderer
  119369. * @param scene The scene the renderer belongs to
  119370. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  119371. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  119372. */
  119373. function DepthRenderer(scene, type, camera) {
  119374. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT; }
  119375. if (camera === void 0) { camera = null; }
  119376. var _this = this;
  119377. /**
  119378. * Specifiess that the depth renderer will only be used within
  119379. * the camera it is created for.
  119380. * This can help forcing its rendering during the camera processing.
  119381. */
  119382. this.useOnlyInActiveCamera = false;
  119383. this._scene = scene;
  119384. DepthRenderer._SceneComponentInitialization(this._scene);
  119385. this._camera = camera;
  119386. var engine = scene.getEngine();
  119387. // Render target
  119388. this._depthMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]("depthMap", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, this._scene, false, true, type);
  119389. this._depthMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  119390. this._depthMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  119391. this._depthMap.refreshRate = 1;
  119392. this._depthMap.renderParticles = false;
  119393. this._depthMap.renderList = null;
  119394. // Camera to get depth map from to support multiple concurrent cameras
  119395. this._depthMap.activeCamera = this._camera;
  119396. this._depthMap.ignoreCameraViewport = true;
  119397. this._depthMap.useCameraPostProcesses = false;
  119398. // set default depth value to 1.0 (far away)
  119399. this._depthMap.onClearObservable.add(function (engine) {
  119400. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0), true, true, true);
  119401. });
  119402. // Custom render function
  119403. var renderSubMesh = function (subMesh) {
  119404. var mesh = subMesh.getRenderingMesh();
  119405. var scene = _this._scene;
  119406. var engine = scene.getEngine();
  119407. var material = subMesh.getMaterial();
  119408. if (!material) {
  119409. return;
  119410. }
  119411. // Culling and reverse (right handed system)
  119412. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  119413. // Managing instances
  119414. var batch = mesh._getInstancesRenderList(subMesh._id);
  119415. if (batch.mustReturn) {
  119416. return;
  119417. }
  119418. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  119419. var camera = _this._camera || scene.activeCamera;
  119420. if (_this.isReady(subMesh, hardwareInstancedRendering) && camera) {
  119421. engine.enableEffect(_this._effect);
  119422. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  119423. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  119424. _this._effect.setFloat2("depthValues", camera.minZ, camera.minZ + camera.maxZ);
  119425. // Alpha test
  119426. if (material && material.needAlphaTesting()) {
  119427. var alphaTexture = material.getAlphaTestTexture();
  119428. if (alphaTexture) {
  119429. _this._effect.setTexture("diffuseSampler", alphaTexture);
  119430. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  119431. }
  119432. }
  119433. // Bones
  119434. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  119435. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  119436. }
  119437. // Draw
  119438. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  119439. }
  119440. };
  119441. this._depthMap.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  119442. var index;
  119443. if (depthOnlySubMeshes.length) {
  119444. engine.setColorWrite(false);
  119445. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  119446. renderSubMesh(depthOnlySubMeshes.data[index]);
  119447. }
  119448. engine.setColorWrite(true);
  119449. }
  119450. for (index = 0; index < opaqueSubMeshes.length; index++) {
  119451. renderSubMesh(opaqueSubMeshes.data[index]);
  119452. }
  119453. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  119454. renderSubMesh(alphaTestSubMeshes.data[index]);
  119455. }
  119456. };
  119457. }
  119458. /**
  119459. * Creates the depth rendering effect and checks if the effect is ready.
  119460. * @param subMesh The submesh to be used to render the depth map of
  119461. * @param useInstances If multiple world instances should be used
  119462. * @returns if the depth renderer is ready to render the depth map
  119463. */
  119464. DepthRenderer.prototype.isReady = function (subMesh, useInstances) {
  119465. var material = subMesh.getMaterial();
  119466. if (material.disableDepthWrite) {
  119467. return false;
  119468. }
  119469. var defines = [];
  119470. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  119471. var mesh = subMesh.getMesh();
  119472. // Alpha test
  119473. if (material && material.needAlphaTesting() && material.getAlphaTestTexture()) {
  119474. defines.push("#define ALPHATEST");
  119475. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  119476. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  119477. defines.push("#define UV1");
  119478. }
  119479. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  119480. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  119481. defines.push("#define UV2");
  119482. }
  119483. }
  119484. // Bones
  119485. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  119486. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  119487. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  119488. if (mesh.numBoneInfluencers > 4) {
  119489. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  119490. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  119491. }
  119492. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  119493. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  119494. }
  119495. else {
  119496. defines.push("#define NUM_BONE_INFLUENCERS 0");
  119497. }
  119498. // Instances
  119499. if (useInstances) {
  119500. defines.push("#define INSTANCES");
  119501. attribs.push("world0");
  119502. attribs.push("world1");
  119503. attribs.push("world2");
  119504. attribs.push("world3");
  119505. }
  119506. // Get correct effect
  119507. var join = defines.join("\n");
  119508. if (this._cachedDefines !== join) {
  119509. this._cachedDefines = join;
  119510. this._effect = this._scene.getEngine().createEffect("depth", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "depthValues"], ["diffuseSampler"], join);
  119511. }
  119512. return this._effect.isReady();
  119513. };
  119514. /**
  119515. * Gets the texture which the depth map will be written to.
  119516. * @returns The depth map texture
  119517. */
  119518. DepthRenderer.prototype.getDepthMap = function () {
  119519. return this._depthMap;
  119520. };
  119521. /**
  119522. * Disposes of the depth renderer.
  119523. */
  119524. DepthRenderer.prototype.dispose = function () {
  119525. this._depthMap.dispose();
  119526. };
  119527. /** @hidden */
  119528. DepthRenderer._SceneComponentInitialization = function (_) {
  119529. throw "Import DepthRendererSceneComponent before creating DepthRenderer.";
  119530. };
  119531. return DepthRenderer;
  119532. }());
  119533. /***/ }),
  119534. /***/ "./Rendering/depthRendererSceneComponent.ts":
  119535. /*!**************************************************!*\
  119536. !*** ./Rendering/depthRendererSceneComponent.ts ***!
  119537. \**************************************************/
  119538. /*! exports provided: DepthRendererSceneComponent */
  119539. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119540. "use strict";
  119541. __webpack_require__.r(__webpack_exports__);
  119542. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return DepthRendererSceneComponent; });
  119543. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  119544. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  119545. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119546. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  119547. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableDepthRenderer = function (camera) {
  119548. camera = camera || this.activeCamera;
  119549. if (!camera) {
  119550. throw "No camera available to enable depth renderer";
  119551. }
  119552. if (!this._depthRenderer) {
  119553. this._depthRenderer = {};
  119554. }
  119555. if (!this._depthRenderer[camera.id]) {
  119556. var textureType = 0;
  119557. if (this.getEngine().getCaps().textureHalfFloatRender) {
  119558. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  119559. }
  119560. else if (this.getEngine().getCaps().textureFloatRender) {
  119561. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  119562. }
  119563. else {
  119564. throw "Depth renderer does not support int texture type";
  119565. }
  119566. this._depthRenderer[camera.id] = new _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"](this, textureType, camera);
  119567. }
  119568. return this._depthRenderer[camera.id];
  119569. };
  119570. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableDepthRenderer = function (camera) {
  119571. camera = camera || this.activeCamera;
  119572. if (!camera || !this._depthRenderer || !this._depthRenderer[camera.id]) {
  119573. return;
  119574. }
  119575. this._depthRenderer[camera.id].dispose();
  119576. delete this._depthRenderer[camera.id];
  119577. };
  119578. /**
  119579. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  119580. * in several rendering techniques.
  119581. */
  119582. var DepthRendererSceneComponent = /** @class */ (function () {
  119583. /**
  119584. * Creates a new instance of the component for the given scene
  119585. * @param scene Defines the scene to register the component in
  119586. */
  119587. function DepthRendererSceneComponent(scene) {
  119588. /**
  119589. * The component name helpfull to identify the component in the list of scene components.
  119590. */
  119591. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER;
  119592. this.scene = scene;
  119593. }
  119594. /**
  119595. * Registers the component in a given scene
  119596. */
  119597. DepthRendererSceneComponent.prototype.register = function () {
  119598. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets);
  119599. this.scene._gatherActiveCameraRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);
  119600. };
  119601. /**
  119602. * Rebuilds the elements related to this component in case of
  119603. * context lost for instance.
  119604. */
  119605. DepthRendererSceneComponent.prototype.rebuild = function () {
  119606. // Nothing to do for this component
  119607. };
  119608. /**
  119609. * Disposes the component and the associated ressources
  119610. */
  119611. DepthRendererSceneComponent.prototype.dispose = function () {
  119612. for (var key in this.scene._depthRenderer) {
  119613. this.scene._depthRenderer[key].dispose();
  119614. }
  119615. };
  119616. DepthRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  119617. if (this.scene._depthRenderer) {
  119618. for (var key in this.scene._depthRenderer) {
  119619. var depthRenderer = this.scene._depthRenderer[key];
  119620. if (!depthRenderer.useOnlyInActiveCamera) {
  119621. renderTargets.push(depthRenderer.getDepthMap());
  119622. }
  119623. }
  119624. }
  119625. };
  119626. DepthRendererSceneComponent.prototype._gatherActiveCameraRenderTargets = function (renderTargets) {
  119627. if (this.scene._depthRenderer) {
  119628. for (var key in this.scene._depthRenderer) {
  119629. var depthRenderer = this.scene._depthRenderer[key];
  119630. if (depthRenderer.useOnlyInActiveCamera && this.scene.activeCamera.id === key) {
  119631. renderTargets.push(depthRenderer.getDepthMap());
  119632. }
  119633. }
  119634. }
  119635. };
  119636. return DepthRendererSceneComponent;
  119637. }());
  119638. _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]._SceneComponentInitialization = function (scene) {
  119639. // Register the G Buffer component to the scene.
  119640. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER);
  119641. if (!component) {
  119642. component = new DepthRendererSceneComponent(scene);
  119643. scene._addComponent(component);
  119644. }
  119645. };
  119646. /***/ }),
  119647. /***/ "./Rendering/edgesRenderer.ts":
  119648. /*!************************************!*\
  119649. !*** ./Rendering/edgesRenderer.ts ***!
  119650. \************************************/
  119651. /*! exports provided: EdgesRenderer, LineEdgesRenderer */
  119652. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119653. "use strict";
  119654. __webpack_require__.r(__webpack_exports__);
  119655. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return EdgesRenderer; });
  119656. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return LineEdgesRenderer; });
  119657. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119658. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  119659. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  119660. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  119661. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119662. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  119663. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  119664. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  119665. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119666. /* harmony import */ var _Shaders_line_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/line.fragment */ "./Shaders/line.fragment.ts");
  119667. /* harmony import */ var _Shaders_line_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/line.vertex */ "./Shaders/line.vertex.ts");
  119668. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.disableEdgesRendering = function () {
  119669. if (this._edgesRenderer) {
  119670. this._edgesRenderer.dispose();
  119671. this._edgesRenderer = null;
  119672. }
  119673. return this;
  119674. };
  119675. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  119676. if (epsilon === void 0) { epsilon = 0.95; }
  119677. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  119678. this.disableEdgesRendering();
  119679. this._edgesRenderer = new EdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  119680. return this;
  119681. };
  119682. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "edgesRenderer", {
  119683. get: function () {
  119684. return this._edgesRenderer;
  119685. },
  119686. enumerable: true,
  119687. configurable: true
  119688. });
  119689. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  119690. if (epsilon === void 0) { epsilon = 0.95; }
  119691. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  119692. this.disableEdgesRendering();
  119693. this._edgesRenderer = new LineEdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  119694. return this;
  119695. };
  119696. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["InstancedLinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  119697. if (epsilon === void 0) { epsilon = 0.95; }
  119698. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  119699. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering.apply(this, arguments);
  119700. return this;
  119701. };
  119702. /**
  119703. * FaceAdjacencies Helper class to generate edges
  119704. */
  119705. var FaceAdjacencies = /** @class */ (function () {
  119706. function FaceAdjacencies() {
  119707. this.edges = new Array();
  119708. this.edgesConnectedCount = 0;
  119709. }
  119710. return FaceAdjacencies;
  119711. }());
  119712. /**
  119713. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  119714. */
  119715. var EdgesRenderer = /** @class */ (function () {
  119716. /**
  119717. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  119718. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  119719. * @param source Mesh used to create edges
  119720. * @param epsilon sum of angles in adjacency to check for edge
  119721. * @param checkVerticesInsteadOfIndices
  119722. * @param generateEdgesLines - should generate Lines or only prepare resources.
  119723. */
  119724. function EdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices, generateEdgesLines) {
  119725. if (epsilon === void 0) { epsilon = 0.95; }
  119726. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  119727. if (generateEdgesLines === void 0) { generateEdgesLines = true; }
  119728. var _this = this;
  119729. /**
  119730. * Define the size of the edges with an orthographic camera
  119731. */
  119732. this.edgesWidthScalerForOrthographic = 1000.0;
  119733. /**
  119734. * Define the size of the edges with a perspective camera
  119735. */
  119736. this.edgesWidthScalerForPerspective = 50.0;
  119737. this._linesPositions = new Array();
  119738. this._linesNormals = new Array();
  119739. this._linesIndices = new Array();
  119740. this._buffers = {};
  119741. this._checkVerticesInsteadOfIndices = false;
  119742. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  119743. this.isEnabled = true;
  119744. this._source = source;
  119745. this._checkVerticesInsteadOfIndices = checkVerticesInsteadOfIndices;
  119746. this._epsilon = epsilon;
  119747. this._prepareRessources();
  119748. if (generateEdgesLines) {
  119749. this._generateEdgesLines();
  119750. }
  119751. this._meshRebuildObserver = this._source.onRebuildObservable.add(function () {
  119752. _this._rebuild();
  119753. });
  119754. this._meshDisposeObserver = this._source.onDisposeObservable.add(function () {
  119755. _this.dispose();
  119756. });
  119757. }
  119758. EdgesRenderer.prototype._prepareRessources = function () {
  119759. if (this._lineShader) {
  119760. return;
  119761. }
  119762. this._lineShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("lineShader", this._source.getScene(), "line", {
  119763. attributes: ["position", "normal"],
  119764. uniforms: ["worldViewProjection", "color", "width", "aspectRatio"]
  119765. });
  119766. this._lineShader.disableDepthWrite = true;
  119767. this._lineShader.backFaceCulling = false;
  119768. };
  119769. /** @hidden */
  119770. EdgesRenderer.prototype._rebuild = function () {
  119771. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  119772. if (buffer) {
  119773. buffer._rebuild();
  119774. }
  119775. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  119776. if (buffer) {
  119777. buffer._rebuild();
  119778. }
  119779. var scene = this._source.getScene();
  119780. var engine = scene.getEngine();
  119781. this._ib = engine.createIndexBuffer(this._linesIndices);
  119782. };
  119783. /**
  119784. * Releases the required resources for the edges renderer
  119785. */
  119786. EdgesRenderer.prototype.dispose = function () {
  119787. this._source.onRebuildObservable.remove(this._meshRebuildObserver);
  119788. this._source.onDisposeObservable.remove(this._meshDisposeObserver);
  119789. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  119790. if (buffer) {
  119791. buffer.dispose();
  119792. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  119793. }
  119794. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  119795. if (buffer) {
  119796. buffer.dispose();
  119797. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind] = null;
  119798. }
  119799. this._source.getScene().getEngine()._releaseBuffer(this._ib);
  119800. this._lineShader.dispose();
  119801. };
  119802. EdgesRenderer.prototype._processEdgeForAdjacencies = function (pa, pb, p0, p1, p2) {
  119803. if (pa === p0 && pb === p1 || pa === p1 && pb === p0) {
  119804. return 0;
  119805. }
  119806. if (pa === p1 && pb === p2 || pa === p2 && pb === p1) {
  119807. return 1;
  119808. }
  119809. if (pa === p2 && pb === p0 || pa === p0 && pb === p2) {
  119810. return 2;
  119811. }
  119812. return -1;
  119813. };
  119814. EdgesRenderer.prototype._processEdgeForAdjacenciesWithVertices = function (pa, pb, p0, p1, p2) {
  119815. if (pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p1) || pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p0)) {
  119816. return 0;
  119817. }
  119818. if (pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p2) || pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p1)) {
  119819. return 1;
  119820. }
  119821. if (pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p0) || pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p2)) {
  119822. return 2;
  119823. }
  119824. return -1;
  119825. };
  119826. /**
  119827. * Checks if the pair of p0 and p1 is en edge
  119828. * @param faceIndex
  119829. * @param edge
  119830. * @param faceNormals
  119831. * @param p0
  119832. * @param p1
  119833. * @private
  119834. */
  119835. EdgesRenderer.prototype._checkEdge = function (faceIndex, edge, faceNormals, p0, p1) {
  119836. var needToCreateLine;
  119837. if (edge === undefined) {
  119838. needToCreateLine = true;
  119839. }
  119840. else {
  119841. var dotProduct = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Dot(faceNormals[faceIndex], faceNormals[edge]);
  119842. needToCreateLine = dotProduct < this._epsilon;
  119843. }
  119844. if (needToCreateLine) {
  119845. this.createLine(p0, p1, this._linesPositions.length / 3);
  119846. }
  119847. };
  119848. /**
  119849. * push line into the position, normal and index buffer
  119850. * @protected
  119851. */
  119852. EdgesRenderer.prototype.createLine = function (p0, p1, offset) {
  119853. // Positions
  119854. 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);
  119855. // Normals
  119856. 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);
  119857. // Indices
  119858. this._linesIndices.push(offset, offset + 1, offset + 2, offset, offset + 2, offset + 3);
  119859. };
  119860. /**
  119861. * Generates lines edges from adjacencjes
  119862. * @private
  119863. */
  119864. EdgesRenderer.prototype._generateEdgesLines = function () {
  119865. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  119866. var indices = this._source.getIndices();
  119867. if (!indices || !positions) {
  119868. return;
  119869. }
  119870. // First let's find adjacencies
  119871. var adjacencies = new Array();
  119872. var faceNormals = new Array();
  119873. var index;
  119874. var faceAdjacencies;
  119875. // Prepare faces
  119876. for (index = 0; index < indices.length; index += 3) {
  119877. faceAdjacencies = new FaceAdjacencies();
  119878. var p0Index = indices[index];
  119879. var p1Index = indices[index + 1];
  119880. var p2Index = indices[index + 2];
  119881. faceAdjacencies.p0 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p0Index * 3], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);
  119882. faceAdjacencies.p1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p1Index * 3], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);
  119883. faceAdjacencies.p2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p2Index * 3], positions[p2Index * 3 + 1], positions[p2Index * 3 + 2]);
  119884. var faceNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Cross(faceAdjacencies.p1.subtract(faceAdjacencies.p0), faceAdjacencies.p2.subtract(faceAdjacencies.p1));
  119885. faceNormal.normalize();
  119886. faceNormals.push(faceNormal);
  119887. adjacencies.push(faceAdjacencies);
  119888. }
  119889. // Scan
  119890. for (index = 0; index < adjacencies.length; index++) {
  119891. faceAdjacencies = adjacencies[index];
  119892. for (var otherIndex = index + 1; otherIndex < adjacencies.length; otherIndex++) {
  119893. var otherFaceAdjacencies = adjacencies[otherIndex];
  119894. if (faceAdjacencies.edgesConnectedCount === 3) { // Full
  119895. break;
  119896. }
  119897. if (otherFaceAdjacencies.edgesConnectedCount === 3) { // Full
  119898. continue;
  119899. }
  119900. var otherP0 = indices[otherIndex * 3];
  119901. var otherP1 = indices[otherIndex * 3 + 1];
  119902. var otherP2 = indices[otherIndex * 3 + 2];
  119903. for (var edgeIndex = 0; edgeIndex < 3; edgeIndex++) {
  119904. var otherEdgeIndex = 0;
  119905. if (faceAdjacencies.edges[edgeIndex] !== undefined) {
  119906. continue;
  119907. }
  119908. switch (edgeIndex) {
  119909. case 0:
  119910. if (this._checkVerticesInsteadOfIndices) {
  119911. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p0, faceAdjacencies.p1, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  119912. }
  119913. else {
  119914. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3], indices[index * 3 + 1], otherP0, otherP1, otherP2);
  119915. }
  119916. break;
  119917. case 1:
  119918. if (this._checkVerticesInsteadOfIndices) {
  119919. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p1, faceAdjacencies.p2, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  119920. }
  119921. else {
  119922. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 1], indices[index * 3 + 2], otherP0, otherP1, otherP2);
  119923. }
  119924. break;
  119925. case 2:
  119926. if (this._checkVerticesInsteadOfIndices) {
  119927. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p2, faceAdjacencies.p0, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  119928. }
  119929. else {
  119930. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 2], indices[index * 3], otherP0, otherP1, otherP2);
  119931. }
  119932. break;
  119933. }
  119934. if (otherEdgeIndex === -1) {
  119935. continue;
  119936. }
  119937. faceAdjacencies.edges[edgeIndex] = otherIndex;
  119938. otherFaceAdjacencies.edges[otherEdgeIndex] = index;
  119939. faceAdjacencies.edgesConnectedCount++;
  119940. otherFaceAdjacencies.edgesConnectedCount++;
  119941. if (faceAdjacencies.edgesConnectedCount === 3) {
  119942. break;
  119943. }
  119944. }
  119945. }
  119946. }
  119947. // Create lines
  119948. for (index = 0; index < adjacencies.length; index++) {
  119949. // 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
  119950. var current = adjacencies[index];
  119951. this._checkEdge(index, current.edges[0], faceNormals, current.p0, current.p1);
  119952. this._checkEdge(index, current.edges[1], faceNormals, current.p1, current.p2);
  119953. this._checkEdge(index, current.edges[2], faceNormals, current.p2, current.p0);
  119954. }
  119955. // Merge into a single mesh
  119956. var engine = this._source.getScene().getEngine();
  119957. 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);
  119958. 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);
  119959. this._ib = engine.createIndexBuffer(this._linesIndices);
  119960. this._indicesCount = this._linesIndices.length;
  119961. };
  119962. /**
  119963. * Checks wether or not the edges renderer is ready to render.
  119964. * @return true if ready, otherwise false.
  119965. */
  119966. EdgesRenderer.prototype.isReady = function () {
  119967. return this._lineShader.isReady();
  119968. };
  119969. /**
  119970. * Renders the edges of the attached mesh,
  119971. */
  119972. EdgesRenderer.prototype.render = function () {
  119973. var scene = this._source.getScene();
  119974. if (!this.isReady() || !scene.activeCamera) {
  119975. return;
  119976. }
  119977. var engine = scene.getEngine();
  119978. this._lineShader._preBind();
  119979. if (this._source.edgesColor.a !== 1) {
  119980. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE);
  119981. }
  119982. else {
  119983. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  119984. }
  119985. // VBOs
  119986. engine.bindBuffers(this._buffers, this._ib, this._lineShader.getEffect());
  119987. scene.resetCachedMaterial();
  119988. this._lineShader.setColor4("color", this._source.edgesColor);
  119989. if (scene.activeCamera.mode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__["Camera"].ORTHOGRAPHIC_CAMERA) {
  119990. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic);
  119991. }
  119992. else {
  119993. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective);
  119994. }
  119995. this._lineShader.setFloat("aspectRatio", engine.getAspectRatio(scene.activeCamera));
  119996. this._lineShader.bind(this._source.getWorldMatrix());
  119997. // Draw order
  119998. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, this._indicesCount);
  119999. this._lineShader.unbind();
  120000. };
  120001. return EdgesRenderer;
  120002. }());
  120003. /**
  120004. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  120005. */
  120006. var LineEdgesRenderer = /** @class */ (function (_super) {
  120007. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LineEdgesRenderer, _super);
  120008. /**
  120009. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  120010. * @param source LineMesh used to generate edges
  120011. * @param epsilon not important (specified angle for edge detection)
  120012. * @param checkVerticesInsteadOfIndices not important for LineMesh
  120013. */
  120014. function LineEdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices) {
  120015. if (epsilon === void 0) { epsilon = 0.95; }
  120016. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  120017. var _this = _super.call(this, source, epsilon, checkVerticesInsteadOfIndices, false) || this;
  120018. _this._generateEdgesLines();
  120019. return _this;
  120020. }
  120021. /**
  120022. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  120023. */
  120024. LineEdgesRenderer.prototype._generateEdgesLines = function () {
  120025. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  120026. var indices = this._source.getIndices();
  120027. if (!indices || !positions) {
  120028. return;
  120029. }
  120030. var p0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  120031. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  120032. var len = indices.length - 1;
  120033. for (var i = 0, offset = 0; i < len; i += 2, offset += 4) {
  120034. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i], p0);
  120035. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i + 1], p1);
  120036. this.createLine(p0, p1, offset);
  120037. }
  120038. // Merge into a single mesh
  120039. var engine = this._source.getScene().getEngine();
  120040. 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);
  120041. 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);
  120042. this._ib = engine.createIndexBuffer(this._linesIndices);
  120043. this._indicesCount = this._linesIndices.length;
  120044. };
  120045. return LineEdgesRenderer;
  120046. }(EdgesRenderer));
  120047. /***/ }),
  120048. /***/ "./Rendering/geometryBufferRenderer.ts":
  120049. /*!*********************************************!*\
  120050. !*** ./Rendering/geometryBufferRenderer.ts ***!
  120051. \*********************************************/
  120052. /*! exports provided: GeometryBufferRenderer */
  120053. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120054. "use strict";
  120055. __webpack_require__.r(__webpack_exports__);
  120056. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return GeometryBufferRenderer; });
  120057. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120058. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  120059. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120060. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  120061. /* harmony import */ var _Materials_Textures_multiRenderTarget__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  120062. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  120063. /* harmony import */ var _Shaders_geometry_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/geometry.fragment */ "./Shaders/geometry.fragment.ts");
  120064. /* harmony import */ var _Shaders_geometry_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/geometry.vertex */ "./Shaders/geometry.vertex.ts");
  120065. /**
  120066. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  120067. */
  120068. var GeometryBufferRenderer = /** @class */ (function () {
  120069. /**
  120070. * Creates a new G Buffer for the scene
  120071. * @param scene The scene the buffer belongs to
  120072. * @param ratio How big is the buffer related to the main canvas.
  120073. */
  120074. function GeometryBufferRenderer(scene, ratio) {
  120075. if (ratio === void 0) { ratio = 1; }
  120076. /**
  120077. * Dictionary used to store the previous transformation matrices of each rendered mesh
  120078. * in order to compute objects velocities when enableVelocity is set to "true"
  120079. * @hidden
  120080. */
  120081. this._previousTransformationMatrices = {};
  120082. this._enablePosition = false;
  120083. this._enableVelocity = false;
  120084. this._positionIndex = -1;
  120085. this._velocityIndex = -1;
  120086. this._scene = scene;
  120087. this._ratio = ratio;
  120088. GeometryBufferRenderer._SceneComponentInitialization(this._scene);
  120089. // Render target
  120090. this._createRenderTargets();
  120091. }
  120092. Object.defineProperty(GeometryBufferRenderer.prototype, "renderList", {
  120093. /**
  120094. * Set the render list (meshes to be rendered) used in the G buffer.
  120095. */
  120096. set: function (meshes) {
  120097. this._multiRenderTarget.renderList = meshes;
  120098. },
  120099. enumerable: true,
  120100. configurable: true
  120101. });
  120102. Object.defineProperty(GeometryBufferRenderer.prototype, "isSupported", {
  120103. /**
  120104. * Gets wether or not G buffer are supported by the running hardware.
  120105. * This requires draw buffer supports
  120106. */
  120107. get: function () {
  120108. return this._multiRenderTarget.isSupported;
  120109. },
  120110. enumerable: true,
  120111. configurable: true
  120112. });
  120113. /**
  120114. * Returns the index of the given texture type in the G-Buffer textures array
  120115. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  120116. * @returns the index of the given texture type in the G-Buffer textures array
  120117. */
  120118. GeometryBufferRenderer.prototype.getTextureIndex = function (textureType) {
  120119. switch (textureType) {
  120120. case GeometryBufferRenderer.POSITION_TEXTURE_TYPE: return this._positionIndex;
  120121. case GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE: return this._velocityIndex;
  120122. default: return -1;
  120123. }
  120124. };
  120125. Object.defineProperty(GeometryBufferRenderer.prototype, "enablePosition", {
  120126. /**
  120127. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  120128. */
  120129. get: function () {
  120130. return this._enablePosition;
  120131. },
  120132. /**
  120133. * Sets whether or not objects positions are enabled for the G buffer.
  120134. */
  120135. set: function (enable) {
  120136. this._enablePosition = enable;
  120137. this.dispose();
  120138. this._createRenderTargets();
  120139. },
  120140. enumerable: true,
  120141. configurable: true
  120142. });
  120143. Object.defineProperty(GeometryBufferRenderer.prototype, "enableVelocity", {
  120144. /**
  120145. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  120146. */
  120147. get: function () {
  120148. return this._enableVelocity;
  120149. },
  120150. /**
  120151. * Sets wether or not objects velocities are enabled for the G buffer.
  120152. */
  120153. set: function (enable) {
  120154. this._enableVelocity = enable;
  120155. this.dispose();
  120156. this._createRenderTargets();
  120157. },
  120158. enumerable: true,
  120159. configurable: true
  120160. });
  120161. Object.defineProperty(GeometryBufferRenderer.prototype, "scene", {
  120162. /**
  120163. * Gets the scene associated with the buffer.
  120164. */
  120165. get: function () {
  120166. return this._scene;
  120167. },
  120168. enumerable: true,
  120169. configurable: true
  120170. });
  120171. Object.defineProperty(GeometryBufferRenderer.prototype, "ratio", {
  120172. /**
  120173. * Gets the ratio used by the buffer during its creation.
  120174. * How big is the buffer related to the main canvas.
  120175. */
  120176. get: function () {
  120177. return this._ratio;
  120178. },
  120179. enumerable: true,
  120180. configurable: true
  120181. });
  120182. /**
  120183. * Checks wether everything is ready to render a submesh to the G buffer.
  120184. * @param subMesh the submesh to check readiness for
  120185. * @param useInstances is the mesh drawn using instance or not
  120186. * @returns true if ready otherwise false
  120187. */
  120188. GeometryBufferRenderer.prototype.isReady = function (subMesh, useInstances) {
  120189. var material = subMesh.getMaterial();
  120190. if (material && material.disableDepthWrite) {
  120191. return false;
  120192. }
  120193. var defines = [];
  120194. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  120195. var mesh = subMesh.getMesh();
  120196. // Alpha test
  120197. if (material && material.needAlphaTesting()) {
  120198. defines.push("#define ALPHATEST");
  120199. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  120200. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  120201. defines.push("#define UV1");
  120202. }
  120203. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  120204. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  120205. defines.push("#define UV2");
  120206. }
  120207. }
  120208. // Buffers
  120209. if (this._enablePosition) {
  120210. defines.push("#define POSITION");
  120211. defines.push("#define POSITION_INDEX " + this._positionIndex);
  120212. }
  120213. if (this._enableVelocity) {
  120214. defines.push("#define VELOCITY");
  120215. defines.push("#define VELOCITY_INDEX " + this._velocityIndex);
  120216. }
  120217. // Bones
  120218. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  120219. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  120220. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  120221. if (mesh.numBoneInfluencers > 4) {
  120222. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  120223. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  120224. }
  120225. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  120226. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  120227. }
  120228. else {
  120229. defines.push("#define NUM_BONE_INFLUENCERS 0");
  120230. }
  120231. // Instances
  120232. if (useInstances) {
  120233. defines.push("#define INSTANCES");
  120234. attribs.push("world0");
  120235. attribs.push("world1");
  120236. attribs.push("world2");
  120237. attribs.push("world3");
  120238. }
  120239. // Setup textures count
  120240. defines.push("#define RENDER_TARGET_COUNT " + this._multiRenderTarget.textures.length);
  120241. // Get correct effect
  120242. var join = defines.join("\n");
  120243. if (this._cachedDefines !== join) {
  120244. this._cachedDefines = join;
  120245. this._effect = this._scene.getEngine().createEffect("geometry", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorldViewProjection"], ["diffuseSampler"], join, undefined, undefined, undefined, { buffersCount: this._enablePosition ? 3 : 2 });
  120246. }
  120247. return this._effect.isReady();
  120248. };
  120249. /**
  120250. * Gets the current underlying G Buffer.
  120251. * @returns the buffer
  120252. */
  120253. GeometryBufferRenderer.prototype.getGBuffer = function () {
  120254. return this._multiRenderTarget;
  120255. };
  120256. Object.defineProperty(GeometryBufferRenderer.prototype, "samples", {
  120257. /**
  120258. * Gets the number of samples used to render the buffer (anti aliasing).
  120259. */
  120260. get: function () {
  120261. return this._multiRenderTarget.samples;
  120262. },
  120263. /**
  120264. * Sets the number of samples used to render the buffer (anti aliasing).
  120265. */
  120266. set: function (value) {
  120267. this._multiRenderTarget.samples = value;
  120268. },
  120269. enumerable: true,
  120270. configurable: true
  120271. });
  120272. /**
  120273. * Disposes the renderer and frees up associated resources.
  120274. */
  120275. GeometryBufferRenderer.prototype.dispose = function () {
  120276. this.getGBuffer().dispose();
  120277. };
  120278. GeometryBufferRenderer.prototype._createRenderTargets = function () {
  120279. var _this = this;
  120280. var engine = this._scene.getEngine();
  120281. var count = 2;
  120282. if (this._enablePosition) {
  120283. this._positionIndex = count;
  120284. count++;
  120285. }
  120286. if (this._enableVelocity) {
  120287. this._velocityIndex = count;
  120288. count++;
  120289. }
  120290. 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 });
  120291. if (!this.isSupported) {
  120292. return;
  120293. }
  120294. this._multiRenderTarget.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  120295. this._multiRenderTarget.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  120296. this._multiRenderTarget.refreshRate = 1;
  120297. this._multiRenderTarget.renderParticles = false;
  120298. this._multiRenderTarget.renderList = null;
  120299. // set default depth value to 1.0 (far away)
  120300. this._multiRenderTarget.onClearObservable.add(function (engine) {
  120301. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0.0, 0.0, 0.0, 1.0), true, true, true);
  120302. });
  120303. // Custom render function
  120304. var renderSubMesh = function (subMesh) {
  120305. var mesh = subMesh.getRenderingMesh();
  120306. var scene = _this._scene;
  120307. var engine = scene.getEngine();
  120308. var material = subMesh.getMaterial();
  120309. if (!material) {
  120310. return;
  120311. }
  120312. // Velocity
  120313. if (!_this._previousTransformationMatrices[mesh.uniqueId]) {
  120314. _this._previousTransformationMatrices[mesh.uniqueId] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  120315. }
  120316. // Culling
  120317. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  120318. // Managing instances
  120319. var batch = mesh._getInstancesRenderList(subMesh._id);
  120320. if (batch.mustReturn) {
  120321. return;
  120322. }
  120323. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  120324. if (_this.isReady(subMesh, hardwareInstancedRendering)) {
  120325. engine.enableEffect(_this._effect);
  120326. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  120327. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  120328. _this._effect.setMatrix("view", scene.getViewMatrix());
  120329. // Alpha test
  120330. if (material && material.needAlphaTesting()) {
  120331. var alphaTexture = material.getAlphaTestTexture();
  120332. if (alphaTexture) {
  120333. _this._effect.setTexture("diffuseSampler", alphaTexture);
  120334. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  120335. }
  120336. }
  120337. // Bones
  120338. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  120339. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  120340. }
  120341. // Velocity
  120342. _this._effect.setMatrix("previousWorldViewProjection", _this._previousTransformationMatrices[mesh.uniqueId]);
  120343. // Draw
  120344. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  120345. }
  120346. // Velocity
  120347. _this._previousTransformationMatrices[mesh.uniqueId] = mesh.getWorldMatrix().multiply(_this._scene.getTransformMatrix());
  120348. };
  120349. this._multiRenderTarget.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  120350. var index;
  120351. if (depthOnlySubMeshes.length) {
  120352. engine.setColorWrite(false);
  120353. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  120354. renderSubMesh(depthOnlySubMeshes.data[index]);
  120355. }
  120356. engine.setColorWrite(true);
  120357. }
  120358. for (index = 0; index < opaqueSubMeshes.length; index++) {
  120359. renderSubMesh(opaqueSubMeshes.data[index]);
  120360. }
  120361. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  120362. renderSubMesh(alphaTestSubMeshes.data[index]);
  120363. }
  120364. };
  120365. };
  120366. /**
  120367. * Constant used to retrieve the position texture index in the G-Buffer textures array
  120368. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  120369. */
  120370. GeometryBufferRenderer.POSITION_TEXTURE_TYPE = 1;
  120371. /**
  120372. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  120373. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  120374. */
  120375. GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE = 2;
  120376. /** @hidden */
  120377. GeometryBufferRenderer._SceneComponentInitialization = function (_) {
  120378. throw "Import GeometryBufferRendererSceneComponent before creating GeometryBufferRenderer.";
  120379. };
  120380. return GeometryBufferRenderer;
  120381. }());
  120382. /***/ }),
  120383. /***/ "./Rendering/geometryBufferRendererSceneComponent.ts":
  120384. /*!***********************************************************!*\
  120385. !*** ./Rendering/geometryBufferRendererSceneComponent.ts ***!
  120386. \***********************************************************/
  120387. /*! exports provided: GeometryBufferRendererSceneComponent */
  120388. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120389. "use strict";
  120390. __webpack_require__.r(__webpack_exports__);
  120391. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return GeometryBufferRendererSceneComponent; });
  120392. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  120393. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  120394. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  120395. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "geometryBufferRenderer", {
  120396. get: function () {
  120397. this._geometryBufferRenderer;
  120398. },
  120399. set: function (value) {
  120400. if (value && value.isSupported) {
  120401. this._geometryBufferRenderer = value;
  120402. }
  120403. },
  120404. enumerable: true,
  120405. configurable: true
  120406. });
  120407. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableGeometryBufferRenderer = function (ratio) {
  120408. if (ratio === void 0) { ratio = 1; }
  120409. if (this._geometryBufferRenderer) {
  120410. return this._geometryBufferRenderer;
  120411. }
  120412. this._geometryBufferRenderer = new _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"](this, ratio);
  120413. if (!this._geometryBufferRenderer.isSupported) {
  120414. this._geometryBufferRenderer = null;
  120415. }
  120416. return this._geometryBufferRenderer;
  120417. };
  120418. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableGeometryBufferRenderer = function () {
  120419. if (!this._geometryBufferRenderer) {
  120420. return;
  120421. }
  120422. this._geometryBufferRenderer.dispose();
  120423. this._geometryBufferRenderer = null;
  120424. };
  120425. /**
  120426. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  120427. * in several rendering techniques.
  120428. */
  120429. var GeometryBufferRendererSceneComponent = /** @class */ (function () {
  120430. /**
  120431. * Creates a new instance of the component for the given scene
  120432. * @param scene Defines the scene to register the component in
  120433. */
  120434. function GeometryBufferRendererSceneComponent(scene) {
  120435. /**
  120436. * The component name helpful to identify the component in the list of scene components.
  120437. */
  120438. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER;
  120439. this.scene = scene;
  120440. }
  120441. /**
  120442. * Registers the component in a given scene
  120443. */
  120444. GeometryBufferRendererSceneComponent.prototype.register = function () {
  120445. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets);
  120446. };
  120447. /**
  120448. * Rebuilds the elements related to this component in case of
  120449. * context lost for instance.
  120450. */
  120451. GeometryBufferRendererSceneComponent.prototype.rebuild = function () {
  120452. // Nothing to do for this component
  120453. };
  120454. /**
  120455. * Disposes the component and the associated ressources
  120456. */
  120457. GeometryBufferRendererSceneComponent.prototype.dispose = function () {
  120458. // Nothing to do for this component
  120459. };
  120460. GeometryBufferRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  120461. if (this.scene._geometryBufferRenderer) {
  120462. renderTargets.push(this.scene._geometryBufferRenderer.getGBuffer());
  120463. }
  120464. };
  120465. return GeometryBufferRendererSceneComponent;
  120466. }());
  120467. _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"]._SceneComponentInitialization = function (scene) {
  120468. // Register the G Buffer component to the scene.
  120469. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER);
  120470. if (!component) {
  120471. component = new GeometryBufferRendererSceneComponent(scene);
  120472. scene._addComponent(component);
  120473. }
  120474. };
  120475. /***/ }),
  120476. /***/ "./Rendering/index.ts":
  120477. /*!****************************!*\
  120478. !*** ./Rendering/index.ts ***!
  120479. \****************************/
  120480. /*! exports provided: BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer */
  120481. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120482. "use strict";
  120483. __webpack_require__.r(__webpack_exports__);
  120484. /* harmony import */ var _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBoxRenderer */ "./Rendering/boundingBoxRenderer.ts");
  120485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  120486. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  120487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]; });
  120488. /* harmony import */ var _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./depthRendererSceneComponent */ "./Rendering/depthRendererSceneComponent.ts");
  120489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__["DepthRendererSceneComponent"]; });
  120490. /* harmony import */ var _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./edgesRenderer */ "./Rendering/edgesRenderer.ts");
  120491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["EdgesRenderer"]; });
  120492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["LineEdgesRenderer"]; });
  120493. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  120494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__["GeometryBufferRenderer"]; });
  120495. /* harmony import */ var _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  120496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRendererSceneComponent"]; });
  120497. /* harmony import */ var _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./outlineRenderer */ "./Rendering/outlineRenderer.ts");
  120498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__["OutlineRenderer"]; });
  120499. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  120500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _renderingGroup__WEBPACK_IMPORTED_MODULE_7__["RenderingGroup"]; });
  120501. /* harmony import */ var _renderingManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./renderingManager */ "./Rendering/renderingManager.ts");
  120502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingGroupInfo"]; });
  120503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingManager"]; });
  120504. /* harmony import */ var _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  120505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"]; });
  120506. /***/ }),
  120507. /***/ "./Rendering/outlineRenderer.ts":
  120508. /*!**************************************!*\
  120509. !*** ./Rendering/outlineRenderer.ts ***!
  120510. \**************************************/
  120511. /*! exports provided: OutlineRenderer */
  120512. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120513. "use strict";
  120514. __webpack_require__.r(__webpack_exports__);
  120515. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return OutlineRenderer; });
  120516. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  120517. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  120518. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  120519. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120520. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  120521. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  120522. /* harmony import */ var _Shaders_outline_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/outline.fragment */ "./Shaders/outline.fragment.ts");
  120523. /* harmony import */ var _Shaders_outline_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/outline.vertex */ "./Shaders/outline.vertex.ts");
  120524. /**
  120525. * Gets the outline renderer associated with the scene
  120526. * @returns a OutlineRenderer
  120527. */
  120528. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype.getOutlineRenderer = function () {
  120529. if (!this._outlineRenderer) {
  120530. this._outlineRenderer = new OutlineRenderer(this);
  120531. }
  120532. return this._outlineRenderer;
  120533. };
  120534. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOutline", {
  120535. get: function () {
  120536. return this._renderOutline;
  120537. },
  120538. set: function (value) {
  120539. if (value) {
  120540. // Lazy Load the component.
  120541. this.getScene().getOutlineRenderer();
  120542. }
  120543. this._renderOutline = value;
  120544. },
  120545. enumerable: true,
  120546. configurable: true
  120547. });
  120548. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOverlay", {
  120549. get: function () {
  120550. return this._renderOverlay;
  120551. },
  120552. set: function (value) {
  120553. if (value) {
  120554. // Lazy Load the component.
  120555. this.getScene().getOutlineRenderer();
  120556. }
  120557. this._renderOverlay = value;
  120558. },
  120559. enumerable: true,
  120560. configurable: true
  120561. });
  120562. /**
  120563. * This class is responsible to draw bothe outline/overlay of meshes.
  120564. * It should not be used directly but through the available method on mesh.
  120565. */
  120566. var OutlineRenderer = /** @class */ (function () {
  120567. /**
  120568. * Instantiates a new outline renderer. (There could be only one per scene).
  120569. * @param scene Defines the scene it belongs to
  120570. */
  120571. function OutlineRenderer(scene) {
  120572. /**
  120573. * The name of the component. Each component must have a unique name.
  120574. */
  120575. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OUTLINERENDERER;
  120576. /**
  120577. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  120578. */
  120579. this.zOffset = 1;
  120580. this.scene = scene;
  120581. this._engine = scene.getEngine();
  120582. this.scene._addComponent(this);
  120583. }
  120584. /**
  120585. * Register the component to one instance of a scene.
  120586. */
  120587. OutlineRenderer.prototype.register = function () {
  120588. this.scene._beforeRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_BEFORERENDERINGMESH_OUTLINE, this, this._beforeRenderingMesh);
  120589. this.scene._afterRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDERINGMESH_OUTLINE, this, this._afterRenderingMesh);
  120590. };
  120591. /**
  120592. * Rebuilds the elements related to this component in case of
  120593. * context lost for instance.
  120594. */
  120595. OutlineRenderer.prototype.rebuild = function () {
  120596. // Nothing to do here.
  120597. };
  120598. /**
  120599. * Disposes the component and the associated ressources.
  120600. */
  120601. OutlineRenderer.prototype.dispose = function () {
  120602. // Nothing to do here.
  120603. };
  120604. /**
  120605. * Renders the outline in the canvas.
  120606. * @param subMesh Defines the sumesh to render
  120607. * @param batch Defines the batch of meshes in case of instances
  120608. * @param useOverlay Defines if the rendering is for the overlay or the outline
  120609. */
  120610. OutlineRenderer.prototype.render = function (subMesh, batch, useOverlay) {
  120611. var _this = this;
  120612. if (useOverlay === void 0) { useOverlay = false; }
  120613. var scene = this.scene;
  120614. var engine = scene.getEngine();
  120615. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  120616. if (!this.isReady(subMesh, hardwareInstancedRendering)) {
  120617. return;
  120618. }
  120619. var mesh = subMesh.getRenderingMesh();
  120620. var material = subMesh.getMaterial();
  120621. if (!material || !scene.activeCamera) {
  120622. return;
  120623. }
  120624. engine.enableEffect(this._effect);
  120625. // Logarithmic depth
  120626. if (material.useLogarithmicDepth) {
  120627. this._effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  120628. }
  120629. this._effect.setFloat("offset", useOverlay ? 0 : mesh.outlineWidth);
  120630. this._effect.setColor4("color", useOverlay ? mesh.overlayColor : mesh.outlineColor, useOverlay ? mesh.overlayAlpha : material.alpha);
  120631. this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  120632. // Bones
  120633. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  120634. this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  120635. }
  120636. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  120637. // Alpha test
  120638. if (material && material.needAlphaTesting()) {
  120639. var alphaTexture = material.getAlphaTestTexture();
  120640. if (alphaTexture) {
  120641. this._effect.setTexture("diffuseSampler", alphaTexture);
  120642. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  120643. }
  120644. }
  120645. engine.setZOffset(-this.zOffset);
  120646. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { _this._effect.setMatrix("world", world); });
  120647. engine.setZOffset(0);
  120648. };
  120649. /**
  120650. * Returns whether or not the outline renderer is ready for a given submesh.
  120651. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  120652. * @param subMesh Defines the submesh to check readyness for
  120653. * @param useInstances Defines wheter wee are trying to render instances or not
  120654. * @returns true if ready otherwise false
  120655. */
  120656. OutlineRenderer.prototype.isReady = function (subMesh, useInstances) {
  120657. var defines = [];
  120658. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].NormalKind];
  120659. var mesh = subMesh.getMesh();
  120660. var material = subMesh.getMaterial();
  120661. if (material) {
  120662. // Alpha test
  120663. if (material.needAlphaTesting()) {
  120664. defines.push("#define ALPHATEST");
  120665. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind)) {
  120666. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind);
  120667. defines.push("#define UV1");
  120668. }
  120669. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind)) {
  120670. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind);
  120671. defines.push("#define UV2");
  120672. }
  120673. }
  120674. //Logarithmic depth
  120675. if (material.useLogarithmicDepth) {
  120676. defines.push("#define LOGARITHMICDEPTH");
  120677. }
  120678. }
  120679. // Bones
  120680. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  120681. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesKind);
  120682. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsKind);
  120683. if (mesh.numBoneInfluencers > 4) {
  120684. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesExtraKind);
  120685. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsExtraKind);
  120686. }
  120687. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  120688. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  120689. }
  120690. else {
  120691. defines.push("#define NUM_BONE_INFLUENCERS 0");
  120692. }
  120693. // Instances
  120694. if (useInstances) {
  120695. defines.push("#define INSTANCES");
  120696. attribs.push("world0");
  120697. attribs.push("world1");
  120698. attribs.push("world2");
  120699. attribs.push("world3");
  120700. }
  120701. // Get correct effect
  120702. var join = defines.join("\n");
  120703. if (this._cachedDefines !== join) {
  120704. this._cachedDefines = join;
  120705. this._effect = this.scene.getEngine().createEffect("outline", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "offset", "color", "logarithmicDepthConstant"], ["diffuseSampler"], join);
  120706. }
  120707. return this._effect.isReady();
  120708. };
  120709. OutlineRenderer.prototype._beforeRenderingMesh = function (mesh, subMesh, batch) {
  120710. // Outline - step 1
  120711. this._savedDepthWrite = this._engine.getDepthWrite();
  120712. if (mesh.renderOutline) {
  120713. this._engine.setDepthWrite(false);
  120714. this.render(subMesh, batch);
  120715. this._engine.setDepthWrite(this._savedDepthWrite);
  120716. }
  120717. };
  120718. OutlineRenderer.prototype._afterRenderingMesh = function (mesh, subMesh, batch) {
  120719. // Outline - step 2
  120720. if (mesh.renderOutline && this._savedDepthWrite) {
  120721. this._engine.setDepthWrite(true);
  120722. this._engine.setColorWrite(false);
  120723. this.render(subMesh, batch);
  120724. this._engine.setColorWrite(true);
  120725. }
  120726. // Overlay
  120727. if (mesh.renderOverlay) {
  120728. var currentMode = this._engine.getAlphaMode();
  120729. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALPHA_COMBINE);
  120730. this.render(subMesh, batch, true);
  120731. this._engine.setAlphaMode(currentMode);
  120732. }
  120733. };
  120734. return OutlineRenderer;
  120735. }());
  120736. /***/ }),
  120737. /***/ "./Rendering/renderingGroup.ts":
  120738. /*!*************************************!*\
  120739. !*** ./Rendering/renderingGroup.ts ***!
  120740. \*************************************/
  120741. /*! exports provided: RenderingGroup */
  120742. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120743. "use strict";
  120744. __webpack_require__.r(__webpack_exports__);
  120745. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return RenderingGroup; });
  120746. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  120747. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120748. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120749. /**
  120750. * This represents the object necessary to create a rendering group.
  120751. * This is exclusively used and created by the rendering manager.
  120752. * To modify the behavior, you use the available helpers in your scene or meshes.
  120753. * @hidden
  120754. */
  120755. var RenderingGroup = /** @class */ (function () {
  120756. /**
  120757. * Creates a new rendering group.
  120758. * @param index The rendering group index
  120759. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  120760. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  120761. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  120762. */
  120763. function RenderingGroup(index, scene, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  120764. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  120765. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  120766. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  120767. this.index = index;
  120768. this._opaqueSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  120769. this._transparentSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  120770. this._alphaTestSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  120771. this._depthOnlySubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  120772. this._particleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  120773. this._spriteManagers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  120774. this._edgesRenderers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  120775. this._scene = scene;
  120776. this.opaqueSortCompareFn = opaqueSortCompareFn;
  120777. this.alphaTestSortCompareFn = alphaTestSortCompareFn;
  120778. this.transparentSortCompareFn = transparentSortCompareFn;
  120779. }
  120780. Object.defineProperty(RenderingGroup.prototype, "opaqueSortCompareFn", {
  120781. /**
  120782. * Set the opaque sort comparison function.
  120783. * If null the sub meshes will be render in the order they were created
  120784. */
  120785. set: function (value) {
  120786. this._opaqueSortCompareFn = value;
  120787. if (value) {
  120788. this._renderOpaque = this.renderOpaqueSorted;
  120789. }
  120790. else {
  120791. this._renderOpaque = RenderingGroup.renderUnsorted;
  120792. }
  120793. },
  120794. enumerable: true,
  120795. configurable: true
  120796. });
  120797. Object.defineProperty(RenderingGroup.prototype, "alphaTestSortCompareFn", {
  120798. /**
  120799. * Set the alpha test sort comparison function.
  120800. * If null the sub meshes will be render in the order they were created
  120801. */
  120802. set: function (value) {
  120803. this._alphaTestSortCompareFn = value;
  120804. if (value) {
  120805. this._renderAlphaTest = this.renderAlphaTestSorted;
  120806. }
  120807. else {
  120808. this._renderAlphaTest = RenderingGroup.renderUnsorted;
  120809. }
  120810. },
  120811. enumerable: true,
  120812. configurable: true
  120813. });
  120814. Object.defineProperty(RenderingGroup.prototype, "transparentSortCompareFn", {
  120815. /**
  120816. * Set the transparent sort comparison function.
  120817. * If null the sub meshes will be render in the order they were created
  120818. */
  120819. set: function (value) {
  120820. if (value) {
  120821. this._transparentSortCompareFn = value;
  120822. }
  120823. else {
  120824. this._transparentSortCompareFn = RenderingGroup.defaultTransparentSortCompare;
  120825. }
  120826. this._renderTransparent = this.renderTransparentSorted;
  120827. },
  120828. enumerable: true,
  120829. configurable: true
  120830. });
  120831. /**
  120832. * Render all the sub meshes contained in the group.
  120833. * @param customRenderFunction Used to override the default render behaviour of the group.
  120834. * @returns true if rendered some submeshes.
  120835. */
  120836. RenderingGroup.prototype.render = function (customRenderFunction, renderSprites, renderParticles, activeMeshes) {
  120837. if (customRenderFunction) {
  120838. customRenderFunction(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
  120839. return;
  120840. }
  120841. var engine = this._scene.getEngine();
  120842. // Depth only
  120843. if (this._depthOnlySubMeshes.length !== 0) {
  120844. engine.setColorWrite(false);
  120845. this._renderAlphaTest(this._depthOnlySubMeshes);
  120846. engine.setColorWrite(true);
  120847. }
  120848. // Opaque
  120849. if (this._opaqueSubMeshes.length !== 0) {
  120850. this._renderOpaque(this._opaqueSubMeshes);
  120851. }
  120852. // Alpha test
  120853. if (this._alphaTestSubMeshes.length !== 0) {
  120854. this._renderAlphaTest(this._alphaTestSubMeshes);
  120855. }
  120856. var stencilState = engine.getStencilBuffer();
  120857. engine.setStencilBuffer(false);
  120858. // Sprites
  120859. if (renderSprites) {
  120860. this._renderSprites();
  120861. }
  120862. // Particles
  120863. if (renderParticles) {
  120864. this._renderParticles(activeMeshes);
  120865. }
  120866. if (this.onBeforeTransparentRendering) {
  120867. this.onBeforeTransparentRendering();
  120868. }
  120869. // Transparent
  120870. if (this._transparentSubMeshes.length !== 0) {
  120871. this._renderTransparent(this._transparentSubMeshes);
  120872. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  120873. }
  120874. // Set back stencil to false in case it changes before the edge renderer.
  120875. engine.setStencilBuffer(false);
  120876. // Edges
  120877. if (this._edgesRenderers.length) {
  120878. for (var edgesRendererIndex = 0; edgesRendererIndex < this._edgesRenderers.length; edgesRendererIndex++) {
  120879. this._edgesRenderers.data[edgesRendererIndex].render();
  120880. }
  120881. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  120882. }
  120883. // Restore Stencil state.
  120884. engine.setStencilBuffer(stencilState);
  120885. };
  120886. /**
  120887. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  120888. * @param subMeshes The submeshes to render
  120889. */
  120890. RenderingGroup.prototype.renderOpaqueSorted = function (subMeshes) {
  120891. return RenderingGroup.renderSorted(subMeshes, this._opaqueSortCompareFn, this._scene.activeCamera, false);
  120892. };
  120893. /**
  120894. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  120895. * @param subMeshes The submeshes to render
  120896. */
  120897. RenderingGroup.prototype.renderAlphaTestSorted = function (subMeshes) {
  120898. return RenderingGroup.renderSorted(subMeshes, this._alphaTestSortCompareFn, this._scene.activeCamera, false);
  120899. };
  120900. /**
  120901. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  120902. * @param subMeshes The submeshes to render
  120903. */
  120904. RenderingGroup.prototype.renderTransparentSorted = function (subMeshes) {
  120905. return RenderingGroup.renderSorted(subMeshes, this._transparentSortCompareFn, this._scene.activeCamera, true);
  120906. };
  120907. /**
  120908. * Renders the submeshes in a specified order.
  120909. * @param subMeshes The submeshes to sort before render
  120910. * @param sortCompareFn The comparison function use to sort
  120911. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  120912. * @param transparent Specifies to activate blending if true
  120913. */
  120914. RenderingGroup.renderSorted = function (subMeshes, sortCompareFn, camera, transparent) {
  120915. var subIndex = 0;
  120916. var subMesh;
  120917. var cameraPosition = camera ? camera.globalPosition : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  120918. for (; subIndex < subMeshes.length; subIndex++) {
  120919. subMesh = subMeshes.data[subIndex];
  120920. subMesh._alphaIndex = subMesh.getMesh().alphaIndex;
  120921. subMesh._distanceToCamera = subMesh.getBoundingInfo().boundingSphere.centerWorld.subtract(cameraPosition).length();
  120922. }
  120923. var sortedArray = subMeshes.data.slice(0, subMeshes.length);
  120924. if (sortCompareFn) {
  120925. sortedArray.sort(sortCompareFn);
  120926. }
  120927. for (subIndex = 0; subIndex < sortedArray.length; subIndex++) {
  120928. subMesh = sortedArray[subIndex];
  120929. if (transparent) {
  120930. var material = subMesh.getMaterial();
  120931. if (material && material.needDepthPrePass) {
  120932. var engine = material.getScene().getEngine();
  120933. engine.setColorWrite(false);
  120934. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  120935. subMesh.render(false);
  120936. engine.setColorWrite(true);
  120937. }
  120938. }
  120939. subMesh.render(transparent);
  120940. }
  120941. };
  120942. /**
  120943. * Renders the submeshes in the order they were dispatched (no sort applied).
  120944. * @param subMeshes The submeshes to render
  120945. */
  120946. RenderingGroup.renderUnsorted = function (subMeshes) {
  120947. for (var subIndex = 0; subIndex < subMeshes.length; subIndex++) {
  120948. var submesh = subMeshes.data[subIndex];
  120949. submesh.render(false);
  120950. }
  120951. };
  120952. /**
  120953. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  120954. * are rendered back to front if in the same alpha index.
  120955. *
  120956. * @param a The first submesh
  120957. * @param b The second submesh
  120958. * @returns The result of the comparison
  120959. */
  120960. RenderingGroup.defaultTransparentSortCompare = function (a, b) {
  120961. // Alpha index first
  120962. if (a._alphaIndex > b._alphaIndex) {
  120963. return 1;
  120964. }
  120965. if (a._alphaIndex < b._alphaIndex) {
  120966. return -1;
  120967. }
  120968. // Then distance to camera
  120969. return RenderingGroup.backToFrontSortCompare(a, b);
  120970. };
  120971. /**
  120972. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  120973. * are rendered back to front.
  120974. *
  120975. * @param a The first submesh
  120976. * @param b The second submesh
  120977. * @returns The result of the comparison
  120978. */
  120979. RenderingGroup.backToFrontSortCompare = function (a, b) {
  120980. // Then distance to camera
  120981. if (a._distanceToCamera < b._distanceToCamera) {
  120982. return 1;
  120983. }
  120984. if (a._distanceToCamera > b._distanceToCamera) {
  120985. return -1;
  120986. }
  120987. return 0;
  120988. };
  120989. /**
  120990. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  120991. * are rendered front to back (prevent overdraw).
  120992. *
  120993. * @param a The first submesh
  120994. * @param b The second submesh
  120995. * @returns The result of the comparison
  120996. */
  120997. RenderingGroup.frontToBackSortCompare = function (a, b) {
  120998. // Then distance to camera
  120999. if (a._distanceToCamera < b._distanceToCamera) {
  121000. return -1;
  121001. }
  121002. if (a._distanceToCamera > b._distanceToCamera) {
  121003. return 1;
  121004. }
  121005. return 0;
  121006. };
  121007. /**
  121008. * Resets the different lists of submeshes to prepare a new frame.
  121009. */
  121010. RenderingGroup.prototype.prepare = function () {
  121011. this._opaqueSubMeshes.reset();
  121012. this._transparentSubMeshes.reset();
  121013. this._alphaTestSubMeshes.reset();
  121014. this._depthOnlySubMeshes.reset();
  121015. this._particleSystems.reset();
  121016. this._spriteManagers.reset();
  121017. this._edgesRenderers.reset();
  121018. };
  121019. RenderingGroup.prototype.dispose = function () {
  121020. this._opaqueSubMeshes.dispose();
  121021. this._transparentSubMeshes.dispose();
  121022. this._alphaTestSubMeshes.dispose();
  121023. this._depthOnlySubMeshes.dispose();
  121024. this._particleSystems.dispose();
  121025. this._spriteManagers.dispose();
  121026. this._edgesRenderers.dispose();
  121027. };
  121028. /**
  121029. * Inserts the submesh in its correct queue depending on its material.
  121030. * @param subMesh The submesh to dispatch
  121031. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  121032. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  121033. */
  121034. RenderingGroup.prototype.dispatch = function (subMesh, mesh, material) {
  121035. // Get mesh and materials if not provided
  121036. if (mesh === undefined) {
  121037. mesh = subMesh.getMesh();
  121038. }
  121039. if (material === undefined) {
  121040. material = subMesh.getMaterial();
  121041. }
  121042. if (material === null || material === undefined) {
  121043. return;
  121044. }
  121045. if (material.needAlphaBlendingForMesh(mesh)) { // Transparent
  121046. this._transparentSubMeshes.push(subMesh);
  121047. }
  121048. else if (material.needAlphaTesting()) { // Alpha test
  121049. if (material.needDepthPrePass) {
  121050. this._depthOnlySubMeshes.push(subMesh);
  121051. }
  121052. this._alphaTestSubMeshes.push(subMesh);
  121053. }
  121054. else {
  121055. if (material.needDepthPrePass) {
  121056. this._depthOnlySubMeshes.push(subMesh);
  121057. }
  121058. this._opaqueSubMeshes.push(subMesh); // Opaque
  121059. }
  121060. if (mesh._edgesRenderer && mesh._edgesRenderer.isEnabled) {
  121061. this._edgesRenderers.push(mesh._edgesRenderer);
  121062. }
  121063. };
  121064. RenderingGroup.prototype.dispatchSprites = function (spriteManager) {
  121065. this._spriteManagers.push(spriteManager);
  121066. };
  121067. RenderingGroup.prototype.dispatchParticles = function (particleSystem) {
  121068. this._particleSystems.push(particleSystem);
  121069. };
  121070. RenderingGroup.prototype._renderParticles = function (activeMeshes) {
  121071. if (this._particleSystems.length === 0) {
  121072. return;
  121073. }
  121074. // Particles
  121075. var activeCamera = this._scene.activeCamera;
  121076. this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
  121077. for (var particleIndex = 0; particleIndex < this._particleSystems.length; particleIndex++) {
  121078. var particleSystem = this._particleSystems.data[particleIndex];
  121079. if ((activeCamera && activeCamera.layerMask & particleSystem.layerMask) === 0) {
  121080. continue;
  121081. }
  121082. var emitter = particleSystem.emitter;
  121083. if (!emitter.position || !activeMeshes || activeMeshes.indexOf(emitter) !== -1) {
  121084. this._scene._activeParticles.addCount(particleSystem.render(), false);
  121085. }
  121086. }
  121087. this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene);
  121088. };
  121089. RenderingGroup.prototype._renderSprites = function () {
  121090. if (!this._scene.spritesEnabled || this._spriteManagers.length === 0) {
  121091. return;
  121092. }
  121093. // Sprites
  121094. var activeCamera = this._scene.activeCamera;
  121095. this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
  121096. for (var id = 0; id < this._spriteManagers.length; id++) {
  121097. var spriteManager = this._spriteManagers.data[id];
  121098. if (((activeCamera && activeCamera.layerMask & spriteManager.layerMask) !== 0)) {
  121099. spriteManager.render();
  121100. }
  121101. }
  121102. this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene);
  121103. };
  121104. return RenderingGroup;
  121105. }());
  121106. /***/ }),
  121107. /***/ "./Rendering/renderingManager.ts":
  121108. /*!***************************************!*\
  121109. !*** ./Rendering/renderingManager.ts ***!
  121110. \***************************************/
  121111. /*! exports provided: RenderingGroupInfo, RenderingManager */
  121112. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121113. "use strict";
  121114. __webpack_require__.r(__webpack_exports__);
  121115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return RenderingGroupInfo; });
  121116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return RenderingManager; });
  121117. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  121118. /**
  121119. * This class is used by the onRenderingGroupObservable
  121120. */
  121121. var RenderingGroupInfo = /** @class */ (function () {
  121122. function RenderingGroupInfo() {
  121123. }
  121124. return RenderingGroupInfo;
  121125. }());
  121126. /**
  121127. * This is the manager responsible of all the rendering for meshes sprites and particles.
  121128. * It is enable to manage the different groups as well as the different necessary sort functions.
  121129. * This should not be used directly aside of the few static configurations
  121130. */
  121131. var RenderingManager = /** @class */ (function () {
  121132. /**
  121133. * Instantiates a new rendering group for a particular scene
  121134. * @param scene Defines the scene the groups belongs to
  121135. */
  121136. function RenderingManager(scene) {
  121137. /**
  121138. * @hidden
  121139. */
  121140. this._useSceneAutoClearSetup = false;
  121141. this._renderingGroups = new Array();
  121142. this._autoClearDepthStencil = {};
  121143. this._customOpaqueSortCompareFn = {};
  121144. this._customAlphaTestSortCompareFn = {};
  121145. this._customTransparentSortCompareFn = {};
  121146. this._renderingGroupInfo = new RenderingGroupInfo();
  121147. this._scene = scene;
  121148. for (var i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {
  121149. this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };
  121150. }
  121151. }
  121152. RenderingManager.prototype._clearDepthStencilBuffer = function (depth, stencil) {
  121153. if (depth === void 0) { depth = true; }
  121154. if (stencil === void 0) { stencil = true; }
  121155. if (this._depthStencilBufferAlreadyCleaned) {
  121156. return;
  121157. }
  121158. this._scene.getEngine().clear(null, false, depth, stencil);
  121159. this._depthStencilBufferAlreadyCleaned = true;
  121160. };
  121161. /**
  121162. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  121163. * @hidden
  121164. */
  121165. RenderingManager.prototype.render = function (customRenderFunction, activeMeshes, renderParticles, renderSprites) {
  121166. // Update the observable context (not null as it only goes away on dispose)
  121167. var info = this._renderingGroupInfo;
  121168. info.scene = this._scene;
  121169. info.camera = this._scene.activeCamera;
  121170. // Dispatch sprites
  121171. if (this._scene.spriteManagers && renderSprites) {
  121172. for (var index = 0; index < this._scene.spriteManagers.length; index++) {
  121173. var manager = this._scene.spriteManagers[index];
  121174. this.dispatchSprites(manager);
  121175. }
  121176. }
  121177. // Render
  121178. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  121179. this._depthStencilBufferAlreadyCleaned = index === RenderingManager.MIN_RENDERINGGROUPS;
  121180. var renderingGroup = this._renderingGroups[index];
  121181. if (!renderingGroup) {
  121182. continue;
  121183. }
  121184. var renderingGroupMask = Math.pow(2, index);
  121185. info.renderingGroupId = index;
  121186. // Before Observable
  121187. this._scene.onBeforeRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  121188. // Clear depth/stencil if needed
  121189. if (RenderingManager.AUTOCLEAR) {
  121190. var autoClear = this._useSceneAutoClearSetup ?
  121191. this._scene.getAutoClearDepthStencilSetup(index) :
  121192. this._autoClearDepthStencil[index];
  121193. if (autoClear && autoClear.autoClear) {
  121194. this._clearDepthStencilBuffer(autoClear.depth, autoClear.stencil);
  121195. }
  121196. }
  121197. // Render
  121198. for (var _i = 0, _a = this._scene._beforeRenderingGroupDrawStage; _i < _a.length; _i++) {
  121199. var step = _a[_i];
  121200. step.action(index);
  121201. }
  121202. renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes);
  121203. for (var _b = 0, _c = this._scene._afterRenderingGroupDrawStage; _b < _c.length; _b++) {
  121204. var step = _c[_b];
  121205. step.action(index);
  121206. }
  121207. // After Observable
  121208. this._scene.onAfterRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  121209. }
  121210. };
  121211. /**
  121212. * Resets the different information of the group to prepare a new frame
  121213. * @hidden
  121214. */
  121215. RenderingManager.prototype.reset = function () {
  121216. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  121217. var renderingGroup = this._renderingGroups[index];
  121218. if (renderingGroup) {
  121219. renderingGroup.prepare();
  121220. }
  121221. }
  121222. };
  121223. /**
  121224. * Dispose and release the group and its associated resources.
  121225. * @hidden
  121226. */
  121227. RenderingManager.prototype.dispose = function () {
  121228. this.freeRenderingGroups();
  121229. this._renderingGroups.length = 0;
  121230. this._renderingGroupInfo = null;
  121231. };
  121232. /**
  121233. * Clear the info related to rendering groups preventing retention points during dispose.
  121234. */
  121235. RenderingManager.prototype.freeRenderingGroups = function () {
  121236. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  121237. var renderingGroup = this._renderingGroups[index];
  121238. if (renderingGroup) {
  121239. renderingGroup.dispose();
  121240. }
  121241. }
  121242. };
  121243. RenderingManager.prototype._prepareRenderingGroup = function (renderingGroupId) {
  121244. if (this._renderingGroups[renderingGroupId] === undefined) {
  121245. this._renderingGroups[renderingGroupId] = new _renderingGroup__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"](renderingGroupId, this._scene, this._customOpaqueSortCompareFn[renderingGroupId], this._customAlphaTestSortCompareFn[renderingGroupId], this._customTransparentSortCompareFn[renderingGroupId]);
  121246. }
  121247. };
  121248. /**
  121249. * Add a sprite manager to the rendering manager in order to render it this frame.
  121250. * @param spriteManager Define the sprite manager to render
  121251. */
  121252. RenderingManager.prototype.dispatchSprites = function (spriteManager) {
  121253. var renderingGroupId = spriteManager.renderingGroupId || 0;
  121254. this._prepareRenderingGroup(renderingGroupId);
  121255. this._renderingGroups[renderingGroupId].dispatchSprites(spriteManager);
  121256. };
  121257. /**
  121258. * Add a particle system to the rendering manager in order to render it this frame.
  121259. * @param particleSystem Define the particle system to render
  121260. */
  121261. RenderingManager.prototype.dispatchParticles = function (particleSystem) {
  121262. var renderingGroupId = particleSystem.renderingGroupId || 0;
  121263. this._prepareRenderingGroup(renderingGroupId);
  121264. this._renderingGroups[renderingGroupId].dispatchParticles(particleSystem);
  121265. };
  121266. /**
  121267. * Add a submesh to the manager in order to render it this frame
  121268. * @param subMesh The submesh to dispatch
  121269. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  121270. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  121271. */
  121272. RenderingManager.prototype.dispatch = function (subMesh, mesh, material) {
  121273. if (mesh === undefined) {
  121274. mesh = subMesh.getMesh();
  121275. }
  121276. var renderingGroupId = mesh.renderingGroupId || 0;
  121277. this._prepareRenderingGroup(renderingGroupId);
  121278. this._renderingGroups[renderingGroupId].dispatch(subMesh, mesh, material);
  121279. };
  121280. /**
  121281. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  121282. * This allowed control for front to back rendering or reversly depending of the special needs.
  121283. *
  121284. * @param renderingGroupId The rendering group id corresponding to its index
  121285. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  121286. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  121287. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  121288. */
  121289. RenderingManager.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  121290. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  121291. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  121292. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  121293. this._customOpaqueSortCompareFn[renderingGroupId] = opaqueSortCompareFn;
  121294. this._customAlphaTestSortCompareFn[renderingGroupId] = alphaTestSortCompareFn;
  121295. this._customTransparentSortCompareFn[renderingGroupId] = transparentSortCompareFn;
  121296. if (this._renderingGroups[renderingGroupId]) {
  121297. var group = this._renderingGroups[renderingGroupId];
  121298. group.opaqueSortCompareFn = this._customOpaqueSortCompareFn[renderingGroupId];
  121299. group.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[renderingGroupId];
  121300. group.transparentSortCompareFn = this._customTransparentSortCompareFn[renderingGroupId];
  121301. }
  121302. };
  121303. /**
  121304. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  121305. *
  121306. * @param renderingGroupId The rendering group id corresponding to its index
  121307. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  121308. * @param depth Automatically clears depth between groups if true and autoClear is true.
  121309. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  121310. */
  121311. RenderingManager.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  121312. if (depth === void 0) { depth = true; }
  121313. if (stencil === void 0) { stencil = true; }
  121314. this._autoClearDepthStencil[renderingGroupId] = {
  121315. autoClear: autoClearDepthStencil,
  121316. depth: depth,
  121317. stencil: stencil
  121318. };
  121319. };
  121320. /**
  121321. * Gets the current auto clear configuration for one rendering group of the rendering
  121322. * manager.
  121323. * @param index the rendering group index to get the information for
  121324. * @returns The auto clear setup for the requested rendering group
  121325. */
  121326. RenderingManager.prototype.getAutoClearDepthStencilSetup = function (index) {
  121327. return this._autoClearDepthStencil[index];
  121328. };
  121329. /**
  121330. * The max id used for rendering groups (not included)
  121331. */
  121332. RenderingManager.MAX_RENDERINGGROUPS = 4;
  121333. /**
  121334. * The min id used for rendering groups (included)
  121335. */
  121336. RenderingManager.MIN_RENDERINGGROUPS = 0;
  121337. /**
  121338. * Used to globally prevent autoclearing scenes.
  121339. */
  121340. RenderingManager.AUTOCLEAR = true;
  121341. return RenderingManager;
  121342. }());
  121343. /***/ }),
  121344. /***/ "./Rendering/utilityLayerRenderer.ts":
  121345. /*!*******************************************!*\
  121346. !*** ./Rendering/utilityLayerRenderer.ts ***!
  121347. \*******************************************/
  121348. /*! exports provided: UtilityLayerRenderer */
  121349. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121350. "use strict";
  121351. __webpack_require__.r(__webpack_exports__);
  121352. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return UtilityLayerRenderer; });
  121353. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  121354. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  121355. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  121356. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  121357. /**
  121358. * Renders a layer on top of an existing scene
  121359. */
  121360. var UtilityLayerRenderer = /** @class */ (function () {
  121361. /**
  121362. * Instantiates a UtilityLayerRenderer
  121363. * @param originalScene the original scene that will be rendered on top of
  121364. * @param handleEvents boolean indicating if the utility layer should handle events
  121365. */
  121366. function UtilityLayerRenderer(
  121367. /** the original scene that will be rendered on top of */
  121368. originalScene, handleEvents) {
  121369. if (handleEvents === void 0) { handleEvents = true; }
  121370. var _this = this;
  121371. this.originalScene = originalScene;
  121372. this._pointerCaptures = {};
  121373. this._lastPointerEvents = {};
  121374. /**
  121375. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  121376. */
  121377. this.pickUtilitySceneFirst = true;
  121378. /**
  121379. * If the utility layer should automatically be rendered on top of existing scene
  121380. */
  121381. this.shouldRender = true;
  121382. /**
  121383. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  121384. */
  121385. this.onlyCheckPointerDownEvents = true;
  121386. /**
  121387. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  121388. */
  121389. this.processAllEvents = false;
  121390. /**
  121391. * Observable raised when the pointer move from the utility layer scene to the main scene
  121392. */
  121393. this.onPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  121394. // Create scene which will be rendered in the foreground and remove it from being referenced by engine to avoid interfering with existing app
  121395. this.utilityLayerScene = new _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"](originalScene.getEngine());
  121396. this.utilityLayerScene.useRightHandedSystem = originalScene.useRightHandedSystem;
  121397. this.utilityLayerScene._allowPostProcessClearColor = false;
  121398. originalScene.getEngine().scenes.pop();
  121399. // Detach controls on utility scene, events will be fired by logic below to handle picking priority
  121400. this.utilityLayerScene.detachControl();
  121401. if (handleEvents) {
  121402. this._originalPointerObserver = originalScene.onPrePointerObservable.add(function (prePointerInfo, eventState) {
  121403. if (!_this.utilityLayerScene.activeCamera) {
  121404. return;
  121405. }
  121406. if (!_this.processAllEvents) {
  121407. if (prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE
  121408. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP
  121409. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  121410. return;
  121411. }
  121412. }
  121413. _this.utilityLayerScene.pointerX = originalScene.pointerX;
  121414. _this.utilityLayerScene.pointerY = originalScene.pointerY;
  121415. var pointerEvent = (prePointerInfo.event);
  121416. if (originalScene.isPointerCaptured(pointerEvent.pointerId)) {
  121417. _this._pointerCaptures[pointerEvent.pointerId] = false;
  121418. return;
  121419. }
  121420. var utilityScenePick = prePointerInfo.ray ? _this.utilityLayerScene.pickWithRay(prePointerInfo.ray) : _this.utilityLayerScene.pick(originalScene.pointerX, originalScene.pointerY);
  121421. if (!prePointerInfo.ray && utilityScenePick) {
  121422. prePointerInfo.ray = utilityScenePick.ray;
  121423. }
  121424. // always fire the prepointer oversvable
  121425. _this.utilityLayerScene.onPrePointerObservable.notifyObservers(prePointerInfo);
  121426. // allow every non pointer down event to flow to the utility layer
  121427. if (_this.onlyCheckPointerDownEvents && prePointerInfo.type != _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  121428. if (!prePointerInfo.skipOnPointerObservable) {
  121429. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  121430. }
  121431. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent.pointerId]) {
  121432. _this._pointerCaptures[pointerEvent.pointerId] = false;
  121433. }
  121434. return;
  121435. }
  121436. if (_this.utilityLayerScene.autoClearDepthAndStencil || _this.pickUtilitySceneFirst) {
  121437. // If this layer is an overlay, check if this layer was hit and if so, skip pointer events for the main scene
  121438. if (utilityScenePick && utilityScenePick.hit) {
  121439. if (!prePointerInfo.skipOnPointerObservable) {
  121440. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  121441. }
  121442. prePointerInfo.skipOnPointerObservable = true;
  121443. }
  121444. }
  121445. else {
  121446. var originalScenePick = prePointerInfo.ray ? originalScene.pickWithRay(prePointerInfo.ray) : originalScene.pick(originalScene.pointerX, originalScene.pointerY);
  121447. var pointerEvent_1 = (prePointerInfo.event);
  121448. // If the layer can be occluded by the original scene, only fire pointer events to the first layer that hit they ray
  121449. if (originalScenePick && utilityScenePick) {
  121450. // No pick in utility scene
  121451. if (utilityScenePick.distance === 0 && originalScenePick.pickedMesh) {
  121452. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  121453. // We touched an utility mesh present in the main scene
  121454. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  121455. prePointerInfo.skipOnPointerObservable = true;
  121456. }
  121457. else if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  121458. _this._pointerCaptures[pointerEvent_1.pointerId] = true;
  121459. }
  121460. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  121461. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  121462. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  121463. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  121464. }
  121465. }
  121466. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance < originalScenePick.distance || originalScenePick.distance === 0)) {
  121467. // We pick something in utility scene or the pick in utility is closer than the one in main scene
  121468. _this._notifyObservers(prePointerInfo, utilityScenePick, pointerEvent_1);
  121469. // If a previous utility layer set this, do not unset this
  121470. if (!prePointerInfo.skipOnPointerObservable) {
  121471. prePointerInfo.skipOnPointerObservable = utilityScenePick.distance > 0;
  121472. }
  121473. }
  121474. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance > originalScenePick.distance)) {
  121475. // We have a pick in both scenes but main is closer than utility
  121476. // We touched an utility mesh present in the main scene
  121477. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  121478. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  121479. prePointerInfo.skipOnPointerObservable = true;
  121480. }
  121481. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  121482. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  121483. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  121484. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  121485. }
  121486. }
  121487. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent_1.pointerId]) {
  121488. _this._pointerCaptures[pointerEvent_1.pointerId] = false;
  121489. }
  121490. }
  121491. }
  121492. });
  121493. }
  121494. // Render directly on top of existing scene without clearing
  121495. this.utilityLayerScene.autoClear = false;
  121496. this._afterRenderObserver = this.originalScene.onAfterRenderObservable.add(function () {
  121497. if (_this.shouldRender) {
  121498. _this.render();
  121499. }
  121500. });
  121501. this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add(function () {
  121502. _this.dispose();
  121503. });
  121504. this._updateCamera();
  121505. }
  121506. Object.defineProperty(UtilityLayerRenderer, "DefaultUtilityLayer", {
  121507. /**
  121508. * 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)
  121509. */
  121510. get: function () {
  121511. if (UtilityLayerRenderer._DefaultUtilityLayer == null) {
  121512. UtilityLayerRenderer._DefaultUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  121513. UtilityLayerRenderer._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  121514. UtilityLayerRenderer._DefaultUtilityLayer = null;
  121515. });
  121516. }
  121517. return UtilityLayerRenderer._DefaultUtilityLayer;
  121518. },
  121519. enumerable: true,
  121520. configurable: true
  121521. });
  121522. Object.defineProperty(UtilityLayerRenderer, "DefaultKeepDepthUtilityLayer", {
  121523. /**
  121524. * 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)
  121525. */
  121526. get: function () {
  121527. if (UtilityLayerRenderer._DefaultKeepDepthUtilityLayer == null) {
  121528. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  121529. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  121530. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  121531. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  121532. });
  121533. }
  121534. return UtilityLayerRenderer._DefaultKeepDepthUtilityLayer;
  121535. },
  121536. enumerable: true,
  121537. configurable: true
  121538. });
  121539. UtilityLayerRenderer.prototype._notifyObservers = function (prePointerInfo, pickInfo, pointerEvent) {
  121540. if (!prePointerInfo.skipOnPointerObservable) {
  121541. this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, pickInfo));
  121542. this._lastPointerEvents[pointerEvent.pointerId] = true;
  121543. }
  121544. };
  121545. /**
  121546. * Renders the utility layers scene on top of the original scene
  121547. */
  121548. UtilityLayerRenderer.prototype.render = function () {
  121549. this._updateCamera();
  121550. if (this.utilityLayerScene.activeCamera) {
  121551. // Set the camera's scene to utility layers scene
  121552. var oldScene = this.utilityLayerScene.activeCamera.getScene();
  121553. var camera = this.utilityLayerScene.activeCamera;
  121554. camera._scene = this.utilityLayerScene;
  121555. if (camera.leftCamera) {
  121556. camera.leftCamera._scene = this.utilityLayerScene;
  121557. }
  121558. if (camera.rightCamera) {
  121559. camera.rightCamera._scene = this.utilityLayerScene;
  121560. }
  121561. this.utilityLayerScene.render(false);
  121562. // Reset camera's scene back to original
  121563. camera._scene = oldScene;
  121564. if (camera.leftCamera) {
  121565. camera.leftCamera._scene = oldScene;
  121566. }
  121567. if (camera.rightCamera) {
  121568. camera.rightCamera._scene = oldScene;
  121569. }
  121570. }
  121571. };
  121572. /**
  121573. * Disposes of the renderer
  121574. */
  121575. UtilityLayerRenderer.prototype.dispose = function () {
  121576. this.onPointerOutObservable.clear();
  121577. if (this._afterRenderObserver) {
  121578. this.originalScene.onAfterRenderObservable.remove(this._afterRenderObserver);
  121579. }
  121580. if (this._sceneDisposeObserver) {
  121581. this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver);
  121582. }
  121583. if (this._originalPointerObserver) {
  121584. this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver);
  121585. }
  121586. this.utilityLayerScene.dispose();
  121587. };
  121588. UtilityLayerRenderer.prototype._updateCamera = function () {
  121589. if (this.originalScene.activeCameras.length > 1) {
  121590. this.utilityLayerScene.activeCamera = this.originalScene.activeCameras[this.originalScene.activeCameras.length - 1];
  121591. }
  121592. else {
  121593. this.utilityLayerScene.activeCamera = this.originalScene.activeCamera;
  121594. }
  121595. };
  121596. UtilityLayerRenderer._DefaultUtilityLayer = null;
  121597. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  121598. return UtilityLayerRenderer;
  121599. }());
  121600. /***/ }),
  121601. /***/ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts":
  121602. /*!*****************************************************************!*\
  121603. !*** ./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts ***!
  121604. \*****************************************************************/
  121605. /*! exports provided: backgroundFragmentDeclaration */
  121606. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121607. "use strict";
  121608. __webpack_require__.r(__webpack_exports__);
  121609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundFragmentDeclaration", function() { return backgroundFragmentDeclaration; });
  121610. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121611. var name = 'backgroundFragmentDeclaration';
  121612. 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";
  121613. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121614. /** @hidden */
  121615. var backgroundFragmentDeclaration = { name: name, shader: shader };
  121616. /***/ }),
  121617. /***/ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts":
  121618. /*!************************************************************!*\
  121619. !*** ./Shaders/ShadersInclude/backgroundUboDeclaration.ts ***!
  121620. \************************************************************/
  121621. /*! exports provided: backgroundUboDeclaration */
  121622. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121623. "use strict";
  121624. __webpack_require__.r(__webpack_exports__);
  121625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundUboDeclaration", function() { return backgroundUboDeclaration; });
  121626. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121627. var name = 'backgroundUboDeclaration';
  121628. 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};";
  121629. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121630. /** @hidden */
  121631. var backgroundUboDeclaration = { name: name, shader: shader };
  121632. /***/ }),
  121633. /***/ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts":
  121634. /*!***************************************************************!*\
  121635. !*** ./Shaders/ShadersInclude/backgroundVertexDeclaration.ts ***!
  121636. \***************************************************************/
  121637. /*! exports provided: backgroundVertexDeclaration */
  121638. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121639. "use strict";
  121640. __webpack_require__.r(__webpack_exports__);
  121641. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexDeclaration", function() { return backgroundVertexDeclaration; });
  121642. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121643. var name = 'backgroundVertexDeclaration';
  121644. 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";
  121645. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121646. /** @hidden */
  121647. var backgroundVertexDeclaration = { name: name, shader: shader };
  121648. /***/ }),
  121649. /***/ "./Shaders/ShadersInclude/bonesDeclaration.ts":
  121650. /*!****************************************************!*\
  121651. !*** ./Shaders/ShadersInclude/bonesDeclaration.ts ***!
  121652. \****************************************************/
  121653. /*! exports provided: bonesDeclaration */
  121654. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121655. "use strict";
  121656. __webpack_require__.r(__webpack_exports__);
  121657. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesDeclaration", function() { return bonesDeclaration; });
  121658. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121659. var name = 'bonesDeclaration';
  121660. 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";
  121661. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121662. /** @hidden */
  121663. var bonesDeclaration = { name: name, shader: shader };
  121664. /***/ }),
  121665. /***/ "./Shaders/ShadersInclude/bonesVertex.ts":
  121666. /*!***********************************************!*\
  121667. !*** ./Shaders/ShadersInclude/bonesVertex.ts ***!
  121668. \***********************************************/
  121669. /*! exports provided: bonesVertex */
  121670. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121671. "use strict";
  121672. __webpack_require__.r(__webpack_exports__);
  121673. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesVertex", function() { return bonesVertex; });
  121674. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121675. var name = 'bonesVertex';
  121676. 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";
  121677. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121678. /** @hidden */
  121679. var bonesVertex = { name: name, shader: shader };
  121680. /***/ }),
  121681. /***/ "./Shaders/ShadersInclude/bumpFragment.ts":
  121682. /*!************************************************!*\
  121683. !*** ./Shaders/ShadersInclude/bumpFragment.ts ***!
  121684. \************************************************/
  121685. /*! exports provided: bumpFragment */
  121686. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121687. "use strict";
  121688. __webpack_require__.r(__webpack_exports__);
  121689. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragment", function() { return bumpFragment; });
  121690. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121691. var name = 'bumpFragment';
  121692. 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";
  121693. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121694. /** @hidden */
  121695. var bumpFragment = { name: name, shader: shader };
  121696. /***/ }),
  121697. /***/ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts":
  121698. /*!*********************************************************!*\
  121699. !*** ./Shaders/ShadersInclude/bumpFragmentFunctions.ts ***!
  121700. \*********************************************************/
  121701. /*! exports provided: bumpFragmentFunctions */
  121702. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121703. "use strict";
  121704. __webpack_require__.r(__webpack_exports__);
  121705. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragmentFunctions", function() { return bumpFragmentFunctions; });
  121706. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121707. var name = 'bumpFragmentFunctions';
  121708. 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";
  121709. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121710. /** @hidden */
  121711. var bumpFragmentFunctions = { name: name, shader: shader };
  121712. /***/ }),
  121713. /***/ "./Shaders/ShadersInclude/bumpVertex.ts":
  121714. /*!**********************************************!*\
  121715. !*** ./Shaders/ShadersInclude/bumpVertex.ts ***!
  121716. \**********************************************/
  121717. /*! exports provided: bumpVertex */
  121718. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121719. "use strict";
  121720. __webpack_require__.r(__webpack_exports__);
  121721. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertex", function() { return bumpVertex; });
  121722. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121723. var name = 'bumpVertex';
  121724. 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";
  121725. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121726. /** @hidden */
  121727. var bumpVertex = { name: name, shader: shader };
  121728. /***/ }),
  121729. /***/ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts":
  121730. /*!*********************************************************!*\
  121731. !*** ./Shaders/ShadersInclude/bumpVertexDeclaration.ts ***!
  121732. \*********************************************************/
  121733. /*! exports provided: bumpVertexDeclaration */
  121734. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121735. "use strict";
  121736. __webpack_require__.r(__webpack_exports__);
  121737. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertexDeclaration", function() { return bumpVertexDeclaration; });
  121738. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121739. var name = 'bumpVertexDeclaration';
  121740. var shader = "#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#endif\n";
  121741. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121742. /** @hidden */
  121743. var bumpVertexDeclaration = { name: name, shader: shader };
  121744. /***/ }),
  121745. /***/ "./Shaders/ShadersInclude/clipPlaneFragment.ts":
  121746. /*!*****************************************************!*\
  121747. !*** ./Shaders/ShadersInclude/clipPlaneFragment.ts ***!
  121748. \*****************************************************/
  121749. /*! exports provided: clipPlaneFragment */
  121750. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121751. "use strict";
  121752. __webpack_require__.r(__webpack_exports__);
  121753. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragment", function() { return clipPlaneFragment; });
  121754. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121755. var name = 'clipPlaneFragment';
  121756. 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";
  121757. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121758. /** @hidden */
  121759. var clipPlaneFragment = { name: name, shader: shader };
  121760. /***/ }),
  121761. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts":
  121762. /*!****************************************************************!*\
  121763. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts ***!
  121764. \****************************************************************/
  121765. /*! exports provided: clipPlaneFragmentDeclaration */
  121766. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121767. "use strict";
  121768. __webpack_require__.r(__webpack_exports__);
  121769. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration", function() { return clipPlaneFragmentDeclaration; });
  121770. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121771. var name = 'clipPlaneFragmentDeclaration';
  121772. 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";
  121773. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121774. /** @hidden */
  121775. var clipPlaneFragmentDeclaration = { name: name, shader: shader };
  121776. /***/ }),
  121777. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts":
  121778. /*!*****************************************************************!*\
  121779. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts ***!
  121780. \*****************************************************************/
  121781. /*! exports provided: clipPlaneFragmentDeclaration2 */
  121782. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121783. "use strict";
  121784. __webpack_require__.r(__webpack_exports__);
  121785. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration2", function() { return clipPlaneFragmentDeclaration2; });
  121786. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121787. var name = 'clipPlaneFragmentDeclaration2';
  121788. 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";
  121789. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121790. /** @hidden */
  121791. var clipPlaneFragmentDeclaration2 = { name: name, shader: shader };
  121792. /***/ }),
  121793. /***/ "./Shaders/ShadersInclude/clipPlaneVertex.ts":
  121794. /*!***************************************************!*\
  121795. !*** ./Shaders/ShadersInclude/clipPlaneVertex.ts ***!
  121796. \***************************************************/
  121797. /*! exports provided: clipPlaneVertex */
  121798. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121799. "use strict";
  121800. __webpack_require__.r(__webpack_exports__);
  121801. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertex", function() { return clipPlaneVertex; });
  121802. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121803. var name = 'clipPlaneVertex';
  121804. 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";
  121805. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121806. /** @hidden */
  121807. var clipPlaneVertex = { name: name, shader: shader };
  121808. /***/ }),
  121809. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts":
  121810. /*!**************************************************************!*\
  121811. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts ***!
  121812. \**************************************************************/
  121813. /*! exports provided: clipPlaneVertexDeclaration */
  121814. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121815. "use strict";
  121816. __webpack_require__.r(__webpack_exports__);
  121817. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration", function() { return clipPlaneVertexDeclaration; });
  121818. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121819. var name = 'clipPlaneVertexDeclaration';
  121820. 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";
  121821. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121822. /** @hidden */
  121823. var clipPlaneVertexDeclaration = { name: name, shader: shader };
  121824. /***/ }),
  121825. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts":
  121826. /*!***************************************************************!*\
  121827. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts ***!
  121828. \***************************************************************/
  121829. /*! exports provided: clipPlaneVertexDeclaration2 */
  121830. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121831. "use strict";
  121832. __webpack_require__.r(__webpack_exports__);
  121833. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration2", function() { return clipPlaneVertexDeclaration2; });
  121834. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121835. var name = 'clipPlaneVertexDeclaration2';
  121836. 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";
  121837. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121838. /** @hidden */
  121839. var clipPlaneVertexDeclaration2 = { name: name, shader: shader };
  121840. /***/ }),
  121841. /***/ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts":
  121842. /*!**************************************************************!*\
  121843. !*** ./Shaders/ShadersInclude/defaultFragmentDeclaration.ts ***!
  121844. \**************************************************************/
  121845. /*! exports provided: defaultFragmentDeclaration */
  121846. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121847. "use strict";
  121848. __webpack_require__.r(__webpack_exports__);
  121849. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultFragmentDeclaration", function() { return defaultFragmentDeclaration; });
  121850. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121851. var name = 'defaultFragmentDeclaration';
  121852. 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";
  121853. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121854. /** @hidden */
  121855. var defaultFragmentDeclaration = { name: name, shader: shader };
  121856. /***/ }),
  121857. /***/ "./Shaders/ShadersInclude/defaultUboDeclaration.ts":
  121858. /*!*********************************************************!*\
  121859. !*** ./Shaders/ShadersInclude/defaultUboDeclaration.ts ***!
  121860. \*********************************************************/
  121861. /*! exports provided: defaultUboDeclaration */
  121862. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121863. "use strict";
  121864. __webpack_require__.r(__webpack_exports__);
  121865. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultUboDeclaration", function() { return defaultUboDeclaration; });
  121866. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121867. var name = 'defaultUboDeclaration';
  121868. 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};";
  121869. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121870. /** @hidden */
  121871. var defaultUboDeclaration = { name: name, shader: shader };
  121872. /***/ }),
  121873. /***/ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts":
  121874. /*!************************************************************!*\
  121875. !*** ./Shaders/ShadersInclude/defaultVertexDeclaration.ts ***!
  121876. \************************************************************/
  121877. /*! exports provided: defaultVertexDeclaration */
  121878. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121879. "use strict";
  121880. __webpack_require__.r(__webpack_exports__);
  121881. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexDeclaration", function() { return defaultVertexDeclaration; });
  121882. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121883. var name = 'defaultVertexDeclaration';
  121884. 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";
  121885. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121886. /** @hidden */
  121887. var defaultVertexDeclaration = { name: name, shader: shader };
  121888. /***/ }),
  121889. /***/ "./Shaders/ShadersInclude/depthPrePass.ts":
  121890. /*!************************************************!*\
  121891. !*** ./Shaders/ShadersInclude/depthPrePass.ts ***!
  121892. \************************************************/
  121893. /*! exports provided: depthPrePass */
  121894. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121895. "use strict";
  121896. __webpack_require__.r(__webpack_exports__);
  121897. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPrePass", function() { return depthPrePass; });
  121898. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121899. var name = 'depthPrePass';
  121900. var shader = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  121901. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121902. /** @hidden */
  121903. var depthPrePass = { name: name, shader: shader };
  121904. /***/ }),
  121905. /***/ "./Shaders/ShadersInclude/fogFragment.ts":
  121906. /*!***********************************************!*\
  121907. !*** ./Shaders/ShadersInclude/fogFragment.ts ***!
  121908. \***********************************************/
  121909. /*! exports provided: fogFragment */
  121910. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121911. "use strict";
  121912. __webpack_require__.r(__webpack_exports__);
  121913. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragment", function() { return fogFragment; });
  121914. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121915. var name = 'fogFragment';
  121916. var shader = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  121917. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121918. /** @hidden */
  121919. var fogFragment = { name: name, shader: shader };
  121920. /***/ }),
  121921. /***/ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts":
  121922. /*!**********************************************************!*\
  121923. !*** ./Shaders/ShadersInclude/fogFragmentDeclaration.ts ***!
  121924. \**********************************************************/
  121925. /*! exports provided: fogFragmentDeclaration */
  121926. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121927. "use strict";
  121928. __webpack_require__.r(__webpack_exports__);
  121929. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragmentDeclaration", function() { return fogFragmentDeclaration; });
  121930. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121931. var name = 'fogFragmentDeclaration';
  121932. 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";
  121933. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121934. /** @hidden */
  121935. var fogFragmentDeclaration = { name: name, shader: shader };
  121936. /***/ }),
  121937. /***/ "./Shaders/ShadersInclude/fogVertex.ts":
  121938. /*!*********************************************!*\
  121939. !*** ./Shaders/ShadersInclude/fogVertex.ts ***!
  121940. \*********************************************/
  121941. /*! exports provided: fogVertex */
  121942. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121943. "use strict";
  121944. __webpack_require__.r(__webpack_exports__);
  121945. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertex", function() { return fogVertex; });
  121946. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121947. var name = 'fogVertex';
  121948. var shader = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  121949. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121950. /** @hidden */
  121951. var fogVertex = { name: name, shader: shader };
  121952. /***/ }),
  121953. /***/ "./Shaders/ShadersInclude/fogVertexDeclaration.ts":
  121954. /*!********************************************************!*\
  121955. !*** ./Shaders/ShadersInclude/fogVertexDeclaration.ts ***!
  121956. \********************************************************/
  121957. /*! exports provided: fogVertexDeclaration */
  121958. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121959. "use strict";
  121960. __webpack_require__.r(__webpack_exports__);
  121961. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertexDeclaration", function() { return fogVertexDeclaration; });
  121962. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121963. var name = 'fogVertexDeclaration';
  121964. var shader = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  121965. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121966. /** @hidden */
  121967. var fogVertexDeclaration = { name: name, shader: shader };
  121968. /***/ }),
  121969. /***/ "./Shaders/ShadersInclude/fresnelFunction.ts":
  121970. /*!***************************************************!*\
  121971. !*** ./Shaders/ShadersInclude/fresnelFunction.ts ***!
  121972. \***************************************************/
  121973. /*! exports provided: fresnelFunction */
  121974. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121975. "use strict";
  121976. __webpack_require__.r(__webpack_exports__);
  121977. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fresnelFunction", function() { return fresnelFunction; });
  121978. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121979. var name = 'fresnelFunction';
  121980. 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";
  121981. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121982. /** @hidden */
  121983. var fresnelFunction = { name: name, shader: shader };
  121984. /***/ }),
  121985. /***/ "./Shaders/ShadersInclude/harmonicsFunctions.ts":
  121986. /*!******************************************************!*\
  121987. !*** ./Shaders/ShadersInclude/harmonicsFunctions.ts ***!
  121988. \******************************************************/
  121989. /*! exports provided: harmonicsFunctions */
  121990. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121991. "use strict";
  121992. __webpack_require__.r(__webpack_exports__);
  121993. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "harmonicsFunctions", function() { return harmonicsFunctions; });
  121994. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121995. var name = 'harmonicsFunctions';
  121996. 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";
  121997. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121998. /** @hidden */
  121999. var harmonicsFunctions = { name: name, shader: shader };
  122000. /***/ }),
  122001. /***/ "./Shaders/ShadersInclude/helperFunctions.ts":
  122002. /*!***************************************************!*\
  122003. !*** ./Shaders/ShadersInclude/helperFunctions.ts ***!
  122004. \***************************************************/
  122005. /*! exports provided: helperFunctions */
  122006. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122007. "use strict";
  122008. __webpack_require__.r(__webpack_exports__);
  122009. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "helperFunctions", function() { return helperFunctions; });
  122010. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122011. var name = 'helperFunctions';
  122012. 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}";
  122013. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122014. /** @hidden */
  122015. var helperFunctions = { name: name, shader: shader };
  122016. /***/ }),
  122017. /***/ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts":
  122018. /*!**************************************************************!*\
  122019. !*** ./Shaders/ShadersInclude/imageProcessingDeclaration.ts ***!
  122020. \**************************************************************/
  122021. /*! exports provided: imageProcessingDeclaration */
  122022. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122023. "use strict";
  122024. __webpack_require__.r(__webpack_exports__);
  122025. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingDeclaration", function() { return imageProcessingDeclaration; });
  122026. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122027. var name = 'imageProcessingDeclaration';
  122028. 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";
  122029. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122030. /** @hidden */
  122031. var imageProcessingDeclaration = { name: name, shader: shader };
  122032. /***/ }),
  122033. /***/ "./Shaders/ShadersInclude/imageProcessingFunctions.ts":
  122034. /*!************************************************************!*\
  122035. !*** ./Shaders/ShadersInclude/imageProcessingFunctions.ts ***!
  122036. \************************************************************/
  122037. /*! exports provided: imageProcessingFunctions */
  122038. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122039. "use strict";
  122040. __webpack_require__.r(__webpack_exports__);
  122041. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingFunctions", function() { return imageProcessingFunctions; });
  122042. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122043. var name = 'imageProcessingFunctions';
  122044. 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}";
  122045. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122046. /** @hidden */
  122047. var imageProcessingFunctions = { name: name, shader: shader };
  122048. /***/ }),
  122049. /***/ "./Shaders/ShadersInclude/instancesDeclaration.ts":
  122050. /*!********************************************************!*\
  122051. !*** ./Shaders/ShadersInclude/instancesDeclaration.ts ***!
  122052. \********************************************************/
  122053. /*! exports provided: instancesDeclaration */
  122054. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122055. "use strict";
  122056. __webpack_require__.r(__webpack_exports__);
  122057. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesDeclaration", function() { return instancesDeclaration; });
  122058. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122059. var name = 'instancesDeclaration';
  122060. var shader = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif";
  122061. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122062. /** @hidden */
  122063. var instancesDeclaration = { name: name, shader: shader };
  122064. /***/ }),
  122065. /***/ "./Shaders/ShadersInclude/instancesVertex.ts":
  122066. /*!***************************************************!*\
  122067. !*** ./Shaders/ShadersInclude/instancesVertex.ts ***!
  122068. \***************************************************/
  122069. /*! exports provided: instancesVertex */
  122070. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122071. "use strict";
  122072. __webpack_require__.r(__webpack_exports__);
  122073. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesVertex", function() { return instancesVertex; });
  122074. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122075. var name = 'instancesVertex';
  122076. var shader = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  122077. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122078. /** @hidden */
  122079. var instancesVertex = { name: name, shader: shader };
  122080. /***/ }),
  122081. /***/ "./Shaders/ShadersInclude/kernelBlurFragment.ts":
  122082. /*!******************************************************!*\
  122083. !*** ./Shaders/ShadersInclude/kernelBlurFragment.ts ***!
  122084. \******************************************************/
  122085. /*! exports provided: kernelBlurFragment */
  122086. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122087. "use strict";
  122088. __webpack_require__.r(__webpack_exports__);
  122089. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment", function() { return kernelBlurFragment; });
  122090. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122091. var name = 'kernelBlurFragment';
  122092. 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";
  122093. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122094. /** @hidden */
  122095. var kernelBlurFragment = { name: name, shader: shader };
  122096. /***/ }),
  122097. /***/ "./Shaders/ShadersInclude/kernelBlurFragment2.ts":
  122098. /*!*******************************************************!*\
  122099. !*** ./Shaders/ShadersInclude/kernelBlurFragment2.ts ***!
  122100. \*******************************************************/
  122101. /*! exports provided: kernelBlurFragment2 */
  122102. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122103. "use strict";
  122104. __webpack_require__.r(__webpack_exports__);
  122105. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment2", function() { return kernelBlurFragment2; });
  122106. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122107. var name = 'kernelBlurFragment2';
  122108. 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";
  122109. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122110. /** @hidden */
  122111. var kernelBlurFragment2 = { name: name, shader: shader };
  122112. /***/ }),
  122113. /***/ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts":
  122114. /*!****************************************************************!*\
  122115. !*** ./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts ***!
  122116. \****************************************************************/
  122117. /*! exports provided: kernelBlurVaryingDeclaration */
  122118. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122119. "use strict";
  122120. __webpack_require__.r(__webpack_exports__);
  122121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVaryingDeclaration", function() { return kernelBlurVaryingDeclaration; });
  122122. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122123. var name = 'kernelBlurVaryingDeclaration';
  122124. var shader = "varying vec2 sampleCoord{X};";
  122125. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122126. /** @hidden */
  122127. var kernelBlurVaryingDeclaration = { name: name, shader: shader };
  122128. /***/ }),
  122129. /***/ "./Shaders/ShadersInclude/kernelBlurVertex.ts":
  122130. /*!****************************************************!*\
  122131. !*** ./Shaders/ShadersInclude/kernelBlurVertex.ts ***!
  122132. \****************************************************/
  122133. /*! exports provided: kernelBlurVertex */
  122134. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122135. "use strict";
  122136. __webpack_require__.r(__webpack_exports__);
  122137. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertex", function() { return kernelBlurVertex; });
  122138. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122139. var name = 'kernelBlurVertex';
  122140. var shader = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
  122141. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122142. /** @hidden */
  122143. var kernelBlurVertex = { name: name, shader: shader };
  122144. /***/ }),
  122145. /***/ "./Shaders/ShadersInclude/lightFragment.ts":
  122146. /*!*************************************************!*\
  122147. !*** ./Shaders/ShadersInclude/lightFragment.ts ***!
  122148. \*************************************************/
  122149. /*! exports provided: lightFragment */
  122150. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122151. "use strict";
  122152. __webpack_require__.r(__webpack_exports__);
  122153. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragment", function() { return lightFragment; });
  122154. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122155. var name = 'lightFragment';
  122156. 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";
  122157. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122158. /** @hidden */
  122159. var lightFragment = { name: name, shader: shader };
  122160. /***/ }),
  122161. /***/ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts":
  122162. /*!************************************************************!*\
  122163. !*** ./Shaders/ShadersInclude/lightFragmentDeclaration.ts ***!
  122164. \************************************************************/
  122165. /*! exports provided: lightFragmentDeclaration */
  122166. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122167. "use strict";
  122168. __webpack_require__.r(__webpack_exports__);
  122169. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragmentDeclaration", function() { return lightFragmentDeclaration; });
  122170. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122171. var name = 'lightFragmentDeclaration';
  122172. 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";
  122173. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122174. /** @hidden */
  122175. var lightFragmentDeclaration = { name: name, shader: shader };
  122176. /***/ }),
  122177. /***/ "./Shaders/ShadersInclude/lightUboDeclaration.ts":
  122178. /*!*******************************************************!*\
  122179. !*** ./Shaders/ShadersInclude/lightUboDeclaration.ts ***!
  122180. \*******************************************************/
  122181. /*! exports provided: lightUboDeclaration */
  122182. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122183. "use strict";
  122184. __webpack_require__.r(__webpack_exports__);
  122185. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightUboDeclaration", function() { return lightUboDeclaration; });
  122186. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122187. var name = 'lightUboDeclaration';
  122188. 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";
  122189. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122190. /** @hidden */
  122191. var lightUboDeclaration = { name: name, shader: shader };
  122192. /***/ }),
  122193. /***/ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts":
  122194. /*!***********************************************************!*\
  122195. !*** ./Shaders/ShadersInclude/lightsFragmentFunctions.ts ***!
  122196. \***********************************************************/
  122197. /*! exports provided: lightsFragmentFunctions */
  122198. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122199. "use strict";
  122200. __webpack_require__.r(__webpack_exports__);
  122201. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightsFragmentFunctions", function() { return lightsFragmentFunctions; });
  122202. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122203. var name = 'lightsFragmentFunctions';
  122204. 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}";
  122205. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122206. /** @hidden */
  122207. var lightsFragmentFunctions = { name: name, shader: shader };
  122208. /***/ }),
  122209. /***/ "./Shaders/ShadersInclude/logDepthDeclaration.ts":
  122210. /*!*******************************************************!*\
  122211. !*** ./Shaders/ShadersInclude/logDepthDeclaration.ts ***!
  122212. \*******************************************************/
  122213. /*! exports provided: logDepthDeclaration */
  122214. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122215. "use strict";
  122216. __webpack_require__.r(__webpack_exports__);
  122217. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthDeclaration", function() { return logDepthDeclaration; });
  122218. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122219. var name = 'logDepthDeclaration';
  122220. var shader = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  122221. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122222. /** @hidden */
  122223. var logDepthDeclaration = { name: name, shader: shader };
  122224. /***/ }),
  122225. /***/ "./Shaders/ShadersInclude/logDepthFragment.ts":
  122226. /*!****************************************************!*\
  122227. !*** ./Shaders/ShadersInclude/logDepthFragment.ts ***!
  122228. \****************************************************/
  122229. /*! exports provided: logDepthFragment */
  122230. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122231. "use strict";
  122232. __webpack_require__.r(__webpack_exports__);
  122233. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthFragment", function() { return logDepthFragment; });
  122234. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122235. var name = 'logDepthFragment';
  122236. var shader = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  122237. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122238. /** @hidden */
  122239. var logDepthFragment = { name: name, shader: shader };
  122240. /***/ }),
  122241. /***/ "./Shaders/ShadersInclude/logDepthVertex.ts":
  122242. /*!**************************************************!*\
  122243. !*** ./Shaders/ShadersInclude/logDepthVertex.ts ***!
  122244. \**************************************************/
  122245. /*! exports provided: logDepthVertex */
  122246. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122247. "use strict";
  122248. __webpack_require__.r(__webpack_exports__);
  122249. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthVertex", function() { return logDepthVertex; });
  122250. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122251. var name = 'logDepthVertex';
  122252. var shader = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  122253. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122254. /** @hidden */
  122255. var logDepthVertex = { name: name, shader: shader };
  122256. /***/ }),
  122257. /***/ "./Shaders/ShadersInclude/morphTargetsVertex.ts":
  122258. /*!******************************************************!*\
  122259. !*** ./Shaders/ShadersInclude/morphTargetsVertex.ts ***!
  122260. \******************************************************/
  122261. /*! exports provided: morphTargetsVertex */
  122262. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122263. "use strict";
  122264. __webpack_require__.r(__webpack_exports__);
  122265. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertex", function() { return morphTargetsVertex; });
  122266. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122267. var name = 'morphTargetsVertex';
  122268. 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";
  122269. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122270. /** @hidden */
  122271. var morphTargetsVertex = { name: name, shader: shader };
  122272. /***/ }),
  122273. /***/ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts":
  122274. /*!*****************************************************************!*\
  122275. !*** ./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts ***!
  122276. \*****************************************************************/
  122277. /*! exports provided: morphTargetsVertexDeclaration */
  122278. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122279. "use strict";
  122280. __webpack_require__.r(__webpack_exports__);
  122281. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexDeclaration", function() { return morphTargetsVertexDeclaration; });
  122282. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122283. var name = 'morphTargetsVertexDeclaration';
  122284. 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";
  122285. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122286. /** @hidden */
  122287. var morphTargetsVertexDeclaration = { name: name, shader: shader };
  122288. /***/ }),
  122289. /***/ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts":
  122290. /*!***********************************************************************!*\
  122291. !*** ./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts ***!
  122292. \***********************************************************************/
  122293. /*! exports provided: morphTargetsVertexGlobalDeclaration */
  122294. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122295. "use strict";
  122296. __webpack_require__.r(__webpack_exports__);
  122297. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexGlobalDeclaration", function() { return morphTargetsVertexGlobalDeclaration; });
  122298. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122299. var name = 'morphTargetsVertexGlobalDeclaration';
  122300. var shader = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  122301. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122302. /** @hidden */
  122303. var morphTargetsVertexGlobalDeclaration = { name: name, shader: shader };
  122304. /***/ }),
  122305. /***/ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts":
  122306. /*!**********************************************************!*\
  122307. !*** ./Shaders/ShadersInclude/mrtFragmentDeclaration.ts ***!
  122308. \**********************************************************/
  122309. /*! exports provided: mrtFragmentDeclaration */
  122310. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122311. "use strict";
  122312. __webpack_require__.r(__webpack_exports__);
  122313. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mrtFragmentDeclaration", function() { return mrtFragmentDeclaration; });
  122314. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122315. var name = 'mrtFragmentDeclaration';
  122316. var shader = "#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";
  122317. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122318. /** @hidden */
  122319. var mrtFragmentDeclaration = { name: name, shader: shader };
  122320. /***/ }),
  122321. /***/ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts":
  122322. /*!**********************************************************!*\
  122323. !*** ./Shaders/ShadersInclude/pbrFragmentDeclaration.ts ***!
  122324. \**********************************************************/
  122325. /*! exports provided: pbrFragmentDeclaration */
  122326. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122327. "use strict";
  122328. __webpack_require__.r(__webpack_exports__);
  122329. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentDeclaration", function() { return pbrFragmentDeclaration; });
  122330. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122331. var name = 'pbrFragmentDeclaration';
  122332. 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";
  122333. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122334. /** @hidden */
  122335. var pbrFragmentDeclaration = { name: name, shader: shader };
  122336. /***/ }),
  122337. /***/ "./Shaders/ShadersInclude/pbrFunctions.ts":
  122338. /*!************************************************!*\
  122339. !*** ./Shaders/ShadersInclude/pbrFunctions.ts ***!
  122340. \************************************************/
  122341. /*! exports provided: pbrFunctions */
  122342. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122343. "use strict";
  122344. __webpack_require__.r(__webpack_exports__);
  122345. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFunctions", function() { return pbrFunctions; });
  122346. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122347. var name = 'pbrFunctions';
  122348. 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}";
  122349. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122350. /** @hidden */
  122351. var pbrFunctions = { name: name, shader: shader };
  122352. /***/ }),
  122353. /***/ "./Shaders/ShadersInclude/pbrLightFunctions.ts":
  122354. /*!*****************************************************!*\
  122355. !*** ./Shaders/ShadersInclude/pbrLightFunctions.ts ***!
  122356. \*****************************************************/
  122357. /*! exports provided: pbrLightFunctions */
  122358. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122359. "use strict";
  122360. __webpack_require__.r(__webpack_exports__);
  122361. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrLightFunctions", function() { return pbrLightFunctions; });
  122362. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122363. var name = 'pbrLightFunctions';
  122364. 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}";
  122365. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122366. /** @hidden */
  122367. var pbrLightFunctions = { name: name, shader: shader };
  122368. /***/ }),
  122369. /***/ "./Shaders/ShadersInclude/pbrUboDeclaration.ts":
  122370. /*!*****************************************************!*\
  122371. !*** ./Shaders/ShadersInclude/pbrUboDeclaration.ts ***!
  122372. \*****************************************************/
  122373. /*! exports provided: pbrUboDeclaration */
  122374. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122375. "use strict";
  122376. __webpack_require__.r(__webpack_exports__);
  122377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrUboDeclaration", function() { return pbrUboDeclaration; });
  122378. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122379. var name = 'pbrUboDeclaration';
  122380. 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};";
  122381. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122382. /** @hidden */
  122383. var pbrUboDeclaration = { name: name, shader: shader };
  122384. /***/ }),
  122385. /***/ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts":
  122386. /*!********************************************************!*\
  122387. !*** ./Shaders/ShadersInclude/pbrVertexDeclaration.ts ***!
  122388. \********************************************************/
  122389. /*! exports provided: pbrVertexDeclaration */
  122390. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122391. "use strict";
  122392. __webpack_require__.r(__webpack_exports__);
  122393. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexDeclaration", function() { return pbrVertexDeclaration; });
  122394. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122395. var name = 'pbrVertexDeclaration';
  122396. 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";
  122397. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122398. /** @hidden */
  122399. var pbrVertexDeclaration = { name: name, shader: shader };
  122400. /***/ }),
  122401. /***/ "./Shaders/ShadersInclude/pointCloudVertex.ts":
  122402. /*!****************************************************!*\
  122403. !*** ./Shaders/ShadersInclude/pointCloudVertex.ts ***!
  122404. \****************************************************/
  122405. /*! exports provided: pointCloudVertex */
  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__, "pointCloudVertex", function() { return pointCloudVertex; });
  122410. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122411. var name = 'pointCloudVertex';
  122412. var shader = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  122413. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122414. /** @hidden */
  122415. var pointCloudVertex = { name: name, shader: shader };
  122416. /***/ }),
  122417. /***/ "./Shaders/ShadersInclude/reflectionFunction.ts":
  122418. /*!******************************************************!*\
  122419. !*** ./Shaders/ShadersInclude/reflectionFunction.ts ***!
  122420. \******************************************************/
  122421. /*! exports provided: reflectionFunction */
  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__, "reflectionFunction", function() { return reflectionFunction; });
  122426. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122427. var name = 'reflectionFunction';
  122428. 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}";
  122429. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122430. /** @hidden */
  122431. var reflectionFunction = { name: name, shader: shader };
  122432. /***/ }),
  122433. /***/ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts":
  122434. /*!************************************************************!*\
  122435. !*** ./Shaders/ShadersInclude/shadowsFragmentFunctions.ts ***!
  122436. \************************************************************/
  122437. /*! exports provided: shadowsFragmentFunctions */
  122438. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122439. "use strict";
  122440. __webpack_require__.r(__webpack_exports__);
  122441. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsFragmentFunctions", function() { return shadowsFragmentFunctions; });
  122442. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122443. var name = 'shadowsFragmentFunctions';
  122444. 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";
  122445. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122446. /** @hidden */
  122447. var shadowsFragmentFunctions = { name: name, shader: shader };
  122448. /***/ }),
  122449. /***/ "./Shaders/ShadersInclude/shadowsVertex.ts":
  122450. /*!*************************************************!*\
  122451. !*** ./Shaders/ShadersInclude/shadowsVertex.ts ***!
  122452. \*************************************************/
  122453. /*! exports provided: shadowsVertex */
  122454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122455. "use strict";
  122456. __webpack_require__.r(__webpack_exports__);
  122457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsVertex", function() { return shadowsVertex; });
  122458. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122459. var name = 'shadowsVertex';
  122460. 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";
  122461. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122462. /** @hidden */
  122463. var shadowsVertex = { name: name, shader: shader };
  122464. /***/ }),
  122465. /***/ "./Shaders/anaglyph.fragment.ts":
  122466. /*!**************************************!*\
  122467. !*** ./Shaders/anaglyph.fragment.ts ***!
  122468. \**************************************/
  122469. /*! exports provided: anaglyphPixelShader */
  122470. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122471. "use strict";
  122472. __webpack_require__.r(__webpack_exports__);
  122473. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "anaglyphPixelShader", function() { return anaglyphPixelShader; });
  122474. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122475. var name = 'anaglyphPixelShader';
  122476. 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}";
  122477. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122478. /** @hidden */
  122479. var anaglyphPixelShader = { name: name, shader: shader };
  122480. /***/ }),
  122481. /***/ "./Shaders/background.fragment.ts":
  122482. /*!****************************************!*\
  122483. !*** ./Shaders/background.fragment.ts ***!
  122484. \****************************************/
  122485. /*! exports provided: backgroundPixelShader */
  122486. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122487. "use strict";
  122488. __webpack_require__.r(__webpack_exports__);
  122489. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundPixelShader", function() { return backgroundPixelShader; });
  122490. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122491. /* harmony import */ var _ShadersInclude_backgroundFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundFragmentDeclaration */ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts");
  122492. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  122493. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  122494. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  122495. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  122496. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  122497. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  122498. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  122499. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  122500. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  122501. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  122502. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  122503. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  122504. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  122505. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  122506. var name = 'backgroundPixelShader';
  122507. 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";
  122508. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122509. /** @hidden */
  122510. var backgroundPixelShader = { name: name, shader: shader };
  122511. /***/ }),
  122512. /***/ "./Shaders/background.vertex.ts":
  122513. /*!**************************************!*\
  122514. !*** ./Shaders/background.vertex.ts ***!
  122515. \**************************************/
  122516. /*! exports provided: backgroundVertexShader */
  122517. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122518. "use strict";
  122519. __webpack_require__.r(__webpack_exports__);
  122520. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexShader", function() { return backgroundVertexShader; });
  122521. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122522. /* harmony import */ var _ShadersInclude_backgroundVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundVertexDeclaration */ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts");
  122523. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  122524. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  122525. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  122526. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  122527. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  122528. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  122529. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  122530. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  122531. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  122532. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  122533. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  122534. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  122535. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  122536. var name = 'backgroundVertexShader';
  122537. 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";
  122538. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122539. /** @hidden */
  122540. var backgroundVertexShader = { name: name, shader: shader };
  122541. /***/ }),
  122542. /***/ "./Shaders/blackAndWhite.fragment.ts":
  122543. /*!*******************************************!*\
  122544. !*** ./Shaders/blackAndWhite.fragment.ts ***!
  122545. \*******************************************/
  122546. /*! exports provided: blackAndWhitePixelShader */
  122547. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122548. "use strict";
  122549. __webpack_require__.r(__webpack_exports__);
  122550. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "blackAndWhitePixelShader", function() { return blackAndWhitePixelShader; });
  122551. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122552. var name = 'blackAndWhitePixelShader';
  122553. 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}";
  122554. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122555. /** @hidden */
  122556. var blackAndWhitePixelShader = { name: name, shader: shader };
  122557. /***/ }),
  122558. /***/ "./Shaders/bloomMerge.fragment.ts":
  122559. /*!****************************************!*\
  122560. !*** ./Shaders/bloomMerge.fragment.ts ***!
  122561. \****************************************/
  122562. /*! exports provided: bloomMergePixelShader */
  122563. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122564. "use strict";
  122565. __webpack_require__.r(__webpack_exports__);
  122566. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bloomMergePixelShader", function() { return bloomMergePixelShader; });
  122567. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122568. var name = 'bloomMergePixelShader';
  122569. 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";
  122570. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122571. /** @hidden */
  122572. var bloomMergePixelShader = { name: name, shader: shader };
  122573. /***/ }),
  122574. /***/ "./Shaders/chromaticAberration.fragment.ts":
  122575. /*!*************************************************!*\
  122576. !*** ./Shaders/chromaticAberration.fragment.ts ***!
  122577. \*************************************************/
  122578. /*! exports provided: chromaticAberrationPixelShader */
  122579. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122580. "use strict";
  122581. __webpack_require__.r(__webpack_exports__);
  122582. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "chromaticAberrationPixelShader", function() { return chromaticAberrationPixelShader; });
  122583. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122584. var name = 'chromaticAberrationPixelShader';
  122585. 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}";
  122586. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122587. /** @hidden */
  122588. var chromaticAberrationPixelShader = { name: name, shader: shader };
  122589. /***/ }),
  122590. /***/ "./Shaders/circleOfConfusion.fragment.ts":
  122591. /*!***********************************************!*\
  122592. !*** ./Shaders/circleOfConfusion.fragment.ts ***!
  122593. \***********************************************/
  122594. /*! exports provided: circleOfConfusionPixelShader */
  122595. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122596. "use strict";
  122597. __webpack_require__.r(__webpack_exports__);
  122598. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "circleOfConfusionPixelShader", function() { return circleOfConfusionPixelShader; });
  122599. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122600. var name = 'circleOfConfusionPixelShader';
  122601. 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";
  122602. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122603. /** @hidden */
  122604. var circleOfConfusionPixelShader = { name: name, shader: shader };
  122605. /***/ }),
  122606. /***/ "./Shaders/color.fragment.ts":
  122607. /*!***********************************!*\
  122608. !*** ./Shaders/color.fragment.ts ***!
  122609. \***********************************/
  122610. /*! exports provided: colorPixelShader */
  122611. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122612. "use strict";
  122613. __webpack_require__.r(__webpack_exports__);
  122614. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorPixelShader", function() { return colorPixelShader; });
  122615. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122616. var name = 'colorPixelShader';
  122617. 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}";
  122618. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122619. /** @hidden */
  122620. var colorPixelShader = { name: name, shader: shader };
  122621. /***/ }),
  122622. /***/ "./Shaders/color.vertex.ts":
  122623. /*!*********************************!*\
  122624. !*** ./Shaders/color.vertex.ts ***!
  122625. \*********************************/
  122626. /*! exports provided: colorVertexShader */
  122627. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122628. "use strict";
  122629. __webpack_require__.r(__webpack_exports__);
  122630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorVertexShader", function() { return colorVertexShader; });
  122631. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122632. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  122633. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  122634. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  122635. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  122636. var name = 'colorVertexShader';
  122637. 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}";
  122638. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122639. /** @hidden */
  122640. var colorVertexShader = { name: name, shader: shader };
  122641. /***/ }),
  122642. /***/ "./Shaders/colorCorrection.fragment.ts":
  122643. /*!*********************************************!*\
  122644. !*** ./Shaders/colorCorrection.fragment.ts ***!
  122645. \*********************************************/
  122646. /*! exports provided: colorCorrectionPixelShader */
  122647. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122648. "use strict";
  122649. __webpack_require__.r(__webpack_exports__);
  122650. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorCorrectionPixelShader", function() { return colorCorrectionPixelShader; });
  122651. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122652. var name = 'colorCorrectionPixelShader';
  122653. 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}";
  122654. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122655. /** @hidden */
  122656. var colorCorrectionPixelShader = { name: name, shader: shader };
  122657. /***/ }),
  122658. /***/ "./Shaders/convolution.fragment.ts":
  122659. /*!*****************************************!*\
  122660. !*** ./Shaders/convolution.fragment.ts ***!
  122661. \*****************************************/
  122662. /*! exports provided: convolutionPixelShader */
  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__, "convolutionPixelShader", function() { return convolutionPixelShader; });
  122667. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122668. var name = 'convolutionPixelShader';
  122669. 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}";
  122670. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122671. /** @hidden */
  122672. var convolutionPixelShader = { name: name, shader: shader };
  122673. /***/ }),
  122674. /***/ "./Shaders/default.fragment.ts":
  122675. /*!*************************************!*\
  122676. !*** ./Shaders/default.fragment.ts ***!
  122677. \*************************************/
  122678. /*! exports provided: defaultPixelShader */
  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__, "defaultPixelShader", function() { return defaultPixelShader; });
  122683. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122684. /* harmony import */ var _ShadersInclude_defaultFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultFragmentDeclaration */ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts");
  122685. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  122686. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  122687. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  122688. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  122689. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  122690. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  122691. /* harmony import */ var _ShadersInclude_fresnelFunction__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fresnelFunction */ "./Shaders/ShadersInclude/fresnelFunction.ts");
  122692. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  122693. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  122694. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  122695. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  122696. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  122697. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  122698. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  122699. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  122700. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  122701. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  122702. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  122703. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  122704. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  122705. var name = 'defaultPixelShader';
  122706. 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";
  122707. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122708. /** @hidden */
  122709. var defaultPixelShader = { name: name, shader: shader };
  122710. /***/ }),
  122711. /***/ "./Shaders/default.vertex.ts":
  122712. /*!***********************************!*\
  122713. !*** ./Shaders/default.vertex.ts ***!
  122714. \***********************************/
  122715. /*! exports provided: defaultVertexShader */
  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__, "defaultVertexShader", function() { return defaultVertexShader; });
  122720. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122721. /* harmony import */ var _ShadersInclude_defaultVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultVertexDeclaration */ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts");
  122722. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  122723. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  122724. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  122725. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  122726. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  122727. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  122728. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  122729. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  122730. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  122731. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  122732. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  122733. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  122734. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  122735. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  122736. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  122737. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  122738. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  122739. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  122740. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  122741. /* harmony import */ var _ShadersInclude_pointCloudVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/pointCloudVertex */ "./Shaders/ShadersInclude/pointCloudVertex.ts");
  122742. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  122743. var name = 'defaultVertexShader';
  122744. 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";
  122745. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122746. /** @hidden */
  122747. var defaultVertexShader = { name: name, shader: shader };
  122748. /***/ }),
  122749. /***/ "./Shaders/depth.fragment.ts":
  122750. /*!***********************************!*\
  122751. !*** ./Shaders/depth.fragment.ts ***!
  122752. \***********************************/
  122753. /*! exports provided: depthPixelShader */
  122754. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122755. "use strict";
  122756. __webpack_require__.r(__webpack_exports__);
  122757. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPixelShader", function() { return depthPixelShader; });
  122758. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122759. var name = 'depthPixelShader';
  122760. 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}";
  122761. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122762. /** @hidden */
  122763. var depthPixelShader = { name: name, shader: shader };
  122764. /***/ }),
  122765. /***/ "./Shaders/depth.vertex.ts":
  122766. /*!*********************************!*\
  122767. !*** ./Shaders/depth.vertex.ts ***!
  122768. \*********************************/
  122769. /*! exports provided: depthVertexShader */
  122770. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122771. "use strict";
  122772. __webpack_require__.r(__webpack_exports__);
  122773. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthVertexShader", function() { return depthVertexShader; });
  122774. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122775. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  122776. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  122777. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  122778. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  122779. var name = 'depthVertexShader';
  122780. 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}";
  122781. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122782. /** @hidden */
  122783. var depthVertexShader = { name: name, shader: shader };
  122784. /***/ }),
  122785. /***/ "./Shaders/depthBoxBlur.fragment.ts":
  122786. /*!******************************************!*\
  122787. !*** ./Shaders/depthBoxBlur.fragment.ts ***!
  122788. \******************************************/
  122789. /*! exports provided: depthBoxBlurPixelShader */
  122790. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122791. "use strict";
  122792. __webpack_require__.r(__webpack_exports__);
  122793. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthBoxBlurPixelShader", function() { return depthBoxBlurPixelShader; });
  122794. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122795. var name = 'depthBoxBlurPixelShader';
  122796. 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}";
  122797. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122798. /** @hidden */
  122799. var depthBoxBlurPixelShader = { name: name, shader: shader };
  122800. /***/ }),
  122801. /***/ "./Shaders/depthOfField.fragment.ts":
  122802. /*!******************************************!*\
  122803. !*** ./Shaders/depthOfField.fragment.ts ***!
  122804. \******************************************/
  122805. /*! exports provided: depthOfFieldPixelShader */
  122806. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122807. "use strict";
  122808. __webpack_require__.r(__webpack_exports__);
  122809. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldPixelShader", function() { return depthOfFieldPixelShader; });
  122810. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122811. var name = 'depthOfFieldPixelShader';
  122812. 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";
  122813. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122814. /** @hidden */
  122815. var depthOfFieldPixelShader = { name: name, shader: shader };
  122816. /***/ }),
  122817. /***/ "./Shaders/depthOfFieldMerge.fragment.ts":
  122818. /*!***********************************************!*\
  122819. !*** ./Shaders/depthOfFieldMerge.fragment.ts ***!
  122820. \***********************************************/
  122821. /*! exports provided: depthOfFieldMergePixelShader */
  122822. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122823. "use strict";
  122824. __webpack_require__.r(__webpack_exports__);
  122825. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldMergePixelShader", function() { return depthOfFieldMergePixelShader; });
  122826. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122827. var name = 'depthOfFieldMergePixelShader';
  122828. 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";
  122829. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122830. /** @hidden */
  122831. var depthOfFieldMergePixelShader = { name: name, shader: shader };
  122832. /***/ }),
  122833. /***/ "./Shaders/displayPass.fragment.ts":
  122834. /*!*****************************************!*\
  122835. !*** ./Shaders/displayPass.fragment.ts ***!
  122836. \*****************************************/
  122837. /*! exports provided: displayPassPixelShader */
  122838. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122839. "use strict";
  122840. __webpack_require__.r(__webpack_exports__);
  122841. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayPassPixelShader", function() { return displayPassPixelShader; });
  122842. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122843. var name = 'displayPassPixelShader';
  122844. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}";
  122845. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122846. /** @hidden */
  122847. var displayPassPixelShader = { name: name, shader: shader };
  122848. /***/ }),
  122849. /***/ "./Shaders/extractHighlights.fragment.ts":
  122850. /*!***********************************************!*\
  122851. !*** ./Shaders/extractHighlights.fragment.ts ***!
  122852. \***********************************************/
  122853. /*! exports provided: extractHighlightsPixelShader */
  122854. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122855. "use strict";
  122856. __webpack_require__.r(__webpack_exports__);
  122857. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractHighlightsPixelShader", function() { return extractHighlightsPixelShader; });
  122858. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122859. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  122860. var name = 'extractHighlightsPixelShader';
  122861. 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}";
  122862. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122863. /** @hidden */
  122864. var extractHighlightsPixelShader = { name: name, shader: shader };
  122865. /***/ }),
  122866. /***/ "./Shaders/filter.fragment.ts":
  122867. /*!************************************!*\
  122868. !*** ./Shaders/filter.fragment.ts ***!
  122869. \************************************/
  122870. /*! exports provided: filterPixelShader */
  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__, "filterPixelShader", function() { return filterPixelShader; });
  122875. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122876. var name = 'filterPixelShader';
  122877. 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}";
  122878. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122879. /** @hidden */
  122880. var filterPixelShader = { name: name, shader: shader };
  122881. /***/ }),
  122882. /***/ "./Shaders/fxaa.fragment.ts":
  122883. /*!**********************************!*\
  122884. !*** ./Shaders/fxaa.fragment.ts ***!
  122885. \**********************************/
  122886. /*! exports provided: fxaaPixelShader */
  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__, "fxaaPixelShader", function() { return fxaaPixelShader; });
  122891. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122892. var name = 'fxaaPixelShader';
  122893. 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}";
  122894. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122895. /** @hidden */
  122896. var fxaaPixelShader = { name: name, shader: shader };
  122897. /***/ }),
  122898. /***/ "./Shaders/fxaa.vertex.ts":
  122899. /*!********************************!*\
  122900. !*** ./Shaders/fxaa.vertex.ts ***!
  122901. \********************************/
  122902. /*! exports provided: fxaaVertexShader */
  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__, "fxaaVertexShader", function() { return fxaaVertexShader; });
  122907. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122908. var name = 'fxaaVertexShader';
  122909. 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}";
  122910. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122911. /** @hidden */
  122912. var fxaaVertexShader = { name: name, shader: shader };
  122913. /***/ }),
  122914. /***/ "./Shaders/geometry.fragment.ts":
  122915. /*!**************************************!*\
  122916. !*** ./Shaders/geometry.fragment.ts ***!
  122917. \**************************************/
  122918. /*! exports provided: geometryPixelShader */
  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__, "geometryPixelShader", function() { return geometryPixelShader; });
  122923. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122924. /* harmony import */ var _ShadersInclude_mrtFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/mrtFragmentDeclaration */ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts");
  122925. var name = 'geometryPixelShader';
  122926. 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}";
  122927. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122928. /** @hidden */
  122929. var geometryPixelShader = { name: name, shader: shader };
  122930. /***/ }),
  122931. /***/ "./Shaders/geometry.vertex.ts":
  122932. /*!************************************!*\
  122933. !*** ./Shaders/geometry.vertex.ts ***!
  122934. \************************************/
  122935. /*! exports provided: geometryVertexShader */
  122936. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122937. "use strict";
  122938. __webpack_require__.r(__webpack_exports__);
  122939. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryVertexShader", function() { return geometryVertexShader; });
  122940. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122941. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  122942. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  122943. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  122944. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  122945. var name = 'geometryVertexShader';
  122946. 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}";
  122947. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122948. /** @hidden */
  122949. var geometryVertexShader = { name: name, shader: shader };
  122950. /***/ }),
  122951. /***/ "./Shaders/glowBlurPostProcess.fragment.ts":
  122952. /*!*************************************************!*\
  122953. !*** ./Shaders/glowBlurPostProcess.fragment.ts ***!
  122954. \*************************************************/
  122955. /*! exports provided: glowBlurPostProcessPixelShader */
  122956. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122957. "use strict";
  122958. __webpack_require__.r(__webpack_exports__);
  122959. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowBlurPostProcessPixelShader", function() { return glowBlurPostProcessPixelShader; });
  122960. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122961. var name = 'glowBlurPostProcessPixelShader';
  122962. 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}";
  122963. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122964. /** @hidden */
  122965. var glowBlurPostProcessPixelShader = { name: name, shader: shader };
  122966. /***/ }),
  122967. /***/ "./Shaders/glowMapGeneration.fragment.ts":
  122968. /*!***********************************************!*\
  122969. !*** ./Shaders/glowMapGeneration.fragment.ts ***!
  122970. \***********************************************/
  122971. /*! exports provided: glowMapGenerationPixelShader */
  122972. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122973. "use strict";
  122974. __webpack_require__.r(__webpack_exports__);
  122975. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationPixelShader", function() { return glowMapGenerationPixelShader; });
  122976. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122977. var name = 'glowMapGenerationPixelShader';
  122978. 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}";
  122979. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122980. /** @hidden */
  122981. var glowMapGenerationPixelShader = { name: name, shader: shader };
  122982. /***/ }),
  122983. /***/ "./Shaders/glowMapGeneration.vertex.ts":
  122984. /*!*********************************************!*\
  122985. !*** ./Shaders/glowMapGeneration.vertex.ts ***!
  122986. \*********************************************/
  122987. /*! exports provided: glowMapGenerationVertexShader */
  122988. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122989. "use strict";
  122990. __webpack_require__.r(__webpack_exports__);
  122991. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationVertexShader", function() { return glowMapGenerationVertexShader; });
  122992. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122993. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  122994. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  122995. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  122996. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  122997. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  122998. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  122999. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123000. var name = 'glowMapGenerationVertexShader';
  123001. 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}";
  123002. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123003. /** @hidden */
  123004. var glowMapGenerationVertexShader = { name: name, shader: shader };
  123005. /***/ }),
  123006. /***/ "./Shaders/glowMapMerge.fragment.ts":
  123007. /*!******************************************!*\
  123008. !*** ./Shaders/glowMapMerge.fragment.ts ***!
  123009. \******************************************/
  123010. /*! exports provided: glowMapMergePixelShader */
  123011. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123012. "use strict";
  123013. __webpack_require__.r(__webpack_exports__);
  123014. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergePixelShader", function() { return glowMapMergePixelShader; });
  123015. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123016. var name = 'glowMapMergePixelShader';
  123017. 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}";
  123018. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123019. /** @hidden */
  123020. var glowMapMergePixelShader = { name: name, shader: shader };
  123021. /***/ }),
  123022. /***/ "./Shaders/glowMapMerge.vertex.ts":
  123023. /*!****************************************!*\
  123024. !*** ./Shaders/glowMapMerge.vertex.ts ***!
  123025. \****************************************/
  123026. /*! exports provided: glowMapMergeVertexShader */
  123027. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123028. "use strict";
  123029. __webpack_require__.r(__webpack_exports__);
  123030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergeVertexShader", function() { return glowMapMergeVertexShader; });
  123031. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123032. var name = 'glowMapMergeVertexShader';
  123033. 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}";
  123034. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123035. /** @hidden */
  123036. var glowMapMergeVertexShader = { name: name, shader: shader };
  123037. /***/ }),
  123038. /***/ "./Shaders/gpuRenderParticles.fragment.ts":
  123039. /*!************************************************!*\
  123040. !*** ./Shaders/gpuRenderParticles.fragment.ts ***!
  123041. \************************************************/
  123042. /*! exports provided: gpuRenderParticlesPixelShader */
  123043. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123044. "use strict";
  123045. __webpack_require__.r(__webpack_exports__);
  123046. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesPixelShader", function() { return gpuRenderParticlesPixelShader; });
  123047. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123048. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts");
  123049. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  123050. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123051. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  123052. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  123053. var name = 'gpuRenderParticlesPixelShader';
  123054. 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";
  123055. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123056. /** @hidden */
  123057. var gpuRenderParticlesPixelShader = { name: name, shader: shader };
  123058. /***/ }),
  123059. /***/ "./Shaders/gpuRenderParticles.vertex.ts":
  123060. /*!**********************************************!*\
  123061. !*** ./Shaders/gpuRenderParticles.vertex.ts ***!
  123062. \**********************************************/
  123063. /*! exports provided: gpuRenderParticlesVertexShader */
  123064. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123065. "use strict";
  123066. __webpack_require__.r(__webpack_exports__);
  123067. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesVertexShader", function() { return gpuRenderParticlesVertexShader; });
  123068. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123069. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts");
  123070. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  123071. var name = 'gpuRenderParticlesVertexShader';
  123072. 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}";
  123073. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123074. /** @hidden */
  123075. var gpuRenderParticlesVertexShader = { name: name, shader: shader };
  123076. /***/ }),
  123077. /***/ "./Shaders/gpuUpdateParticles.fragment.ts":
  123078. /*!************************************************!*\
  123079. !*** ./Shaders/gpuUpdateParticles.fragment.ts ***!
  123080. \************************************************/
  123081. /*! exports provided: gpuUpdateParticlesPixelShader */
  123082. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123083. "use strict";
  123084. __webpack_require__.r(__webpack_exports__);
  123085. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesPixelShader", function() { return gpuUpdateParticlesPixelShader; });
  123086. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123087. var name = 'gpuUpdateParticlesPixelShader';
  123088. var shader = "#version 300 es\nvoid main() {\ndiscard;\n}\n";
  123089. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123090. /** @hidden */
  123091. var gpuUpdateParticlesPixelShader = { name: name, shader: shader };
  123092. /***/ }),
  123093. /***/ "./Shaders/gpuUpdateParticles.vertex.ts":
  123094. /*!**********************************************!*\
  123095. !*** ./Shaders/gpuUpdateParticles.vertex.ts ***!
  123096. \**********************************************/
  123097. /*! exports provided: gpuUpdateParticlesVertexShader */
  123098. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123099. "use strict";
  123100. __webpack_require__.r(__webpack_exports__);
  123101. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesVertexShader", function() { return gpuUpdateParticlesVertexShader; });
  123102. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123103. var name = 'gpuUpdateParticlesVertexShader';
  123104. 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}";
  123105. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123106. /** @hidden */
  123107. var gpuUpdateParticlesVertexShader = { name: name, shader: shader };
  123108. /***/ }),
  123109. /***/ "./Shaders/grain.fragment.ts":
  123110. /*!***********************************!*\
  123111. !*** ./Shaders/grain.fragment.ts ***!
  123112. \***********************************/
  123113. /*! exports provided: grainPixelShader */
  123114. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123115. "use strict";
  123116. __webpack_require__.r(__webpack_exports__);
  123117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "grainPixelShader", function() { return grainPixelShader; });
  123118. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123119. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123120. var name = 'grainPixelShader';
  123121. 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}";
  123122. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123123. /** @hidden */
  123124. var grainPixelShader = { name: name, shader: shader };
  123125. /***/ }),
  123126. /***/ "./Shaders/highlights.fragment.ts":
  123127. /*!****************************************!*\
  123128. !*** ./Shaders/highlights.fragment.ts ***!
  123129. \****************************************/
  123130. /*! exports provided: highlightsPixelShader */
  123131. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123132. "use strict";
  123133. __webpack_require__.r(__webpack_exports__);
  123134. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "highlightsPixelShader", function() { return highlightsPixelShader; });
  123135. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123136. var name = 'highlightsPixelShader';
  123137. 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}";
  123138. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123139. /** @hidden */
  123140. var highlightsPixelShader = { name: name, shader: shader };
  123141. /***/ }),
  123142. /***/ "./Shaders/imageProcessing.fragment.ts":
  123143. /*!*********************************************!*\
  123144. !*** ./Shaders/imageProcessing.fragment.ts ***!
  123145. \*********************************************/
  123146. /*! exports provided: imageProcessingPixelShader */
  123147. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123148. "use strict";
  123149. __webpack_require__.r(__webpack_exports__);
  123150. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingPixelShader", function() { return imageProcessingPixelShader; });
  123151. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123152. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  123153. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123154. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  123155. var name = 'imageProcessingPixelShader';
  123156. 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}";
  123157. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123158. /** @hidden */
  123159. var imageProcessingPixelShader = { name: name, shader: shader };
  123160. /***/ }),
  123161. /***/ "./Shaders/kernelBlur.fragment.ts":
  123162. /*!****************************************!*\
  123163. !*** ./Shaders/kernelBlur.fragment.ts ***!
  123164. \****************************************/
  123165. /*! exports provided: kernelBlurPixelShader */
  123166. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123167. "use strict";
  123168. __webpack_require__.r(__webpack_exports__);
  123169. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurPixelShader", function() { return kernelBlurPixelShader; });
  123170. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123171. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  123172. /* harmony import */ var _ShadersInclude_kernelBlurFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment */ "./Shaders/ShadersInclude/kernelBlurFragment.ts");
  123173. /* harmony import */ var _ShadersInclude_kernelBlurFragment2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment2 */ "./Shaders/ShadersInclude/kernelBlurFragment2.ts");
  123174. var name = 'kernelBlurPixelShader';
  123175. 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}";
  123176. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123177. /** @hidden */
  123178. var kernelBlurPixelShader = { name: name, shader: shader };
  123179. /***/ }),
  123180. /***/ "./Shaders/kernelBlur.vertex.ts":
  123181. /*!**************************************!*\
  123182. !*** ./Shaders/kernelBlur.vertex.ts ***!
  123183. \**************************************/
  123184. /*! exports provided: kernelBlurVertexShader */
  123185. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123186. "use strict";
  123187. __webpack_require__.r(__webpack_exports__);
  123188. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertexShader", function() { return kernelBlurVertexShader; });
  123189. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123190. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  123191. /* harmony import */ var _ShadersInclude_kernelBlurVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVertex */ "./Shaders/ShadersInclude/kernelBlurVertex.ts");
  123192. var name = 'kernelBlurVertexShader';
  123193. 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}";
  123194. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123195. /** @hidden */
  123196. var kernelBlurVertexShader = { name: name, shader: shader };
  123197. /***/ }),
  123198. /***/ "./Shaders/layer.fragment.ts":
  123199. /*!***********************************!*\
  123200. !*** ./Shaders/layer.fragment.ts ***!
  123201. \***********************************/
  123202. /*! exports provided: layerPixelShader */
  123203. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123204. "use strict";
  123205. __webpack_require__.r(__webpack_exports__);
  123206. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerPixelShader", function() { return layerPixelShader; });
  123207. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123208. var name = 'layerPixelShader';
  123209. 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}";
  123210. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123211. /** @hidden */
  123212. var layerPixelShader = { name: name, shader: shader };
  123213. /***/ }),
  123214. /***/ "./Shaders/layer.vertex.ts":
  123215. /*!*********************************!*\
  123216. !*** ./Shaders/layer.vertex.ts ***!
  123217. \*********************************/
  123218. /*! exports provided: layerVertexShader */
  123219. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123220. "use strict";
  123221. __webpack_require__.r(__webpack_exports__);
  123222. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerVertexShader", function() { return layerVertexShader; });
  123223. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123224. var name = 'layerVertexShader';
  123225. 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}";
  123226. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123227. /** @hidden */
  123228. var layerVertexShader = { name: name, shader: shader };
  123229. /***/ }),
  123230. /***/ "./Shaders/lensFlare.fragment.ts":
  123231. /*!***************************************!*\
  123232. !*** ./Shaders/lensFlare.fragment.ts ***!
  123233. \***************************************/
  123234. /*! exports provided: lensFlarePixelShader */
  123235. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123236. "use strict";
  123237. __webpack_require__.r(__webpack_exports__);
  123238. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlarePixelShader", function() { return lensFlarePixelShader; });
  123239. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123240. var name = 'lensFlarePixelShader';
  123241. 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}";
  123242. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123243. /** @hidden */
  123244. var lensFlarePixelShader = { name: name, shader: shader };
  123245. /***/ }),
  123246. /***/ "./Shaders/lensFlare.vertex.ts":
  123247. /*!*************************************!*\
  123248. !*** ./Shaders/lensFlare.vertex.ts ***!
  123249. \*************************************/
  123250. /*! exports provided: lensFlareVertexShader */
  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__, "lensFlareVertexShader", function() { return lensFlareVertexShader; });
  123255. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123256. var name = 'lensFlareVertexShader';
  123257. 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}";
  123258. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123259. /** @hidden */
  123260. var lensFlareVertexShader = { name: name, shader: shader };
  123261. /***/ }),
  123262. /***/ "./Shaders/lensHighlights.fragment.ts":
  123263. /*!********************************************!*\
  123264. !*** ./Shaders/lensHighlights.fragment.ts ***!
  123265. \********************************************/
  123266. /*! exports provided: lensHighlightsPixelShader */
  123267. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123268. "use strict";
  123269. __webpack_require__.r(__webpack_exports__);
  123270. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensHighlightsPixelShader", function() { return lensHighlightsPixelShader; });
  123271. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123272. var name = 'lensHighlightsPixelShader';
  123273. 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}";
  123274. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123275. /** @hidden */
  123276. var lensHighlightsPixelShader = { name: name, shader: shader };
  123277. /***/ }),
  123278. /***/ "./Shaders/line.fragment.ts":
  123279. /*!**********************************!*\
  123280. !*** ./Shaders/line.fragment.ts ***!
  123281. \**********************************/
  123282. /*! exports provided: linePixelShader */
  123283. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123284. "use strict";
  123285. __webpack_require__.r(__webpack_exports__);
  123286. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "linePixelShader", function() { return linePixelShader; });
  123287. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123288. var name = 'linePixelShader';
  123289. var shader = "uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}";
  123290. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123291. /** @hidden */
  123292. var linePixelShader = { name: name, shader: shader };
  123293. /***/ }),
  123294. /***/ "./Shaders/line.vertex.ts":
  123295. /*!********************************!*\
  123296. !*** ./Shaders/line.vertex.ts ***!
  123297. \********************************/
  123298. /*! exports provided: lineVertexShader */
  123299. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123300. "use strict";
  123301. __webpack_require__.r(__webpack_exports__);
  123302. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lineVertexShader", function() { return lineVertexShader; });
  123303. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123304. var name = 'lineVertexShader';
  123305. 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}";
  123306. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123307. /** @hidden */
  123308. var lineVertexShader = { name: name, shader: shader };
  123309. /***/ }),
  123310. /***/ "./Shaders/motionBlur.fragment.ts":
  123311. /*!****************************************!*\
  123312. !*** ./Shaders/motionBlur.fragment.ts ***!
  123313. \****************************************/
  123314. /*! exports provided: motionBlurPixelShader */
  123315. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123316. "use strict";
  123317. __webpack_require__.r(__webpack_exports__);
  123318. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "motionBlurPixelShader", function() { return motionBlurPixelShader; });
  123319. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123320. var name = 'motionBlurPixelShader';
  123321. 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";
  123322. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123323. /** @hidden */
  123324. var motionBlurPixelShader = { name: name, shader: shader };
  123325. /***/ }),
  123326. /***/ "./Shaders/noise.fragment.ts":
  123327. /*!***********************************!*\
  123328. !*** ./Shaders/noise.fragment.ts ***!
  123329. \***********************************/
  123330. /*! exports provided: noisePixelShader */
  123331. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123332. "use strict";
  123333. __webpack_require__.r(__webpack_exports__);
  123334. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "noisePixelShader", function() { return noisePixelShader; });
  123335. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123336. var name = 'noisePixelShader';
  123337. 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";
  123338. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123339. /** @hidden */
  123340. var noisePixelShader = { name: name, shader: shader };
  123341. /***/ }),
  123342. /***/ "./Shaders/outline.fragment.ts":
  123343. /*!*************************************!*\
  123344. !*** ./Shaders/outline.fragment.ts ***!
  123345. \*************************************/
  123346. /*! exports provided: outlinePixelShader */
  123347. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123348. "use strict";
  123349. __webpack_require__.r(__webpack_exports__);
  123350. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlinePixelShader", function() { return outlinePixelShader; });
  123351. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123352. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123353. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  123354. var name = 'outlinePixelShader';
  123355. 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}";
  123356. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123357. /** @hidden */
  123358. var outlinePixelShader = { name: name, shader: shader };
  123359. /***/ }),
  123360. /***/ "./Shaders/outline.vertex.ts":
  123361. /*!***********************************!*\
  123362. !*** ./Shaders/outline.vertex.ts ***!
  123363. \***********************************/
  123364. /*! exports provided: outlineVertexShader */
  123365. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123366. "use strict";
  123367. __webpack_require__.r(__webpack_exports__);
  123368. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlineVertexShader", function() { return outlineVertexShader; });
  123369. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123370. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123371. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123372. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123373. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123374. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123375. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  123376. var name = 'outlineVertexShader';
  123377. 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";
  123378. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123379. /** @hidden */
  123380. var outlineVertexShader = { name: name, shader: shader };
  123381. /***/ }),
  123382. /***/ "./Shaders/particles.fragment.ts":
  123383. /*!***************************************!*\
  123384. !*** ./Shaders/particles.fragment.ts ***!
  123385. \***************************************/
  123386. /*! exports provided: particlesPixelShader */
  123387. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123388. "use strict";
  123389. __webpack_require__.r(__webpack_exports__);
  123390. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesPixelShader", function() { return particlesPixelShader; });
  123391. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123392. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  123393. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  123394. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123395. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  123396. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  123397. var name = 'particlesPixelShader';
  123398. 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}";
  123399. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123400. /** @hidden */
  123401. var particlesPixelShader = { name: name, shader: shader };
  123402. /***/ }),
  123403. /***/ "./Shaders/particles.vertex.ts":
  123404. /*!*************************************!*\
  123405. !*** ./Shaders/particles.vertex.ts ***!
  123406. \*************************************/
  123407. /*! exports provided: particlesVertexShader */
  123408. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123409. "use strict";
  123410. __webpack_require__.r(__webpack_exports__);
  123411. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesVertexShader", function() { return particlesVertexShader; });
  123412. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123413. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  123414. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  123415. var name = 'particlesVertexShader';
  123416. 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}";
  123417. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123418. /** @hidden */
  123419. var particlesVertexShader = { name: name, shader: shader };
  123420. /***/ }),
  123421. /***/ "./Shaders/pass.fragment.ts":
  123422. /*!**********************************!*\
  123423. !*** ./Shaders/pass.fragment.ts ***!
  123424. \**********************************/
  123425. /*! exports provided: passPixelShader */
  123426. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123427. "use strict";
  123428. __webpack_require__.r(__webpack_exports__);
  123429. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passPixelShader", function() { return passPixelShader; });
  123430. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123431. var name = 'passPixelShader';
  123432. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";
  123433. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123434. /** @hidden */
  123435. var passPixelShader = { name: name, shader: shader };
  123436. /***/ }),
  123437. /***/ "./Shaders/passCube.fragment.ts":
  123438. /*!**************************************!*\
  123439. !*** ./Shaders/passCube.fragment.ts ***!
  123440. \**************************************/
  123441. /*! exports provided: passCubePixelShader */
  123442. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123443. "use strict";
  123444. __webpack_require__.r(__webpack_exports__);
  123445. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passCubePixelShader", function() { return passCubePixelShader; });
  123446. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123447. var name = 'passCubePixelShader';
  123448. 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}";
  123449. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123450. /** @hidden */
  123451. var passCubePixelShader = { name: name, shader: shader };
  123452. /***/ }),
  123453. /***/ "./Shaders/pbr.fragment.ts":
  123454. /*!*********************************!*\
  123455. !*** ./Shaders/pbr.fragment.ts ***!
  123456. \*********************************/
  123457. /*! exports provided: pbrPixelShader */
  123458. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123459. "use strict";
  123460. __webpack_require__.r(__webpack_exports__);
  123461. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrPixelShader", function() { return pbrPixelShader; });
  123462. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123463. /* harmony import */ var _ShadersInclude_pbrFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentDeclaration */ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts");
  123464. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  123465. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123466. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123467. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  123468. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  123469. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123470. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  123471. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  123472. /* harmony import */ var _ShadersInclude_pbrFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/pbrFunctions */ "./Shaders/ShadersInclude/pbrFunctions.ts");
  123473. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  123474. /* harmony import */ var _ShadersInclude_pbrLightFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/pbrLightFunctions */ "./Shaders/ShadersInclude/pbrLightFunctions.ts");
  123475. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  123476. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  123477. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123478. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  123479. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  123480. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  123481. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  123482. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  123483. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  123484. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  123485. var name = 'pbrPixelShader';
  123486. 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";
  123487. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123488. /** @hidden */
  123489. var pbrPixelShader = { name: name, shader: shader };
  123490. /***/ }),
  123491. /***/ "./Shaders/pbr.vertex.ts":
  123492. /*!*******************************!*\
  123493. !*** ./Shaders/pbr.vertex.ts ***!
  123494. \*******************************/
  123495. /*! exports provided: pbrVertexShader */
  123496. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123497. "use strict";
  123498. __webpack_require__.r(__webpack_exports__);
  123499. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexShader", function() { return pbrVertexShader; });
  123500. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123501. /* harmony import */ var _ShadersInclude_pbrVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrVertexDeclaration */ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts");
  123502. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  123503. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123504. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123505. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123506. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  123507. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  123508. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  123509. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  123510. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123511. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123512. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  123513. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  123514. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123515. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  123516. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123517. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123518. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  123519. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  123520. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  123521. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  123522. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  123523. var name = 'pbrVertexShader';
  123524. 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}";
  123525. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123526. /** @hidden */
  123527. var pbrVertexShader = { name: name, shader: shader };
  123528. /***/ }),
  123529. /***/ "./Shaders/postprocess.vertex.ts":
  123530. /*!***************************************!*\
  123531. !*** ./Shaders/postprocess.vertex.ts ***!
  123532. \***************************************/
  123533. /*! exports provided: postprocessVertexShader */
  123534. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123535. "use strict";
  123536. __webpack_require__.r(__webpack_exports__);
  123537. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postprocessVertexShader", function() { return postprocessVertexShader; });
  123538. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123539. var name = 'postprocessVertexShader';
  123540. 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}";
  123541. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123542. /** @hidden */
  123543. var postprocessVertexShader = { name: name, shader: shader };
  123544. /***/ }),
  123545. /***/ "./Shaders/procedural.vertex.ts":
  123546. /*!**************************************!*\
  123547. !*** ./Shaders/procedural.vertex.ts ***!
  123548. \**************************************/
  123549. /*! exports provided: proceduralVertexShader */
  123550. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123551. "use strict";
  123552. __webpack_require__.r(__webpack_exports__);
  123553. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "proceduralVertexShader", function() { return proceduralVertexShader; });
  123554. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123555. var name = 'proceduralVertexShader';
  123556. 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}";
  123557. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123558. /** @hidden */
  123559. var proceduralVertexShader = { name: name, shader: shader };
  123560. /***/ }),
  123561. /***/ "./Shaders/refraction.fragment.ts":
  123562. /*!****************************************!*\
  123563. !*** ./Shaders/refraction.fragment.ts ***!
  123564. \****************************************/
  123565. /*! exports provided: refractionPixelShader */
  123566. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123567. "use strict";
  123568. __webpack_require__.r(__webpack_exports__);
  123569. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "refractionPixelShader", function() { return refractionPixelShader; });
  123570. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123571. var name = 'refractionPixelShader';
  123572. 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}";
  123573. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123574. /** @hidden */
  123575. var refractionPixelShader = { name: name, shader: shader };
  123576. /***/ }),
  123577. /***/ "./Shaders/rgbdDecode.fragment.ts":
  123578. /*!****************************************!*\
  123579. !*** ./Shaders/rgbdDecode.fragment.ts ***!
  123580. \****************************************/
  123581. /*! exports provided: rgbdDecodePixelShader */
  123582. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123583. "use strict";
  123584. __webpack_require__.r(__webpack_exports__);
  123585. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdDecodePixelShader", function() { return rgbdDecodePixelShader; });
  123586. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123587. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123588. var name = 'rgbdDecodePixelShader';
  123589. 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}";
  123590. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123591. /** @hidden */
  123592. var rgbdDecodePixelShader = { name: name, shader: shader };
  123593. /***/ }),
  123594. /***/ "./Shaders/rgbdEncode.fragment.ts":
  123595. /*!****************************************!*\
  123596. !*** ./Shaders/rgbdEncode.fragment.ts ***!
  123597. \****************************************/
  123598. /*! exports provided: rgbdEncodePixelShader */
  123599. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123600. "use strict";
  123601. __webpack_require__.r(__webpack_exports__);
  123602. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdEncodePixelShader", function() { return rgbdEncodePixelShader; });
  123603. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123604. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123605. var name = 'rgbdEncodePixelShader';
  123606. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";
  123607. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123608. /** @hidden */
  123609. var rgbdEncodePixelShader = { name: name, shader: shader };
  123610. /***/ }),
  123611. /***/ "./Shaders/shadowMap.fragment.ts":
  123612. /*!***************************************!*\
  123613. !*** ./Shaders/shadowMap.fragment.ts ***!
  123614. \***************************************/
  123615. /*! exports provided: shadowMapPixelShader */
  123616. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123617. "use strict";
  123618. __webpack_require__.r(__webpack_exports__);
  123619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapPixelShader", function() { return shadowMapPixelShader; });
  123620. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123621. var name = 'shadowMapPixelShader';
  123622. 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}";
  123623. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123624. /** @hidden */
  123625. var shadowMapPixelShader = { name: name, shader: shader };
  123626. /***/ }),
  123627. /***/ "./Shaders/shadowMap.vertex.ts":
  123628. /*!*************************************!*\
  123629. !*** ./Shaders/shadowMap.vertex.ts ***!
  123630. \*************************************/
  123631. /*! exports provided: shadowMapVertexShader */
  123632. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123633. "use strict";
  123634. __webpack_require__.r(__webpack_exports__);
  123635. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapVertexShader", function() { return shadowMapVertexShader; });
  123636. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123637. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123638. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  123639. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  123640. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123641. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123642. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  123643. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123644. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123645. var name = 'shadowMapVertexShader';
  123646. 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}";
  123647. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123648. /** @hidden */
  123649. var shadowMapVertexShader = { name: name, shader: shader };
  123650. /***/ }),
  123651. /***/ "./Shaders/sharpen.fragment.ts":
  123652. /*!*************************************!*\
  123653. !*** ./Shaders/sharpen.fragment.ts ***!
  123654. \*************************************/
  123655. /*! exports provided: sharpenPixelShader */
  123656. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123657. "use strict";
  123658. __webpack_require__.r(__webpack_exports__);
  123659. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sharpenPixelShader", function() { return sharpenPixelShader; });
  123660. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123661. var name = 'sharpenPixelShader';
  123662. 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}";
  123663. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123664. /** @hidden */
  123665. var sharpenPixelShader = { name: name, shader: shader };
  123666. /***/ }),
  123667. /***/ "./Shaders/sprites.fragment.ts":
  123668. /*!*************************************!*\
  123669. !*** ./Shaders/sprites.fragment.ts ***!
  123670. \*************************************/
  123671. /*! exports provided: spritesPixelShader */
  123672. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123673. "use strict";
  123674. __webpack_require__.r(__webpack_exports__);
  123675. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesPixelShader", function() { return spritesPixelShader; });
  123676. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123677. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  123678. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  123679. var name = 'spritesPixelShader';
  123680. 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}";
  123681. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123682. /** @hidden */
  123683. var spritesPixelShader = { name: name, shader: shader };
  123684. /***/ }),
  123685. /***/ "./Shaders/sprites.vertex.ts":
  123686. /*!***********************************!*\
  123687. !*** ./Shaders/sprites.vertex.ts ***!
  123688. \***********************************/
  123689. /*! exports provided: spritesVertexShader */
  123690. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123691. "use strict";
  123692. __webpack_require__.r(__webpack_exports__);
  123693. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesVertexShader", function() { return spritesVertexShader; });
  123694. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123695. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  123696. var name = 'spritesVertexShader';
  123697. 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}";
  123698. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123699. /** @hidden */
  123700. var spritesVertexShader = { name: name, shader: shader };
  123701. /***/ }),
  123702. /***/ "./Shaders/ssao.fragment.ts":
  123703. /*!**********************************!*\
  123704. !*** ./Shaders/ssao.fragment.ts ***!
  123705. \**********************************/
  123706. /*! exports provided: ssaoPixelShader */
  123707. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123708. "use strict";
  123709. __webpack_require__.r(__webpack_exports__);
  123710. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoPixelShader", function() { return ssaoPixelShader; });
  123711. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123712. var name = 'ssaoPixelShader';
  123713. 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";
  123714. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123715. /** @hidden */
  123716. var ssaoPixelShader = { name: name, shader: shader };
  123717. /***/ }),
  123718. /***/ "./Shaders/ssao2.fragment.ts":
  123719. /*!***********************************!*\
  123720. !*** ./Shaders/ssao2.fragment.ts ***!
  123721. \***********************************/
  123722. /*! exports provided: ssao2PixelShader */
  123723. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123724. "use strict";
  123725. __webpack_require__.r(__webpack_exports__);
  123726. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssao2PixelShader", function() { return ssao2PixelShader; });
  123727. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123728. var name = 'ssao2PixelShader';
  123729. 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";
  123730. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123731. /** @hidden */
  123732. var ssao2PixelShader = { name: name, shader: shader };
  123733. /***/ }),
  123734. /***/ "./Shaders/ssaoCombine.fragment.ts":
  123735. /*!*****************************************!*\
  123736. !*** ./Shaders/ssaoCombine.fragment.ts ***!
  123737. \*****************************************/
  123738. /*! exports provided: ssaoCombinePixelShader */
  123739. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123740. "use strict";
  123741. __webpack_require__.r(__webpack_exports__);
  123742. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoCombinePixelShader", function() { return ssaoCombinePixelShader; });
  123743. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123744. var name = 'ssaoCombinePixelShader';
  123745. 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";
  123746. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123747. /** @hidden */
  123748. var ssaoCombinePixelShader = { name: name, shader: shader };
  123749. /***/ }),
  123750. /***/ "./Shaders/standard.fragment.ts":
  123751. /*!**************************************!*\
  123752. !*** ./Shaders/standard.fragment.ts ***!
  123753. \**************************************/
  123754. /*! exports provided: standardPixelShader */
  123755. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123756. "use strict";
  123757. __webpack_require__.r(__webpack_exports__);
  123758. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "standardPixelShader", function() { return standardPixelShader; });
  123759. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123760. var name = 'standardPixelShader';
  123761. 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";
  123762. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123763. /** @hidden */
  123764. var standardPixelShader = { name: name, shader: shader };
  123765. /***/ }),
  123766. /***/ "./Shaders/stereoscopicInterlace.fragment.ts":
  123767. /*!***************************************************!*\
  123768. !*** ./Shaders/stereoscopicInterlace.fragment.ts ***!
  123769. \***************************************************/
  123770. /*! exports provided: stereoscopicInterlacePixelShader */
  123771. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123772. "use strict";
  123773. __webpack_require__.r(__webpack_exports__);
  123774. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stereoscopicInterlacePixelShader", function() { return stereoscopicInterlacePixelShader; });
  123775. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123776. var name = 'stereoscopicInterlacePixelShader';
  123777. 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}";
  123778. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123779. /** @hidden */
  123780. var stereoscopicInterlacePixelShader = { name: name, shader: shader };
  123781. /***/ }),
  123782. /***/ "./Shaders/tonemap.fragment.ts":
  123783. /*!*************************************!*\
  123784. !*** ./Shaders/tonemap.fragment.ts ***!
  123785. \*************************************/
  123786. /*! exports provided: tonemapPixelShader */
  123787. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123788. "use strict";
  123789. __webpack_require__.r(__webpack_exports__);
  123790. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tonemapPixelShader", function() { return tonemapPixelShader; });
  123791. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123792. var name = 'tonemapPixelShader';
  123793. 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}";
  123794. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123795. /** @hidden */
  123796. var tonemapPixelShader = { name: name, shader: shader };
  123797. /***/ }),
  123798. /***/ "./Shaders/volumetricLightScattering.fragment.ts":
  123799. /*!*******************************************************!*\
  123800. !*** ./Shaders/volumetricLightScattering.fragment.ts ***!
  123801. \*******************************************************/
  123802. /*! exports provided: volumetricLightScatteringPixelShader */
  123803. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123804. "use strict";
  123805. __webpack_require__.r(__webpack_exports__);
  123806. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPixelShader", function() { return volumetricLightScatteringPixelShader; });
  123807. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123808. var name = 'volumetricLightScatteringPixelShader';
  123809. 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";
  123810. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123811. /** @hidden */
  123812. var volumetricLightScatteringPixelShader = { name: name, shader: shader };
  123813. /***/ }),
  123814. /***/ "./Shaders/volumetricLightScatteringPass.fragment.ts":
  123815. /*!***********************************************************!*\
  123816. !*** ./Shaders/volumetricLightScatteringPass.fragment.ts ***!
  123817. \***********************************************************/
  123818. /*! exports provided: volumetricLightScatteringPassPixelShader */
  123819. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123820. "use strict";
  123821. __webpack_require__.r(__webpack_exports__);
  123822. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPassPixelShader", function() { return volumetricLightScatteringPassPixelShader; });
  123823. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123824. var name = 'volumetricLightScatteringPassPixelShader';
  123825. 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";
  123826. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123827. /** @hidden */
  123828. var volumetricLightScatteringPassPixelShader = { name: name, shader: shader };
  123829. /***/ }),
  123830. /***/ "./Shaders/vrDistortionCorrection.fragment.ts":
  123831. /*!****************************************************!*\
  123832. !*** ./Shaders/vrDistortionCorrection.fragment.ts ***!
  123833. \****************************************************/
  123834. /*! exports provided: vrDistortionCorrectionPixelShader */
  123835. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123836. "use strict";
  123837. __webpack_require__.r(__webpack_exports__);
  123838. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrDistortionCorrectionPixelShader", function() { return vrDistortionCorrectionPixelShader; });
  123839. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123840. var name = 'vrDistortionCorrectionPixelShader';
  123841. 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}";
  123842. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123843. /** @hidden */
  123844. var vrDistortionCorrectionPixelShader = { name: name, shader: shader };
  123845. /***/ }),
  123846. /***/ "./Sprites/index.ts":
  123847. /*!**************************!*\
  123848. !*** ./Sprites/index.ts ***!
  123849. \**************************/
  123850. /*! exports provided: Sprite, SpriteManager, SpriteSceneComponent */
  123851. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123852. "use strict";
  123853. __webpack_require__.r(__webpack_exports__);
  123854. /* harmony import */ var _sprite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sprite */ "./Sprites/sprite.ts");
  123855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _sprite__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  123856. /* harmony import */ var _spriteManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./spriteManager */ "./Sprites/spriteManager.ts");
  123857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _spriteManager__WEBPACK_IMPORTED_MODULE_1__["SpriteManager"]; });
  123858. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  123859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__["SpriteSceneComponent"]; });
  123860. /***/ }),
  123861. /***/ "./Sprites/sprite.ts":
  123862. /*!***************************!*\
  123863. !*** ./Sprites/sprite.ts ***!
  123864. \***************************/
  123865. /*! exports provided: Sprite */
  123866. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123867. "use strict";
  123868. __webpack_require__.r(__webpack_exports__);
  123869. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return Sprite; });
  123870. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  123871. /**
  123872. * Class used to represent a sprite
  123873. * @see http://doc.babylonjs.com/babylon101/sprites
  123874. */
  123875. var Sprite = /** @class */ (function () {
  123876. /**
  123877. * Creates a new Sprite
  123878. * @param name defines the name
  123879. * @param manager defines the manager
  123880. */
  123881. function Sprite(
  123882. /** defines the name */
  123883. name, manager) {
  123884. this.name = name;
  123885. /** Gets or sets the main color */
  123886. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  123887. /** Gets or sets the width */
  123888. this.width = 1.0;
  123889. /** Gets or sets the height */
  123890. this.height = 1.0;
  123891. /** Gets or sets rotation angle */
  123892. this.angle = 0;
  123893. /** Gets or sets the cell index in the sprite sheet */
  123894. this.cellIndex = 0;
  123895. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  123896. this.invertU = 0;
  123897. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  123898. this.invertV = 0;
  123899. /** Gets the list of attached animations */
  123900. this.animations = new Array();
  123901. /** Gets or sets a boolean indicating if the sprite can be picked */
  123902. this.isPickable = false;
  123903. this._animationStarted = false;
  123904. this._loopAnimation = false;
  123905. this._fromIndex = 0;
  123906. this._toIndex = 0;
  123907. this._delay = 0;
  123908. this._direction = 1;
  123909. this._time = 0;
  123910. /**
  123911. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  123912. */
  123913. this.isVisible = true;
  123914. this._manager = manager;
  123915. this._manager.sprites.push(this);
  123916. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  123917. }
  123918. Object.defineProperty(Sprite.prototype, "size", {
  123919. /**
  123920. * Gets or sets the sprite size
  123921. */
  123922. get: function () {
  123923. return this.width;
  123924. },
  123925. set: function (value) {
  123926. this.width = value;
  123927. this.height = value;
  123928. },
  123929. enumerable: true,
  123930. configurable: true
  123931. });
  123932. /**
  123933. * Starts an animation
  123934. * @param from defines the initial key
  123935. * @param to defines the end key
  123936. * @param loop defines if the animation must loop
  123937. * @param delay defines the start delay (in ms)
  123938. * @param onAnimationEnd defines a callback to call when animation ends
  123939. */
  123940. Sprite.prototype.playAnimation = function (from, to, loop, delay, onAnimationEnd) {
  123941. this._fromIndex = from;
  123942. this._toIndex = to;
  123943. this._loopAnimation = loop;
  123944. this._delay = delay;
  123945. this._animationStarted = true;
  123946. this._direction = from < to ? 1 : -1;
  123947. this.cellIndex = from;
  123948. this._time = 0;
  123949. this._onAnimationEnd = onAnimationEnd;
  123950. };
  123951. /** Stops current animation (if any) */
  123952. Sprite.prototype.stopAnimation = function () {
  123953. this._animationStarted = false;
  123954. };
  123955. /** @hidden */
  123956. Sprite.prototype._animate = function (deltaTime) {
  123957. if (!this._animationStarted) {
  123958. return;
  123959. }
  123960. this._time += deltaTime;
  123961. if (this._time > this._delay) {
  123962. this._time = this._time % this._delay;
  123963. this.cellIndex += this._direction;
  123964. if (this.cellIndex > this._toIndex) {
  123965. if (this._loopAnimation) {
  123966. this.cellIndex = this._fromIndex;
  123967. }
  123968. else {
  123969. this.cellIndex = this._toIndex;
  123970. this._animationStarted = false;
  123971. if (this._onAnimationEnd) {
  123972. this._onAnimationEnd();
  123973. }
  123974. if (this.disposeWhenFinishedAnimating) {
  123975. this.dispose();
  123976. }
  123977. }
  123978. }
  123979. }
  123980. };
  123981. /** Release associated resources */
  123982. Sprite.prototype.dispose = function () {
  123983. for (var i = 0; i < this._manager.sprites.length; i++) {
  123984. if (this._manager.sprites[i] == this) {
  123985. this._manager.sprites.splice(i, 1);
  123986. }
  123987. }
  123988. };
  123989. return Sprite;
  123990. }());
  123991. /***/ }),
  123992. /***/ "./Sprites/spriteManager.ts":
  123993. /*!**********************************!*\
  123994. !*** ./Sprites/spriteManager.ts ***!
  123995. \**********************************/
  123996. /*! exports provided: SpriteManager */
  123997. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123998. "use strict";
  123999. __webpack_require__.r(__webpack_exports__);
  124000. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return SpriteManager; });
  124001. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  124002. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  124003. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  124004. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124005. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  124006. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  124007. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  124008. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  124009. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  124010. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124011. /* harmony import */ var _Shaders_sprites_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/sprites.fragment */ "./Shaders/sprites.fragment.ts");
  124012. /* harmony import */ var _Shaders_sprites_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/sprites.vertex */ "./Shaders/sprites.vertex.ts");
  124013. /**
  124014. * Class used to manage multiple sprites on the same spritesheet
  124015. * @see http://doc.babylonjs.com/babylon101/sprites
  124016. */
  124017. var SpriteManager = /** @class */ (function () {
  124018. /**
  124019. * Creates a new sprite manager
  124020. * @param name defines the manager's name
  124021. * @param imgUrl defines the sprite sheet url
  124022. * @param capacity defines the maximum allowed number of sprites
  124023. * @param cellSize defines the size of a sprite cell
  124024. * @param scene defines the hosting scene
  124025. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  124026. * @param samplingMode defines the smapling mode to use with spritesheet
  124027. */
  124028. function SpriteManager(
  124029. /** defines the manager's name */
  124030. name, imgUrl, capacity, cellSize, scene, epsilon, samplingMode) {
  124031. if (epsilon === void 0) { epsilon = 0.01; }
  124032. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].TRILINEAR_SAMPLINGMODE; }
  124033. this.name = name;
  124034. /** Gets the list of sprites */
  124035. this.sprites = new Array();
  124036. /** Gets or sets the rendering group id (0 by default) */
  124037. this.renderingGroupId = 0;
  124038. /** Gets or sets camera layer mask */
  124039. this.layerMask = 0x0FFFFFFF;
  124040. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  124041. this.fogEnabled = true;
  124042. /** Gets or sets a boolean indicating if the sprites are pickable */
  124043. this.isPickable = false;
  124044. /**
  124045. * An event triggered when the manager is disposed.
  124046. */
  124047. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  124048. this._vertexBuffers = {};
  124049. if (!scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_8__["SceneComponentConstants"].NAME_SPRITE)) {
  124050. scene._addComponent(new _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__["SpriteSceneComponent"](scene));
  124051. }
  124052. this._capacity = capacity;
  124053. this._spriteTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](imgUrl, scene, true, false, samplingMode);
  124054. this._spriteTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  124055. this._spriteTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  124056. if (cellSize.width && cellSize.height) {
  124057. this.cellWidth = cellSize.width;
  124058. this.cellHeight = cellSize.height;
  124059. }
  124060. else if (cellSize !== undefined) {
  124061. this.cellWidth = cellSize;
  124062. this.cellHeight = cellSize;
  124063. }
  124064. else {
  124065. return;
  124066. }
  124067. this._epsilon = epsilon;
  124068. this._scene = scene;
  124069. this._scene.spriteManagers.push(this);
  124070. var indices = [];
  124071. var index = 0;
  124072. for (var count = 0; count < capacity; count++) {
  124073. indices.push(index);
  124074. indices.push(index + 1);
  124075. indices.push(index + 2);
  124076. indices.push(index);
  124077. indices.push(index + 2);
  124078. indices.push(index + 3);
  124079. index += 4;
  124080. }
  124081. this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
  124082. // VBO
  124083. // 16 floats per sprite (x, y, z, angle, sizeX, sizeY, offsetX, offsetY, invertU, invertV, cellIndexX, cellIndexY, color r, color g, color b, color a)
  124084. this._vertexData = new Float32Array(capacity * 16 * 4);
  124085. this._buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["Buffer"](scene.getEngine(), this._vertexData, true, 16);
  124086. var positions = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, 0, 4);
  124087. var options = this._buffer.createVertexBuffer("options", 4, 4);
  124088. var cellInfo = this._buffer.createVertexBuffer("cellInfo", 8, 4);
  124089. var colors = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, 12, 4);
  124090. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind] = positions;
  124091. this._vertexBuffers["options"] = options;
  124092. this._vertexBuffers["cellInfo"] = cellInfo;
  124093. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind] = colors;
  124094. // Effects
  124095. 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"], "");
  124096. 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");
  124097. }
  124098. Object.defineProperty(SpriteManager.prototype, "onDispose", {
  124099. /**
  124100. * Callback called when the manager is disposed
  124101. */
  124102. set: function (callback) {
  124103. if (this._onDisposeObserver) {
  124104. this.onDisposeObservable.remove(this._onDisposeObserver);
  124105. }
  124106. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  124107. },
  124108. enumerable: true,
  124109. configurable: true
  124110. });
  124111. Object.defineProperty(SpriteManager.prototype, "texture", {
  124112. /**
  124113. * Gets or sets the spritesheet texture
  124114. */
  124115. get: function () {
  124116. return this._spriteTexture;
  124117. },
  124118. set: function (value) {
  124119. this._spriteTexture = value;
  124120. },
  124121. enumerable: true,
  124122. configurable: true
  124123. });
  124124. SpriteManager.prototype._appendSpriteVertex = function (index, sprite, offsetX, offsetY, rowSize) {
  124125. var arrayOffset = index * 16;
  124126. if (offsetX === 0) {
  124127. offsetX = this._epsilon;
  124128. }
  124129. else if (offsetX === 1) {
  124130. offsetX = 1 - this._epsilon;
  124131. }
  124132. if (offsetY === 0) {
  124133. offsetY = this._epsilon;
  124134. }
  124135. else if (offsetY === 1) {
  124136. offsetY = 1 - this._epsilon;
  124137. }
  124138. this._vertexData[arrayOffset] = sprite.position.x;
  124139. this._vertexData[arrayOffset + 1] = sprite.position.y;
  124140. this._vertexData[arrayOffset + 2] = sprite.position.z;
  124141. this._vertexData[arrayOffset + 3] = sprite.angle;
  124142. this._vertexData[arrayOffset + 4] = sprite.width;
  124143. this._vertexData[arrayOffset + 5] = sprite.height;
  124144. this._vertexData[arrayOffset + 6] = offsetX;
  124145. this._vertexData[arrayOffset + 7] = offsetY;
  124146. this._vertexData[arrayOffset + 8] = sprite.invertU ? 1 : 0;
  124147. this._vertexData[arrayOffset + 9] = sprite.invertV ? 1 : 0;
  124148. var offset = (sprite.cellIndex / rowSize) >> 0;
  124149. this._vertexData[arrayOffset + 10] = sprite.cellIndex - offset * rowSize;
  124150. this._vertexData[arrayOffset + 11] = offset;
  124151. // Color
  124152. this._vertexData[arrayOffset + 12] = sprite.color.r;
  124153. this._vertexData[arrayOffset + 13] = sprite.color.g;
  124154. this._vertexData[arrayOffset + 14] = sprite.color.b;
  124155. this._vertexData[arrayOffset + 15] = sprite.color.a;
  124156. };
  124157. /**
  124158. * Intersects the sprites with a ray
  124159. * @param ray defines the ray to intersect with
  124160. * @param camera defines the current active camera
  124161. * @param predicate defines a predicate used to select candidate sprites
  124162. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  124163. * @returns null if no hit or a PickingInfo
  124164. */
  124165. SpriteManager.prototype.intersects = function (ray, camera, predicate, fastCheck) {
  124166. var count = Math.min(this._capacity, this.sprites.length);
  124167. var min = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  124168. var max = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  124169. var distance = Number.MAX_VALUE;
  124170. var currentSprite = null;
  124171. var cameraSpacePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  124172. var cameraView = camera.getViewMatrix();
  124173. for (var index = 0; index < count; index++) {
  124174. var sprite = this.sprites[index];
  124175. if (!sprite) {
  124176. continue;
  124177. }
  124178. if (predicate) {
  124179. if (!predicate(sprite)) {
  124180. continue;
  124181. }
  124182. }
  124183. else if (!sprite.isPickable) {
  124184. continue;
  124185. }
  124186. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(sprite.position, cameraView, cameraSpacePosition);
  124187. min.copyFromFloats(cameraSpacePosition.x - sprite.width / 2, cameraSpacePosition.y - sprite.height / 2, cameraSpacePosition.z);
  124188. max.copyFromFloats(cameraSpacePosition.x + sprite.width / 2, cameraSpacePosition.y + sprite.height / 2, cameraSpacePosition.z);
  124189. if (ray.intersectsBoxMinMax(min, max)) {
  124190. var currentDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(cameraSpacePosition, ray.origin);
  124191. if (distance > currentDistance) {
  124192. distance = currentDistance;
  124193. currentSprite = sprite;
  124194. if (fastCheck) {
  124195. break;
  124196. }
  124197. }
  124198. }
  124199. }
  124200. if (currentSprite) {
  124201. var result = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__["PickingInfo"]();
  124202. result.hit = true;
  124203. result.pickedSprite = currentSprite;
  124204. result.distance = distance;
  124205. return result;
  124206. }
  124207. return null;
  124208. };
  124209. /**
  124210. * Render all child sprites
  124211. */
  124212. SpriteManager.prototype.render = function () {
  124213. // Check
  124214. if (!this._effectBase.isReady() || !this._effectFog.isReady() || !this._spriteTexture
  124215. || !this._spriteTexture.isReady() || !this.sprites.length) {
  124216. return;
  124217. }
  124218. var engine = this._scene.getEngine();
  124219. var baseSize = this._spriteTexture.getBaseSize();
  124220. // Sprites
  124221. var deltaTime = engine.getDeltaTime();
  124222. var max = Math.min(this._capacity, this.sprites.length);
  124223. var rowSize = baseSize.width / this.cellWidth;
  124224. var offset = 0;
  124225. for (var index = 0; index < max; index++) {
  124226. var sprite = this.sprites[index];
  124227. if (!sprite || !sprite.isVisible) {
  124228. continue;
  124229. }
  124230. sprite._animate(deltaTime);
  124231. this._appendSpriteVertex(offset++, sprite, 0, 0, rowSize);
  124232. this._appendSpriteVertex(offset++, sprite, 1, 0, rowSize);
  124233. this._appendSpriteVertex(offset++, sprite, 1, 1, rowSize);
  124234. this._appendSpriteVertex(offset++, sprite, 0, 1, rowSize);
  124235. }
  124236. this._buffer.update(this._vertexData);
  124237. // Render
  124238. var effect = this._effectBase;
  124239. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  124240. effect = this._effectFog;
  124241. }
  124242. engine.enableEffect(effect);
  124243. var viewMatrix = this._scene.getViewMatrix();
  124244. effect.setTexture("diffuseSampler", this._spriteTexture);
  124245. effect.setMatrix("view", viewMatrix);
  124246. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  124247. effect.setFloat2("textureInfos", this.cellWidth / baseSize.width, this.cellHeight / baseSize.height);
  124248. // Fog
  124249. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  124250. effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
  124251. effect.setColor3("vFogColor", this._scene.fogColor);
  124252. }
  124253. // VBOs
  124254. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  124255. // Draw order
  124256. engine.setDepthFunctionToLessOrEqual();
  124257. effect.setBool("alphaTest", true);
  124258. engine.setColorWrite(false);
  124259. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  124260. engine.setColorWrite(true);
  124261. effect.setBool("alphaTest", false);
  124262. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_COMBINE);
  124263. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  124264. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_DISABLE);
  124265. };
  124266. /**
  124267. * Release associated resources
  124268. */
  124269. SpriteManager.prototype.dispose = function () {
  124270. if (this._buffer) {
  124271. this._buffer.dispose();
  124272. this._buffer = null;
  124273. }
  124274. if (this._indexBuffer) {
  124275. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  124276. this._indexBuffer = null;
  124277. }
  124278. if (this._spriteTexture) {
  124279. this._spriteTexture.dispose();
  124280. this._spriteTexture = null;
  124281. }
  124282. // Remove from scene
  124283. var index = this._scene.spriteManagers.indexOf(this);
  124284. this._scene.spriteManagers.splice(index, 1);
  124285. // Callback
  124286. this.onDisposeObservable.notifyObservers(this);
  124287. this.onDisposeObservable.clear();
  124288. };
  124289. return SpriteManager;
  124290. }());
  124291. /***/ }),
  124292. /***/ "./Sprites/spriteSceneComponent.ts":
  124293. /*!*****************************************!*\
  124294. !*** ./Sprites/spriteSceneComponent.ts ***!
  124295. \*****************************************/
  124296. /*! exports provided: SpriteSceneComponent */
  124297. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124298. "use strict";
  124299. __webpack_require__.r(__webpack_exports__);
  124300. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return SpriteSceneComponent; });
  124301. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  124302. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  124303. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  124304. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  124305. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  124306. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Actions/actionEvent */ "./Actions/actionEvent.ts");
  124307. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124308. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype._internalPickSprites = function (ray, predicate, fastCheck, camera) {
  124309. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]) {
  124310. return null;
  124311. }
  124312. var pickingInfo = null;
  124313. if (!camera) {
  124314. if (!this.activeCamera) {
  124315. return null;
  124316. }
  124317. camera = this.activeCamera;
  124318. }
  124319. if (this.spriteManagers.length > 0) {
  124320. for (var spriteIndex = 0; spriteIndex < this.spriteManagers.length; spriteIndex++) {
  124321. var spriteManager = this.spriteManagers[spriteIndex];
  124322. if (!spriteManager.isPickable) {
  124323. continue;
  124324. }
  124325. var result = spriteManager.intersects(ray, camera, predicate, fastCheck);
  124326. if (!result || !result.hit) {
  124327. continue;
  124328. }
  124329. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  124330. continue;
  124331. }
  124332. pickingInfo = result;
  124333. if (fastCheck) {
  124334. break;
  124335. }
  124336. }
  124337. }
  124338. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]();
  124339. };
  124340. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSprite = function (x, y, predicate, fastCheck, camera) {
  124341. this.createPickingRayInCameraSpaceToRef(x, y, this._tempSpritePickingRay, camera);
  124342. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  124343. };
  124344. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSpriteWithRay = function (ray, predicate, fastCheck, camera) {
  124345. if (!this._tempSpritePickingRay) {
  124346. return null;
  124347. }
  124348. if (!camera) {
  124349. if (!this.activeCamera) {
  124350. return null;
  124351. }
  124352. camera = this.activeCamera;
  124353. }
  124354. _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].TransformToRef(ray, camera.getViewMatrix(), this._tempSpritePickingRay);
  124355. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  124356. };
  124357. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.setPointerOverSprite = function (sprite) {
  124358. if (this._pointerOverSprite === sprite) {
  124359. return;
  124360. }
  124361. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  124362. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  124363. }
  124364. this._pointerOverSprite = sprite;
  124365. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  124366. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  124367. }
  124368. };
  124369. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.getPointerOverSprite = function () {
  124370. return this._pointerOverSprite;
  124371. };
  124372. /**
  124373. * Defines the sprite scene component responsible to manage sprites
  124374. * in a given scene.
  124375. */
  124376. var SpriteSceneComponent = /** @class */ (function () {
  124377. /**
  124378. * Creates a new instance of the component for the given scene
  124379. * @param scene Defines the scene to register the component in
  124380. */
  124381. function SpriteSceneComponent(scene) {
  124382. /**
  124383. * The component name helpfull to identify the component in the list of scene components.
  124384. */
  124385. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_SPRITE;
  124386. this.scene = scene;
  124387. this.scene.spriteManagers = new Array();
  124388. this.scene._tempSpritePickingRay = _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"] ? _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].Zero() : null;
  124389. this.scene.onBeforeSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  124390. this.scene.onAfterSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  124391. this._spritePredicate = function (sprite) {
  124392. if (!sprite.actionManager) {
  124393. return false;
  124394. }
  124395. return sprite.isPickable && sprite.actionManager.hasPointerTriggers;
  124396. };
  124397. }
  124398. /**
  124399. * Registers the component in a given scene
  124400. */
  124401. SpriteSceneComponent.prototype.register = function () {
  124402. this.scene._pointerMoveStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERMOVE_SPRITE, this, this._pointerMove);
  124403. this.scene._pointerDownStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERDOWN_SPRITE, this, this._pointerDown);
  124404. this.scene._pointerUpStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERUP_SPRITE, this, this._pointerUp);
  124405. };
  124406. /**
  124407. * Rebuilds the elements related to this component in case of
  124408. * context lost for instance.
  124409. */
  124410. SpriteSceneComponent.prototype.rebuild = function () {
  124411. /** Nothing to do for sprites */
  124412. };
  124413. /**
  124414. * Disposes the component and the associated ressources.
  124415. */
  124416. SpriteSceneComponent.prototype.dispose = function () {
  124417. this.scene.onBeforeSpritesRenderingObservable.clear();
  124418. this.scene.onAfterSpritesRenderingObservable.clear();
  124419. var spriteManagers = this.scene.spriteManagers;
  124420. while (spriteManagers.length) {
  124421. spriteManagers[0].dispose();
  124422. }
  124423. };
  124424. SpriteSceneComponent.prototype._pickSpriteButKeepRay = function (originalPointerInfo, x, y, fastCheck, camera) {
  124425. var result = this.scene.pickSprite(x, y, this._spritePredicate, fastCheck, camera);
  124426. if (result) {
  124427. result.ray = originalPointerInfo ? originalPointerInfo.ray : null;
  124428. }
  124429. return result;
  124430. };
  124431. SpriteSceneComponent.prototype._pointerMove = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, isMeshPicked, canvas) {
  124432. var scene = this.scene;
  124433. if (isMeshPicked) {
  124434. scene.setPointerOverSprite(null);
  124435. }
  124436. else {
  124437. pickResult = this._pickSpriteButKeepRay(pickResult, unTranslatedPointerX, unTranslatedPointerY, false, scene.cameraToUseForPointers || undefined);
  124438. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  124439. scene.setPointerOverSprite(pickResult.pickedSprite);
  124440. if (scene._pointerOverSprite && scene._pointerOverSprite.actionManager && scene._pointerOverSprite.actionManager.hoverCursor) {
  124441. canvas.style.cursor = scene._pointerOverSprite.actionManager.hoverCursor;
  124442. }
  124443. else {
  124444. canvas.style.cursor = scene.hoverCursor;
  124445. }
  124446. }
  124447. else {
  124448. scene.setPointerOverSprite(null);
  124449. }
  124450. }
  124451. return pickResult;
  124452. };
  124453. SpriteSceneComponent.prototype._pointerDown = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  124454. var scene = this.scene;
  124455. scene._pickedDownSprite = null;
  124456. if (scene.spriteManagers.length > 0) {
  124457. pickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  124458. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  124459. if (pickResult.pickedSprite.actionManager) {
  124460. scene._pickedDownSprite = pickResult.pickedSprite;
  124461. switch (evt.button) {
  124462. case 0:
  124463. 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));
  124464. break;
  124465. case 1:
  124466. 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));
  124467. break;
  124468. case 2:
  124469. 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));
  124470. break;
  124471. }
  124472. if (pickResult.pickedSprite.actionManager) {
  124473. 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));
  124474. }
  124475. }
  124476. }
  124477. }
  124478. return pickResult;
  124479. };
  124480. SpriteSceneComponent.prototype._pointerUp = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  124481. var scene = this.scene;
  124482. if (scene.spriteManagers.length > 0) {
  124483. var spritePickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  124484. if (spritePickResult) {
  124485. if (spritePickResult.hit && spritePickResult.pickedSprite) {
  124486. if (spritePickResult.pickedSprite.actionManager) {
  124487. 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));
  124488. if (spritePickResult.pickedSprite.actionManager) {
  124489. if (!this.scene._isPointerSwiping()) {
  124490. 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));
  124491. }
  124492. }
  124493. }
  124494. }
  124495. if (scene._pickedDownSprite && scene._pickedDownSprite.actionManager && scene._pickedDownSprite !== spritePickResult.pickedSprite) {
  124496. 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));
  124497. }
  124498. }
  124499. }
  124500. return pickResult;
  124501. };
  124502. return SpriteSceneComponent;
  124503. }());
  124504. /***/ }),
  124505. /***/ "./States/alphaCullingState.ts":
  124506. /*!*************************************!*\
  124507. !*** ./States/alphaCullingState.ts ***!
  124508. \*************************************/
  124509. /*! exports provided: _AlphaState */
  124510. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124511. "use strict";
  124512. __webpack_require__.r(__webpack_exports__);
  124513. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _AlphaState; });
  124514. /**
  124515. * @hidden
  124516. **/
  124517. var _AlphaState = /** @class */ (function () {
  124518. /**
  124519. * Initializes the state.
  124520. */
  124521. function _AlphaState() {
  124522. this._isAlphaBlendDirty = false;
  124523. this._isBlendFunctionParametersDirty = false;
  124524. this._isBlendEquationParametersDirty = false;
  124525. this._isBlendConstantsDirty = false;
  124526. this._alphaBlend = false;
  124527. this._blendFunctionParameters = new Array(4);
  124528. this._blendEquationParameters = new Array(2);
  124529. this._blendConstants = new Array(4);
  124530. this.reset();
  124531. }
  124532. Object.defineProperty(_AlphaState.prototype, "isDirty", {
  124533. get: function () {
  124534. return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty;
  124535. },
  124536. enumerable: true,
  124537. configurable: true
  124538. });
  124539. Object.defineProperty(_AlphaState.prototype, "alphaBlend", {
  124540. get: function () {
  124541. return this._alphaBlend;
  124542. },
  124543. set: function (value) {
  124544. if (this._alphaBlend === value) {
  124545. return;
  124546. }
  124547. this._alphaBlend = value;
  124548. this._isAlphaBlendDirty = true;
  124549. },
  124550. enumerable: true,
  124551. configurable: true
  124552. });
  124553. _AlphaState.prototype.setAlphaBlendConstants = function (r, g, b, a) {
  124554. if (this._blendConstants[0] === r &&
  124555. this._blendConstants[1] === g &&
  124556. this._blendConstants[2] === b &&
  124557. this._blendConstants[3] === a) {
  124558. return;
  124559. }
  124560. this._blendConstants[0] = r;
  124561. this._blendConstants[1] = g;
  124562. this._blendConstants[2] = b;
  124563. this._blendConstants[3] = a;
  124564. this._isBlendConstantsDirty = true;
  124565. };
  124566. _AlphaState.prototype.setAlphaBlendFunctionParameters = function (value0, value1, value2, value3) {
  124567. if (this._blendFunctionParameters[0] === value0 &&
  124568. this._blendFunctionParameters[1] === value1 &&
  124569. this._blendFunctionParameters[2] === value2 &&
  124570. this._blendFunctionParameters[3] === value3) {
  124571. return;
  124572. }
  124573. this._blendFunctionParameters[0] = value0;
  124574. this._blendFunctionParameters[1] = value1;
  124575. this._blendFunctionParameters[2] = value2;
  124576. this._blendFunctionParameters[3] = value3;
  124577. this._isBlendFunctionParametersDirty = true;
  124578. };
  124579. _AlphaState.prototype.setAlphaEquationParameters = function (rgb, alpha) {
  124580. if (this._blendEquationParameters[0] === rgb &&
  124581. this._blendEquationParameters[1] === alpha) {
  124582. return;
  124583. }
  124584. this._blendEquationParameters[0] = rgb;
  124585. this._blendEquationParameters[1] = alpha;
  124586. this._isBlendEquationParametersDirty = true;
  124587. };
  124588. _AlphaState.prototype.reset = function () {
  124589. this._alphaBlend = false;
  124590. this._blendFunctionParameters[0] = null;
  124591. this._blendFunctionParameters[1] = null;
  124592. this._blendFunctionParameters[2] = null;
  124593. this._blendFunctionParameters[3] = null;
  124594. this._blendEquationParameters[0] = null;
  124595. this._blendEquationParameters[1] = null;
  124596. this._blendConstants[0] = null;
  124597. this._blendConstants[1] = null;
  124598. this._blendConstants[2] = null;
  124599. this._blendConstants[3] = null;
  124600. this._isAlphaBlendDirty = true;
  124601. this._isBlendFunctionParametersDirty = false;
  124602. this._isBlendEquationParametersDirty = false;
  124603. this._isBlendConstantsDirty = false;
  124604. };
  124605. _AlphaState.prototype.apply = function (gl) {
  124606. if (!this.isDirty) {
  124607. return;
  124608. }
  124609. // Alpha blend
  124610. if (this._isAlphaBlendDirty) {
  124611. if (this._alphaBlend) {
  124612. gl.enable(gl.BLEND);
  124613. }
  124614. else {
  124615. gl.disable(gl.BLEND);
  124616. }
  124617. this._isAlphaBlendDirty = false;
  124618. }
  124619. // Alpha function
  124620. if (this._isBlendFunctionParametersDirty) {
  124621. gl.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]);
  124622. this._isBlendFunctionParametersDirty = false;
  124623. }
  124624. // Alpha equation
  124625. if (this._isBlendEquationParametersDirty) {
  124626. gl.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]);
  124627. this._isBlendEquationParametersDirty = false;
  124628. }
  124629. // Constants
  124630. if (this._isBlendConstantsDirty) {
  124631. gl.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]);
  124632. this._isBlendConstantsDirty = false;
  124633. }
  124634. };
  124635. return _AlphaState;
  124636. }());
  124637. /***/ }),
  124638. /***/ "./States/depthCullingState.ts":
  124639. /*!*************************************!*\
  124640. !*** ./States/depthCullingState.ts ***!
  124641. \*************************************/
  124642. /*! exports provided: _DepthCullingState */
  124643. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124644. "use strict";
  124645. __webpack_require__.r(__webpack_exports__);
  124646. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _DepthCullingState; });
  124647. /**
  124648. * @hidden
  124649. **/
  124650. var _DepthCullingState = /** @class */ (function () {
  124651. /**
  124652. * Initializes the state.
  124653. */
  124654. function _DepthCullingState() {
  124655. this._isDepthTestDirty = false;
  124656. this._isDepthMaskDirty = false;
  124657. this._isDepthFuncDirty = false;
  124658. this._isCullFaceDirty = false;
  124659. this._isCullDirty = false;
  124660. this._isZOffsetDirty = false;
  124661. this._isFrontFaceDirty = false;
  124662. this.reset();
  124663. }
  124664. Object.defineProperty(_DepthCullingState.prototype, "isDirty", {
  124665. get: function () {
  124666. return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty;
  124667. },
  124668. enumerable: true,
  124669. configurable: true
  124670. });
  124671. Object.defineProperty(_DepthCullingState.prototype, "zOffset", {
  124672. get: function () {
  124673. return this._zOffset;
  124674. },
  124675. set: function (value) {
  124676. if (this._zOffset === value) {
  124677. return;
  124678. }
  124679. this._zOffset = value;
  124680. this._isZOffsetDirty = true;
  124681. },
  124682. enumerable: true,
  124683. configurable: true
  124684. });
  124685. Object.defineProperty(_DepthCullingState.prototype, "cullFace", {
  124686. get: function () {
  124687. return this._cullFace;
  124688. },
  124689. set: function (value) {
  124690. if (this._cullFace === value) {
  124691. return;
  124692. }
  124693. this._cullFace = value;
  124694. this._isCullFaceDirty = true;
  124695. },
  124696. enumerable: true,
  124697. configurable: true
  124698. });
  124699. Object.defineProperty(_DepthCullingState.prototype, "cull", {
  124700. get: function () {
  124701. return this._cull;
  124702. },
  124703. set: function (value) {
  124704. if (this._cull === value) {
  124705. return;
  124706. }
  124707. this._cull = value;
  124708. this._isCullDirty = true;
  124709. },
  124710. enumerable: true,
  124711. configurable: true
  124712. });
  124713. Object.defineProperty(_DepthCullingState.prototype, "depthFunc", {
  124714. get: function () {
  124715. return this._depthFunc;
  124716. },
  124717. set: function (value) {
  124718. if (this._depthFunc === value) {
  124719. return;
  124720. }
  124721. this._depthFunc = value;
  124722. this._isDepthFuncDirty = true;
  124723. },
  124724. enumerable: true,
  124725. configurable: true
  124726. });
  124727. Object.defineProperty(_DepthCullingState.prototype, "depthMask", {
  124728. get: function () {
  124729. return this._depthMask;
  124730. },
  124731. set: function (value) {
  124732. if (this._depthMask === value) {
  124733. return;
  124734. }
  124735. this._depthMask = value;
  124736. this._isDepthMaskDirty = true;
  124737. },
  124738. enumerable: true,
  124739. configurable: true
  124740. });
  124741. Object.defineProperty(_DepthCullingState.prototype, "depthTest", {
  124742. get: function () {
  124743. return this._depthTest;
  124744. },
  124745. set: function (value) {
  124746. if (this._depthTest === value) {
  124747. return;
  124748. }
  124749. this._depthTest = value;
  124750. this._isDepthTestDirty = true;
  124751. },
  124752. enumerable: true,
  124753. configurable: true
  124754. });
  124755. Object.defineProperty(_DepthCullingState.prototype, "frontFace", {
  124756. get: function () {
  124757. return this._frontFace;
  124758. },
  124759. set: function (value) {
  124760. if (this._frontFace === value) {
  124761. return;
  124762. }
  124763. this._frontFace = value;
  124764. this._isFrontFaceDirty = true;
  124765. },
  124766. enumerable: true,
  124767. configurable: true
  124768. });
  124769. _DepthCullingState.prototype.reset = function () {
  124770. this._depthMask = true;
  124771. this._depthTest = true;
  124772. this._depthFunc = null;
  124773. this._cullFace = null;
  124774. this._cull = null;
  124775. this._zOffset = 0;
  124776. this._frontFace = null;
  124777. this._isDepthTestDirty = true;
  124778. this._isDepthMaskDirty = true;
  124779. this._isDepthFuncDirty = false;
  124780. this._isCullFaceDirty = false;
  124781. this._isCullDirty = false;
  124782. this._isZOffsetDirty = false;
  124783. this._isFrontFaceDirty = false;
  124784. };
  124785. _DepthCullingState.prototype.apply = function (gl) {
  124786. if (!this.isDirty) {
  124787. return;
  124788. }
  124789. // Cull
  124790. if (this._isCullDirty) {
  124791. if (this.cull) {
  124792. gl.enable(gl.CULL_FACE);
  124793. }
  124794. else {
  124795. gl.disable(gl.CULL_FACE);
  124796. }
  124797. this._isCullDirty = false;
  124798. }
  124799. // Cull face
  124800. if (this._isCullFaceDirty) {
  124801. gl.cullFace(this.cullFace);
  124802. this._isCullFaceDirty = false;
  124803. }
  124804. // Depth mask
  124805. if (this._isDepthMaskDirty) {
  124806. gl.depthMask(this.depthMask);
  124807. this._isDepthMaskDirty = false;
  124808. }
  124809. // Depth test
  124810. if (this._isDepthTestDirty) {
  124811. if (this.depthTest) {
  124812. gl.enable(gl.DEPTH_TEST);
  124813. }
  124814. else {
  124815. gl.disable(gl.DEPTH_TEST);
  124816. }
  124817. this._isDepthTestDirty = false;
  124818. }
  124819. // Depth func
  124820. if (this._isDepthFuncDirty) {
  124821. gl.depthFunc(this.depthFunc);
  124822. this._isDepthFuncDirty = false;
  124823. }
  124824. // zOffset
  124825. if (this._isZOffsetDirty) {
  124826. if (this.zOffset) {
  124827. gl.enable(gl.POLYGON_OFFSET_FILL);
  124828. gl.polygonOffset(this.zOffset, 0);
  124829. }
  124830. else {
  124831. gl.disable(gl.POLYGON_OFFSET_FILL);
  124832. }
  124833. this._isZOffsetDirty = false;
  124834. }
  124835. // Front face
  124836. if (this._isFrontFaceDirty) {
  124837. gl.frontFace(this.frontFace);
  124838. this._isFrontFaceDirty = false;
  124839. }
  124840. };
  124841. return _DepthCullingState;
  124842. }());
  124843. /***/ }),
  124844. /***/ "./States/index.ts":
  124845. /*!*************************!*\
  124846. !*** ./States/index.ts ***!
  124847. \*************************/
  124848. /*! exports provided: _AlphaState, _DepthCullingState, _StencilState */
  124849. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124850. "use strict";
  124851. __webpack_require__.r(__webpack_exports__);
  124852. /* harmony import */ var _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./alphaCullingState */ "./States/alphaCullingState.ts");
  124853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  124854. /* harmony import */ var _depthCullingState__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthCullingState */ "./States/depthCullingState.ts");
  124855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _depthCullingState__WEBPACK_IMPORTED_MODULE_1__["_DepthCullingState"]; });
  124856. /* harmony import */ var _stencilState__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stencilState */ "./States/stencilState.ts");
  124857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _stencilState__WEBPACK_IMPORTED_MODULE_2__["_StencilState"]; });
  124858. /***/ }),
  124859. /***/ "./States/stencilState.ts":
  124860. /*!********************************!*\
  124861. !*** ./States/stencilState.ts ***!
  124862. \********************************/
  124863. /*! exports provided: _StencilState */
  124864. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124865. "use strict";
  124866. __webpack_require__.r(__webpack_exports__);
  124867. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _StencilState; });
  124868. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124869. /**
  124870. * @hidden
  124871. **/
  124872. var _StencilState = /** @class */ (function () {
  124873. function _StencilState() {
  124874. this._isStencilTestDirty = false;
  124875. this._isStencilMaskDirty = false;
  124876. this._isStencilFuncDirty = false;
  124877. this._isStencilOpDirty = false;
  124878. this.reset();
  124879. }
  124880. Object.defineProperty(_StencilState.prototype, "isDirty", {
  124881. get: function () {
  124882. return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty;
  124883. },
  124884. enumerable: true,
  124885. configurable: true
  124886. });
  124887. Object.defineProperty(_StencilState.prototype, "stencilFunc", {
  124888. get: function () {
  124889. return this._stencilFunc;
  124890. },
  124891. set: function (value) {
  124892. if (this._stencilFunc === value) {
  124893. return;
  124894. }
  124895. this._stencilFunc = value;
  124896. this._isStencilFuncDirty = true;
  124897. },
  124898. enumerable: true,
  124899. configurable: true
  124900. });
  124901. Object.defineProperty(_StencilState.prototype, "stencilFuncRef", {
  124902. get: function () {
  124903. return this._stencilFuncRef;
  124904. },
  124905. set: function (value) {
  124906. if (this._stencilFuncRef === value) {
  124907. return;
  124908. }
  124909. this._stencilFuncRef = value;
  124910. this._isStencilFuncDirty = true;
  124911. },
  124912. enumerable: true,
  124913. configurable: true
  124914. });
  124915. Object.defineProperty(_StencilState.prototype, "stencilFuncMask", {
  124916. get: function () {
  124917. return this._stencilFuncMask;
  124918. },
  124919. set: function (value) {
  124920. if (this._stencilFuncMask === value) {
  124921. return;
  124922. }
  124923. this._stencilFuncMask = value;
  124924. this._isStencilFuncDirty = true;
  124925. },
  124926. enumerable: true,
  124927. configurable: true
  124928. });
  124929. Object.defineProperty(_StencilState.prototype, "stencilOpStencilFail", {
  124930. get: function () {
  124931. return this._stencilOpStencilFail;
  124932. },
  124933. set: function (value) {
  124934. if (this._stencilOpStencilFail === value) {
  124935. return;
  124936. }
  124937. this._stencilOpStencilFail = value;
  124938. this._isStencilOpDirty = true;
  124939. },
  124940. enumerable: true,
  124941. configurable: true
  124942. });
  124943. Object.defineProperty(_StencilState.prototype, "stencilOpDepthFail", {
  124944. get: function () {
  124945. return this._stencilOpDepthFail;
  124946. },
  124947. set: function (value) {
  124948. if (this._stencilOpDepthFail === value) {
  124949. return;
  124950. }
  124951. this._stencilOpDepthFail = value;
  124952. this._isStencilOpDirty = true;
  124953. },
  124954. enumerable: true,
  124955. configurable: true
  124956. });
  124957. Object.defineProperty(_StencilState.prototype, "stencilOpStencilDepthPass", {
  124958. get: function () {
  124959. return this._stencilOpStencilDepthPass;
  124960. },
  124961. set: function (value) {
  124962. if (this._stencilOpStencilDepthPass === value) {
  124963. return;
  124964. }
  124965. this._stencilOpStencilDepthPass = value;
  124966. this._isStencilOpDirty = true;
  124967. },
  124968. enumerable: true,
  124969. configurable: true
  124970. });
  124971. Object.defineProperty(_StencilState.prototype, "stencilMask", {
  124972. get: function () {
  124973. return this._stencilMask;
  124974. },
  124975. set: function (value) {
  124976. if (this._stencilMask === value) {
  124977. return;
  124978. }
  124979. this._stencilMask = value;
  124980. this._isStencilMaskDirty = true;
  124981. },
  124982. enumerable: true,
  124983. configurable: true
  124984. });
  124985. Object.defineProperty(_StencilState.prototype, "stencilTest", {
  124986. get: function () {
  124987. return this._stencilTest;
  124988. },
  124989. set: function (value) {
  124990. if (this._stencilTest === value) {
  124991. return;
  124992. }
  124993. this._stencilTest = value;
  124994. this._isStencilTestDirty = true;
  124995. },
  124996. enumerable: true,
  124997. configurable: true
  124998. });
  124999. _StencilState.prototype.reset = function () {
  125000. this._stencilTest = false;
  125001. this._stencilMask = 0xFF;
  125002. this._stencilFunc = _StencilState.ALWAYS;
  125003. this._stencilFuncRef = 1;
  125004. this._stencilFuncMask = 0xFF;
  125005. this._stencilOpStencilFail = _StencilState.KEEP;
  125006. this._stencilOpDepthFail = _StencilState.KEEP;
  125007. this._stencilOpStencilDepthPass = _StencilState.REPLACE;
  125008. this._isStencilTestDirty = true;
  125009. this._isStencilMaskDirty = true;
  125010. this._isStencilFuncDirty = true;
  125011. this._isStencilOpDirty = true;
  125012. };
  125013. _StencilState.prototype.apply = function (gl) {
  125014. if (!this.isDirty) {
  125015. return;
  125016. }
  125017. // Stencil test
  125018. if (this._isStencilTestDirty) {
  125019. if (this.stencilTest) {
  125020. gl.enable(gl.STENCIL_TEST);
  125021. }
  125022. else {
  125023. gl.disable(gl.STENCIL_TEST);
  125024. }
  125025. this._isStencilTestDirty = false;
  125026. }
  125027. // Stencil mask
  125028. if (this._isStencilMaskDirty) {
  125029. gl.stencilMask(this.stencilMask);
  125030. this._isStencilMaskDirty = false;
  125031. }
  125032. // Stencil func
  125033. if (this._isStencilFuncDirty) {
  125034. gl.stencilFunc(this.stencilFunc, this.stencilFuncRef, this.stencilFuncMask);
  125035. this._isStencilFuncDirty = false;
  125036. }
  125037. // Stencil op
  125038. if (this._isStencilOpDirty) {
  125039. gl.stencilOp(this.stencilOpStencilFail, this.stencilOpDepthFail, this.stencilOpStencilDepthPass);
  125040. this._isStencilOpDirty = false;
  125041. }
  125042. };
  125043. /** 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 */
  125044. _StencilState.ALWAYS = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ALWAYS;
  125045. /** Passed to stencilOperation to specify that stencil value must be kept */
  125046. _StencilState.KEEP = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].KEEP;
  125047. /** Passed to stencilOperation to specify that stencil value must be replaced */
  125048. _StencilState.REPLACE = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].REPLACE;
  125049. return _StencilState;
  125050. }());
  125051. /***/ }),
  125052. /***/ "./abstractScene.ts":
  125053. /*!**************************!*\
  125054. !*** ./abstractScene.ts ***!
  125055. \**************************/
  125056. /*! exports provided: AbstractScene */
  125057. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125058. "use strict";
  125059. __webpack_require__.r(__webpack_exports__);
  125060. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return AbstractScene; });
  125061. /**
  125062. * Base class of the scene acting as a container for the different elements composing a scene.
  125063. * This class is dynamically extended by the different components of the scene increasing
  125064. * flexibility and reducing coupling
  125065. */
  125066. var AbstractScene = /** @class */ (function () {
  125067. function AbstractScene() {
  125068. /**
  125069. * Gets the list of root nodes (ie. nodes with no parent)
  125070. */
  125071. this.rootNodes = new Array();
  125072. /** All of the cameras added to this scene
  125073. * @see http://doc.babylonjs.com/babylon101/cameras
  125074. */
  125075. this.cameras = new Array();
  125076. /**
  125077. * All of the lights added to this scene
  125078. * @see http://doc.babylonjs.com/babylon101/lights
  125079. */
  125080. this.lights = new Array();
  125081. /**
  125082. * All of the (abstract) meshes added to this scene
  125083. */
  125084. this.meshes = new Array();
  125085. /**
  125086. * The list of skeletons added to the scene
  125087. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  125088. */
  125089. this.skeletons = new Array();
  125090. /**
  125091. * All of the particle systems added to this scene
  125092. * @see http://doc.babylonjs.com/babylon101/particles
  125093. */
  125094. this.particleSystems = new Array();
  125095. /**
  125096. * Gets a list of Animations associated with the scene
  125097. */
  125098. this.animations = [];
  125099. /**
  125100. * All of the animation groups added to this scene
  125101. * @see http://doc.babylonjs.com/how_to/group
  125102. */
  125103. this.animationGroups = new Array();
  125104. /**
  125105. * All of the multi-materials added to this scene
  125106. * @see http://doc.babylonjs.com/how_to/multi_materials
  125107. */
  125108. this.multiMaterials = new Array();
  125109. /**
  125110. * All of the materials added to this scene
  125111. * In the context of a Scene, it is not supposed to be modified manually.
  125112. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  125113. * Note also that the order of the Material wihin the array is not significant and might change.
  125114. * @see http://doc.babylonjs.com/babylon101/materials
  125115. */
  125116. this.materials = new Array();
  125117. /**
  125118. * The list of morph target managers added to the scene
  125119. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  125120. */
  125121. this.morphTargetManagers = new Array();
  125122. /**
  125123. * The list of geometries used in the scene.
  125124. */
  125125. this.geometries = new Array();
  125126. /**
  125127. * All of the tranform nodes added to this scene
  125128. * In the context of a Scene, it is not supposed to be modified manually.
  125129. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  125130. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  125131. * @see http://doc.babylonjs.com/how_to/transformnode
  125132. */
  125133. this.transformNodes = new Array();
  125134. /**
  125135. * ActionManagers available on the scene.
  125136. */
  125137. this.actionManagers = new Array();
  125138. /**
  125139. * Textures to keep.
  125140. */
  125141. this.textures = new Array();
  125142. }
  125143. /**
  125144. * Adds a parser in the list of available ones
  125145. * @param name Defines the name of the parser
  125146. * @param parser Defines the parser to add
  125147. */
  125148. AbstractScene.AddParser = function (name, parser) {
  125149. this._BabylonFileParsers[name] = parser;
  125150. };
  125151. /**
  125152. * Gets a general parser from the list of avaialble ones
  125153. * @param name Defines the name of the parser
  125154. * @returns the requested parser or null
  125155. */
  125156. AbstractScene.GetParser = function (name) {
  125157. if (this._BabylonFileParsers[name]) {
  125158. return this._BabylonFileParsers[name];
  125159. }
  125160. return null;
  125161. };
  125162. /**
  125163. * Adds n individual parser in the list of available ones
  125164. * @param name Defines the name of the parser
  125165. * @param parser Defines the parser to add
  125166. */
  125167. AbstractScene.AddIndividualParser = function (name, parser) {
  125168. this._IndividualBabylonFileParsers[name] = parser;
  125169. };
  125170. /**
  125171. * Gets an individual parser from the list of avaialble ones
  125172. * @param name Defines the name of the parser
  125173. * @returns the requested parser or null
  125174. */
  125175. AbstractScene.GetIndividualParser = function (name) {
  125176. if (this._IndividualBabylonFileParsers[name]) {
  125177. return this._IndividualBabylonFileParsers[name];
  125178. }
  125179. return null;
  125180. };
  125181. /**
  125182. * Parser json data and populate both a scene and its associated container object
  125183. * @param jsonData Defines the data to parse
  125184. * @param scene Defines the scene to parse the data for
  125185. * @param container Defines the container attached to the parsing sequence
  125186. * @param rootUrl Defines the root url of the data
  125187. */
  125188. AbstractScene.Parse = function (jsonData, scene, container, rootUrl) {
  125189. for (var parserName in this._BabylonFileParsers) {
  125190. if (this._BabylonFileParsers.hasOwnProperty(parserName)) {
  125191. this._BabylonFileParsers[parserName](jsonData, scene, container, rootUrl);
  125192. }
  125193. }
  125194. };
  125195. /**
  125196. * Stores the list of available parsers in the application.
  125197. */
  125198. AbstractScene._BabylonFileParsers = {};
  125199. /**
  125200. * Stores the list of available individual parsers in the application.
  125201. */
  125202. AbstractScene._IndividualBabylonFileParsers = {};
  125203. return AbstractScene;
  125204. }());
  125205. /***/ }),
  125206. /***/ "./assetContainer.ts":
  125207. /*!***************************!*\
  125208. !*** ./assetContainer.ts ***!
  125209. \***************************/
  125210. /*! exports provided: KeepAssets, AssetContainer */
  125211. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125212. "use strict";
  125213. __webpack_require__.r(__webpack_exports__);
  125214. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return KeepAssets; });
  125215. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return AssetContainer; });
  125216. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125217. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  125218. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Meshes/mesh */ "./Meshes/mesh.ts");
  125219. /**
  125220. * Set of assets to keep when moving a scene into an asset container.
  125221. */
  125222. var KeepAssets = /** @class */ (function (_super) {
  125223. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeepAssets, _super);
  125224. function KeepAssets() {
  125225. return _super !== null && _super.apply(this, arguments) || this;
  125226. }
  125227. return KeepAssets;
  125228. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  125229. /**
  125230. * Container with a set of assets that can be added or removed from a scene.
  125231. */
  125232. var AssetContainer = /** @class */ (function (_super) {
  125233. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AssetContainer, _super);
  125234. /**
  125235. * Instantiates an AssetContainer.
  125236. * @param scene The scene the AssetContainer belongs to.
  125237. */
  125238. function AssetContainer(scene) {
  125239. var _this = _super.call(this) || this;
  125240. _this.scene = scene;
  125241. _this["sounds"] = [];
  125242. _this["effectLayers"] = [];
  125243. _this["layers"] = [];
  125244. _this["lensFlareSystems"] = [];
  125245. _this["proceduralTextures"] = [];
  125246. _this["reflectionProbes"] = [];
  125247. return _this;
  125248. }
  125249. /**
  125250. * Adds all the assets from the container to the scene.
  125251. */
  125252. AssetContainer.prototype.addAllToScene = function () {
  125253. var _this = this;
  125254. this.cameras.forEach(function (o) {
  125255. _this.scene.addCamera(o);
  125256. });
  125257. this.lights.forEach(function (o) {
  125258. _this.scene.addLight(o);
  125259. });
  125260. this.meshes.forEach(function (o) {
  125261. _this.scene.addMesh(o);
  125262. });
  125263. this.skeletons.forEach(function (o) {
  125264. _this.scene.addSkeleton(o);
  125265. });
  125266. this.animations.forEach(function (o) {
  125267. _this.scene.addAnimation(o);
  125268. });
  125269. this.animationGroups.forEach(function (o) {
  125270. _this.scene.addAnimationGroup(o);
  125271. });
  125272. this.multiMaterials.forEach(function (o) {
  125273. _this.scene.addMultiMaterial(o);
  125274. });
  125275. this.materials.forEach(function (o) {
  125276. _this.scene.addMaterial(o);
  125277. });
  125278. this.morphTargetManagers.forEach(function (o) {
  125279. _this.scene.addMorphTargetManager(o);
  125280. });
  125281. this.geometries.forEach(function (o) {
  125282. _this.scene.addGeometry(o);
  125283. });
  125284. this.transformNodes.forEach(function (o) {
  125285. _this.scene.addTransformNode(o);
  125286. });
  125287. this.actionManagers.forEach(function (o) {
  125288. _this.scene.addActionManager(o);
  125289. });
  125290. this.textures.forEach(function (o) {
  125291. _this.scene.addTexture(o);
  125292. });
  125293. this.reflectionProbes.forEach(function (o) {
  125294. _this.scene.addReflectionProbe(o);
  125295. });
  125296. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  125297. var component = _a[_i];
  125298. component.addFromContainer(this);
  125299. }
  125300. };
  125301. /**
  125302. * Removes all the assets in the container from the scene
  125303. */
  125304. AssetContainer.prototype.removeAllFromScene = function () {
  125305. var _this = this;
  125306. this.cameras.forEach(function (o) {
  125307. _this.scene.removeCamera(o);
  125308. });
  125309. this.lights.forEach(function (o) {
  125310. _this.scene.removeLight(o);
  125311. });
  125312. this.meshes.forEach(function (o) {
  125313. _this.scene.removeMesh(o);
  125314. });
  125315. this.skeletons.forEach(function (o) {
  125316. _this.scene.removeSkeleton(o);
  125317. });
  125318. this.animations.forEach(function (o) {
  125319. _this.scene.removeAnimation(o);
  125320. });
  125321. this.animationGroups.forEach(function (o) {
  125322. _this.scene.removeAnimationGroup(o);
  125323. });
  125324. this.multiMaterials.forEach(function (o) {
  125325. _this.scene.removeMultiMaterial(o);
  125326. });
  125327. this.materials.forEach(function (o) {
  125328. _this.scene.removeMaterial(o);
  125329. });
  125330. this.morphTargetManagers.forEach(function (o) {
  125331. _this.scene.removeMorphTargetManager(o);
  125332. });
  125333. this.geometries.forEach(function (o) {
  125334. _this.scene.removeGeometry(o);
  125335. });
  125336. this.transformNodes.forEach(function (o) {
  125337. _this.scene.removeTransformNode(o);
  125338. });
  125339. this.actionManagers.forEach(function (o) {
  125340. _this.scene.removeActionManager(o);
  125341. });
  125342. this.textures.forEach(function (o) {
  125343. _this.scene.removeTexture(o);
  125344. });
  125345. this.reflectionProbes.forEach(function (o) {
  125346. _this.scene.removeReflectionProbe(o);
  125347. });
  125348. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  125349. var component = _a[_i];
  125350. component.removeFromContainer(this);
  125351. }
  125352. };
  125353. /**
  125354. * Disposes all the assets in the container
  125355. */
  125356. AssetContainer.prototype.dispose = function () {
  125357. this.cameras.forEach(function (o) {
  125358. o.dispose();
  125359. });
  125360. this.lights.forEach(function (o) {
  125361. o.dispose();
  125362. });
  125363. this.meshes.forEach(function (o) {
  125364. o.dispose();
  125365. });
  125366. this.skeletons.forEach(function (o) {
  125367. o.dispose();
  125368. });
  125369. this.animationGroups.forEach(function (o) {
  125370. o.dispose();
  125371. });
  125372. this.multiMaterials.forEach(function (o) {
  125373. o.dispose();
  125374. });
  125375. this.materials.forEach(function (o) {
  125376. o.dispose();
  125377. });
  125378. this.geometries.forEach(function (o) {
  125379. o.dispose();
  125380. });
  125381. this.transformNodes.forEach(function (o) {
  125382. o.dispose();
  125383. });
  125384. this.actionManagers.forEach(function (o) {
  125385. o.dispose();
  125386. });
  125387. this.textures.forEach(function (o) {
  125388. o.dispose();
  125389. });
  125390. this.reflectionProbes.forEach(function (o) {
  125391. o.dispose();
  125392. });
  125393. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  125394. var component = _a[_i];
  125395. component.dispose();
  125396. }
  125397. };
  125398. AssetContainer.prototype._moveAssets = function (sourceAssets, targetAssets, keepAssets) {
  125399. if (!sourceAssets) {
  125400. return;
  125401. }
  125402. for (var _i = 0, sourceAssets_1 = sourceAssets; _i < sourceAssets_1.length; _i++) {
  125403. var asset = sourceAssets_1[_i];
  125404. var move = true;
  125405. if (keepAssets) {
  125406. for (var _a = 0, keepAssets_1 = keepAssets; _a < keepAssets_1.length; _a++) {
  125407. var keepAsset = keepAssets_1[_a];
  125408. if (asset === keepAsset) {
  125409. move = false;
  125410. break;
  125411. }
  125412. }
  125413. }
  125414. if (move) {
  125415. targetAssets.push(asset);
  125416. }
  125417. }
  125418. };
  125419. /**
  125420. * Removes all the assets contained in the scene and adds them to the container.
  125421. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  125422. */
  125423. AssetContainer.prototype.moveAllFromScene = function (keepAssets) {
  125424. if (keepAssets === undefined) {
  125425. keepAssets = new KeepAssets();
  125426. }
  125427. for (var key in this) {
  125428. if (this.hasOwnProperty(key)) {
  125429. this[key] = this[key] || [];
  125430. this._moveAssets(this.scene[key], this[key], keepAssets[key]);
  125431. }
  125432. }
  125433. this.removeAllFromScene();
  125434. };
  125435. /**
  125436. * 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.
  125437. * @returns the root mesh
  125438. */
  125439. AssetContainer.prototype.createRootMesh = function () {
  125440. var rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("assetContainerRootMesh", this.scene);
  125441. this.meshes.forEach(function (m) {
  125442. if (!m.parent) {
  125443. rootMesh.addChild(m);
  125444. }
  125445. });
  125446. this.meshes.unshift(rootMesh);
  125447. return rootMesh;
  125448. };
  125449. return AssetContainer;
  125450. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  125451. /***/ }),
  125452. /***/ "./index.ts":
  125453. /*!******************!*\
  125454. !*** ./index.ts ***!
  125455. \******************/
  125456. /*! exports provided: AbstractScene, KeepAssets, AssetContainer, Node, Scene, SceneComponentConstants, Stage, Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction, Animatable, AnimationRange, AnimationEvent, PathCursor, AnimationKeyInterpolation, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, CollisionCoordinatorLegacy, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, _PrimitiveGeometry, RibbonGeometry, BoxGeometry, SphereGeometry, DiscGeometry, CylinderGeometry, TorusGeometry, GroundGeometry, TiledGroundGeometry, PlaneGeometry, TorusKnotGeometry, GroundMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, MorphTarget, MorphTargetManager, Database, BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, ReflectionProbe, BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer, Sprite, SpriteManager, SpriteSceneComponent, _AlphaState, _DepthCullingState, _StencilState, AndOrNotEvaluator, AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, FilesInput, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  125457. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125458. "use strict";
  125459. __webpack_require__.r(__webpack_exports__);
  125460. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  125461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _abstractScene__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  125462. /* harmony import */ var _Actions_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Actions/index */ "./Actions/index.ts");
  125463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Action"]; });
  125464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  125465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionManager"]; });
  125466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Condition"]; });
  125467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ValueCondition"]; });
  125468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PredicateCondition"]; });
  125469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StateCondition"]; });
  125470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SwitchBooleanAction"]; });
  125471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetStateAction"]; });
  125472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetValueAction"]; });
  125473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["IncrementValueAction"]; });
  125474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlayAnimationAction"]; });
  125475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopAnimationAction"]; });
  125476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["DoNothingAction"]; });
  125477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["CombineAction"]; });
  125478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ExecuteCodeAction"]; });
  125479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetParentAction"]; });
  125480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlaySoundAction"]; });
  125481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopSoundAction"]; });
  125482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["InterpolateValueAction"]; });
  125483. /* harmony import */ var _Animations_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Animations/index */ "./Animations/index.ts");
  125484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animatable"]; });
  125485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationRange"]; });
  125486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationEvent"]; });
  125487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PathCursor", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["PathCursor"]; });
  125488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationKeyInterpolation"]; });
  125489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animation"]; });
  125490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  125491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  125492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationPropertiesOverride"]; });
  125493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["EasingFunction"]; });
  125494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CircleEase"]; });
  125495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BackEase"]; });
  125496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BounceEase"]; });
  125497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CubicEase"]; });
  125498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ElasticEase"]; });
  125499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ExponentialEase"]; });
  125500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["PowerEase"]; });
  125501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuadraticEase"]; });
  125502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuarticEase"]; });
  125503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuinticEase"]; });
  125504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["SineEase"]; });
  125505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BezierCurveEase"]; });
  125506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["RuntimeAnimation"]; });
  125507. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./assetContainer */ "./assetContainer.ts");
  125508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["KeepAssets"]; });
  125509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["AssetContainer"]; });
  125510. /* harmony import */ var _Audio_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Audio/index */ "./Audio/index.ts");
  125511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Analyser"]; });
  125512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioEngine"]; });
  125513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioSceneComponent"]; });
  125514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Sound"]; });
  125515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  125516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["WeightedSound"]; });
  125517. /* harmony import */ var _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Behaviors/index */ "./Behaviors/index.ts");
  125518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AutoRotationBehavior"]; });
  125519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["BouncingBehavior"]; });
  125520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FramingBehavior"]; });
  125521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AttachToBoxBehavior"]; });
  125522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FadeInOutBehavior"]; });
  125523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["MultiPointerScaleBehavior"]; });
  125524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]; });
  125525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]; });
  125526. /* harmony import */ var _Bones_index__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Bones/index */ "./Bones/index.ts");
  125527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Bone"]; });
  125528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneIKController"]; });
  125529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneLookController"]; });
  125530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Skeleton"]; });
  125531. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Cameras/index */ "./Cameras/index.ts");
  125532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputTypes"]; });
  125533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputsManager"]; });
  125534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["Camera"]; });
  125535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TargetCamera"]; });
  125536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCamera"]; });
  125537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraInputsManager"]; });
  125538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TouchCamera"]; });
  125539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  125540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraInputsManager"]; });
  125541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["DeviceOrientationCamera"]; });
  125542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCamera"]; });
  125543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraInputsManager"]; });
  125544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCamera"]; });
  125545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcFollowCamera"]; });
  125546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["GamepadCamera"]; });
  125547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["UniversalCamera"]; });
  125548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VirtualJoysticksCamera"]; });
  125549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraGamepadInput"]; });
  125550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraKeyboardMoveInput"]; });
  125551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraMouseWheelInput"]; });
  125552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraPointersInput"]; });
  125553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraVRDeviceOrientationInput"]; });
  125554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraKeyboardInput"]; });
  125555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraMouseInput"]; });
  125556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  125557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraGamepadInput"]; });
  125558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraKeyboardMoveInput"]; });
  125559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraMouseInput"]; });
  125560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraTouchInput"]; });
  125561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraVirtualJoystickInput"]; });
  125562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphArcRotateCamera"]; });
  125563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphFreeCamera"]; });
  125564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphGamepadCamera"]; });
  125565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphUniversalCamera"]; });
  125566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicArcRotateCamera"]; });
  125567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicFreeCamera"]; });
  125568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicGamepadCamera"]; });
  125569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  125570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRCameraMetrics"]; });
  125571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationArcRotateCamera"]; });
  125572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationFreeCamera"]; });
  125573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationGamepadCamera"]; });
  125574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRExperienceHelper"]; });
  125575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]; });
  125576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRCamera"]; });
  125577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIButton"]; });
  125578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIOptions"]; });
  125579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUI"]; });
  125580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRState"]; });
  125581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRExperienceHelper"]; });
  125582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRController"]; });
  125583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRInput"]; });
  125584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRManagedOutputCanvas"]; });
  125585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRSessionManager"]; });
  125586. /* harmony import */ var _Collisions_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Collisions/index */ "./Collisions/index.ts");
  125587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["Collider"]; });
  125588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CollisionCoordinatorLegacy", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["CollisionCoordinatorLegacy"]; });
  125589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]; });
  125590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["IntersectionInfo"]; });
  125591. /* harmony import */ var _Culling_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Culling/index */ "./Culling/index.ts");
  125592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingBox"]; });
  125593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"]; });
  125594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingSphere"]; });
  125595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Ray"]; });
  125596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Octree"]; });
  125597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeBlock"]; });
  125598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeSceneComponent"]; });
  125599. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Debug/index */ "./Debug/index.ts");
  125600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["AxesViewer"]; });
  125601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["BoneAxesViewer"]; });
  125602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["DebugLayer"]; });
  125603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["PhysicsViewer"]; });
  125604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["RayHelper"]; });
  125605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["SkeletonViewer"]; });
  125606. /* harmony import */ var _Engines_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Engines/index */ "./Engines/index.ts");
  125607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Constants"]; });
  125608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["InstancingAttributeInfo"]; });
  125609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["DepthTextureCreationOptions"]; });
  125610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineCapabilities"]; });
  125611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Engine"]; });
  125612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineStore"]; });
  125613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngineOptions"]; });
  125614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngine"]; });
  125615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_OcclusionDataStorage"]; });
  125616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_forceTransformFeedbackToBundle"]; });
  125617. /* harmony import */ var _Events_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Events/index */ "./Events/index.ts");
  125618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardEventTypes"]; });
  125619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfo"]; });
  125620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfoPre"]; });
  125621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerEventTypes"]; });
  125622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoBase"]; });
  125623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoPre"]; });
  125624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfo"]; });
  125625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardEventTypes"]; });
  125626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardInfo"]; });
  125627. /* harmony import */ var _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Gamepads/index */ "./Gamepads/index.ts");
  125628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["DaydreamController"]; });
  125629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GearVRController"]; });
  125630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericController"]; });
  125631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["OculusTouchController"]; });
  125632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerType"]; });
  125633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerHelper"]; });
  125634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledController"]; });
  125635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["ViveController"]; });
  125636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WebVRController"]; });
  125637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WindowsMotionController"]; });
  125638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["StickValues"]; });
  125639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Gamepad"]; });
  125640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericPad"]; });
  125641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadManager"]; });
  125642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadSystemSceneComponent"]; });
  125643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"]; });
  125644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Dpad"]; });
  125645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Pad"]; });
  125646. /* harmony import */ var _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Gizmos/index */ "./Gizmos/index.ts");
  125647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisDragGizmo"]; });
  125648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisScaleGizmo"]; });
  125649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["BoundingBoxGizmo"]; });
  125650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["Gizmo"]; });
  125651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["GizmoManager"]; });
  125652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PlaneRotationGizmo"]; });
  125653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PositionGizmo"]; });
  125654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["RotationGizmo"]; });
  125655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["ScaleGizmo"]; });
  125656. /* harmony import */ var _Helpers_index__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Helpers/index */ "./Helpers/index.ts");
  125657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["EnvironmentHelper"]; });
  125658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["PhotoDome"]; });
  125659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["_forceSceneHelpersToBundle"]; });
  125660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["VideoDome"]; });
  125661. /* harmony import */ var _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Instrumentation/index */ "./Instrumentation/index.ts");
  125662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["EngineInstrumentation"]; });
  125663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["SceneInstrumentation"]; });
  125664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["_TimeToken"]; });
  125665. /* harmony import */ var _Layers_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Layers/index */ "./Layers/index.ts");
  125666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayer"]; });
  125667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayerSceneComponent"]; });
  125668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["GlowLayer"]; });
  125669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["HighlightLayer"]; });
  125670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["Layer"]; });
  125671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["LayerSceneComponent"]; });
  125672. /* harmony import */ var _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./LensFlares/index */ "./LensFlares/index.ts");
  125673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlare"]; });
  125674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystem"]; });
  125675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystemSceneComponent"]; });
  125676. /* harmony import */ var _Lights_index__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Lights/index */ "./Lights/index.ts");
  125677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["Light"]; });
  125678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowLight"]; });
  125679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["DirectionalLight"]; });
  125680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["HemisphericLight"]; });
  125681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["PointLight"]; });
  125682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["SpotLight"]; });
  125683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGenerator"]; });
  125684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGeneratorSceneComponent"]; });
  125685. /* harmony import */ var _Loading_index__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Loading/index */ "./Loading/index.ts");
  125686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["DefaultLoadingScreen"]; });
  125687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderProgressEvent"]; });
  125688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoader"]; });
  125689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderFlags"]; });
  125690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["_BabylonLoaderRegistered"]; });
  125691. /* harmony import */ var _Materials_index__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Materials/index */ "./Materials/index.ts");
  125692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorCurves"]; });
  125693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectFallbacks"]; });
  125694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectCreationOptions"]; });
  125695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Effect"]; });
  125696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["FresnelParameters"]; });
  125697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfigurationDefines"]; });
  125698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfiguration"]; });
  125699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Material"]; });
  125700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialDefines"]; });
  125701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialHelper"]; });
  125702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiMaterial"]; });
  125703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PushMaterial"]; });
  125704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ShaderMaterial"]; });
  125705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterialDefines"]; });
  125706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterial"]; });
  125707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BaseTexture"]; });
  125708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CubeTexture"]; });
  125709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["HDRCubeTexture"]; });
  125710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["InternalTexture"]; });
  125711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DummyInternalTextureTracker"]; });
  125712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MirrorTexture"]; });
  125713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiRenderTarget"]; });
  125714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture"]; });
  125715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RenderTargetTexture"]; });
  125716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Texture"]; });
  125717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["UniformBuffer"]; });
  125718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialFlags"]; });
  125719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BackgroundMaterial"]; });
  125720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseMaterial"]; });
  125721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseSimpleMaterial"]; });
  125722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterial"]; });
  125723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMetallicRoughnessMaterial"]; });
  125724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRSpecularGlossinessMaterial"]; });
  125725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorGradingTexture"]; });
  125726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DynamicTexture"]; });
  125727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTexture"]; });
  125728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawCubeTexture"]; });
  125729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture3D"]; });
  125730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RefractionTexture"]; });
  125731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["VideoTexture"]; });
  125732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_DDSTextureLoader"]; });
  125733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_ENVTextureLoader"]; });
  125734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_KTXTextureLoader"]; });
  125735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_TGATextureLoader"]; });
  125736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CustomProceduralTexture"]; });
  125737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NoiseProceduralTexture"]; });
  125738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTextureSceneComponent"]; });
  125739. /* harmony import */ var _Maths_index__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Maths/index */ "./Maths/index.ts");
  125740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Scalar"]; });
  125741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToGammaSpace"]; });
  125742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToLinearSpace"]; });
  125743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Epsilon"]; });
  125744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color3"]; });
  125745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color4"]; });
  125746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector2"]; });
  125747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector3"]; });
  125748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector4"]; });
  125749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Size"]; });
  125750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Quaternion"]; });
  125751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Matrix"]; });
  125752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Plane"]; });
  125753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Viewport"]; });
  125754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Frustum"]; });
  125755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Space"]; });
  125756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Axis"]; });
  125757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["BezierCurve"]; });
  125758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Orientation"]; });
  125759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Angle"]; });
  125760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Arc2"]; });
  125761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path2"]; });
  125762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path3D"]; });
  125763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Curve3"]; });
  125764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalVertex"]; });
  125765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalTextureVertex"]; });
  125766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Tmp"]; });
  125767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalPolynomial"]; });
  125768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalHarmonics"]; });
  125769. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Meshes/index */ "./Meshes/index.ts");
  125770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["AbstractMesh"]; });
  125771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Buffer"]; });
  125772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexBuffer"]; });
  125773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CSG"]; });
  125774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Geometry"]; });
  125775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_PrimitiveGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_PrimitiveGeometry"]; });
  125776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["RibbonGeometry"]; });
  125777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BoxGeometry"]; });
  125778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SphereGeometry"]; });
  125779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DiscGeometry"]; });
  125780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CylinderGeometry"]; });
  125781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusGeometry"]; });
  125782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundGeometry"]; });
  125783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TiledGroundGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TiledGroundGeometry"]; });
  125784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PlaneGeometry"]; });
  125785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusKnotGeometry"]; });
  125786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundMesh"]; });
  125787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedMesh"]; });
  125788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesMesh"]; });
  125789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedLinesMesh"]; });
  125790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshLODLevel"]; });
  125791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_CreationDataStorage"]; });
  125792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_InstancesBatch"]; });
  125793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Mesh"]; });
  125794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexData"]; });
  125795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshBuilder"]; });
  125796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationSettings"]; });
  125797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationQueue"]; });
  125798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationType"]; });
  125799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplicationQueueSceneComponent"]; });
  125800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Polygon"]; });
  125801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonMeshBuilder"]; });
  125802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BaseSubMesh"]; });
  125803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SubMesh"]; });
  125804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TransformNode"]; });
  125805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DracoCompression"]; });
  125806. /* harmony import */ var _Morph_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Morph/index */ "./Morph/index.ts");
  125807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTarget"]; });
  125808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTargetManager"]; });
  125809. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./node */ "./node.ts");
  125810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _node__WEBPACK_IMPORTED_MODULE_25__["Node"]; });
  125811. /* harmony import */ var _Offline_index__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Offline/index */ "./Offline/index.ts");
  125812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _Offline_index__WEBPACK_IMPORTED_MODULE_26__["Database"]; });
  125813. /* harmony import */ var _Particles_index__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Particles/index */ "./Particles/index.ts");
  125814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BaseParticleSystem"]; });
  125815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["GPUParticleSystem"]; });
  125816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["Particle"]; });
  125817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleHelper"]; });
  125818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystem"]; });
  125819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["_IDoNeedToBeInTheBuild"]; });
  125820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystemSet"]; });
  125821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticle"]; });
  125822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ModelShape"]; });
  125823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["DepthSortedParticle"]; });
  125824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticleSystem"]; });
  125825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitterType"]; });
  125826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitter"]; });
  125827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BoxParticleEmitter"]; });
  125828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ConeParticleEmitter"]; });
  125829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderParticleEmitter"]; });
  125830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderDirectedParticleEmitter"]; });
  125831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["HemisphericParticleEmitter"]; });
  125832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["PointParticleEmitter"]; });
  125833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereParticleEmitter"]; });
  125834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereDirectedParticleEmitter"]; });
  125835. /* harmony import */ var _Physics_index__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./Physics/index */ "./Physics/index.ts");
  125836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngine"]; });
  125837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngineSceneComponent"]; });
  125838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsHelper"]; });
  125839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialExplosionEvent"]; });
  125840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsGravitationalFieldEvent"]; });
  125841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftEvent"]; });
  125842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsVortexEvent"]; });
  125843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialImpulseFalloff"]; });
  125844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftMode"]; });
  125845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsImpostor"]; });
  125846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsJoint"]; });
  125847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["DistanceJoint"]; });
  125848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["MotorEnabledJoint"]; });
  125849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["HingeJoint"]; });
  125850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["Hinge2Joint"]; });
  125851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["CannonJSPlugin"]; });
  125852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["AmmoJSPlugin"]; });
  125853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["OimoJSPlugin"]; });
  125854. /* harmony import */ var _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./PostProcesses/index */ "./PostProcesses/index.ts");
  125855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["AnaglyphPostProcess"]; });
  125856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlackAndWhitePostProcess"]; });
  125857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomEffect"]; });
  125858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomMergePostProcess"]; });
  125859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlurPostProcess"]; });
  125860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ChromaticAberrationPostProcess"]; });
  125861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["CircleOfConfusionPostProcess"]; });
  125862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ColorCorrectionPostProcess"]; });
  125863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ConvolutionPostProcess"]; });
  125864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldBlurPostProcess"]; });
  125865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffectBlurLevel"]; });
  125866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffect"]; });
  125867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcessOptions"]; });
  125868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcess"]; });
  125869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DisplayPassPostProcess"]; });
  125870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ExtractHighlightsPostProcess"]; });
  125871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FilterPostProcess"]; });
  125872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FxaaPostProcess"]; });
  125873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["GrainPostProcess"]; });
  125874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["HighlightsPostProcess"]; });
  125875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ImageProcessingPostProcess"]; });
  125876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["MotionBlurPostProcess"]; });
  125877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassPostProcess"]; });
  125878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassCubePostProcess"]; });
  125879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcess"]; });
  125880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessManager"]; });
  125881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["RefractionPostProcess"]; });
  125882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SharpenPostProcess"]; });
  125883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StereoscopicInterlacePostProcess"]; });
  125884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemappingOperator"]; });
  125885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemapPostProcess"]; });
  125886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VolumetricLightScatteringPostProcess"]; });
  125887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  125888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderEffect"]; });
  125889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipeline"]; });
  125890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManager"]; });
  125891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManagerSceneComponent"]; });
  125892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DefaultRenderingPipeline"]; });
  125893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["LensRenderingPipeline"]; });
  125894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAO2RenderingPipeline"]; });
  125895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAORenderingPipeline"]; });
  125896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StandardRenderingPipeline"]; });
  125897. /* harmony import */ var _Probes_index__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./Probes/index */ "./Probes/index.ts");
  125898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _Probes_index__WEBPACK_IMPORTED_MODULE_30__["ReflectionProbe"]; });
  125899. /* harmony import */ var _Rendering_index__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./Rendering/index */ "./Rendering/index.ts");
  125900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["BoundingBoxRenderer"]; });
  125901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRenderer"]; });
  125902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRendererSceneComponent"]; });
  125903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["EdgesRenderer"]; });
  125904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["LineEdgesRenderer"]; });
  125905. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRenderer"]; });
  125906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRendererSceneComponent"]; });
  125907. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["OutlineRenderer"]; });
  125908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroup"]; });
  125909. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroupInfo"]; });
  125910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingManager"]; });
  125911. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["UtilityLayerRenderer"]; });
  125912. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./scene */ "./scene.ts");
  125913. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _scene__WEBPACK_IMPORTED_MODULE_32__["Scene"]; });
  125914. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  125915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["SceneComponentConstants"]; });
  125916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["Stage"]; });
  125917. /* harmony import */ var _Sprites_index__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./Sprites/index */ "./Sprites/index.ts");
  125918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["Sprite"]; });
  125919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteManager"]; });
  125920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteSceneComponent"]; });
  125921. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./States/index */ "./States/index.ts");
  125922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_AlphaState"]; });
  125923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_DepthCullingState"]; });
  125924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_StencilState"]; });
  125925. /* harmony import */ var _Misc_index__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Misc/index */ "./Misc/index.ts");
  125926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AndOrNotEvaluator"]; });
  125927. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetTaskState"]; });
  125928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AbstractAssetTask"]; });
  125929. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsProgressEvent"]; });
  125930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshAssetTask"]; });
  125931. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextFileAssetTask"]; });
  125932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["BinaryFileAssetTask"]; });
  125933. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ImageAssetTask"]; });
  125934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureAssetTask"]; });
  125935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeTextureAssetTask"]; });
  125936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRCubeTextureAssetTask"]; });
  125937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsManager"]; });
  125938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DDSTools"]; });
  125939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["expandToProperty"]; });
  125940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serialize"]; });
  125941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsTexture"]; });
  125942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor3"]; });
  125943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsFresnelParameters"]; });
  125944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector2"]; });
  125945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector3"]; });
  125946. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMeshReference"]; });
  125947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColorCurves"]; });
  125948. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor4"]; });
  125949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsImageProcessingConfiguration"]; });
  125950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsQuaternion"]; });
  125951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsCameraReference"]; });
  125952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SerializationHelper"]; });
  125953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Deferred"]; });
  125954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EnvironmentTextureTools"]; });
  125955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInput"]; });
  125956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["KhronosTextureContainer"]; });
  125957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EventState"]; });
  125958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observer"]; });
  125959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MultiObserver"]; });
  125960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observable"]; });
  125961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerformanceMonitor"]; });
  125962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RollingAverage"]; });
  125963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PromisePolyfill"]; });
  125964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimization"]; });
  125965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureOptimization"]; });
  125966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HardwareScalingOptimization"]; });
  125967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ShadowsOptimization"]; });
  125968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PostProcessesOptimization"]; });
  125969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LensFlaresOptimization"]; });
  125970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CustomOptimization"]; });
  125971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ParticlesOptimization"]; });
  125972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RenderTargetsOptimization"]; });
  125973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MergeMeshesOptimization"]; });
  125974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizerOptions"]; });
  125975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizer"]; });
  125976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneSerializer"]; });
  125977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArray"]; });
  125978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArrayNoDuplicate"]; });
  125979. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["StringDictionary"]; });
  125980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tags"]; });
  125981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureTools"]; });
  125982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TGATools"]; });
  125983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ColorGradient"]; });
  125984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Color3Gradient"]; });
  125985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FactorGradient"]; });
  125986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LoadFileError"]; });
  125987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RetryStrategy"]; });
  125988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tools"]; });
  125989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerfCounter"]; });
  125990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["className"]; });
  125991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AsyncLoop"]; });
  125992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VideoRecorder"]; });
  125993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["JoystickAxis"]; });
  125994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VirtualJoystick"]; });
  125995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WorkerPool"]; });
  125996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Logger"]; });
  125997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["_TypeStore"]; });
  125998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInputStore"]; });
  125999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DeepCopier"]; });
  126000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PivotTools"]; });
  126001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PrecisionDate"]; });
  126002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ScreenshotTools"]; });
  126003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeMapToSphericalPolynomialTools"]; });
  126004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRTools"]; });
  126005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PanoramaToCubeMapTools"]; });
  126006. /***/ }),
  126007. /***/ "./node.ts":
  126008. /*!*****************!*\
  126009. !*** ./node.ts ***!
  126010. \*****************/
  126011. /*! exports provided: Node */
  126012. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126013. "use strict";
  126014. __webpack_require__.r(__webpack_exports__);
  126015. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return Node; });
  126016. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  126017. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  126018. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/decorators */ "./Misc/decorators.ts");
  126019. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  126020. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  126021. /**
  126022. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  126023. */
  126024. var Node = /** @class */ (function () {
  126025. /**
  126026. * Creates a new Node
  126027. * @param name the name and id to be given to this node
  126028. * @param scene the scene this node will be added to
  126029. * @param addToRootNodes the node will be added to scene.rootNodes
  126030. */
  126031. function Node(name, scene, addToRootNodes) {
  126032. if (scene === void 0) { scene = null; }
  126033. if (addToRootNodes === void 0) { addToRootNodes = true; }
  126034. /**
  126035. * Gets or sets a string used to store user defined state for the node
  126036. */
  126037. this.state = "";
  126038. /**
  126039. * Gets or sets an object used to store user defined information for the node
  126040. */
  126041. this.metadata = null;
  126042. /**
  126043. * For internal use only. Please do not use.
  126044. */
  126045. this.reservedDataStore = null;
  126046. /**
  126047. * Gets or sets a boolean used to define if the node must be serialized
  126048. */
  126049. this.doNotSerialize = false;
  126050. /** @hidden */
  126051. this._isDisposed = false;
  126052. /**
  126053. * Gets a list of Animations associated with the node
  126054. */
  126055. this.animations = new Array();
  126056. this._ranges = {};
  126057. this._isEnabled = true;
  126058. this._isParentEnabled = true;
  126059. this._isReady = true;
  126060. /** @hidden */
  126061. this._currentRenderId = -1;
  126062. this._parentRenderId = -1;
  126063. this._childRenderId = -1;
  126064. /** @hidden */
  126065. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  126066. /** @hidden */
  126067. this._worldMatrixDeterminant = 0;
  126068. /** @hidden */
  126069. this._sceneRootNodesIndex = -1;
  126070. this._animationPropertiesOverride = null;
  126071. /** @hidden */
  126072. this._isNode = true;
  126073. /**
  126074. * An event triggered when the mesh is disposed
  126075. */
  126076. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126077. // Behaviors
  126078. this._behaviors = new Array();
  126079. this.name = name;
  126080. this.id = name;
  126081. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene);
  126082. this.uniqueId = this._scene.getUniqueId();
  126083. this._initCache();
  126084. if (addToRootNodes) {
  126085. this.addToSceneRootNodes();
  126086. }
  126087. }
  126088. /**
  126089. * Add a new node constructor
  126090. * @param type defines the type name of the node to construct
  126091. * @param constructorFunc defines the constructor function
  126092. */
  126093. Node.AddNodeConstructor = function (type, constructorFunc) {
  126094. this._NodeConstructors[type] = constructorFunc;
  126095. };
  126096. /**
  126097. * Returns a node constructor based on type name
  126098. * @param type defines the type name
  126099. * @param name defines the new node name
  126100. * @param scene defines the hosting scene
  126101. * @param options defines optional options to transmit to constructors
  126102. * @returns the new constructor or null
  126103. */
  126104. Node.Construct = function (type, name, scene, options) {
  126105. var constructorFunc = this._NodeConstructors[type];
  126106. if (!constructorFunc) {
  126107. return null;
  126108. }
  126109. return constructorFunc(name, scene, options);
  126110. };
  126111. /**
  126112. * Gets a boolean indicating if the node has been disposed
  126113. * @returns true if the node was disposed
  126114. */
  126115. Node.prototype.isDisposed = function () {
  126116. return this._isDisposed;
  126117. };
  126118. Object.defineProperty(Node.prototype, "parent", {
  126119. get: function () {
  126120. return this._parentNode;
  126121. },
  126122. /**
  126123. * Gets or sets the parent of the node
  126124. */
  126125. set: function (parent) {
  126126. if (this._parentNode === parent) {
  126127. return;
  126128. }
  126129. var previousParentNode = this._parentNode;
  126130. // Remove self from list of children of parent
  126131. if (this._parentNode && this._parentNode._children !== undefined && this._parentNode._children !== null) {
  126132. var index = this._parentNode._children.indexOf(this);
  126133. if (index !== -1) {
  126134. this._parentNode._children.splice(index, 1);
  126135. }
  126136. if (!parent && !this._isDisposed) {
  126137. this.addToSceneRootNodes();
  126138. }
  126139. }
  126140. // Store new parent
  126141. this._parentNode = parent;
  126142. // Add as child to new parent
  126143. if (this._parentNode) {
  126144. if (this._parentNode._children === undefined || this._parentNode._children === null) {
  126145. this._parentNode._children = new Array();
  126146. }
  126147. this._parentNode._children.push(this);
  126148. if (!previousParentNode) {
  126149. this.removeFromSceneRootNodes();
  126150. }
  126151. }
  126152. // Enabled state
  126153. this._syncParentEnabledState();
  126154. },
  126155. enumerable: true,
  126156. configurable: true
  126157. });
  126158. Node.prototype.addToSceneRootNodes = function () {
  126159. if (this._sceneRootNodesIndex === -1) {
  126160. this._sceneRootNodesIndex = this._scene.rootNodes.length;
  126161. this._scene.rootNodes.push(this);
  126162. }
  126163. };
  126164. Node.prototype.removeFromSceneRootNodes = function () {
  126165. if (this._sceneRootNodesIndex !== -1) {
  126166. var rootNodes = this._scene.rootNodes;
  126167. var lastIdx = rootNodes.length - 1;
  126168. rootNodes[this._sceneRootNodesIndex] = rootNodes[lastIdx];
  126169. rootNodes[this._sceneRootNodesIndex]._sceneRootNodesIndex = this._sceneRootNodesIndex;
  126170. this._scene.rootNodes.pop();
  126171. this._sceneRootNodesIndex = -1;
  126172. }
  126173. };
  126174. Object.defineProperty(Node.prototype, "animationPropertiesOverride", {
  126175. /**
  126176. * Gets or sets the animation properties override
  126177. */
  126178. get: function () {
  126179. if (!this._animationPropertiesOverride) {
  126180. return this._scene.animationPropertiesOverride;
  126181. }
  126182. return this._animationPropertiesOverride;
  126183. },
  126184. set: function (value) {
  126185. this._animationPropertiesOverride = value;
  126186. },
  126187. enumerable: true,
  126188. configurable: true
  126189. });
  126190. /**
  126191. * Gets a string idenfifying the name of the class
  126192. * @returns "Node" string
  126193. */
  126194. Node.prototype.getClassName = function () {
  126195. return "Node";
  126196. };
  126197. Object.defineProperty(Node.prototype, "onDispose", {
  126198. /**
  126199. * Sets a callback that will be raised when the node will be disposed
  126200. */
  126201. set: function (callback) {
  126202. if (this._onDisposeObserver) {
  126203. this.onDisposeObservable.remove(this._onDisposeObserver);
  126204. }
  126205. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  126206. },
  126207. enumerable: true,
  126208. configurable: true
  126209. });
  126210. /**
  126211. * Gets the scene of the node
  126212. * @returns a scene
  126213. */
  126214. Node.prototype.getScene = function () {
  126215. return this._scene;
  126216. };
  126217. /**
  126218. * Gets the engine of the node
  126219. * @returns a Engine
  126220. */
  126221. Node.prototype.getEngine = function () {
  126222. return this._scene.getEngine();
  126223. };
  126224. /**
  126225. * Attach a behavior to the node
  126226. * @see http://doc.babylonjs.com/features/behaviour
  126227. * @param behavior defines the behavior to attach
  126228. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  126229. * @returns the current Node
  126230. */
  126231. Node.prototype.addBehavior = function (behavior, attachImmediately) {
  126232. var _this = this;
  126233. if (attachImmediately === void 0) { attachImmediately = false; }
  126234. var index = this._behaviors.indexOf(behavior);
  126235. if (index !== -1) {
  126236. return this;
  126237. }
  126238. behavior.init();
  126239. if (this._scene.isLoading && !attachImmediately) {
  126240. // We defer the attach when the scene will be loaded
  126241. this._scene.onDataLoadedObservable.addOnce(function () {
  126242. behavior.attach(_this);
  126243. });
  126244. }
  126245. else {
  126246. behavior.attach(this);
  126247. }
  126248. this._behaviors.push(behavior);
  126249. return this;
  126250. };
  126251. /**
  126252. * Remove an attached behavior
  126253. * @see http://doc.babylonjs.com/features/behaviour
  126254. * @param behavior defines the behavior to attach
  126255. * @returns the current Node
  126256. */
  126257. Node.prototype.removeBehavior = function (behavior) {
  126258. var index = this._behaviors.indexOf(behavior);
  126259. if (index === -1) {
  126260. return this;
  126261. }
  126262. this._behaviors[index].detach();
  126263. this._behaviors.splice(index, 1);
  126264. return this;
  126265. };
  126266. Object.defineProperty(Node.prototype, "behaviors", {
  126267. /**
  126268. * Gets the list of attached behaviors
  126269. * @see http://doc.babylonjs.com/features/behaviour
  126270. */
  126271. get: function () {
  126272. return this._behaviors;
  126273. },
  126274. enumerable: true,
  126275. configurable: true
  126276. });
  126277. /**
  126278. * Gets an attached behavior by name
  126279. * @param name defines the name of the behavior to look for
  126280. * @see http://doc.babylonjs.com/features/behaviour
  126281. * @returns null if behavior was not found else the requested behavior
  126282. */
  126283. Node.prototype.getBehaviorByName = function (name) {
  126284. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  126285. var behavior = _a[_i];
  126286. if (behavior.name === name) {
  126287. return behavior;
  126288. }
  126289. }
  126290. return null;
  126291. };
  126292. /**
  126293. * Returns the latest update of the World matrix
  126294. * @returns a Matrix
  126295. */
  126296. Node.prototype.getWorldMatrix = function () {
  126297. if (this._currentRenderId !== this._scene.getRenderId()) {
  126298. this.computeWorldMatrix();
  126299. }
  126300. return this._worldMatrix;
  126301. };
  126302. /** @hidden */
  126303. Node.prototype._getWorldMatrixDeterminant = function () {
  126304. return this._worldMatrixDeterminant;
  126305. };
  126306. Object.defineProperty(Node.prototype, "worldMatrixFromCache", {
  126307. /**
  126308. * Returns directly the latest state of the mesh World matrix.
  126309. * A Matrix is returned.
  126310. */
  126311. get: function () {
  126312. return this._worldMatrix;
  126313. },
  126314. enumerable: true,
  126315. configurable: true
  126316. });
  126317. // override it in derived class if you add new variables to the cache
  126318. // and call the parent class method
  126319. /** @hidden */
  126320. Node.prototype._initCache = function () {
  126321. this._cache = {};
  126322. this._cache.parent = undefined;
  126323. };
  126324. /** @hidden */
  126325. Node.prototype.updateCache = function (force) {
  126326. if (!force && this.isSynchronized()) {
  126327. return;
  126328. }
  126329. this._cache.parent = this.parent;
  126330. this._updateCache();
  126331. };
  126332. // override it in derived class if you add new variables to the cache
  126333. // and call the parent class method if !ignoreParentClass
  126334. /** @hidden */
  126335. Node.prototype._updateCache = function (ignoreParentClass) {
  126336. };
  126337. // override it in derived class if you add new variables to the cache
  126338. /** @hidden */
  126339. Node.prototype._isSynchronized = function () {
  126340. return true;
  126341. };
  126342. /** @hidden */
  126343. Node.prototype._markSyncedWithParent = function () {
  126344. if (this._parentNode) {
  126345. this._parentRenderId = this._parentNode._childRenderId;
  126346. }
  126347. };
  126348. /** @hidden */
  126349. Node.prototype.isSynchronizedWithParent = function () {
  126350. if (!this._parentNode) {
  126351. return true;
  126352. }
  126353. if (this._parentRenderId !== this._parentNode._childRenderId) {
  126354. return false;
  126355. }
  126356. return this._parentNode.isSynchronized();
  126357. };
  126358. /** @hidden */
  126359. Node.prototype.isSynchronized = function () {
  126360. if (this._cache.parent != this._parentNode) {
  126361. this._cache.parent = this._parentNode;
  126362. return false;
  126363. }
  126364. if (this._parentNode && !this.isSynchronizedWithParent()) {
  126365. return false;
  126366. }
  126367. return this._isSynchronized();
  126368. };
  126369. /**
  126370. * Is this node ready to be used/rendered
  126371. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  126372. * @return true if the node is ready
  126373. */
  126374. Node.prototype.isReady = function (completeCheck) {
  126375. if (completeCheck === void 0) { completeCheck = false; }
  126376. return this._isReady;
  126377. };
  126378. /**
  126379. * Is this node enabled?
  126380. * 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
  126381. * @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
  126382. * @return whether this node (and its parent) is enabled
  126383. */
  126384. Node.prototype.isEnabled = function (checkAncestors) {
  126385. if (checkAncestors === void 0) { checkAncestors = true; }
  126386. if (checkAncestors === false) {
  126387. return this._isEnabled;
  126388. }
  126389. if (!this._isEnabled) {
  126390. return false;
  126391. }
  126392. return this._isParentEnabled;
  126393. };
  126394. /** @hidden */
  126395. Node.prototype._syncParentEnabledState = function () {
  126396. this._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : true;
  126397. if (this._children) {
  126398. this._children.forEach(function (c) {
  126399. c._syncParentEnabledState(); // Force children to update accordingly
  126400. });
  126401. }
  126402. };
  126403. /**
  126404. * Set the enabled state of this node
  126405. * @param value defines the new enabled state
  126406. */
  126407. Node.prototype.setEnabled = function (value) {
  126408. this._isEnabled = value;
  126409. this._syncParentEnabledState();
  126410. };
  126411. /**
  126412. * Is this node a descendant of the given node?
  126413. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  126414. * @param ancestor defines the parent node to inspect
  126415. * @returns a boolean indicating if this node is a descendant of the given node
  126416. */
  126417. Node.prototype.isDescendantOf = function (ancestor) {
  126418. if (this.parent) {
  126419. if (this.parent === ancestor) {
  126420. return true;
  126421. }
  126422. return this.parent.isDescendantOf(ancestor);
  126423. }
  126424. return false;
  126425. };
  126426. /** @hidden */
  126427. Node.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  126428. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  126429. if (!this._children) {
  126430. return;
  126431. }
  126432. for (var index = 0; index < this._children.length; index++) {
  126433. var item = this._children[index];
  126434. if (!predicate || predicate(item)) {
  126435. results.push(item);
  126436. }
  126437. if (!directDescendantsOnly) {
  126438. item._getDescendants(results, false, predicate);
  126439. }
  126440. }
  126441. };
  126442. /**
  126443. * Will return all nodes that have this node as ascendant
  126444. * @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
  126445. * @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
  126446. * @return all children nodes of all types
  126447. */
  126448. Node.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  126449. var results = new Array();
  126450. this._getDescendants(results, directDescendantsOnly, predicate);
  126451. return results;
  126452. };
  126453. /**
  126454. * Get all child-meshes of this node
  126455. * @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
  126456. * @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
  126457. * @returns an array of AbstractMesh
  126458. */
  126459. Node.prototype.getChildMeshes = function (directDescendantsOnly, predicate) {
  126460. var results = [];
  126461. this._getDescendants(results, directDescendantsOnly, function (node) {
  126462. return ((!predicate || predicate(node)) && (node.cullingStrategy !== undefined));
  126463. });
  126464. return results;
  126465. };
  126466. /**
  126467. * Get all direct children of this node
  126468. * @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
  126469. * @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)
  126470. * @returns an array of Node
  126471. */
  126472. Node.prototype.getChildren = function (predicate, directDescendantsOnly) {
  126473. if (directDescendantsOnly === void 0) { directDescendantsOnly = true; }
  126474. return this.getDescendants(directDescendantsOnly, predicate);
  126475. };
  126476. /** @hidden */
  126477. Node.prototype._setReady = function (state) {
  126478. if (state === this._isReady) {
  126479. return;
  126480. }
  126481. if (!state) {
  126482. this._isReady = false;
  126483. return;
  126484. }
  126485. if (this.onReady) {
  126486. this.onReady(this);
  126487. }
  126488. this._isReady = true;
  126489. };
  126490. /**
  126491. * Get an animation by name
  126492. * @param name defines the name of the animation to look for
  126493. * @returns null if not found else the requested animation
  126494. */
  126495. Node.prototype.getAnimationByName = function (name) {
  126496. for (var i = 0; i < this.animations.length; i++) {
  126497. var animation = this.animations[i];
  126498. if (animation.name === name) {
  126499. return animation;
  126500. }
  126501. }
  126502. return null;
  126503. };
  126504. /**
  126505. * Creates an animation range for this node
  126506. * @param name defines the name of the range
  126507. * @param from defines the starting key
  126508. * @param to defines the end key
  126509. */
  126510. Node.prototype.createAnimationRange = function (name, from, to) {
  126511. // check name not already in use
  126512. if (!this._ranges[name]) {
  126513. this._ranges[name] = Node._AnimationRangeFactory(name, from, to);
  126514. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  126515. if (this.animations[i]) {
  126516. this.animations[i].createRange(name, from, to);
  126517. }
  126518. }
  126519. }
  126520. };
  126521. /**
  126522. * Delete a specific animation range
  126523. * @param name defines the name of the range to delete
  126524. * @param deleteFrames defines if animation frames from the range must be deleted as well
  126525. */
  126526. Node.prototype.deleteAnimationRange = function (name, deleteFrames) {
  126527. if (deleteFrames === void 0) { deleteFrames = true; }
  126528. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  126529. if (this.animations[i]) {
  126530. this.animations[i].deleteRange(name, deleteFrames);
  126531. }
  126532. }
  126533. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  126534. };
  126535. /**
  126536. * Get an animation range by name
  126537. * @param name defines the name of the animation range to look for
  126538. * @returns null if not found else the requested animation range
  126539. */
  126540. Node.prototype.getAnimationRange = function (name) {
  126541. return this._ranges[name];
  126542. };
  126543. /**
  126544. * Will start the animation sequence
  126545. * @param name defines the range frames for animation sequence
  126546. * @param loop defines if the animation should loop (false by default)
  126547. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  126548. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  126549. * @returns the object created for this animation. If range does not exist, it will return null
  126550. */
  126551. Node.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  126552. var range = this.getAnimationRange(name);
  126553. if (!range) {
  126554. return null;
  126555. }
  126556. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  126557. };
  126558. /**
  126559. * Serialize animation ranges into a JSON compatible object
  126560. * @returns serialization object
  126561. */
  126562. Node.prototype.serializeAnimationRanges = function () {
  126563. var serializationRanges = [];
  126564. for (var name in this._ranges) {
  126565. var localRange = this._ranges[name];
  126566. if (!localRange) {
  126567. continue;
  126568. }
  126569. var range = {};
  126570. range.name = name;
  126571. range.from = localRange.from;
  126572. range.to = localRange.to;
  126573. serializationRanges.push(range);
  126574. }
  126575. return serializationRanges;
  126576. };
  126577. /**
  126578. * Computes the world matrix of the node
  126579. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  126580. * @returns the world matrix
  126581. */
  126582. Node.prototype.computeWorldMatrix = function (force) {
  126583. if (!this._worldMatrix) {
  126584. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  126585. }
  126586. return this._worldMatrix;
  126587. };
  126588. /**
  126589. * Releases resources associated with this node.
  126590. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  126591. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  126592. */
  126593. Node.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  126594. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  126595. this._isDisposed = true;
  126596. if (!doNotRecurse) {
  126597. var nodes = this.getDescendants(true);
  126598. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  126599. var node = nodes_1[_i];
  126600. node.dispose(doNotRecurse, disposeMaterialAndTextures);
  126601. }
  126602. }
  126603. if (!this.parent) {
  126604. this.removeFromSceneRootNodes();
  126605. }
  126606. else {
  126607. this.parent = null;
  126608. }
  126609. // Callback
  126610. this.onDisposeObservable.notifyObservers(this);
  126611. this.onDisposeObservable.clear();
  126612. // Behaviors
  126613. for (var _a = 0, _b = this._behaviors; _a < _b.length; _a++) {
  126614. var behavior = _b[_a];
  126615. behavior.detach();
  126616. }
  126617. this._behaviors = [];
  126618. };
  126619. /**
  126620. * Parse animation range data from a serialization object and store them into a given node
  126621. * @param node defines where to store the animation ranges
  126622. * @param parsedNode defines the serialization object to read data from
  126623. * @param scene defines the hosting scene
  126624. */
  126625. Node.ParseAnimationRanges = function (node, parsedNode, scene) {
  126626. if (parsedNode.ranges) {
  126627. for (var index = 0; index < parsedNode.ranges.length; index++) {
  126628. var data = parsedNode.ranges[index];
  126629. node.createAnimationRange(data.name, data.from, data.to);
  126630. }
  126631. }
  126632. };
  126633. /** @hidden */
  126634. Node._AnimationRangeFactory = function (name, from, to) {
  126635. throw "AnimationRange needs to be imported from animation before being created.";
  126636. };
  126637. Node._NodeConstructors = {};
  126638. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126639. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  126640. ], Node.prototype, "name", void 0);
  126641. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126642. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  126643. ], Node.prototype, "id", void 0);
  126644. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126645. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  126646. ], Node.prototype, "uniqueId", void 0);
  126647. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126648. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  126649. ], Node.prototype, "state", void 0);
  126650. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126651. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  126652. ], Node.prototype, "metadata", void 0);
  126653. return Node;
  126654. }());
  126655. /***/ }),
  126656. /***/ "./scene.ts":
  126657. /*!******************!*\
  126658. !*** ./scene.ts ***!
  126659. \******************/
  126660. /*! exports provided: Scene */
  126661. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126662. "use strict";
  126663. __webpack_require__.r(__webpack_exports__);
  126664. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return Scene; });
  126665. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  126666. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Misc/tools */ "./Misc/tools.ts");
  126667. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/precisionDate */ "./Misc/precisionDate.ts");
  126668. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  126669. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Misc/smartArray */ "./Misc/smartArray.ts");
  126670. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  126671. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Misc/tags */ "./Misc/tags.ts");
  126672. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  126673. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  126674. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Cameras/camera */ "./Cameras/camera.ts");
  126675. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  126676. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  126677. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  126678. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Animations/animation */ "./Animations/animation.ts");
  126679. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Animations/animatable */ "./Animations/animatable.ts");
  126680. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Lights/light */ "./Lights/light.ts");
  126681. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  126682. /* harmony import */ var _Collisions_collisionCoordinator__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Collisions/collisionCoordinator */ "./Collisions/collisionCoordinator.ts");
  126683. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./Events/pointerEvents */ "./Events/pointerEvents.ts");
  126684. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  126685. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Actions/actionEvent */ "./Actions/actionEvent.ts");
  126686. /* harmony import */ var _Actions_actionManager__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Actions/actionManager */ "./Actions/actionManager.ts");
  126687. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  126688. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  126689. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  126690. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./Culling/ray */ "./Culling/ray.ts");
  126691. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Engines/constants */ "./Engines/constants.ts");
  126692. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Misc/domManagement */ "./Misc/domManagement.ts");
  126693. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./Misc/logger */ "./Misc/logger.ts");
  126694. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  126695. /** @hidden */
  126696. var ClickInfo = /** @class */ (function () {
  126697. function ClickInfo() {
  126698. this._singleClick = false;
  126699. this._doubleClick = false;
  126700. this._hasSwiped = false;
  126701. this._ignore = false;
  126702. }
  126703. Object.defineProperty(ClickInfo.prototype, "singleClick", {
  126704. get: function () {
  126705. return this._singleClick;
  126706. },
  126707. set: function (b) {
  126708. this._singleClick = b;
  126709. },
  126710. enumerable: true,
  126711. configurable: true
  126712. });
  126713. Object.defineProperty(ClickInfo.prototype, "doubleClick", {
  126714. get: function () {
  126715. return this._doubleClick;
  126716. },
  126717. set: function (b) {
  126718. this._doubleClick = b;
  126719. },
  126720. enumerable: true,
  126721. configurable: true
  126722. });
  126723. Object.defineProperty(ClickInfo.prototype, "hasSwiped", {
  126724. get: function () {
  126725. return this._hasSwiped;
  126726. },
  126727. set: function (b) {
  126728. this._hasSwiped = b;
  126729. },
  126730. enumerable: true,
  126731. configurable: true
  126732. });
  126733. Object.defineProperty(ClickInfo.prototype, "ignore", {
  126734. get: function () {
  126735. return this._ignore;
  126736. },
  126737. set: function (b) {
  126738. this._ignore = b;
  126739. },
  126740. enumerable: true,
  126741. configurable: true
  126742. });
  126743. return ClickInfo;
  126744. }());
  126745. /**
  126746. * Represents a scene to be rendered by the engine.
  126747. * @see http://doc.babylonjs.com/features/scene
  126748. */
  126749. var Scene = /** @class */ (function (_super) {
  126750. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Scene, _super);
  126751. /**
  126752. * Creates a new Scene
  126753. * @param engine defines the engine to use to render this scene
  126754. */
  126755. function Scene(engine, options) {
  126756. var _this = _super.call(this) || this;
  126757. // Members
  126758. /** @hidden */
  126759. _this._isScene = true;
  126760. /**
  126761. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  126762. */
  126763. _this.autoClear = true;
  126764. /**
  126765. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  126766. */
  126767. _this.autoClearDepthAndStencil = true;
  126768. /**
  126769. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  126770. */
  126771. _this.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color4"](0.2, 0.2, 0.3, 1.0);
  126772. /**
  126773. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  126774. */
  126775. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0, 0, 0);
  126776. _this._forceWireframe = false;
  126777. _this._forcePointsCloud = false;
  126778. /**
  126779. * Gets or sets a boolean indicating if animations are enabled
  126780. */
  126781. _this.animationsEnabled = true;
  126782. _this._animationPropertiesOverride = null;
  126783. /**
  126784. * Gets or sets a boolean indicating if a constant deltatime has to be used
  126785. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  126786. */
  126787. _this.useConstantAnimationDeltaTime = false;
  126788. /**
  126789. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  126790. * Please note that it requires to run a ray cast through the scene on every frame
  126791. */
  126792. _this.constantlyUpdateMeshUnderPointer = false;
  126793. /**
  126794. * Defines the HTML cursor to use when hovering over interactive elements
  126795. */
  126796. _this.hoverCursor = "pointer";
  126797. /**
  126798. * Defines the HTML default cursor to use (empty by default)
  126799. */
  126800. _this.defaultCursor = "";
  126801. /**
  126802. * This is used to call preventDefault() on pointer down
  126803. * in order to block unwanted artifacts like system double clicks
  126804. */
  126805. _this.preventDefaultOnPointerDown = true;
  126806. /**
  126807. * This is used to call preventDefault() on pointer up
  126808. * in order to block unwanted artifacts like system double clicks
  126809. */
  126810. _this.preventDefaultOnPointerUp = true;
  126811. // Metadata
  126812. /**
  126813. * Gets or sets user defined metadata
  126814. */
  126815. _this.metadata = null;
  126816. /**
  126817. * For internal use only. Please do not use.
  126818. */
  126819. _this.reservedDataStore = null;
  126820. /**
  126821. * Use this array to add regular expressions used to disable offline support for specific urls
  126822. */
  126823. _this.disableOfflineSupportExceptionRules = new Array();
  126824. /**
  126825. * An event triggered when the scene is disposed.
  126826. */
  126827. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126828. _this._onDisposeObserver = null;
  126829. /**
  126830. * An event triggered before rendering the scene (right after animations and physics)
  126831. */
  126832. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126833. _this._onBeforeRenderObserver = null;
  126834. /**
  126835. * An event triggered after rendering the scene
  126836. */
  126837. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126838. _this._onAfterRenderObserver = null;
  126839. /**
  126840. * An event triggered before animating the scene
  126841. */
  126842. _this.onBeforeAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126843. /**
  126844. * An event triggered after animations processing
  126845. */
  126846. _this.onAfterAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126847. /**
  126848. * An event triggered before draw calls are ready to be sent
  126849. */
  126850. _this.onBeforeDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126851. /**
  126852. * An event triggered after draw calls have been sent
  126853. */
  126854. _this.onAfterDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126855. /**
  126856. * An event triggered when the scene is ready
  126857. */
  126858. _this.onReadyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126859. /**
  126860. * An event triggered before rendering a camera
  126861. */
  126862. _this.onBeforeCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126863. _this._onBeforeCameraRenderObserver = null;
  126864. /**
  126865. * An event triggered after rendering a camera
  126866. */
  126867. _this.onAfterCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126868. _this._onAfterCameraRenderObserver = null;
  126869. /**
  126870. * An event triggered when active meshes evaluation is about to start
  126871. */
  126872. _this.onBeforeActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126873. /**
  126874. * An event triggered when active meshes evaluation is done
  126875. */
  126876. _this.onAfterActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126877. /**
  126878. * An event triggered when particles rendering is about to start
  126879. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  126880. */
  126881. _this.onBeforeParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126882. /**
  126883. * An event triggered when particles rendering is done
  126884. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  126885. */
  126886. _this.onAfterParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126887. /**
  126888. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  126889. */
  126890. _this.onDataLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126891. /**
  126892. * An event triggered when a camera is created
  126893. */
  126894. _this.onNewCameraAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126895. /**
  126896. * An event triggered when a camera is removed
  126897. */
  126898. _this.onCameraRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126899. /**
  126900. * An event triggered when a light is created
  126901. */
  126902. _this.onNewLightAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126903. /**
  126904. * An event triggered when a light is removed
  126905. */
  126906. _this.onLightRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126907. /**
  126908. * An event triggered when a geometry is created
  126909. */
  126910. _this.onNewGeometryAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126911. /**
  126912. * An event triggered when a geometry is removed
  126913. */
  126914. _this.onGeometryRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126915. /**
  126916. * An event triggered when a transform node is created
  126917. */
  126918. _this.onNewTransformNodeAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126919. /**
  126920. * An event triggered when a transform node is removed
  126921. */
  126922. _this.onTransformNodeRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126923. /**
  126924. * An event triggered when a mesh is created
  126925. */
  126926. _this.onNewMeshAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126927. /**
  126928. * An event triggered when a mesh is removed
  126929. */
  126930. _this.onMeshRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126931. /**
  126932. * An event triggered when a material is created
  126933. */
  126934. _this.onNewMaterialAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126935. /**
  126936. * An event triggered when a material is removed
  126937. */
  126938. _this.onMaterialRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126939. /**
  126940. * An event triggered when a texture is created
  126941. */
  126942. _this.onNewTextureAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126943. /**
  126944. * An event triggered when a texture is removed
  126945. */
  126946. _this.onTextureRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126947. /**
  126948. * An event triggered when render targets are about to be rendered
  126949. * Can happen multiple times per frame.
  126950. */
  126951. _this.onBeforeRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126952. /**
  126953. * An event triggered when render targets were rendered.
  126954. * Can happen multiple times per frame.
  126955. */
  126956. _this.onAfterRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126957. /**
  126958. * An event triggered before calculating deterministic simulation step
  126959. */
  126960. _this.onBeforeStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126961. /**
  126962. * An event triggered after calculating deterministic simulation step
  126963. */
  126964. _this.onAfterStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126965. /**
  126966. * An event triggered when the activeCamera property is updated
  126967. */
  126968. _this.onActiveCameraChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126969. /**
  126970. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  126971. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  126972. * 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)
  126973. */
  126974. _this.onBeforeRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126975. /**
  126976. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  126977. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  126978. * 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)
  126979. */
  126980. _this.onAfterRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126981. /**
  126982. * This Observable will when a mesh has been imported into the scene.
  126983. */
  126984. _this.onMeshImportedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126985. // Animations
  126986. _this._registeredForLateAnimationBindings = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  126987. /**
  126988. * 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).
  126989. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  126990. */
  126991. _this.onPrePointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126992. /**
  126993. * Observable event triggered each time an input event is received from the rendering canvas
  126994. */
  126995. _this.onPointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126996. _this._meshPickProceed = false;
  126997. _this._currentPickResult = null;
  126998. _this._previousPickResult = null;
  126999. _this._totalPointersPressed = 0;
  127000. _this._doubleClickOccured = false;
  127001. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  127002. _this.cameraToUseForPointers = null;
  127003. _this._pointerX = 0;
  127004. _this._pointerY = 0;
  127005. _this._startingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  127006. _this._previousStartingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  127007. _this._startingPointerTime = 0;
  127008. _this._previousStartingPointerTime = 0;
  127009. _this._pointerCaptures = {};
  127010. // Deterministic lockstep
  127011. _this._timeAccumulator = 0;
  127012. _this._currentStepId = 0;
  127013. _this._currentInternalStep = 0;
  127014. // Keyboard
  127015. /**
  127016. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  127017. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  127018. */
  127019. _this.onPreKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127020. /**
  127021. * Observable event triggered each time an keyboard event is received from the hosting window
  127022. */
  127023. _this.onKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127024. // Coordinates system
  127025. _this._useRightHandedSystem = false;
  127026. // Fog
  127027. _this._fogEnabled = true;
  127028. _this._fogMode = Scene.FOGMODE_NONE;
  127029. /**
  127030. * Gets or sets the fog color to use
  127031. * @see http://doc.babylonjs.com/babylon101/environment#fog
  127032. * (Default is Color3(0.2, 0.2, 0.3))
  127033. */
  127034. _this.fogColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0.2, 0.2, 0.3);
  127035. /**
  127036. * Gets or sets the fog density to use
  127037. * @see http://doc.babylonjs.com/babylon101/environment#fog
  127038. * (Default is 0.1)
  127039. */
  127040. _this.fogDensity = 0.1;
  127041. /**
  127042. * Gets or sets the fog start distance to use
  127043. * @see http://doc.babylonjs.com/babylon101/environment#fog
  127044. * (Default is 0)
  127045. */
  127046. _this.fogStart = 0;
  127047. /**
  127048. * Gets or sets the fog end distance to use
  127049. * @see http://doc.babylonjs.com/babylon101/environment#fog
  127050. * (Default is 1000)
  127051. */
  127052. _this.fogEnd = 1000.0;
  127053. // Lights
  127054. _this._shadowsEnabled = true;
  127055. _this._lightsEnabled = true;
  127056. /** All of the active cameras added to this scene. */
  127057. _this.activeCameras = new Array();
  127058. // Textures
  127059. _this._texturesEnabled = true;
  127060. // Particles
  127061. /**
  127062. * Gets or sets a boolean indicating if particles are enabled on this scene
  127063. */
  127064. _this.particlesEnabled = true;
  127065. // Sprites
  127066. /**
  127067. * Gets or sets a boolean indicating if sprites are enabled on this scene
  127068. */
  127069. _this.spritesEnabled = true;
  127070. // Skeletons
  127071. _this._skeletonsEnabled = true;
  127072. // Lens flares
  127073. /**
  127074. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  127075. */
  127076. _this.lensFlaresEnabled = true;
  127077. // Collisions
  127078. /**
  127079. * Gets or sets a boolean indicating if collisions are enabled on this scene
  127080. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  127081. */
  127082. _this.collisionsEnabled = true;
  127083. /**
  127084. * Defines the gravity applied to this scene (used only for collisions)
  127085. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  127086. */
  127087. _this.gravity = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](0, -9.807, 0);
  127088. // Postprocesses
  127089. /**
  127090. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  127091. */
  127092. _this.postProcessesEnabled = true;
  127093. /**
  127094. * The list of postprocesses added to the scene
  127095. */
  127096. _this.postProcesses = new Array();
  127097. // Customs render targets
  127098. /**
  127099. * Gets or sets a boolean indicating if render targets are enabled on this scene
  127100. */
  127101. _this.renderTargetsEnabled = true;
  127102. /**
  127103. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  127104. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  127105. */
  127106. _this.dumpNextRenderTargets = false;
  127107. /**
  127108. * The list of user defined render targets added to the scene
  127109. */
  127110. _this.customRenderTargets = new Array();
  127111. /**
  127112. * Gets the list of meshes imported to the scene through SceneLoader
  127113. */
  127114. _this.importedMeshesFiles = new Array();
  127115. // Probes
  127116. /**
  127117. * Gets or sets a boolean indicating if probes are enabled on this scene
  127118. */
  127119. _this.probesEnabled = true;
  127120. _this._meshesForIntersections = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  127121. // Procedural textures
  127122. /**
  127123. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  127124. */
  127125. _this.proceduralTexturesEnabled = true;
  127126. // Performance counters
  127127. _this._totalVertices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  127128. /** @hidden */
  127129. _this._activeIndices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  127130. /** @hidden */
  127131. _this._activeParticles = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  127132. /** @hidden */
  127133. _this._activeBones = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  127134. _this._animationTime = 0;
  127135. /**
  127136. * Gets or sets a general scale for animation speed
  127137. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  127138. */
  127139. _this.animationTimeScale = 1;
  127140. _this._renderId = 0;
  127141. _this._frameId = 0;
  127142. _this._executeWhenReadyTimeoutId = -1;
  127143. _this._intermediateRendering = false;
  127144. _this._viewUpdateFlag = -1;
  127145. _this._projectionUpdateFlag = -1;
  127146. _this._alternateViewUpdateFlag = -1;
  127147. _this._alternateProjectionUpdateFlag = -1;
  127148. /** @hidden */
  127149. _this._toBeDisposed = new Array(256);
  127150. _this._activeRequests = new Array();
  127151. _this._pendingData = new Array();
  127152. _this._isDisposed = false;
  127153. /**
  127154. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  127155. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  127156. */
  127157. _this.dispatchAllSubMeshesOfActiveMeshes = false;
  127158. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  127159. _this._processedMaterials = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  127160. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  127161. /** @hidden */
  127162. _this._activeParticleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  127163. _this._activeSkeletons = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  127164. _this._softwareSkinnedMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  127165. /** @hidden */
  127166. _this._activeAnimatables = new Array();
  127167. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  127168. _this._useAlternateCameraConfiguration = false;
  127169. _this._alternateRendering = false;
  127170. _this._wheelEventName = "";
  127171. /**
  127172. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  127173. * This is useful if there are more lights that the maximum simulteanous authorized
  127174. */
  127175. _this.requireLightSorting = false;
  127176. /**
  127177. * @hidden
  127178. * Backing store of defined scene components.
  127179. */
  127180. _this._components = [];
  127181. /**
  127182. * @hidden
  127183. * Backing store of defined scene components.
  127184. */
  127185. _this._serializableComponents = [];
  127186. /**
  127187. * List of components to register on the next registration step.
  127188. */
  127189. _this._transientComponents = [];
  127190. /**
  127191. * @hidden
  127192. * Defines the actions happening before camera updates.
  127193. */
  127194. _this._beforeCameraUpdateStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127195. /**
  127196. * @hidden
  127197. * Defines the actions happening before clear the canvas.
  127198. */
  127199. _this._beforeClearStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127200. /**
  127201. * @hidden
  127202. * Defines the actions when collecting render targets for the frame.
  127203. */
  127204. _this._gatherRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127205. /**
  127206. * @hidden
  127207. * Defines the actions happening for one camera in the frame.
  127208. */
  127209. _this._gatherActiveCameraRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127210. /**
  127211. * @hidden
  127212. * Defines the actions happening during the per mesh ready checks.
  127213. */
  127214. _this._isReadyForMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127215. /**
  127216. * @hidden
  127217. * Defines the actions happening before evaluate active mesh checks.
  127218. */
  127219. _this._beforeEvaluateActiveMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127220. /**
  127221. * @hidden
  127222. * Defines the actions happening during the evaluate sub mesh checks.
  127223. */
  127224. _this._evaluateSubMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127225. /**
  127226. * @hidden
  127227. * Defines the actions happening during the active mesh stage.
  127228. */
  127229. _this._activeMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127230. /**
  127231. * @hidden
  127232. * Defines the actions happening during the per camera render target step.
  127233. */
  127234. _this._cameraDrawRenderTargetStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127235. /**
  127236. * @hidden
  127237. * Defines the actions happening just before the active camera is drawing.
  127238. */
  127239. _this._beforeCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127240. /**
  127241. * @hidden
  127242. * Defines the actions happening just before a render target is drawing.
  127243. */
  127244. _this._beforeRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127245. /**
  127246. * @hidden
  127247. * Defines the actions happening just before a rendering group is drawing.
  127248. */
  127249. _this._beforeRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127250. /**
  127251. * @hidden
  127252. * Defines the actions happening just before a mesh is drawing.
  127253. */
  127254. _this._beforeRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127255. /**
  127256. * @hidden
  127257. * Defines the actions happening just after a mesh has been drawn.
  127258. */
  127259. _this._afterRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127260. /**
  127261. * @hidden
  127262. * Defines the actions happening just after a rendering group has been drawn.
  127263. */
  127264. _this._afterRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127265. /**
  127266. * @hidden
  127267. * Defines the actions happening just after the active camera has been drawn.
  127268. */
  127269. _this._afterCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127270. /**
  127271. * @hidden
  127272. * Defines the actions happening just after a render target has been drawn.
  127273. */
  127274. _this._afterRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127275. /**
  127276. * @hidden
  127277. * Defines the actions happening just after rendering all cameras and computing intersections.
  127278. */
  127279. _this._afterRenderStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127280. /**
  127281. * @hidden
  127282. * Defines the actions happening when a pointer move event happens.
  127283. */
  127284. _this._pointerMoveStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127285. /**
  127286. * @hidden
  127287. * Defines the actions happening when a pointer down event happens.
  127288. */
  127289. _this._pointerDownStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127290. /**
  127291. * @hidden
  127292. * Defines the actions happening when a pointer up event happens.
  127293. */
  127294. _this._pointerUpStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127295. /**
  127296. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  127297. */
  127298. _this.geometriesByUniqueId = null;
  127299. _this._defaultMeshCandidates = {
  127300. data: [],
  127301. length: 0
  127302. };
  127303. _this._defaultSubMeshCandidates = {
  127304. data: [],
  127305. length: 0
  127306. };
  127307. _this._preventFreeActiveMeshesAndRenderingGroups = false;
  127308. _this._activeMeshesFrozen = false;
  127309. /** @hidden */
  127310. _this._allowPostProcessClearColor = true;
  127311. /**
  127312. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  127313. */
  127314. _this.getDeterministicFrameTime = function () {
  127315. return 1000.0 / 60.0; // frame time in ms
  127316. };
  127317. _this._tempPickingRay = _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"] ? _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"].Zero() : null;
  127318. _this._blockMaterialDirtyMechanism = false;
  127319. _this._engine = engine || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_29__["EngineStore"].LastCreatedEngine;
  127320. _this._engine.scenes.push(_this);
  127321. _this._uid = null;
  127322. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_23__["RenderingManager"](_this);
  127323. if (_PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"]) {
  127324. _this.postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"](_this);
  127325. }
  127326. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_27__["DomManagement"].IsWindowObjectExist()) {
  127327. _this.attachControl();
  127328. }
  127329. //collision coordinator initialization. For now legacy per default.
  127330. _this.workerCollisions = false; //(!!Worker && (!!CollisionWorker || WorkerIncluded));
  127331. // Uniform Buffer
  127332. _this._createUbo();
  127333. // Default Image processing definition
  127334. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]) {
  127335. _this._imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]();
  127336. }
  127337. _this.setDefaultCandidateProviders();
  127338. if (options && options.useGeometryUniqueIdsMap === true) {
  127339. _this.geometriesByUniqueId = {};
  127340. }
  127341. _this.useMaterialMeshMap = options && options.useGeometryUniqueIdsMap || false;
  127342. _this.useClonedMeshhMap = options && options.useClonedMeshhMap || false;
  127343. _this._engine.onNewSceneAddedObservable.notifyObservers(_this);
  127344. return _this;
  127345. }
  127346. /**
  127347. * Factory used to create the default material.
  127348. * @param name The name of the material to create
  127349. * @param scene The scene to create the material for
  127350. * @returns The default material
  127351. */
  127352. Scene.DefaultMaterialFactory = function (scene) {
  127353. throw "Import StandardMaterial or Fill DefaultMaterialFactory static property on scene before relying on default material creation.";
  127354. };
  127355. Object.defineProperty(Scene.prototype, "environmentTexture", {
  127356. /**
  127357. * Texture used in all pbr material as the reflection texture.
  127358. * As in the majority of the scene they are the same (exception for multi room and so on),
  127359. * this is easier to reference from here than from all the materials.
  127360. */
  127361. get: function () {
  127362. return this._environmentTexture;
  127363. },
  127364. /**
  127365. * Texture used in all pbr material as the reflection texture.
  127366. * As in the majority of the scene they are the same (exception for multi room and so on),
  127367. * this is easier to set here than in all the materials.
  127368. */
  127369. set: function (value) {
  127370. if (this._environmentTexture === value) {
  127371. return;
  127372. }
  127373. this._environmentTexture = value;
  127374. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_TextureDirtyFlag);
  127375. },
  127376. enumerable: true,
  127377. configurable: true
  127378. });
  127379. Object.defineProperty(Scene.prototype, "imageProcessingConfiguration", {
  127380. /**
  127381. * Default image processing configuration used either in the rendering
  127382. * Forward main pass or through the imageProcessingPostProcess if present.
  127383. * As in the majority of the scene they are the same (exception for multi camera),
  127384. * this is easier to reference from here than from all the materials and post process.
  127385. *
  127386. * No setter as we it is a shared configuration, you can set the values instead.
  127387. */
  127388. get: function () {
  127389. return this._imageProcessingConfiguration;
  127390. },
  127391. enumerable: true,
  127392. configurable: true
  127393. });
  127394. Object.defineProperty(Scene.prototype, "forceWireframe", {
  127395. get: function () {
  127396. return this._forceWireframe;
  127397. },
  127398. /**
  127399. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  127400. */
  127401. set: function (value) {
  127402. if (this._forceWireframe === value) {
  127403. return;
  127404. }
  127405. this._forceWireframe = value;
  127406. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_MiscDirtyFlag);
  127407. },
  127408. enumerable: true,
  127409. configurable: true
  127410. });
  127411. Object.defineProperty(Scene.prototype, "forcePointsCloud", {
  127412. get: function () {
  127413. return this._forcePointsCloud;
  127414. },
  127415. /**
  127416. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  127417. */
  127418. set: function (value) {
  127419. if (this._forcePointsCloud === value) {
  127420. return;
  127421. }
  127422. this._forcePointsCloud = value;
  127423. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_MiscDirtyFlag);
  127424. },
  127425. enumerable: true,
  127426. configurable: true
  127427. });
  127428. Object.defineProperty(Scene.prototype, "animationPropertiesOverride", {
  127429. /**
  127430. * Gets or sets the animation properties override
  127431. */
  127432. get: function () {
  127433. return this._animationPropertiesOverride;
  127434. },
  127435. set: function (value) {
  127436. this._animationPropertiesOverride = value;
  127437. },
  127438. enumerable: true,
  127439. configurable: true
  127440. });
  127441. Object.defineProperty(Scene.prototype, "onDispose", {
  127442. /** Sets a function to be executed when this scene is disposed. */
  127443. set: function (callback) {
  127444. if (this._onDisposeObserver) {
  127445. this.onDisposeObservable.remove(this._onDisposeObserver);
  127446. }
  127447. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  127448. },
  127449. enumerable: true,
  127450. configurable: true
  127451. });
  127452. Object.defineProperty(Scene.prototype, "beforeRender", {
  127453. /** Sets a function to be executed before rendering this scene */
  127454. set: function (callback) {
  127455. if (this._onBeforeRenderObserver) {
  127456. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  127457. }
  127458. if (callback) {
  127459. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  127460. }
  127461. },
  127462. enumerable: true,
  127463. configurable: true
  127464. });
  127465. Object.defineProperty(Scene.prototype, "afterRender", {
  127466. /** Sets a function to be executed after rendering this scene */
  127467. set: function (callback) {
  127468. if (this._onAfterRenderObserver) {
  127469. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  127470. }
  127471. if (callback) {
  127472. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  127473. }
  127474. },
  127475. enumerable: true,
  127476. configurable: true
  127477. });
  127478. Object.defineProperty(Scene.prototype, "beforeCameraRender", {
  127479. /** Sets a function to be executed before rendering a camera*/
  127480. set: function (callback) {
  127481. if (this._onBeforeCameraRenderObserver) {
  127482. this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  127483. }
  127484. this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(callback);
  127485. },
  127486. enumerable: true,
  127487. configurable: true
  127488. });
  127489. Object.defineProperty(Scene.prototype, "afterCameraRender", {
  127490. /** Sets a function to be executed after rendering a camera*/
  127491. set: function (callback) {
  127492. if (this._onAfterCameraRenderObserver) {
  127493. this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  127494. }
  127495. this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(callback);
  127496. },
  127497. enumerable: true,
  127498. configurable: true
  127499. });
  127500. Object.defineProperty(Scene.prototype, "unTranslatedPointer", {
  127501. /**
  127502. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  127503. */
  127504. get: function () {
  127505. return new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](this._unTranslatedPointerX, this._unTranslatedPointerY);
  127506. },
  127507. enumerable: true,
  127508. configurable: true
  127509. });
  127510. Object.defineProperty(Scene.prototype, "useRightHandedSystem", {
  127511. get: function () {
  127512. return this._useRightHandedSystem;
  127513. },
  127514. /**
  127515. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  127516. */
  127517. set: function (value) {
  127518. if (this._useRightHandedSystem === value) {
  127519. return;
  127520. }
  127521. this._useRightHandedSystem = value;
  127522. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_MiscDirtyFlag);
  127523. },
  127524. enumerable: true,
  127525. configurable: true
  127526. });
  127527. /**
  127528. * Sets the step Id used by deterministic lock step
  127529. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127530. * @param newStepId defines the step Id
  127531. */
  127532. Scene.prototype.setStepId = function (newStepId) {
  127533. this._currentStepId = newStepId;
  127534. };
  127535. /**
  127536. * Gets the step Id used by deterministic lock step
  127537. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127538. * @returns the step Id
  127539. */
  127540. Scene.prototype.getStepId = function () {
  127541. return this._currentStepId;
  127542. };
  127543. /**
  127544. * Gets the internal step used by deterministic lock step
  127545. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127546. * @returns the internal step
  127547. */
  127548. Scene.prototype.getInternalStep = function () {
  127549. return this._currentInternalStep;
  127550. };
  127551. Object.defineProperty(Scene.prototype, "fogEnabled", {
  127552. get: function () {
  127553. return this._fogEnabled;
  127554. },
  127555. /**
  127556. * Gets or sets a boolean indicating if fog is enabled on this scene
  127557. * @see http://doc.babylonjs.com/babylon101/environment#fog
  127558. * (Default is true)
  127559. */
  127560. set: function (value) {
  127561. if (this._fogEnabled === value) {
  127562. return;
  127563. }
  127564. this._fogEnabled = value;
  127565. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_MiscDirtyFlag);
  127566. },
  127567. enumerable: true,
  127568. configurable: true
  127569. });
  127570. Object.defineProperty(Scene.prototype, "fogMode", {
  127571. get: function () {
  127572. return this._fogMode;
  127573. },
  127574. /**
  127575. * Gets or sets the fog mode to use
  127576. * @see http://doc.babylonjs.com/babylon101/environment#fog
  127577. * | mode | value |
  127578. * | --- | --- |
  127579. * | FOGMODE_NONE | 0 |
  127580. * | FOGMODE_EXP | 1 |
  127581. * | FOGMODE_EXP2 | 2 |
  127582. * | FOGMODE_LINEAR | 3 |
  127583. */
  127584. set: function (value) {
  127585. if (this._fogMode === value) {
  127586. return;
  127587. }
  127588. this._fogMode = value;
  127589. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_MiscDirtyFlag);
  127590. },
  127591. enumerable: true,
  127592. configurable: true
  127593. });
  127594. Object.defineProperty(Scene.prototype, "shadowsEnabled", {
  127595. get: function () {
  127596. return this._shadowsEnabled;
  127597. },
  127598. /**
  127599. * Gets or sets a boolean indicating if shadows are enabled on this scene
  127600. */
  127601. set: function (value) {
  127602. if (this._shadowsEnabled === value) {
  127603. return;
  127604. }
  127605. this._shadowsEnabled = value;
  127606. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_LightDirtyFlag);
  127607. },
  127608. enumerable: true,
  127609. configurable: true
  127610. });
  127611. Object.defineProperty(Scene.prototype, "lightsEnabled", {
  127612. get: function () {
  127613. return this._lightsEnabled;
  127614. },
  127615. /**
  127616. * Gets or sets a boolean indicating if lights are enabled on this scene
  127617. */
  127618. set: function (value) {
  127619. if (this._lightsEnabled === value) {
  127620. return;
  127621. }
  127622. this._lightsEnabled = value;
  127623. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_LightDirtyFlag);
  127624. },
  127625. enumerable: true,
  127626. configurable: true
  127627. });
  127628. Object.defineProperty(Scene.prototype, "activeCamera", {
  127629. /** Gets or sets the current active camera */
  127630. get: function () {
  127631. return this._activeCamera;
  127632. },
  127633. set: function (value) {
  127634. if (value === this._activeCamera) {
  127635. return;
  127636. }
  127637. this._activeCamera = value;
  127638. this.onActiveCameraChanged.notifyObservers(this);
  127639. },
  127640. enumerable: true,
  127641. configurable: true
  127642. });
  127643. Object.defineProperty(Scene.prototype, "defaultMaterial", {
  127644. /** The default material used on meshes when no material is affected */
  127645. get: function () {
  127646. if (!this._defaultMaterial) {
  127647. this._defaultMaterial = Scene.DefaultMaterialFactory(this);
  127648. }
  127649. return this._defaultMaterial;
  127650. },
  127651. /** The default material used on meshes when no material is affected */
  127652. set: function (value) {
  127653. this._defaultMaterial = value;
  127654. },
  127655. enumerable: true,
  127656. configurable: true
  127657. });
  127658. Object.defineProperty(Scene.prototype, "texturesEnabled", {
  127659. get: function () {
  127660. return this._texturesEnabled;
  127661. },
  127662. /**
  127663. * Gets or sets a boolean indicating if textures are enabled on this scene
  127664. */
  127665. set: function (value) {
  127666. if (this._texturesEnabled === value) {
  127667. return;
  127668. }
  127669. this._texturesEnabled = value;
  127670. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_TextureDirtyFlag);
  127671. },
  127672. enumerable: true,
  127673. configurable: true
  127674. });
  127675. Object.defineProperty(Scene.prototype, "skeletonsEnabled", {
  127676. get: function () {
  127677. return this._skeletonsEnabled;
  127678. },
  127679. /**
  127680. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  127681. */
  127682. set: function (value) {
  127683. if (this._skeletonsEnabled === value) {
  127684. return;
  127685. }
  127686. this._skeletonsEnabled = value;
  127687. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_AttributesDirtyFlag);
  127688. },
  127689. enumerable: true,
  127690. configurable: true
  127691. });
  127692. Object.defineProperty(Scene.prototype, "_isAlternateRenderingEnabled", {
  127693. /** @hidden */
  127694. get: function () {
  127695. return this._alternateRendering;
  127696. },
  127697. enumerable: true,
  127698. configurable: true
  127699. });
  127700. Object.defineProperty(Scene.prototype, "frustumPlanes", {
  127701. /**
  127702. * Gets the list of frustum planes (built from the active camera)
  127703. */
  127704. get: function () {
  127705. return this._frustumPlanes;
  127706. },
  127707. enumerable: true,
  127708. configurable: true
  127709. });
  127710. /**
  127711. * Registers the transient components if needed.
  127712. */
  127713. Scene.prototype._registerTransientComponents = function () {
  127714. // Register components that have been associated lately to the scene.
  127715. if (this._transientComponents.length > 0) {
  127716. for (var _i = 0, _a = this._transientComponents; _i < _a.length; _i++) {
  127717. var component = _a[_i];
  127718. component.register();
  127719. }
  127720. this._transientComponents = [];
  127721. }
  127722. };
  127723. /**
  127724. * @hidden
  127725. * Add a component to the scene.
  127726. * Note that the ccomponent could be registered on th next frame if this is called after
  127727. * the register component stage.
  127728. * @param component Defines the component to add to the scene
  127729. */
  127730. Scene.prototype._addComponent = function (component) {
  127731. this._components.push(component);
  127732. this._transientComponents.push(component);
  127733. var serializableComponent = component;
  127734. if (serializableComponent.addFromContainer) {
  127735. this._serializableComponents.push(serializableComponent);
  127736. }
  127737. };
  127738. /**
  127739. * @hidden
  127740. * Gets a component from the scene.
  127741. * @param name defines the name of the component to retrieve
  127742. * @returns the component or null if not present
  127743. */
  127744. Scene.prototype._getComponent = function (name) {
  127745. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  127746. var component = _a[_i];
  127747. if (component.name === name) {
  127748. return component;
  127749. }
  127750. }
  127751. return null;
  127752. };
  127753. /**
  127754. * @hidden
  127755. */
  127756. Scene.prototype._getDefaultMeshCandidates = function () {
  127757. this._defaultMeshCandidates.data = this.meshes;
  127758. this._defaultMeshCandidates.length = this.meshes.length;
  127759. return this._defaultMeshCandidates;
  127760. };
  127761. /**
  127762. * @hidden
  127763. */
  127764. Scene.prototype._getDefaultSubMeshCandidates = function (mesh) {
  127765. this._defaultSubMeshCandidates.data = mesh.subMeshes;
  127766. this._defaultSubMeshCandidates.length = mesh.subMeshes.length;
  127767. return this._defaultSubMeshCandidates;
  127768. };
  127769. /**
  127770. * Sets the default candidate providers for the scene.
  127771. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  127772. * and getCollidingSubMeshCandidates to their default function
  127773. */
  127774. Scene.prototype.setDefaultCandidateProviders = function () {
  127775. this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this);
  127776. this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  127777. this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  127778. this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  127779. };
  127780. Object.defineProperty(Scene.prototype, "workerCollisions", {
  127781. /**
  127782. * Gets a boolean indicating if collisions are processed on a web worker
  127783. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  127784. */
  127785. get: function () {
  127786. // Worker has been deprecated.
  127787. // Keep for back compat.
  127788. return false;
  127789. },
  127790. set: function (enabled) {
  127791. if (!_Collisions_collisionCoordinator__WEBPACK_IMPORTED_MODULE_17__["CollisionCoordinatorLegacy"]) {
  127792. return;
  127793. }
  127794. if (this.collisionCoordinator) {
  127795. this.collisionCoordinator.destroy();
  127796. }
  127797. this.collisionCoordinator = new _Collisions_collisionCoordinator__WEBPACK_IMPORTED_MODULE_17__["CollisionCoordinatorLegacy"]();
  127798. this.collisionCoordinator.init(this);
  127799. },
  127800. enumerable: true,
  127801. configurable: true
  127802. });
  127803. Object.defineProperty(Scene.prototype, "meshUnderPointer", {
  127804. /**
  127805. * Gets the mesh that is currently under the pointer
  127806. */
  127807. get: function () {
  127808. return this._pointerOverMesh;
  127809. },
  127810. enumerable: true,
  127811. configurable: true
  127812. });
  127813. Object.defineProperty(Scene.prototype, "pointerX", {
  127814. /**
  127815. * Gets or sets the current on-screen X position of the pointer
  127816. */
  127817. get: function () {
  127818. return this._pointerX;
  127819. },
  127820. set: function (value) {
  127821. this._pointerX = value;
  127822. },
  127823. enumerable: true,
  127824. configurable: true
  127825. });
  127826. Object.defineProperty(Scene.prototype, "pointerY", {
  127827. /**
  127828. * Gets or sets the current on-screen Y position of the pointer
  127829. */
  127830. get: function () {
  127831. return this._pointerY;
  127832. },
  127833. set: function (value) {
  127834. this._pointerY = value;
  127835. },
  127836. enumerable: true,
  127837. configurable: true
  127838. });
  127839. /**
  127840. * Gets the cached material (ie. the latest rendered one)
  127841. * @returns the cached material
  127842. */
  127843. Scene.prototype.getCachedMaterial = function () {
  127844. return this._cachedMaterial;
  127845. };
  127846. /**
  127847. * Gets the cached effect (ie. the latest rendered one)
  127848. * @returns the cached effect
  127849. */
  127850. Scene.prototype.getCachedEffect = function () {
  127851. return this._cachedEffect;
  127852. };
  127853. /**
  127854. * Gets the cached visibility state (ie. the latest rendered one)
  127855. * @returns the cached visibility state
  127856. */
  127857. Scene.prototype.getCachedVisibility = function () {
  127858. return this._cachedVisibility;
  127859. };
  127860. /**
  127861. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  127862. * @param material defines the current material
  127863. * @param effect defines the current effect
  127864. * @param visibility defines the current visibility state
  127865. * @returns true if one parameter is not cached
  127866. */
  127867. Scene.prototype.isCachedMaterialInvalid = function (material, effect, visibility) {
  127868. if (visibility === void 0) { visibility = 1; }
  127869. return this._cachedEffect !== effect || this._cachedMaterial !== material || this._cachedVisibility !== visibility;
  127870. };
  127871. /**
  127872. * Gets the engine associated with the scene
  127873. * @returns an Engine
  127874. */
  127875. Scene.prototype.getEngine = function () {
  127876. return this._engine;
  127877. };
  127878. /**
  127879. * Gets the total number of vertices rendered per frame
  127880. * @returns the total number of vertices rendered per frame
  127881. */
  127882. Scene.prototype.getTotalVertices = function () {
  127883. return this._totalVertices.current;
  127884. };
  127885. Object.defineProperty(Scene.prototype, "totalVerticesPerfCounter", {
  127886. /**
  127887. * Gets the performance counter for total vertices
  127888. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  127889. */
  127890. get: function () {
  127891. return this._totalVertices;
  127892. },
  127893. enumerable: true,
  127894. configurable: true
  127895. });
  127896. /**
  127897. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  127898. * @returns the total number of active indices rendered per frame
  127899. */
  127900. Scene.prototype.getActiveIndices = function () {
  127901. return this._activeIndices.current;
  127902. };
  127903. Object.defineProperty(Scene.prototype, "totalActiveIndicesPerfCounter", {
  127904. /**
  127905. * Gets the performance counter for active indices
  127906. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  127907. */
  127908. get: function () {
  127909. return this._activeIndices;
  127910. },
  127911. enumerable: true,
  127912. configurable: true
  127913. });
  127914. /**
  127915. * Gets the total number of active particles rendered per frame
  127916. * @returns the total number of active particles rendered per frame
  127917. */
  127918. Scene.prototype.getActiveParticles = function () {
  127919. return this._activeParticles.current;
  127920. };
  127921. Object.defineProperty(Scene.prototype, "activeParticlesPerfCounter", {
  127922. /**
  127923. * Gets the performance counter for active particles
  127924. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  127925. */
  127926. get: function () {
  127927. return this._activeParticles;
  127928. },
  127929. enumerable: true,
  127930. configurable: true
  127931. });
  127932. /**
  127933. * Gets the total number of active bones rendered per frame
  127934. * @returns the total number of active bones rendered per frame
  127935. */
  127936. Scene.prototype.getActiveBones = function () {
  127937. return this._activeBones.current;
  127938. };
  127939. Object.defineProperty(Scene.prototype, "activeBonesPerfCounter", {
  127940. /**
  127941. * Gets the performance counter for active bones
  127942. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  127943. */
  127944. get: function () {
  127945. return this._activeBones;
  127946. },
  127947. enumerable: true,
  127948. configurable: true
  127949. });
  127950. /**
  127951. * Gets the array of active meshes
  127952. * @returns an array of AbstractMesh
  127953. */
  127954. Scene.prototype.getActiveMeshes = function () {
  127955. return this._activeMeshes;
  127956. };
  127957. /**
  127958. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  127959. * @returns a number
  127960. */
  127961. Scene.prototype.getAnimationRatio = function () {
  127962. return this._animationRatio !== undefined ? this._animationRatio : 1;
  127963. };
  127964. /**
  127965. * Gets an unique Id for the current render phase
  127966. * @returns a number
  127967. */
  127968. Scene.prototype.getRenderId = function () {
  127969. return this._renderId;
  127970. };
  127971. /**
  127972. * Gets an unique Id for the current frame
  127973. * @returns a number
  127974. */
  127975. Scene.prototype.getFrameId = function () {
  127976. return this._frameId;
  127977. };
  127978. /** Call this function if you want to manually increment the render Id*/
  127979. Scene.prototype.incrementRenderId = function () {
  127980. this._renderId++;
  127981. };
  127982. Scene.prototype._updatePointerPosition = function (evt) {
  127983. var canvasRect = this._engine.getRenderingCanvasClientRect();
  127984. if (!canvasRect) {
  127985. return;
  127986. }
  127987. this._pointerX = evt.clientX - canvasRect.left;
  127988. this._pointerY = evt.clientY - canvasRect.top;
  127989. this._unTranslatedPointerX = this._pointerX;
  127990. this._unTranslatedPointerY = this._pointerY;
  127991. };
  127992. Scene.prototype._createUbo = function () {
  127993. this._sceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  127994. this._sceneUbo.addUniform("viewProjection", 16);
  127995. this._sceneUbo.addUniform("view", 16);
  127996. };
  127997. Scene.prototype._createAlternateUbo = function () {
  127998. this._alternateSceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  127999. this._alternateSceneUbo.addUniform("viewProjection", 16);
  128000. this._alternateSceneUbo.addUniform("view", 16);
  128001. };
  128002. // Pointers handling
  128003. Scene.prototype._setRayOnPointerInfo = function (pointerInfo) {
  128004. if (pointerInfo.pickInfo) {
  128005. if (!pointerInfo.pickInfo.ray) {
  128006. pointerInfo.pickInfo.ray = this.createPickingRay(pointerInfo.event.offsetX, pointerInfo.event.offsetY, _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity(), this.activeCamera);
  128007. }
  128008. }
  128009. };
  128010. /**
  128011. * Use this method to simulate a pointer move on a mesh
  128012. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  128013. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  128014. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  128015. * @returns the current scene
  128016. */
  128017. Scene.prototype.simulatePointerMove = function (pickResult, pointerEventInit) {
  128018. var evt = new PointerEvent("pointermove", pointerEventInit);
  128019. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERMOVE)) {
  128020. return this;
  128021. }
  128022. return this._processPointerMove(pickResult, evt);
  128023. };
  128024. Scene.prototype._processPointerMove = function (pickResult, evt) {
  128025. var canvas = this._engine.getRenderingCanvas();
  128026. if (!canvas) {
  128027. return this;
  128028. }
  128029. // Restore pointer
  128030. canvas.style.cursor = this.defaultCursor;
  128031. var isMeshPicked = (pickResult && pickResult.hit && pickResult.pickedMesh) ? true : false;
  128032. if (isMeshPicked) {
  128033. this.setPointerOverMesh(pickResult.pickedMesh);
  128034. if (this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers) {
  128035. if (this._pointerOverMesh.actionManager.hoverCursor) {
  128036. canvas.style.cursor = this._pointerOverMesh.actionManager.hoverCursor;
  128037. }
  128038. else {
  128039. canvas.style.cursor = this.hoverCursor;
  128040. }
  128041. }
  128042. }
  128043. else {
  128044. this.setPointerOverMesh(null);
  128045. }
  128046. for (var _i = 0, _a = this._pointerMoveStage; _i < _a.length; _i++) {
  128047. var step = _a[_i];
  128048. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, isMeshPicked, canvas);
  128049. }
  128050. if (pickResult) {
  128051. var type = evt.type === this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERMOVE;
  128052. if (this.onPointerMove) {
  128053. this.onPointerMove(evt, pickResult, type);
  128054. }
  128055. if (this.onPointerObservable.hasObservers()) {
  128056. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerInfo"](type, evt, pickResult);
  128057. this._setRayOnPointerInfo(pi);
  128058. this.onPointerObservable.notifyObservers(pi, type);
  128059. }
  128060. }
  128061. return this;
  128062. };
  128063. Scene.prototype._checkPrePointerObservable = function (pickResult, evt, type) {
  128064. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerInfoPre"](type, evt, this._unTranslatedPointerX, this._unTranslatedPointerY);
  128065. if (pickResult) {
  128066. pi.ray = pickResult.ray;
  128067. }
  128068. this.onPrePointerObservable.notifyObservers(pi, type);
  128069. if (pi.skipOnPointerObservable) {
  128070. return true;
  128071. }
  128072. else {
  128073. return false;
  128074. }
  128075. };
  128076. /**
  128077. * Use this method to simulate a pointer down on a mesh
  128078. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  128079. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  128080. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  128081. * @returns the current scene
  128082. */
  128083. Scene.prototype.simulatePointerDown = function (pickResult, pointerEventInit) {
  128084. var evt = new PointerEvent("pointerdown", pointerEventInit);
  128085. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOWN)) {
  128086. return this;
  128087. }
  128088. return this._processPointerDown(pickResult, evt);
  128089. };
  128090. Scene.prototype._processPointerDown = function (pickResult, evt) {
  128091. var _this = this;
  128092. if (pickResult && pickResult.hit && pickResult.pickedMesh) {
  128093. this._pickedDownMesh = pickResult.pickedMesh;
  128094. var actionManager = pickResult.pickedMesh.actionManager;
  128095. if (actionManager) {
  128096. if (actionManager.hasPickTriggers) {
  128097. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnPickDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128098. switch (evt.button) {
  128099. case 0:
  128100. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnLeftPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128101. break;
  128102. case 1:
  128103. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnCenterPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128104. break;
  128105. case 2:
  128106. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnRightPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128107. break;
  128108. }
  128109. }
  128110. if (actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnLongPressTrigger)) {
  128111. window.setTimeout(function () {
  128112. 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);
  128113. if (pickResult && pickResult.hit && pickResult.pickedMesh && actionManager) {
  128114. if (_this._totalPointersPressed !== 0 &&
  128115. ((Date.now() - _this._startingPointerTime) > Scene.LongPressDelay) &&
  128116. !_this._isPointerSwiping()) {
  128117. _this._startingPointerTime = 0;
  128118. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnLongPressTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128119. }
  128120. }
  128121. }, Scene.LongPressDelay);
  128122. }
  128123. }
  128124. }
  128125. else {
  128126. for (var _i = 0, _a = this._pointerDownStage; _i < _a.length; _i++) {
  128127. var step = _a[_i];
  128128. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  128129. }
  128130. }
  128131. if (pickResult) {
  128132. var type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOWN;
  128133. if (this.onPointerDown) {
  128134. this.onPointerDown(evt, pickResult, type);
  128135. }
  128136. if (this.onPointerObservable.hasObservers()) {
  128137. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerInfo"](type, evt, pickResult);
  128138. this._setRayOnPointerInfo(pi);
  128139. this.onPointerObservable.notifyObservers(pi, type);
  128140. }
  128141. }
  128142. return this;
  128143. };
  128144. /**
  128145. * Use this method to simulate a pointer up on a mesh
  128146. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  128147. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  128148. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  128149. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  128150. * @returns the current scene
  128151. */
  128152. Scene.prototype.simulatePointerUp = function (pickResult, pointerEventInit, doubleTap) {
  128153. var evt = new PointerEvent("pointerup", pointerEventInit);
  128154. var clickInfo = new ClickInfo();
  128155. if (doubleTap) {
  128156. clickInfo.doubleClick = true;
  128157. }
  128158. else {
  128159. clickInfo.singleClick = true;
  128160. }
  128161. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERUP)) {
  128162. return this;
  128163. }
  128164. return this._processPointerUp(pickResult, evt, clickInfo);
  128165. };
  128166. Scene.prototype._processPointerUp = function (pickResult, evt, clickInfo) {
  128167. if (pickResult && pickResult && pickResult.pickedMesh) {
  128168. this._pickedUpMesh = pickResult.pickedMesh;
  128169. if (this._pickedDownMesh === this._pickedUpMesh) {
  128170. if (this.onPointerPick) {
  128171. this.onPointerPick(evt, pickResult);
  128172. }
  128173. if (clickInfo.singleClick && !clickInfo.ignore && this.onPointerObservable.hasObservers()) {
  128174. var type_1 = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERPICK;
  128175. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerInfo"](type_1, evt, pickResult);
  128176. this._setRayOnPointerInfo(pi);
  128177. this.onPointerObservable.notifyObservers(pi, type_1);
  128178. }
  128179. }
  128180. if (pickResult.pickedMesh.actionManager && !clickInfo.ignore) {
  128181. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnPickUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128182. if (!clickInfo.hasSwiped && clickInfo.singleClick) {
  128183. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128184. }
  128185. if (clickInfo.doubleClick && pickResult.pickedMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnDoublePickTrigger)) {
  128186. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnDoublePickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128187. }
  128188. }
  128189. }
  128190. else {
  128191. if (!clickInfo.ignore) {
  128192. for (var _i = 0, _a = this._pointerUpStage; _i < _a.length; _i++) {
  128193. var step = _a[_i];
  128194. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  128195. }
  128196. }
  128197. }
  128198. if (this._pickedDownMesh &&
  128199. this._pickedDownMesh.actionManager &&
  128200. this._pickedDownMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnPickOutTrigger) &&
  128201. this._pickedDownMesh !== this._pickedUpMesh) {
  128202. this._pickedDownMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnPickOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(this._pickedDownMesh, evt));
  128203. }
  128204. var type = 0;
  128205. if (this.onPointerObservable.hasObservers()) {
  128206. if (!clickInfo.ignore && !clickInfo.hasSwiped) {
  128207. if (clickInfo.singleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERTAP)) {
  128208. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERTAP;
  128209. }
  128210. else if (clickInfo.doubleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP)) {
  128211. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP;
  128212. }
  128213. if (type) {
  128214. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerInfo"](type, evt, pickResult);
  128215. this._setRayOnPointerInfo(pi);
  128216. this.onPointerObservable.notifyObservers(pi, type);
  128217. }
  128218. }
  128219. if (!clickInfo.ignore) {
  128220. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERUP;
  128221. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerInfo"](type, evt, pickResult);
  128222. this._setRayOnPointerInfo(pi);
  128223. this.onPointerObservable.notifyObservers(pi, type);
  128224. }
  128225. }
  128226. if (this.onPointerUp && !clickInfo.ignore) {
  128227. this.onPointerUp(evt, pickResult, type);
  128228. }
  128229. return this;
  128230. };
  128231. /**
  128232. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  128233. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  128234. * @returns true if the pointer was captured
  128235. */
  128236. Scene.prototype.isPointerCaptured = function (pointerId) {
  128237. if (pointerId === void 0) { pointerId = 0; }
  128238. return this._pointerCaptures[pointerId];
  128239. };
  128240. /** @hidden */
  128241. Scene.prototype._isPointerSwiping = function () {
  128242. return Math.abs(this._startingPointerPosition.x - this._pointerX) > Scene.DragMovementThreshold ||
  128243. Math.abs(this._startingPointerPosition.y - this._pointerY) > Scene.DragMovementThreshold;
  128244. };
  128245. /**
  128246. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  128247. * @param attachUp defines if you want to attach events to pointerup
  128248. * @param attachDown defines if you want to attach events to pointerdown
  128249. * @param attachMove defines if you want to attach events to pointermove
  128250. */
  128251. Scene.prototype.attachControl = function (attachUp, attachDown, attachMove) {
  128252. var _this = this;
  128253. if (attachUp === void 0) { attachUp = true; }
  128254. if (attachDown === void 0) { attachDown = true; }
  128255. if (attachMove === void 0) { attachMove = true; }
  128256. this._initActionManager = function (act, clickInfo) {
  128257. if (!_this._meshPickProceed) {
  128258. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  128259. _this._currentPickResult = pickResult;
  128260. if (pickResult) {
  128261. act = (pickResult.hit && pickResult.pickedMesh) ? pickResult.pickedMesh.actionManager : null;
  128262. }
  128263. _this._meshPickProceed = true;
  128264. }
  128265. return act;
  128266. };
  128267. this._delayedSimpleClick = function (btn, clickInfo, cb) {
  128268. // double click delay is over and that no double click has been raised since, or the 2 consecutive keys pressed are different
  128269. if ((Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay && !_this._doubleClickOccured) ||
  128270. btn !== _this._previousButtonPressed) {
  128271. _this._doubleClickOccured = false;
  128272. clickInfo.singleClick = true;
  128273. clickInfo.ignore = false;
  128274. cb(clickInfo, _this._currentPickResult);
  128275. }
  128276. };
  128277. this._initClickEvent = function (obs1, obs2, evt, cb) {
  128278. var clickInfo = new ClickInfo();
  128279. _this._currentPickResult = null;
  128280. var act = null;
  128281. var checkPicking = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERPICK) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERPICK)
  128282. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERTAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERTAP)
  128283. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP);
  128284. if (!checkPicking && _Actions_actionManager__WEBPACK_IMPORTED_MODULE_21__["ActionManager"]) {
  128285. act = _this._initActionManager(act, clickInfo);
  128286. if (act) {
  128287. checkPicking = act.hasPickTriggers;
  128288. }
  128289. }
  128290. var needToIgnoreNext = false;
  128291. if (checkPicking) {
  128292. var btn = evt.button;
  128293. clickInfo.hasSwiped = _this._isPointerSwiping();
  128294. if (!clickInfo.hasSwiped) {
  128295. var checkSingleClickImmediately = !Scene.ExclusiveDoubleClickMode;
  128296. if (!checkSingleClickImmediately) {
  128297. checkSingleClickImmediately = !obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP) &&
  128298. !obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP);
  128299. if (checkSingleClickImmediately && !_Actions_actionManager__WEBPACK_IMPORTED_MODULE_21__["ActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnDoublePickTrigger)) {
  128300. act = _this._initActionManager(act, clickInfo);
  128301. if (act) {
  128302. checkSingleClickImmediately = !act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnDoublePickTrigger);
  128303. }
  128304. }
  128305. }
  128306. if (checkSingleClickImmediately) {
  128307. // single click detected if double click delay is over or two different successive keys pressed without exclusive double click or no double click required
  128308. if (Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay ||
  128309. btn !== _this._previousButtonPressed) {
  128310. clickInfo.singleClick = true;
  128311. cb(clickInfo, _this._currentPickResult);
  128312. needToIgnoreNext = true;
  128313. }
  128314. }
  128315. // at least one double click is required to be check and exclusive double click is enabled
  128316. else {
  128317. // wait that no double click has been raised during the double click delay
  128318. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  128319. _this._delayedSimpleClickTimeout = window.setTimeout(_this._delayedSimpleClick.bind(_this, btn, clickInfo, cb), Scene.DoubleClickDelay);
  128320. }
  128321. var checkDoubleClick = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP) ||
  128322. obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP);
  128323. if (!checkDoubleClick && _Actions_actionManager__WEBPACK_IMPORTED_MODULE_21__["ActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnDoublePickTrigger)) {
  128324. act = _this._initActionManager(act, clickInfo);
  128325. if (act) {
  128326. checkDoubleClick = act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnDoublePickTrigger);
  128327. }
  128328. }
  128329. if (checkDoubleClick) {
  128330. // two successive keys pressed are equal, double click delay is not over and double click has not just occurred
  128331. if (btn === _this._previousButtonPressed &&
  128332. Date.now() - _this._previousStartingPointerTime < Scene.DoubleClickDelay &&
  128333. !_this._doubleClickOccured) {
  128334. // pointer has not moved for 2 clicks, it's a double click
  128335. if (!clickInfo.hasSwiped &&
  128336. !_this._isPointerSwiping()) {
  128337. _this._previousStartingPointerTime = 0;
  128338. _this._doubleClickOccured = true;
  128339. clickInfo.doubleClick = true;
  128340. clickInfo.ignore = false;
  128341. if (Scene.ExclusiveDoubleClickMode && _this._previousDelayedSimpleClickTimeout) {
  128342. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  128343. }
  128344. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  128345. cb(clickInfo, _this._currentPickResult);
  128346. }
  128347. // if the two successive clicks are too far, it's just two simple clicks
  128348. else {
  128349. _this._doubleClickOccured = false;
  128350. _this._previousStartingPointerTime = _this._startingPointerTime;
  128351. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  128352. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  128353. _this._previousButtonPressed = btn;
  128354. if (Scene.ExclusiveDoubleClickMode) {
  128355. if (_this._previousDelayedSimpleClickTimeout) {
  128356. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  128357. }
  128358. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  128359. cb(clickInfo, _this._previousPickResult);
  128360. }
  128361. else {
  128362. cb(clickInfo, _this._currentPickResult);
  128363. }
  128364. }
  128365. needToIgnoreNext = true;
  128366. }
  128367. // just the first click of the double has been raised
  128368. else {
  128369. _this._doubleClickOccured = false;
  128370. _this._previousStartingPointerTime = _this._startingPointerTime;
  128371. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  128372. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  128373. _this._previousButtonPressed = btn;
  128374. }
  128375. }
  128376. }
  128377. }
  128378. if (!needToIgnoreNext) {
  128379. cb(clickInfo, _this._currentPickResult);
  128380. }
  128381. };
  128382. this._onPointerMove = function (evt) {
  128383. _this._updatePointerPosition(evt);
  128384. // PreObservable support
  128385. 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)) {
  128386. return;
  128387. }
  128388. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  128389. return;
  128390. }
  128391. if (!_this.pointerMovePredicate) {
  128392. _this.pointerMovePredicate = function (mesh) { return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (mesh.enablePointerMoveEvents || _this.constantlyUpdateMeshUnderPointer || (mesh.actionManager !== null && mesh.actionManager !== undefined)); };
  128393. }
  128394. // Meshes
  128395. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerMovePredicate, false, _this.cameraToUseForPointers);
  128396. _this._processPointerMove(pickResult, evt);
  128397. };
  128398. this._onPointerDown = function (evt) {
  128399. _this._totalPointersPressed++;
  128400. _this._pickedDownMesh = null;
  128401. _this._meshPickProceed = false;
  128402. _this._updatePointerPosition(evt);
  128403. if (_this.preventDefaultOnPointerDown && canvas) {
  128404. evt.preventDefault();
  128405. canvas.focus();
  128406. }
  128407. _this._startingPointerPosition.x = _this._pointerX;
  128408. _this._startingPointerPosition.y = _this._pointerY;
  128409. _this._startingPointerTime = Date.now();
  128410. // PreObservable support
  128411. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOWN)) {
  128412. return;
  128413. }
  128414. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  128415. return;
  128416. }
  128417. _this._pointerCaptures[evt.pointerId] = true;
  128418. if (!_this.pointerDownPredicate) {
  128419. _this.pointerDownPredicate = function (mesh) {
  128420. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled();
  128421. };
  128422. }
  128423. // Meshes
  128424. _this._pickedDownMesh = null;
  128425. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  128426. _this._processPointerDown(pickResult, evt);
  128427. };
  128428. this._onPointerUp = function (evt) {
  128429. if (_this._totalPointersPressed === 0) { // We are attaching the pointer up to windows because of a bug in FF
  128430. return; // So we need to test it the pointer down was pressed before.
  128431. }
  128432. _this._totalPointersPressed--;
  128433. _this._pickedUpMesh = null;
  128434. _this._meshPickProceed = false;
  128435. _this._updatePointerPosition(evt);
  128436. if (_this.preventDefaultOnPointerUp && canvas) {
  128437. evt.preventDefault();
  128438. canvas.focus();
  128439. }
  128440. _this._initClickEvent(_this.onPrePointerObservable, _this.onPointerObservable, evt, function (clickInfo, pickResult) {
  128441. _this._pointerCaptures[evt.pointerId] = false;
  128442. // PreObservable support
  128443. if (_this.onPrePointerObservable.hasObservers()) {
  128444. if (!clickInfo.ignore) {
  128445. if (!clickInfo.hasSwiped) {
  128446. if (clickInfo.singleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERTAP)) {
  128447. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERTAP)) {
  128448. return;
  128449. }
  128450. }
  128451. if (clickInfo.doubleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP)) {
  128452. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP)) {
  128453. return;
  128454. }
  128455. }
  128456. }
  128457. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERUP)) {
  128458. return;
  128459. }
  128460. }
  128461. }
  128462. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  128463. return;
  128464. }
  128465. if (!_this.pointerUpPredicate) {
  128466. _this.pointerUpPredicate = function (mesh) {
  128467. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled();
  128468. };
  128469. }
  128470. // Meshes
  128471. if (!_this._meshPickProceed && (_Actions_actionManager__WEBPACK_IMPORTED_MODULE_21__["ActionManager"] && _Actions_actionManager__WEBPACK_IMPORTED_MODULE_21__["ActionManager"].HasTriggers || _this.onPointerObservable.hasObservers())) {
  128472. _this._initActionManager(null, clickInfo);
  128473. }
  128474. if (!pickResult) {
  128475. pickResult = _this._currentPickResult;
  128476. }
  128477. _this._processPointerUp(pickResult, evt, clickInfo);
  128478. _this._previousPickResult = _this._currentPickResult;
  128479. });
  128480. };
  128481. this._onKeyDown = function (evt) {
  128482. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_19__["KeyboardEventTypes"].KEYDOWN;
  128483. if (_this.onPreKeyboardObservable.hasObservers()) {
  128484. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_19__["KeyboardInfoPre"](type, evt);
  128485. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  128486. if (pi.skipOnPointerObservable) {
  128487. return;
  128488. }
  128489. }
  128490. if (_this.onKeyboardObservable.hasObservers()) {
  128491. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_19__["KeyboardInfo"](type, evt);
  128492. _this.onKeyboardObservable.notifyObservers(pi, type);
  128493. }
  128494. if (_this.actionManager) {
  128495. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnKeyDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNewFromScene(_this, evt));
  128496. }
  128497. };
  128498. this._onKeyUp = function (evt) {
  128499. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_19__["KeyboardEventTypes"].KEYUP;
  128500. if (_this.onPreKeyboardObservable.hasObservers()) {
  128501. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_19__["KeyboardInfoPre"](type, evt);
  128502. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  128503. if (pi.skipOnPointerObservable) {
  128504. return;
  128505. }
  128506. }
  128507. if (_this.onKeyboardObservable.hasObservers()) {
  128508. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_19__["KeyboardInfo"](type, evt);
  128509. _this.onKeyboardObservable.notifyObservers(pi, type);
  128510. }
  128511. if (_this.actionManager) {
  128512. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnKeyUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNewFromScene(_this, evt));
  128513. }
  128514. };
  128515. var engine = this.getEngine();
  128516. this._onCanvasFocusObserver = engine.onCanvasFocusObservable.add(function () {
  128517. if (!canvas) {
  128518. return;
  128519. }
  128520. canvas.addEventListener("keydown", _this._onKeyDown, false);
  128521. canvas.addEventListener("keyup", _this._onKeyUp, false);
  128522. });
  128523. this._onCanvasBlurObserver = engine.onCanvasBlurObservable.add(function () {
  128524. if (!canvas) {
  128525. return;
  128526. }
  128527. canvas.removeEventListener("keydown", _this._onKeyDown);
  128528. canvas.removeEventListener("keyup", _this._onKeyUp);
  128529. });
  128530. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  128531. var canvas = this._engine.getRenderingCanvas();
  128532. if (!canvas) {
  128533. return;
  128534. }
  128535. if (attachMove) {
  128536. canvas.addEventListener(eventPrefix + "move", this._onPointerMove, false);
  128537. // Wheel
  128538. this._wheelEventName = "onwheel" in document.createElement("div") ? "wheel" : // Modern browsers support "wheel"
  128539. document.onmousewheel !== undefined ? "mousewheel" : // Webkit and IE support at least "mousewheel"
  128540. "DOMMouseScroll"; // let's assume that remaining browsers are older Firefox
  128541. canvas.addEventListener(this._wheelEventName, this._onPointerMove, false);
  128542. }
  128543. if (attachDown) {
  128544. canvas.addEventListener(eventPrefix + "down", this._onPointerDown, false);
  128545. }
  128546. if (attachUp) {
  128547. window.addEventListener(eventPrefix + "up", this._onPointerUp, false);
  128548. }
  128549. canvas.tabIndex = 1;
  128550. };
  128551. /** Detaches all event handlers*/
  128552. Scene.prototype.detachControl = function () {
  128553. var engine = this.getEngine();
  128554. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  128555. var canvas = engine.getRenderingCanvas();
  128556. if (!canvas) {
  128557. return;
  128558. }
  128559. canvas.removeEventListener(eventPrefix + "move", this._onPointerMove);
  128560. canvas.removeEventListener(eventPrefix + "down", this._onPointerDown);
  128561. window.removeEventListener(eventPrefix + "up", this._onPointerUp);
  128562. if (this._onCanvasBlurObserver) {
  128563. engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  128564. }
  128565. if (this._onCanvasFocusObserver) {
  128566. engine.onCanvasFocusObservable.remove(this._onCanvasFocusObserver);
  128567. }
  128568. // Wheel
  128569. canvas.removeEventListener(this._wheelEventName, this._onPointerMove);
  128570. // Keyboard
  128571. canvas.removeEventListener("keydown", this._onKeyDown);
  128572. canvas.removeEventListener("keyup", this._onKeyUp);
  128573. // Observables
  128574. this.onKeyboardObservable.clear();
  128575. this.onPreKeyboardObservable.clear();
  128576. this.onPointerObservable.clear();
  128577. this.onPrePointerObservable.clear();
  128578. };
  128579. /**
  128580. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  128581. * Delay loaded resources are not taking in account
  128582. * @return true if all required resources are ready
  128583. */
  128584. Scene.prototype.isReady = function () {
  128585. if (this._isDisposed) {
  128586. return false;
  128587. }
  128588. var index;
  128589. var engine = this.getEngine();
  128590. // Effects
  128591. if (!engine.areAllEffectsReady()) {
  128592. return false;
  128593. }
  128594. // Pending data
  128595. if (this._pendingData.length > 0) {
  128596. return false;
  128597. }
  128598. // Meshes
  128599. for (index = 0; index < this.meshes.length; index++) {
  128600. var mesh = this.meshes[index];
  128601. if (!mesh.isEnabled()) {
  128602. continue;
  128603. }
  128604. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  128605. continue;
  128606. }
  128607. if (!mesh.isReady(true)) {
  128608. return false;
  128609. }
  128610. var hardwareInstancedRendering = mesh.getClassName() === "InstancedMesh" || mesh.getClassName() === "InstancedLinesMesh" || engine.getCaps().instancedArrays && mesh.instances.length > 0;
  128611. // Is Ready For Mesh
  128612. for (var _i = 0, _a = this._isReadyForMeshStage; _i < _a.length; _i++) {
  128613. var step = _a[_i];
  128614. if (!step.action(mesh, hardwareInstancedRendering)) {
  128615. return false;
  128616. }
  128617. }
  128618. }
  128619. // Geometries
  128620. for (index = 0; index < this.geometries.length; index++) {
  128621. var geometry = this.geometries[index];
  128622. if (geometry.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].DELAYLOADSTATE_LOADING) {
  128623. return false;
  128624. }
  128625. }
  128626. // Post-processes
  128627. if (this.activeCameras && this.activeCameras.length > 0) {
  128628. for (var _b = 0, _c = this.activeCameras; _b < _c.length; _b++) {
  128629. var camera = _c[_b];
  128630. if (!camera.isReady(true)) {
  128631. return false;
  128632. }
  128633. }
  128634. }
  128635. else if (this.activeCamera) {
  128636. if (!this.activeCamera.isReady(true)) {
  128637. return false;
  128638. }
  128639. }
  128640. // Particles
  128641. for (var _d = 0, _e = this.particleSystems; _d < _e.length; _d++) {
  128642. var particleSystem = _e[_d];
  128643. if (!particleSystem.isReady()) {
  128644. return false;
  128645. }
  128646. }
  128647. return true;
  128648. };
  128649. /** Resets all cached information relative to material (including effect and visibility) */
  128650. Scene.prototype.resetCachedMaterial = function () {
  128651. this._cachedMaterial = null;
  128652. this._cachedEffect = null;
  128653. this._cachedVisibility = null;
  128654. };
  128655. /**
  128656. * Registers a function to be called before every frame render
  128657. * @param func defines the function to register
  128658. */
  128659. Scene.prototype.registerBeforeRender = function (func) {
  128660. this.onBeforeRenderObservable.add(func);
  128661. };
  128662. /**
  128663. * Unregisters a function called before every frame render
  128664. * @param func defines the function to unregister
  128665. */
  128666. Scene.prototype.unregisterBeforeRender = function (func) {
  128667. this.onBeforeRenderObservable.removeCallback(func);
  128668. };
  128669. /**
  128670. * Registers a function to be called after every frame render
  128671. * @param func defines the function to register
  128672. */
  128673. Scene.prototype.registerAfterRender = function (func) {
  128674. this.onAfterRenderObservable.add(func);
  128675. };
  128676. /**
  128677. * Unregisters a function called after every frame render
  128678. * @param func defines the function to unregister
  128679. */
  128680. Scene.prototype.unregisterAfterRender = function (func) {
  128681. this.onAfterRenderObservable.removeCallback(func);
  128682. };
  128683. Scene.prototype._executeOnceBeforeRender = function (func) {
  128684. var _this = this;
  128685. var execFunc = function () {
  128686. func();
  128687. setTimeout(function () {
  128688. _this.unregisterBeforeRender(execFunc);
  128689. });
  128690. };
  128691. this.registerBeforeRender(execFunc);
  128692. };
  128693. /**
  128694. * The provided function will run before render once and will be disposed afterwards.
  128695. * A timeout delay can be provided so that the function will be executed in N ms.
  128696. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  128697. * @param func The function to be executed.
  128698. * @param timeout optional delay in ms
  128699. */
  128700. Scene.prototype.executeOnceBeforeRender = function (func, timeout) {
  128701. var _this = this;
  128702. if (timeout !== undefined) {
  128703. setTimeout(function () {
  128704. _this._executeOnceBeforeRender(func);
  128705. }, timeout);
  128706. }
  128707. else {
  128708. this._executeOnceBeforeRender(func);
  128709. }
  128710. };
  128711. /** @hidden */
  128712. Scene.prototype._addPendingData = function (data) {
  128713. this._pendingData.push(data);
  128714. };
  128715. /** @hidden */
  128716. Scene.prototype._removePendingData = function (data) {
  128717. var wasLoading = this.isLoading;
  128718. var index = this._pendingData.indexOf(data);
  128719. if (index !== -1) {
  128720. this._pendingData.splice(index, 1);
  128721. }
  128722. if (wasLoading && !this.isLoading) {
  128723. this.onDataLoadedObservable.notifyObservers(this);
  128724. }
  128725. };
  128726. /**
  128727. * Returns the number of items waiting to be loaded
  128728. * @returns the number of items waiting to be loaded
  128729. */
  128730. Scene.prototype.getWaitingItemsCount = function () {
  128731. return this._pendingData.length;
  128732. };
  128733. Object.defineProperty(Scene.prototype, "isLoading", {
  128734. /**
  128735. * Returns a boolean indicating if the scene is still loading data
  128736. */
  128737. get: function () {
  128738. return this._pendingData.length > 0;
  128739. },
  128740. enumerable: true,
  128741. configurable: true
  128742. });
  128743. /**
  128744. * Registers a function to be executed when the scene is ready
  128745. * @param {Function} func - the function to be executed
  128746. */
  128747. Scene.prototype.executeWhenReady = function (func) {
  128748. var _this = this;
  128749. this.onReadyObservable.add(func);
  128750. if (this._executeWhenReadyTimeoutId !== -1) {
  128751. return;
  128752. }
  128753. this._executeWhenReadyTimeoutId = setTimeout(function () {
  128754. _this._checkIsReady();
  128755. }, 150);
  128756. };
  128757. /**
  128758. * Returns a promise that resolves when the scene is ready
  128759. * @returns A promise that resolves when the scene is ready
  128760. */
  128761. Scene.prototype.whenReadyAsync = function () {
  128762. var _this = this;
  128763. return new Promise(function (resolve) {
  128764. _this.executeWhenReady(function () {
  128765. resolve();
  128766. });
  128767. });
  128768. };
  128769. /** @hidden */
  128770. Scene.prototype._checkIsReady = function () {
  128771. var _this = this;
  128772. this._registerTransientComponents();
  128773. if (this.isReady()) {
  128774. this.onReadyObservable.notifyObservers(this);
  128775. this.onReadyObservable.clear();
  128776. this._executeWhenReadyTimeoutId = -1;
  128777. return;
  128778. }
  128779. this._executeWhenReadyTimeoutId = setTimeout(function () {
  128780. _this._checkIsReady();
  128781. }, 150);
  128782. };
  128783. // Animations
  128784. /**
  128785. * Will start the animation sequence of a given target
  128786. * @param target defines the target
  128787. * @param from defines from which frame should animation start
  128788. * @param to defines until which frame should animation run.
  128789. * @param weight defines the weight to apply to the animation (1.0 by default)
  128790. * @param loop defines if the animation loops
  128791. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  128792. * @param onAnimationEnd defines the function to be executed when the animation ends
  128793. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  128794. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  128795. * @param onAnimationLoop defines the callback to call when an animation loops
  128796. * @returns the animatable object created for this animation
  128797. */
  128798. Scene.prototype.beginWeightedAnimation = function (target, from, to, weight, loop, speedRatio, onAnimationEnd, animatable, targetMask, onAnimationLoop) {
  128799. if (weight === void 0) { weight = 1.0; }
  128800. if (speedRatio === void 0) { speedRatio = 1.0; }
  128801. var returnedAnimatable = this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, false, targetMask, onAnimationLoop);
  128802. returnedAnimatable.weight = weight;
  128803. return returnedAnimatable;
  128804. };
  128805. /**
  128806. * Will start the animation sequence of a given target
  128807. * @param target defines the target
  128808. * @param from defines from which frame should animation start
  128809. * @param to defines until which frame should animation run.
  128810. * @param loop defines if the animation loops
  128811. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  128812. * @param onAnimationEnd defines the function to be executed when the animation ends
  128813. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  128814. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  128815. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  128816. * @param onAnimationLoop defines the callback to call when an animation loops
  128817. * @returns the animatable object created for this animation
  128818. */
  128819. Scene.prototype.beginAnimation = function (target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  128820. if (speedRatio === void 0) { speedRatio = 1.0; }
  128821. if (stopCurrent === void 0) { stopCurrent = true; }
  128822. if (from > to && speedRatio > 0) {
  128823. speedRatio *= -1;
  128824. }
  128825. if (stopCurrent) {
  128826. this.stopAnimation(target, undefined, targetMask);
  128827. }
  128828. if (!animatable) {
  128829. animatable = new _Animations_animatable__WEBPACK_IMPORTED_MODULE_14__["Animatable"](this, target, from, to, loop, speedRatio, onAnimationEnd, undefined, onAnimationLoop);
  128830. }
  128831. var shouldRunTargetAnimations = targetMask ? targetMask(target) : true;
  128832. // Local animations
  128833. if (target.animations && shouldRunTargetAnimations) {
  128834. animatable.appendAnimations(target, target.animations);
  128835. }
  128836. // Children animations
  128837. if (target.getAnimatables) {
  128838. var animatables = target.getAnimatables();
  128839. for (var index = 0; index < animatables.length; index++) {
  128840. this.beginAnimation(animatables[index], from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop);
  128841. }
  128842. }
  128843. animatable.reset();
  128844. return animatable;
  128845. };
  128846. /**
  128847. * Will start the animation sequence of a given target and its hierarchy
  128848. * @param target defines the target
  128849. * @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.
  128850. * @param from defines from which frame should animation start
  128851. * @param to defines until which frame should animation run.
  128852. * @param loop defines if the animation loops
  128853. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  128854. * @param onAnimationEnd defines the function to be executed when the animation ends
  128855. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  128856. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  128857. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  128858. * @param onAnimationLoop defines the callback to call when an animation loops
  128859. * @returns the list of created animatables
  128860. */
  128861. Scene.prototype.beginHierarchyAnimation = function (target, directDescendantsOnly, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  128862. if (speedRatio === void 0) { speedRatio = 1.0; }
  128863. if (stopCurrent === void 0) { stopCurrent = true; }
  128864. var children = target.getDescendants(directDescendantsOnly);
  128865. var result = [];
  128866. result.push(this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  128867. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  128868. var child = children_1[_i];
  128869. result.push(this.beginAnimation(child, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  128870. }
  128871. return result;
  128872. };
  128873. /**
  128874. * Begin a new animation on a given node
  128875. * @param target defines the target where the animation will take place
  128876. * @param animations defines the list of animations to start
  128877. * @param from defines the initial value
  128878. * @param to defines the final value
  128879. * @param loop defines if you want animation to loop (off by default)
  128880. * @param speedRatio defines the speed ratio to apply to all animations
  128881. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  128882. * @param onAnimationLoop defines the callback to call when an animation loops
  128883. * @returns the list of created animatables
  128884. */
  128885. Scene.prototype.beginDirectAnimation = function (target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  128886. if (speedRatio === undefined) {
  128887. speedRatio = 1.0;
  128888. }
  128889. var animatable = new _Animations_animatable__WEBPACK_IMPORTED_MODULE_14__["Animatable"](this, target, from, to, loop, speedRatio, onAnimationEnd, animations, onAnimationLoop);
  128890. return animatable;
  128891. };
  128892. /**
  128893. * Begin a new animation on a given node and its hierarchy
  128894. * @param target defines the root node where the animation will take place
  128895. * @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.
  128896. * @param animations defines the list of animations to start
  128897. * @param from defines the initial value
  128898. * @param to defines the final value
  128899. * @param loop defines if you want animation to loop (off by default)
  128900. * @param speedRatio defines the speed ratio to apply to all animations
  128901. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  128902. * @param onAnimationLoop defines the callback to call when an animation loops
  128903. * @returns the list of animatables created for all nodes
  128904. */
  128905. Scene.prototype.beginDirectHierarchyAnimation = function (target, directDescendantsOnly, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  128906. var children = target.getDescendants(directDescendantsOnly);
  128907. var result = [];
  128908. result.push(this.beginDirectAnimation(target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  128909. for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
  128910. var child = children_2[_i];
  128911. result.push(this.beginDirectAnimation(child, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  128912. }
  128913. return result;
  128914. };
  128915. /**
  128916. * Gets the animatable associated with a specific target
  128917. * @param target defines the target of the animatable
  128918. * @returns the required animatable if found
  128919. */
  128920. Scene.prototype.getAnimatableByTarget = function (target) {
  128921. for (var index = 0; index < this._activeAnimatables.length; index++) {
  128922. if (this._activeAnimatables[index].target === target) {
  128923. return this._activeAnimatables[index];
  128924. }
  128925. }
  128926. return null;
  128927. };
  128928. /**
  128929. * Gets all animatables associated with a given target
  128930. * @param target defines the target to look animatables for
  128931. * @returns an array of Animatables
  128932. */
  128933. Scene.prototype.getAllAnimatablesByTarget = function (target) {
  128934. var result = [];
  128935. for (var index = 0; index < this._activeAnimatables.length; index++) {
  128936. if (this._activeAnimatables[index].target === target) {
  128937. result.push(this._activeAnimatables[index]);
  128938. }
  128939. }
  128940. return result;
  128941. };
  128942. Object.defineProperty(Scene.prototype, "animatables", {
  128943. /**
  128944. * Gets all animatable attached to the scene
  128945. */
  128946. get: function () {
  128947. return this._activeAnimatables;
  128948. },
  128949. enumerable: true,
  128950. configurable: true
  128951. });
  128952. /**
  128953. * Will stop the animation of the given target
  128954. * @param target - the target
  128955. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  128956. * @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)
  128957. */
  128958. Scene.prototype.stopAnimation = function (target, animationName, targetMask) {
  128959. var animatables = this.getAllAnimatablesByTarget(target);
  128960. for (var _i = 0, animatables_1 = animatables; _i < animatables_1.length; _i++) {
  128961. var animatable = animatables_1[_i];
  128962. animatable.stop(animationName, targetMask);
  128963. }
  128964. };
  128965. /**
  128966. * Stops and removes all animations that have been applied to the scene
  128967. */
  128968. Scene.prototype.stopAllAnimations = function () {
  128969. if (this._activeAnimatables) {
  128970. for (var i = 0; i < this._activeAnimatables.length; i++) {
  128971. this._activeAnimatables[i].stop();
  128972. }
  128973. this._activeAnimatables = [];
  128974. }
  128975. for (var _i = 0, _a = this.animationGroups; _i < _a.length; _i++) {
  128976. var group = _a[_i];
  128977. group.stop();
  128978. }
  128979. };
  128980. /**
  128981. * Resets the last animation time frame.
  128982. * Useful to override when animations start running when loading a scene for the first time.
  128983. */
  128984. Scene.prototype.resetLastAnimationTimeFrame = function () {
  128985. this._animationTimeLast = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now;
  128986. };
  128987. Scene.prototype._animate = function () {
  128988. if (!this.animationsEnabled || this._activeAnimatables.length === 0) {
  128989. return;
  128990. }
  128991. // Getting time
  128992. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now;
  128993. if (!this._animationTimeLast) {
  128994. if (this._pendingData.length > 0) {
  128995. return;
  128996. }
  128997. this._animationTimeLast = now;
  128998. }
  128999. var deltaTime = this.useConstantAnimationDeltaTime ? 16.0 : (now - this._animationTimeLast) * this.animationTimeScale;
  129000. this._animationTime += deltaTime;
  129001. this._animationTimeLast = now;
  129002. for (var index = 0; index < this._activeAnimatables.length; index++) {
  129003. this._activeAnimatables[index]._animate(this._animationTime);
  129004. }
  129005. // Late animation bindings
  129006. this._processLateAnimationBindings();
  129007. };
  129008. /** @hidden */
  129009. Scene.prototype._registerTargetForLateAnimationBinding = function (runtimeAnimation, originalValue) {
  129010. var target = runtimeAnimation.target;
  129011. this._registeredForLateAnimationBindings.pushNoDuplicate(target);
  129012. if (!target._lateAnimationHolders) {
  129013. target._lateAnimationHolders = {};
  129014. }
  129015. if (!target._lateAnimationHolders[runtimeAnimation.targetPath]) {
  129016. target._lateAnimationHolders[runtimeAnimation.targetPath] = {
  129017. totalWeight: 0,
  129018. animations: [],
  129019. originalValue: originalValue
  129020. };
  129021. }
  129022. target._lateAnimationHolders[runtimeAnimation.targetPath].animations.push(runtimeAnimation);
  129023. target._lateAnimationHolders[runtimeAnimation.targetPath].totalWeight += runtimeAnimation.weight;
  129024. };
  129025. Scene.prototype._processLateAnimationBindingsForMatrices = function (holder) {
  129026. var normalizer = 1.0;
  129027. var finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Vector3[0];
  129028. var finalScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Vector3[1];
  129029. var finalQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Quaternion[0];
  129030. var startIndex = 0;
  129031. var originalAnimation = holder.animations[0];
  129032. var originalValue = holder.originalValue;
  129033. var scale = 1;
  129034. if (holder.totalWeight < 1.0) {
  129035. // We need to mix the original value in
  129036. originalValue.decompose(finalScaling, finalQuaternion, finalPosition);
  129037. scale = 1.0 - holder.totalWeight;
  129038. }
  129039. else {
  129040. startIndex = 1;
  129041. // We need to normalize the weights
  129042. normalizer = holder.totalWeight;
  129043. originalAnimation.currentValue.decompose(finalScaling, finalQuaternion, finalPosition);
  129044. scale = originalAnimation.weight / normalizer;
  129045. if (scale == 1) {
  129046. return originalAnimation.currentValue;
  129047. }
  129048. }
  129049. finalScaling.scaleInPlace(scale);
  129050. finalPosition.scaleInPlace(scale);
  129051. finalQuaternion.scaleInPlace(scale);
  129052. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  129053. var runtimeAnimation = holder.animations[animIndex];
  129054. var scale = runtimeAnimation.weight / normalizer;
  129055. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Vector3[2];
  129056. var currentScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Vector3[3];
  129057. var currentQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Quaternion[1];
  129058. runtimeAnimation.currentValue.decompose(currentScaling, currentQuaternion, currentPosition);
  129059. currentScaling.scaleAndAddToRef(scale, finalScaling);
  129060. currentQuaternion.scaleAndAddToRef(scale, finalQuaternion);
  129061. currentPosition.scaleAndAddToRef(scale, finalPosition);
  129062. }
  129063. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].ComposeToRef(finalScaling, finalQuaternion, finalPosition, originalAnimation._workValue);
  129064. return originalAnimation._workValue;
  129065. };
  129066. Scene.prototype._processLateAnimationBindingsForQuaternions = function (holder, refQuaternion) {
  129067. var originalAnimation = holder.animations[0];
  129068. var originalValue = holder.originalValue;
  129069. if (holder.animations.length === 1) {
  129070. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Quaternion"].SlerpToRef(originalValue, originalAnimation.currentValue, Math.min(1.0, holder.totalWeight), refQuaternion);
  129071. return refQuaternion;
  129072. }
  129073. var normalizer = 1.0;
  129074. var quaternions;
  129075. var weights;
  129076. if (holder.totalWeight < 1.0) {
  129077. var scale = 1.0 - holder.totalWeight;
  129078. quaternions = [];
  129079. weights = [];
  129080. quaternions.push(originalValue);
  129081. weights.push(scale);
  129082. }
  129083. else {
  129084. if (holder.animations.length === 2) { // Slerp as soon as we can
  129085. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Quaternion"].SlerpToRef(holder.animations[0].currentValue, holder.animations[1].currentValue, holder.animations[1].weight / holder.totalWeight, refQuaternion);
  129086. return refQuaternion;
  129087. }
  129088. quaternions = [];
  129089. weights = [];
  129090. normalizer = holder.totalWeight;
  129091. }
  129092. for (var animIndex = 0; animIndex < holder.animations.length; animIndex++) {
  129093. var runtimeAnimation = holder.animations[animIndex];
  129094. quaternions.push(runtimeAnimation.currentValue);
  129095. weights.push(runtimeAnimation.weight / normalizer);
  129096. }
  129097. // https://gamedev.stackexchange.com/questions/62354/method-for-interpolation-between-3-quaternions
  129098. var cumulativeAmount = 0;
  129099. var cumulativeQuaternion = null;
  129100. for (var index = 0; index < quaternions.length;) {
  129101. if (!cumulativeQuaternion) {
  129102. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Quaternion"].SlerpToRef(quaternions[index], quaternions[index + 1], weights[index + 1] / (weights[index] + weights[index + 1]), refQuaternion);
  129103. cumulativeQuaternion = refQuaternion;
  129104. cumulativeAmount = weights[index] + weights[index + 1];
  129105. index += 2;
  129106. continue;
  129107. }
  129108. cumulativeAmount += weights[index];
  129109. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Quaternion"].SlerpToRef(cumulativeQuaternion, quaternions[index], weights[index] / cumulativeAmount, cumulativeQuaternion);
  129110. index++;
  129111. }
  129112. return cumulativeQuaternion;
  129113. };
  129114. Scene.prototype._processLateAnimationBindings = function () {
  129115. if (!this._registeredForLateAnimationBindings.length) {
  129116. return;
  129117. }
  129118. for (var index = 0; index < this._registeredForLateAnimationBindings.length; index++) {
  129119. var target = this._registeredForLateAnimationBindings.data[index];
  129120. for (var path in target._lateAnimationHolders) {
  129121. var holder = target._lateAnimationHolders[path];
  129122. var originalAnimation = holder.animations[0];
  129123. var originalValue = holder.originalValue;
  129124. var matrixDecomposeMode = _Animations_animation__WEBPACK_IMPORTED_MODULE_13__["Animation"].AllowMatrixDecomposeForInterpolation && originalValue.m; // ie. data is matrix
  129125. var finalValue = target[path];
  129126. if (matrixDecomposeMode) {
  129127. finalValue = this._processLateAnimationBindingsForMatrices(holder);
  129128. }
  129129. else {
  129130. var quaternionMode = originalValue.w !== undefined;
  129131. if (quaternionMode) {
  129132. finalValue = this._processLateAnimationBindingsForQuaternions(holder, finalValue || _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Quaternion"].Identity());
  129133. }
  129134. else {
  129135. var startIndex = 0;
  129136. var normalizer = 1.0;
  129137. if (holder.totalWeight < 1.0) {
  129138. // We need to mix the original value in
  129139. if (originalValue.scale) {
  129140. finalValue = originalValue.scale(1.0 - holder.totalWeight);
  129141. }
  129142. else {
  129143. finalValue = originalValue * (1.0 - holder.totalWeight);
  129144. }
  129145. }
  129146. else {
  129147. // We need to normalize the weights
  129148. normalizer = holder.totalWeight;
  129149. var scale_1 = originalAnimation.weight / normalizer;
  129150. if (scale_1 !== 1) {
  129151. if (originalAnimation.currentValue.scale) {
  129152. finalValue = originalAnimation.currentValue.scale(scale_1);
  129153. }
  129154. else {
  129155. finalValue = originalAnimation.currentValue * scale_1;
  129156. }
  129157. }
  129158. else {
  129159. finalValue = originalAnimation.currentValue;
  129160. }
  129161. startIndex = 1;
  129162. }
  129163. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  129164. var runtimeAnimation = holder.animations[animIndex];
  129165. var scale = runtimeAnimation.weight / normalizer;
  129166. if (runtimeAnimation.currentValue.scaleAndAddToRef) {
  129167. runtimeAnimation.currentValue.scaleAndAddToRef(scale, finalValue);
  129168. }
  129169. else {
  129170. finalValue += runtimeAnimation.currentValue * scale;
  129171. }
  129172. }
  129173. }
  129174. }
  129175. target[path] = finalValue;
  129176. }
  129177. target._lateAnimationHolders = {};
  129178. }
  129179. this._registeredForLateAnimationBindings.reset();
  129180. };
  129181. // Matrix
  129182. /** @hidden */
  129183. Scene.prototype._switchToAlternateCameraConfiguration = function (active) {
  129184. this._useAlternateCameraConfiguration = active;
  129185. };
  129186. /**
  129187. * Gets the current view matrix
  129188. * @returns a Matrix
  129189. */
  129190. Scene.prototype.getViewMatrix = function () {
  129191. return this._useAlternateCameraConfiguration ? this._alternateViewMatrix : this._viewMatrix;
  129192. };
  129193. /**
  129194. * Gets the current projection matrix
  129195. * @returns a Matrix
  129196. */
  129197. Scene.prototype.getProjectionMatrix = function () {
  129198. return this._useAlternateCameraConfiguration ? this._alternateProjectionMatrix : this._projectionMatrix;
  129199. };
  129200. /**
  129201. * Gets the current transform matrix
  129202. * @returns a Matrix made of View * Projection
  129203. */
  129204. Scene.prototype.getTransformMatrix = function () {
  129205. return this._useAlternateCameraConfiguration ? this._alternateTransformMatrix : this._transformMatrix;
  129206. };
  129207. /**
  129208. * Sets the current transform matrix
  129209. * @param view defines the View matrix to use
  129210. * @param projection defines the Projection matrix to use
  129211. */
  129212. Scene.prototype.setTransformMatrix = function (view, projection) {
  129213. if (this._viewUpdateFlag === view.updateFlag && this._projectionUpdateFlag === projection.updateFlag) {
  129214. return;
  129215. }
  129216. this._viewUpdateFlag = view.updateFlag;
  129217. this._projectionUpdateFlag = projection.updateFlag;
  129218. this._viewMatrix = view;
  129219. this._projectionMatrix = projection;
  129220. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  129221. // Update frustum
  129222. if (!this._frustumPlanes) {
  129223. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanes(this._transformMatrix);
  129224. }
  129225. else {
  129226. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  129227. }
  129228. if (this.activeCamera && this.activeCamera._alternateCamera) {
  129229. var otherCamera = this.activeCamera._alternateCamera;
  129230. otherCamera.getViewMatrix().multiplyToRef(otherCamera.getProjectionMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Matrix[0]);
  129231. _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
  129232. }
  129233. if (this._sceneUbo.useUbo) {
  129234. this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix);
  129235. this._sceneUbo.updateMatrix("view", this._viewMatrix);
  129236. this._sceneUbo.update();
  129237. }
  129238. };
  129239. /** @hidden */
  129240. Scene.prototype._setAlternateTransformMatrix = function (view, projection) {
  129241. if (this._alternateViewUpdateFlag === view.updateFlag && this._alternateProjectionUpdateFlag === projection.updateFlag) {
  129242. return;
  129243. }
  129244. this._alternateViewUpdateFlag = view.updateFlag;
  129245. this._alternateProjectionUpdateFlag = projection.updateFlag;
  129246. this._alternateViewMatrix = view;
  129247. this._alternateProjectionMatrix = projection;
  129248. if (!this._alternateTransformMatrix) {
  129249. this._alternateTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  129250. }
  129251. this._alternateViewMatrix.multiplyToRef(this._alternateProjectionMatrix, this._alternateTransformMatrix);
  129252. if (!this._alternateSceneUbo) {
  129253. this._createAlternateUbo();
  129254. }
  129255. if (this._alternateSceneUbo.useUbo) {
  129256. this._alternateSceneUbo.updateMatrix("viewProjection", this._alternateTransformMatrix);
  129257. this._alternateSceneUbo.updateMatrix("view", this._alternateViewMatrix);
  129258. this._alternateSceneUbo.update();
  129259. }
  129260. };
  129261. /**
  129262. * Gets the uniform buffer used to store scene data
  129263. * @returns a UniformBuffer
  129264. */
  129265. Scene.prototype.getSceneUniformBuffer = function () {
  129266. return this._useAlternateCameraConfiguration ? this._alternateSceneUbo : this._sceneUbo;
  129267. };
  129268. /**
  129269. * Gets an unique (relatively to the current scene) Id
  129270. * @returns an unique number for the scene
  129271. */
  129272. Scene.prototype.getUniqueId = function () {
  129273. var result = Scene._uniqueIdCounter;
  129274. Scene._uniqueIdCounter++;
  129275. return result;
  129276. };
  129277. /**
  129278. * Add a mesh to the list of scene's meshes
  129279. * @param newMesh defines the mesh to add
  129280. * @param recursive if all child meshes should also be added to the scene
  129281. */
  129282. Scene.prototype.addMesh = function (newMesh, recursive) {
  129283. var _this = this;
  129284. if (recursive === void 0) { recursive = false; }
  129285. this.meshes.push(newMesh);
  129286. //notify the collision coordinator
  129287. if (this.collisionCoordinator) {
  129288. this.collisionCoordinator.onMeshAdded(newMesh);
  129289. }
  129290. newMesh._resyncLightSources();
  129291. this.onNewMeshAddedObservable.notifyObservers(newMesh);
  129292. if (recursive) {
  129293. newMesh.getChildMeshes().forEach(function (m) {
  129294. _this.addMesh(m);
  129295. });
  129296. }
  129297. };
  129298. /**
  129299. * Remove a mesh for the list of scene's meshes
  129300. * @param toRemove defines the mesh to remove
  129301. * @param recursive if all child meshes should also be removed from the scene
  129302. * @returns the index where the mesh was in the mesh list
  129303. */
  129304. Scene.prototype.removeMesh = function (toRemove, recursive) {
  129305. var _this = this;
  129306. if (recursive === void 0) { recursive = false; }
  129307. var index = this.meshes.indexOf(toRemove);
  129308. if (index !== -1) {
  129309. // Remove from the scene if mesh found
  129310. this.meshes[index] = this.meshes[this.meshes.length - 1];
  129311. this.meshes.pop();
  129312. }
  129313. this.onMeshRemovedObservable.notifyObservers(toRemove);
  129314. if (recursive) {
  129315. toRemove.getChildMeshes().forEach(function (m) {
  129316. _this.removeMesh(m);
  129317. });
  129318. }
  129319. return index;
  129320. };
  129321. /**
  129322. * Add a transform node to the list of scene's transform nodes
  129323. * @param newTransformNode defines the transform node to add
  129324. */
  129325. Scene.prototype.addTransformNode = function (newTransformNode) {
  129326. newTransformNode._indexInSceneTransformNodesArray = this.transformNodes.length;
  129327. this.transformNodes.push(newTransformNode);
  129328. this.onNewTransformNodeAddedObservable.notifyObservers(newTransformNode);
  129329. };
  129330. /**
  129331. * Remove a transform node for the list of scene's transform nodes
  129332. * @param toRemove defines the transform node to remove
  129333. * @returns the index where the transform node was in the transform node list
  129334. */
  129335. Scene.prototype.removeTransformNode = function (toRemove) {
  129336. var index = toRemove._indexInSceneTransformNodesArray;
  129337. if (index !== -1) {
  129338. if (index !== this.transformNodes.length - 1) {
  129339. var lastNode = this.transformNodes[this.transformNodes.length - 1];
  129340. this.transformNodes[index] = lastNode;
  129341. lastNode._indexInSceneTransformNodesArray = index;
  129342. }
  129343. toRemove._indexInSceneTransformNodesArray = -1;
  129344. this.transformNodes.pop();
  129345. }
  129346. this.onTransformNodeRemovedObservable.notifyObservers(toRemove);
  129347. return index;
  129348. };
  129349. /**
  129350. * Remove a skeleton for the list of scene's skeletons
  129351. * @param toRemove defines the skeleton to remove
  129352. * @returns the index where the skeleton was in the skeleton list
  129353. */
  129354. Scene.prototype.removeSkeleton = function (toRemove) {
  129355. var index = this.skeletons.indexOf(toRemove);
  129356. if (index !== -1) {
  129357. // Remove from the scene if found
  129358. this.skeletons.splice(index, 1);
  129359. }
  129360. return index;
  129361. };
  129362. /**
  129363. * Remove a morph target for the list of scene's morph targets
  129364. * @param toRemove defines the morph target to remove
  129365. * @returns the index where the morph target was in the morph target list
  129366. */
  129367. Scene.prototype.removeMorphTargetManager = function (toRemove) {
  129368. var index = this.morphTargetManagers.indexOf(toRemove);
  129369. if (index !== -1) {
  129370. // Remove from the scene if found
  129371. this.morphTargetManagers.splice(index, 1);
  129372. }
  129373. return index;
  129374. };
  129375. /**
  129376. * Remove a light for the list of scene's lights
  129377. * @param toRemove defines the light to remove
  129378. * @returns the index where the light was in the light list
  129379. */
  129380. Scene.prototype.removeLight = function (toRemove) {
  129381. var index = this.lights.indexOf(toRemove);
  129382. if (index !== -1) {
  129383. // Remove from meshes
  129384. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  129385. var mesh = _a[_i];
  129386. mesh._removeLightSource(toRemove);
  129387. }
  129388. // Remove from the scene if mesh found
  129389. this.lights.splice(index, 1);
  129390. this.sortLightsByPriority();
  129391. }
  129392. this.onLightRemovedObservable.notifyObservers(toRemove);
  129393. return index;
  129394. };
  129395. /**
  129396. * Remove a camera for the list of scene's cameras
  129397. * @param toRemove defines the camera to remove
  129398. * @returns the index where the camera was in the camera list
  129399. */
  129400. Scene.prototype.removeCamera = function (toRemove) {
  129401. var index = this.cameras.indexOf(toRemove);
  129402. if (index !== -1) {
  129403. // Remove from the scene if mesh found
  129404. this.cameras.splice(index, 1);
  129405. }
  129406. // Remove from activeCameras
  129407. var index2 = this.activeCameras.indexOf(toRemove);
  129408. if (index2 !== -1) {
  129409. // Remove from the scene if mesh found
  129410. this.activeCameras.splice(index2, 1);
  129411. }
  129412. // Reset the activeCamera
  129413. if (this.activeCamera === toRemove) {
  129414. if (this.cameras.length > 0) {
  129415. this.activeCamera = this.cameras[0];
  129416. }
  129417. else {
  129418. this.activeCamera = null;
  129419. }
  129420. }
  129421. this.onCameraRemovedObservable.notifyObservers(toRemove);
  129422. return index;
  129423. };
  129424. /**
  129425. * Remove a particle system for the list of scene's particle systems
  129426. * @param toRemove defines the particle system to remove
  129427. * @returns the index where the particle system was in the particle system list
  129428. */
  129429. Scene.prototype.removeParticleSystem = function (toRemove) {
  129430. var index = this.particleSystems.indexOf(toRemove);
  129431. if (index !== -1) {
  129432. this.particleSystems.splice(index, 1);
  129433. }
  129434. return index;
  129435. };
  129436. /**
  129437. * Remove a animation for the list of scene's animations
  129438. * @param toRemove defines the animation to remove
  129439. * @returns the index where the animation was in the animation list
  129440. */
  129441. Scene.prototype.removeAnimation = function (toRemove) {
  129442. var index = this.animations.indexOf(toRemove);
  129443. if (index !== -1) {
  129444. this.animations.splice(index, 1);
  129445. }
  129446. return index;
  129447. };
  129448. /**
  129449. * Removes the given animation group from this scene.
  129450. * @param toRemove The animation group to remove
  129451. * @returns The index of the removed animation group
  129452. */
  129453. Scene.prototype.removeAnimationGroup = function (toRemove) {
  129454. var index = this.animationGroups.indexOf(toRemove);
  129455. if (index !== -1) {
  129456. this.animationGroups.splice(index, 1);
  129457. }
  129458. return index;
  129459. };
  129460. /**
  129461. * Removes the given multi-material from this scene.
  129462. * @param toRemove The multi-material to remove
  129463. * @returns The index of the removed multi-material
  129464. */
  129465. Scene.prototype.removeMultiMaterial = function (toRemove) {
  129466. var index = this.multiMaterials.indexOf(toRemove);
  129467. if (index !== -1) {
  129468. this.multiMaterials.splice(index, 1);
  129469. }
  129470. return index;
  129471. };
  129472. /**
  129473. * Removes the given material from this scene.
  129474. * @param toRemove The material to remove
  129475. * @returns The index of the removed material
  129476. */
  129477. Scene.prototype.removeMaterial = function (toRemove) {
  129478. var index = toRemove._indexInSceneMaterialArray;
  129479. if (index !== -1 && index < this.materials.length) {
  129480. if (index !== this.materials.length - 1) {
  129481. var lastMaterial = this.materials[this.materials.length - 1];
  129482. this.materials[index] = lastMaterial;
  129483. lastMaterial._indexInSceneMaterialArray = index;
  129484. }
  129485. toRemove._indexInSceneMaterialArray = -1;
  129486. this.materials.pop();
  129487. }
  129488. this.onMaterialRemovedObservable.notifyObservers(toRemove);
  129489. return index;
  129490. };
  129491. /**
  129492. * Removes the given action manager from this scene.
  129493. * @param toRemove The action manager to remove
  129494. * @returns The index of the removed action manager
  129495. */
  129496. Scene.prototype.removeActionManager = function (toRemove) {
  129497. var index = this.actionManagers.indexOf(toRemove);
  129498. if (index !== -1) {
  129499. this.actionManagers.splice(index, 1);
  129500. }
  129501. return index;
  129502. };
  129503. /**
  129504. * Removes the given texture from this scene.
  129505. * @param toRemove The texture to remove
  129506. * @returns The index of the removed texture
  129507. */
  129508. Scene.prototype.removeTexture = function (toRemove) {
  129509. var index = this.textures.indexOf(toRemove);
  129510. if (index !== -1) {
  129511. this.textures.splice(index, 1);
  129512. }
  129513. this.onTextureRemovedObservable.notifyObservers(toRemove);
  129514. return index;
  129515. };
  129516. /**
  129517. * Adds the given light to this scene
  129518. * @param newLight The light to add
  129519. */
  129520. Scene.prototype.addLight = function (newLight) {
  129521. this.lights.push(newLight);
  129522. this.sortLightsByPriority();
  129523. // Add light to all meshes (To support if the light is removed and then readded)
  129524. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  129525. var mesh = _a[_i];
  129526. if (mesh._lightSources.indexOf(newLight) === -1) {
  129527. mesh._lightSources.push(newLight);
  129528. mesh._resyncLightSources();
  129529. }
  129530. }
  129531. this.onNewLightAddedObservable.notifyObservers(newLight);
  129532. };
  129533. /**
  129534. * Sorts the list list based on light priorities
  129535. */
  129536. Scene.prototype.sortLightsByPriority = function () {
  129537. if (this.requireLightSorting) {
  129538. this.lights.sort(_Lights_light__WEBPACK_IMPORTED_MODULE_15__["Light"].CompareLightsPriority);
  129539. }
  129540. };
  129541. /**
  129542. * Adds the given camera to this scene
  129543. * @param newCamera The camera to add
  129544. */
  129545. Scene.prototype.addCamera = function (newCamera) {
  129546. this.cameras.push(newCamera);
  129547. this.onNewCameraAddedObservable.notifyObservers(newCamera);
  129548. };
  129549. /**
  129550. * Adds the given skeleton to this scene
  129551. * @param newSkeleton The skeleton to add
  129552. */
  129553. Scene.prototype.addSkeleton = function (newSkeleton) {
  129554. this.skeletons.push(newSkeleton);
  129555. };
  129556. /**
  129557. * Adds the given particle system to this scene
  129558. * @param newParticleSystem The particle system to add
  129559. */
  129560. Scene.prototype.addParticleSystem = function (newParticleSystem) {
  129561. this.particleSystems.push(newParticleSystem);
  129562. };
  129563. /**
  129564. * Adds the given animation to this scene
  129565. * @param newAnimation The animation to add
  129566. */
  129567. Scene.prototype.addAnimation = function (newAnimation) {
  129568. this.animations.push(newAnimation);
  129569. };
  129570. /**
  129571. * Adds the given animation group to this scene.
  129572. * @param newAnimationGroup The animation group to add
  129573. */
  129574. Scene.prototype.addAnimationGroup = function (newAnimationGroup) {
  129575. this.animationGroups.push(newAnimationGroup);
  129576. };
  129577. /**
  129578. * Adds the given multi-material to this scene
  129579. * @param newMultiMaterial The multi-material to add
  129580. */
  129581. Scene.prototype.addMultiMaterial = function (newMultiMaterial) {
  129582. this.multiMaterials.push(newMultiMaterial);
  129583. };
  129584. /**
  129585. * Adds the given material to this scene
  129586. * @param newMaterial The material to add
  129587. */
  129588. Scene.prototype.addMaterial = function (newMaterial) {
  129589. newMaterial._indexInSceneMaterialArray = this.materials.length;
  129590. this.materials.push(newMaterial);
  129591. this.onNewMaterialAddedObservable.notifyObservers(newMaterial);
  129592. };
  129593. /**
  129594. * Adds the given morph target to this scene
  129595. * @param newMorphTargetManager The morph target to add
  129596. */
  129597. Scene.prototype.addMorphTargetManager = function (newMorphTargetManager) {
  129598. this.morphTargetManagers.push(newMorphTargetManager);
  129599. };
  129600. /**
  129601. * Adds the given geometry to this scene
  129602. * @param newGeometry The geometry to add
  129603. */
  129604. Scene.prototype.addGeometry = function (newGeometry) {
  129605. if (this.geometriesByUniqueId) {
  129606. this.geometriesByUniqueId[newGeometry.uniqueId] = this.geometries.length;
  129607. }
  129608. this.geometries.push(newGeometry);
  129609. };
  129610. /**
  129611. * Adds the given action manager to this scene
  129612. * @param newActionManager The action manager to add
  129613. */
  129614. Scene.prototype.addActionManager = function (newActionManager) {
  129615. this.actionManagers.push(newActionManager);
  129616. };
  129617. /**
  129618. * Adds the given texture to this scene.
  129619. * @param newTexture The texture to add
  129620. */
  129621. Scene.prototype.addTexture = function (newTexture) {
  129622. this.textures.push(newTexture);
  129623. this.onNewTextureAddedObservable.notifyObservers(newTexture);
  129624. };
  129625. /**
  129626. * Switch active camera
  129627. * @param newCamera defines the new active camera
  129628. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  129629. */
  129630. Scene.prototype.switchActiveCamera = function (newCamera, attachControl) {
  129631. if (attachControl === void 0) { attachControl = true; }
  129632. var canvas = this._engine.getRenderingCanvas();
  129633. if (!canvas) {
  129634. return;
  129635. }
  129636. if (this.activeCamera) {
  129637. this.activeCamera.detachControl(canvas);
  129638. }
  129639. this.activeCamera = newCamera;
  129640. if (attachControl) {
  129641. newCamera.attachControl(canvas);
  129642. }
  129643. };
  129644. /**
  129645. * sets the active camera of the scene using its ID
  129646. * @param id defines the camera's ID
  129647. * @return the new active camera or null if none found.
  129648. */
  129649. Scene.prototype.setActiveCameraByID = function (id) {
  129650. var camera = this.getCameraByID(id);
  129651. if (camera) {
  129652. this.activeCamera = camera;
  129653. return camera;
  129654. }
  129655. return null;
  129656. };
  129657. /**
  129658. * sets the active camera of the scene using its name
  129659. * @param name defines the camera's name
  129660. * @returns the new active camera or null if none found.
  129661. */
  129662. Scene.prototype.setActiveCameraByName = function (name) {
  129663. var camera = this.getCameraByName(name);
  129664. if (camera) {
  129665. this.activeCamera = camera;
  129666. return camera;
  129667. }
  129668. return null;
  129669. };
  129670. /**
  129671. * get an animation group using its name
  129672. * @param name defines the material's name
  129673. * @return the animation group or null if none found.
  129674. */
  129675. Scene.prototype.getAnimationGroupByName = function (name) {
  129676. for (var index = 0; index < this.animationGroups.length; index++) {
  129677. if (this.animationGroups[index].name === name) {
  129678. return this.animationGroups[index];
  129679. }
  129680. }
  129681. return null;
  129682. };
  129683. /**
  129684. * get a material using its id
  129685. * @param id defines the material's ID
  129686. * @return the material or null if none found.
  129687. */
  129688. Scene.prototype.getMaterialByID = function (id) {
  129689. for (var index = 0; index < this.materials.length; index++) {
  129690. if (this.materials[index].id === id) {
  129691. return this.materials[index];
  129692. }
  129693. }
  129694. return null;
  129695. };
  129696. /**
  129697. * Gets a material using its name
  129698. * @param name defines the material's name
  129699. * @return the material or null if none found.
  129700. */
  129701. Scene.prototype.getMaterialByName = function (name) {
  129702. for (var index = 0; index < this.materials.length; index++) {
  129703. if (this.materials[index].name === name) {
  129704. return this.materials[index];
  129705. }
  129706. }
  129707. return null;
  129708. };
  129709. /**
  129710. * Gets a camera using its id
  129711. * @param id defines the id to look for
  129712. * @returns the camera or null if not found
  129713. */
  129714. Scene.prototype.getCameraByID = function (id) {
  129715. for (var index = 0; index < this.cameras.length; index++) {
  129716. if (this.cameras[index].id === id) {
  129717. return this.cameras[index];
  129718. }
  129719. }
  129720. return null;
  129721. };
  129722. /**
  129723. * Gets a camera using its unique id
  129724. * @param uniqueId defines the unique id to look for
  129725. * @returns the camera or null if not found
  129726. */
  129727. Scene.prototype.getCameraByUniqueID = function (uniqueId) {
  129728. for (var index = 0; index < this.cameras.length; index++) {
  129729. if (this.cameras[index].uniqueId === uniqueId) {
  129730. return this.cameras[index];
  129731. }
  129732. }
  129733. return null;
  129734. };
  129735. /**
  129736. * Gets a camera using its name
  129737. * @param name defines the camera's name
  129738. * @return the camera or null if none found.
  129739. */
  129740. Scene.prototype.getCameraByName = function (name) {
  129741. for (var index = 0; index < this.cameras.length; index++) {
  129742. if (this.cameras[index].name === name) {
  129743. return this.cameras[index];
  129744. }
  129745. }
  129746. return null;
  129747. };
  129748. /**
  129749. * Gets a bone using its id
  129750. * @param id defines the bone's id
  129751. * @return the bone or null if not found
  129752. */
  129753. Scene.prototype.getBoneByID = function (id) {
  129754. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  129755. var skeleton = this.skeletons[skeletonIndex];
  129756. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  129757. if (skeleton.bones[boneIndex].id === id) {
  129758. return skeleton.bones[boneIndex];
  129759. }
  129760. }
  129761. }
  129762. return null;
  129763. };
  129764. /**
  129765. * Gets a bone using its id
  129766. * @param name defines the bone's name
  129767. * @return the bone or null if not found
  129768. */
  129769. Scene.prototype.getBoneByName = function (name) {
  129770. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  129771. var skeleton = this.skeletons[skeletonIndex];
  129772. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  129773. if (skeleton.bones[boneIndex].name === name) {
  129774. return skeleton.bones[boneIndex];
  129775. }
  129776. }
  129777. }
  129778. return null;
  129779. };
  129780. /**
  129781. * Gets a light node using its name
  129782. * @param name defines the the light's name
  129783. * @return the light or null if none found.
  129784. */
  129785. Scene.prototype.getLightByName = function (name) {
  129786. for (var index = 0; index < this.lights.length; index++) {
  129787. if (this.lights[index].name === name) {
  129788. return this.lights[index];
  129789. }
  129790. }
  129791. return null;
  129792. };
  129793. /**
  129794. * Gets a light node using its id
  129795. * @param id defines the light's id
  129796. * @return the light or null if none found.
  129797. */
  129798. Scene.prototype.getLightByID = function (id) {
  129799. for (var index = 0; index < this.lights.length; index++) {
  129800. if (this.lights[index].id === id) {
  129801. return this.lights[index];
  129802. }
  129803. }
  129804. return null;
  129805. };
  129806. /**
  129807. * Gets a light node using its scene-generated unique ID
  129808. * @param uniqueId defines the light's unique id
  129809. * @return the light or null if none found.
  129810. */
  129811. Scene.prototype.getLightByUniqueID = function (uniqueId) {
  129812. for (var index = 0; index < this.lights.length; index++) {
  129813. if (this.lights[index].uniqueId === uniqueId) {
  129814. return this.lights[index];
  129815. }
  129816. }
  129817. return null;
  129818. };
  129819. /**
  129820. * Gets a particle system by id
  129821. * @param id defines the particle system id
  129822. * @return the corresponding system or null if none found
  129823. */
  129824. Scene.prototype.getParticleSystemByID = function (id) {
  129825. for (var index = 0; index < this.particleSystems.length; index++) {
  129826. if (this.particleSystems[index].id === id) {
  129827. return this.particleSystems[index];
  129828. }
  129829. }
  129830. return null;
  129831. };
  129832. /**
  129833. * Gets a geometry using its ID
  129834. * @param id defines the geometry's id
  129835. * @return the geometry or null if none found.
  129836. */
  129837. Scene.prototype.getGeometryByID = function (id) {
  129838. for (var index = 0; index < this.geometries.length; index++) {
  129839. if (this.geometries[index].id === id) {
  129840. return this.geometries[index];
  129841. }
  129842. }
  129843. return null;
  129844. };
  129845. Scene.prototype._getGeometryByUniqueID = function (uniqueId) {
  129846. if (this.geometriesByUniqueId) {
  129847. var index_1 = this.geometriesByUniqueId[uniqueId];
  129848. if (index_1 !== undefined) {
  129849. return this.geometries[index_1];
  129850. }
  129851. }
  129852. else {
  129853. for (var index = 0; index < this.geometries.length; index++) {
  129854. if (this.geometries[index].uniqueId === uniqueId) {
  129855. return this.geometries[index];
  129856. }
  129857. }
  129858. }
  129859. return null;
  129860. };
  129861. /**
  129862. * Add a new geometry to this scene
  129863. * @param geometry defines the geometry to be added to the scene.
  129864. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  129865. * @return a boolean defining if the geometry was added or not
  129866. */
  129867. Scene.prototype.pushGeometry = function (geometry, force) {
  129868. if (!force && this._getGeometryByUniqueID(geometry.uniqueId)) {
  129869. return false;
  129870. }
  129871. this.addGeometry(geometry);
  129872. //notify the collision coordinator
  129873. if (this.collisionCoordinator) {
  129874. this.collisionCoordinator.onGeometryAdded(geometry);
  129875. }
  129876. this.onNewGeometryAddedObservable.notifyObservers(geometry);
  129877. return true;
  129878. };
  129879. /**
  129880. * Removes an existing geometry
  129881. * @param geometry defines the geometry to be removed from the scene
  129882. * @return a boolean defining if the geometry was removed or not
  129883. */
  129884. Scene.prototype.removeGeometry = function (geometry) {
  129885. var index;
  129886. if (this.geometriesByUniqueId) {
  129887. index = this.geometriesByUniqueId[geometry.uniqueId];
  129888. if (index === undefined) {
  129889. return false;
  129890. }
  129891. }
  129892. else {
  129893. index = this.geometries.indexOf(geometry);
  129894. if (index < 0) {
  129895. return false;
  129896. }
  129897. }
  129898. if (index !== this.geometries.length - 1) {
  129899. var lastGeometry = this.geometries[this.geometries.length - 1];
  129900. this.geometries[index] = lastGeometry;
  129901. if (this.geometriesByUniqueId) {
  129902. this.geometriesByUniqueId[lastGeometry.uniqueId] = index;
  129903. this.geometriesByUniqueId[geometry.uniqueId] = undefined;
  129904. }
  129905. }
  129906. this.geometries.pop();
  129907. //notify the collision coordinator
  129908. if (this.collisionCoordinator) {
  129909. this.collisionCoordinator.onGeometryDeleted(geometry);
  129910. }
  129911. this.onGeometryRemovedObservable.notifyObservers(geometry);
  129912. return true;
  129913. };
  129914. /**
  129915. * Gets the list of geometries attached to the scene
  129916. * @returns an array of Geometry
  129917. */
  129918. Scene.prototype.getGeometries = function () {
  129919. return this.geometries;
  129920. };
  129921. /**
  129922. * Gets the first added mesh found of a given ID
  129923. * @param id defines the id to search for
  129924. * @return the mesh found or null if not found at all
  129925. */
  129926. Scene.prototype.getMeshByID = function (id) {
  129927. for (var index = 0; index < this.meshes.length; index++) {
  129928. if (this.meshes[index].id === id) {
  129929. return this.meshes[index];
  129930. }
  129931. }
  129932. return null;
  129933. };
  129934. /**
  129935. * Gets a list of meshes using their id
  129936. * @param id defines the id to search for
  129937. * @returns a list of meshes
  129938. */
  129939. Scene.prototype.getMeshesByID = function (id) {
  129940. return this.meshes.filter(function (m) {
  129941. return m.id === id;
  129942. });
  129943. };
  129944. /**
  129945. * Gets the first added transform node found of a given ID
  129946. * @param id defines the id to search for
  129947. * @return the found transform node or null if not found at all.
  129948. */
  129949. Scene.prototype.getTransformNodeByID = function (id) {
  129950. for (var index = 0; index < this.transformNodes.length; index++) {
  129951. if (this.transformNodes[index].id === id) {
  129952. return this.transformNodes[index];
  129953. }
  129954. }
  129955. return null;
  129956. };
  129957. /**
  129958. * Gets a list of transform nodes using their id
  129959. * @param id defines the id to search for
  129960. * @returns a list of transform nodes
  129961. */
  129962. Scene.prototype.getTransformNodesByID = function (id) {
  129963. return this.transformNodes.filter(function (m) {
  129964. return m.id === id;
  129965. });
  129966. };
  129967. /**
  129968. * Gets a mesh with its auto-generated unique id
  129969. * @param uniqueId defines the unique id to search for
  129970. * @return the found mesh or null if not found at all.
  129971. */
  129972. Scene.prototype.getMeshByUniqueID = function (uniqueId) {
  129973. for (var index = 0; index < this.meshes.length; index++) {
  129974. if (this.meshes[index].uniqueId === uniqueId) {
  129975. return this.meshes[index];
  129976. }
  129977. }
  129978. return null;
  129979. };
  129980. /**
  129981. * Gets a the last added mesh using a given id
  129982. * @param id defines the id to search for
  129983. * @return the found mesh or null if not found at all.
  129984. */
  129985. Scene.prototype.getLastMeshByID = function (id) {
  129986. for (var index = this.meshes.length - 1; index >= 0; index--) {
  129987. if (this.meshes[index].id === id) {
  129988. return this.meshes[index];
  129989. }
  129990. }
  129991. return null;
  129992. };
  129993. /**
  129994. * Gets a the last added node (Mesh, Camera, Light) using a given id
  129995. * @param id defines the id to search for
  129996. * @return the found node or null if not found at all
  129997. */
  129998. Scene.prototype.getLastEntryByID = function (id) {
  129999. var index;
  130000. for (index = this.meshes.length - 1; index >= 0; index--) {
  130001. if (this.meshes[index].id === id) {
  130002. return this.meshes[index];
  130003. }
  130004. }
  130005. for (index = this.transformNodes.length - 1; index >= 0; index--) {
  130006. if (this.transformNodes[index].id === id) {
  130007. return this.transformNodes[index];
  130008. }
  130009. }
  130010. for (index = this.cameras.length - 1; index >= 0; index--) {
  130011. if (this.cameras[index].id === id) {
  130012. return this.cameras[index];
  130013. }
  130014. }
  130015. for (index = this.lights.length - 1; index >= 0; index--) {
  130016. if (this.lights[index].id === id) {
  130017. return this.lights[index];
  130018. }
  130019. }
  130020. return null;
  130021. };
  130022. /**
  130023. * Gets a node (Mesh, Camera, Light) using a given id
  130024. * @param id defines the id to search for
  130025. * @return the found node or null if not found at all
  130026. */
  130027. Scene.prototype.getNodeByID = function (id) {
  130028. var mesh = this.getMeshByID(id);
  130029. if (mesh) {
  130030. return mesh;
  130031. }
  130032. var transformNode = this.getTransformNodeByID(id);
  130033. if (transformNode) {
  130034. return transformNode;
  130035. }
  130036. var light = this.getLightByID(id);
  130037. if (light) {
  130038. return light;
  130039. }
  130040. var camera = this.getCameraByID(id);
  130041. if (camera) {
  130042. return camera;
  130043. }
  130044. var bone = this.getBoneByID(id);
  130045. if (bone) {
  130046. return bone;
  130047. }
  130048. return null;
  130049. };
  130050. /**
  130051. * Gets a node (Mesh, Camera, Light) using a given name
  130052. * @param name defines the name to search for
  130053. * @return the found node or null if not found at all.
  130054. */
  130055. Scene.prototype.getNodeByName = function (name) {
  130056. var mesh = this.getMeshByName(name);
  130057. if (mesh) {
  130058. return mesh;
  130059. }
  130060. var transformNode = this.getTransformNodeByName(name);
  130061. if (transformNode) {
  130062. return transformNode;
  130063. }
  130064. var light = this.getLightByName(name);
  130065. if (light) {
  130066. return light;
  130067. }
  130068. var camera = this.getCameraByName(name);
  130069. if (camera) {
  130070. return camera;
  130071. }
  130072. var bone = this.getBoneByName(name);
  130073. if (bone) {
  130074. return bone;
  130075. }
  130076. return null;
  130077. };
  130078. /**
  130079. * Gets a mesh using a given name
  130080. * @param name defines the name to search for
  130081. * @return the found mesh or null if not found at all.
  130082. */
  130083. Scene.prototype.getMeshByName = function (name) {
  130084. for (var index = 0; index < this.meshes.length; index++) {
  130085. if (this.meshes[index].name === name) {
  130086. return this.meshes[index];
  130087. }
  130088. }
  130089. return null;
  130090. };
  130091. /**
  130092. * Gets a transform node using a given name
  130093. * @param name defines the name to search for
  130094. * @return the found transform node or null if not found at all.
  130095. */
  130096. Scene.prototype.getTransformNodeByName = function (name) {
  130097. for (var index = 0; index < this.transformNodes.length; index++) {
  130098. if (this.transformNodes[index].name === name) {
  130099. return this.transformNodes[index];
  130100. }
  130101. }
  130102. return null;
  130103. };
  130104. /**
  130105. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  130106. * @param id defines the id to search for
  130107. * @return the found skeleton or null if not found at all.
  130108. */
  130109. Scene.prototype.getLastSkeletonByID = function (id) {
  130110. for (var index = this.skeletons.length - 1; index >= 0; index--) {
  130111. if (this.skeletons[index].id === id) {
  130112. return this.skeletons[index];
  130113. }
  130114. }
  130115. return null;
  130116. };
  130117. /**
  130118. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  130119. * @param id defines the id to search for
  130120. * @return the found skeleton or null if not found at all.
  130121. */
  130122. Scene.prototype.getSkeletonById = function (id) {
  130123. for (var index = 0; index < this.skeletons.length; index++) {
  130124. if (this.skeletons[index].id === id) {
  130125. return this.skeletons[index];
  130126. }
  130127. }
  130128. return null;
  130129. };
  130130. /**
  130131. * Gets a skeleton using a given name
  130132. * @param name defines the name to search for
  130133. * @return the found skeleton or null if not found at all.
  130134. */
  130135. Scene.prototype.getSkeletonByName = function (name) {
  130136. for (var index = 0; index < this.skeletons.length; index++) {
  130137. if (this.skeletons[index].name === name) {
  130138. return this.skeletons[index];
  130139. }
  130140. }
  130141. return null;
  130142. };
  130143. /**
  130144. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  130145. * @param id defines the id to search for
  130146. * @return the found morph target manager or null if not found at all.
  130147. */
  130148. Scene.prototype.getMorphTargetManagerById = function (id) {
  130149. for (var index = 0; index < this.morphTargetManagers.length; index++) {
  130150. if (this.morphTargetManagers[index].uniqueId === id) {
  130151. return this.morphTargetManagers[index];
  130152. }
  130153. }
  130154. return null;
  130155. };
  130156. /**
  130157. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  130158. * @param id defines the id to search for
  130159. * @return the found morph target or null if not found at all.
  130160. */
  130161. Scene.prototype.getMorphTargetById = function (id) {
  130162. for (var managerIndex = 0; managerIndex < this.morphTargetManagers.length; ++managerIndex) {
  130163. var morphTargetManager = this.morphTargetManagers[managerIndex];
  130164. for (var index = 0; index < morphTargetManager.numTargets; ++index) {
  130165. var target = morphTargetManager.getTarget(index);
  130166. if (target.id === id) {
  130167. return target;
  130168. }
  130169. }
  130170. }
  130171. return null;
  130172. };
  130173. /**
  130174. * Gets a boolean indicating if the given mesh is active
  130175. * @param mesh defines the mesh to look for
  130176. * @returns true if the mesh is in the active list
  130177. */
  130178. Scene.prototype.isActiveMesh = function (mesh) {
  130179. return (this._activeMeshes.indexOf(mesh) !== -1);
  130180. };
  130181. Object.defineProperty(Scene.prototype, "uid", {
  130182. /**
  130183. * Return a unique id as a string which can serve as an identifier for the scene
  130184. */
  130185. get: function () {
  130186. if (!this._uid) {
  130187. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].RandomId();
  130188. }
  130189. return this._uid;
  130190. },
  130191. enumerable: true,
  130192. configurable: true
  130193. });
  130194. /**
  130195. * Add an externaly attached data from its key.
  130196. * This method call will fail and return false, if such key already exists.
  130197. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  130198. * @param key the unique key that identifies the data
  130199. * @param data the data object to associate to the key for this Engine instance
  130200. * @return true if no such key were already present and the data was added successfully, false otherwise
  130201. */
  130202. Scene.prototype.addExternalData = function (key, data) {
  130203. if (!this._externalData) {
  130204. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  130205. }
  130206. return this._externalData.add(key, data);
  130207. };
  130208. /**
  130209. * Get an externaly attached data from its key
  130210. * @param key the unique key that identifies the data
  130211. * @return the associated data, if present (can be null), or undefined if not present
  130212. */
  130213. Scene.prototype.getExternalData = function (key) {
  130214. if (!this._externalData) {
  130215. return null;
  130216. }
  130217. return this._externalData.get(key);
  130218. };
  130219. /**
  130220. * Get an externaly attached data from its key, create it using a factory if it's not already present
  130221. * @param key the unique key that identifies the data
  130222. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  130223. * @return the associated data, can be null if the factory returned null.
  130224. */
  130225. Scene.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  130226. if (!this._externalData) {
  130227. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  130228. }
  130229. return this._externalData.getOrAddWithFactory(key, factory);
  130230. };
  130231. /**
  130232. * Remove an externaly attached data from the Engine instance
  130233. * @param key the unique key that identifies the data
  130234. * @return true if the data was successfully removed, false if it doesn't exist
  130235. */
  130236. Scene.prototype.removeExternalData = function (key) {
  130237. return this._externalData.remove(key);
  130238. };
  130239. Scene.prototype._evaluateSubMesh = function (subMesh, mesh) {
  130240. if (this.dispatchAllSubMeshesOfActiveMeshes || mesh.alwaysSelectAsActiveMesh || mesh.subMeshes.length === 1 || subMesh.isInFrustum(this._frustumPlanes)) {
  130241. for (var _i = 0, _a = this._evaluateSubMeshStage; _i < _a.length; _i++) {
  130242. var step = _a[_i];
  130243. step.action(mesh, subMesh);
  130244. }
  130245. var material = subMesh.getMaterial();
  130246. if (material !== null && material !== undefined) {
  130247. // Render targets
  130248. if (material.hasRenderTargetTextures && material.getRenderTargetTextures !== undefined) {
  130249. if (this._processedMaterials.indexOf(material) === -1) {
  130250. this._processedMaterials.push(material);
  130251. this._renderTargets.concatWithNoDuplicate(material.getRenderTargetTextures());
  130252. }
  130253. }
  130254. // Dispatch
  130255. this._activeIndices.addCount(subMesh.indexCount, false);
  130256. this._renderingManager.dispatch(subMesh, mesh, material);
  130257. }
  130258. }
  130259. };
  130260. /**
  130261. * Clear the processed materials smart array preventing retention point in material dispose.
  130262. */
  130263. Scene.prototype.freeProcessedMaterials = function () {
  130264. this._processedMaterials.dispose();
  130265. };
  130266. Object.defineProperty(Scene.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
  130267. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  130268. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  130269. * when disposing several meshes in a row or a hierarchy of meshes.
  130270. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  130271. */
  130272. get: function () {
  130273. return this._preventFreeActiveMeshesAndRenderingGroups;
  130274. },
  130275. set: function (value) {
  130276. if (this._preventFreeActiveMeshesAndRenderingGroups === value) {
  130277. return;
  130278. }
  130279. if (value) {
  130280. this.freeActiveMeshes();
  130281. this.freeRenderingGroups();
  130282. }
  130283. this._preventFreeActiveMeshesAndRenderingGroups = value;
  130284. },
  130285. enumerable: true,
  130286. configurable: true
  130287. });
  130288. /**
  130289. * Clear the active meshes smart array preventing retention point in mesh dispose.
  130290. */
  130291. Scene.prototype.freeActiveMeshes = function () {
  130292. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  130293. return;
  130294. }
  130295. this._activeMeshes.dispose();
  130296. if (this.activeCamera && this.activeCamera._activeMeshes) {
  130297. this.activeCamera._activeMeshes.dispose();
  130298. }
  130299. if (this.activeCameras) {
  130300. for (var i = 0; i < this.activeCameras.length; i++) {
  130301. var activeCamera = this.activeCameras[i];
  130302. if (activeCamera && activeCamera._activeMeshes) {
  130303. activeCamera._activeMeshes.dispose();
  130304. }
  130305. }
  130306. }
  130307. };
  130308. /**
  130309. * Clear the info related to rendering groups preventing retention points during dispose.
  130310. */
  130311. Scene.prototype.freeRenderingGroups = function () {
  130312. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  130313. return;
  130314. }
  130315. if (this._renderingManager) {
  130316. this._renderingManager.freeRenderingGroups();
  130317. }
  130318. if (this.textures) {
  130319. for (var i = 0; i < this.textures.length; i++) {
  130320. var texture = this.textures[i];
  130321. if (texture && texture.renderList) {
  130322. texture.freeRenderingGroups();
  130323. }
  130324. }
  130325. }
  130326. };
  130327. /** @hidden */
  130328. Scene.prototype._isInIntermediateRendering = function () {
  130329. return this._intermediateRendering;
  130330. };
  130331. /**
  130332. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  130333. * @returns the current scene
  130334. */
  130335. Scene.prototype.freezeActiveMeshes = function () {
  130336. if (!this.activeCamera) {
  130337. return this;
  130338. }
  130339. if (!this._frustumPlanes) {
  130340. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  130341. }
  130342. this._evaluateActiveMeshes();
  130343. this._activeMeshesFrozen = true;
  130344. return this;
  130345. };
  130346. /**
  130347. * Use this function to restart evaluating active meshes on every frame
  130348. * @returns the current scene
  130349. */
  130350. Scene.prototype.unfreezeActiveMeshes = function () {
  130351. this._activeMeshesFrozen = false;
  130352. return this;
  130353. };
  130354. Scene.prototype._evaluateActiveMeshes = function () {
  130355. if (this._activeMeshesFrozen && this._activeMeshes.length) {
  130356. return;
  130357. }
  130358. if (!this.activeCamera) {
  130359. return;
  130360. }
  130361. this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this);
  130362. this.activeCamera._activeMeshes.reset();
  130363. this._activeMeshes.reset();
  130364. this._renderingManager.reset();
  130365. this._processedMaterials.reset();
  130366. this._activeParticleSystems.reset();
  130367. this._activeSkeletons.reset();
  130368. this._softwareSkinnedMeshes.reset();
  130369. for (var _i = 0, _a = this._beforeEvaluateActiveMeshStage; _i < _a.length; _i++) {
  130370. var step = _a[_i];
  130371. step.action();
  130372. }
  130373. // Determine mesh candidates
  130374. var meshes = this.getActiveMeshCandidates();
  130375. // Check each mesh
  130376. var len = meshes.length;
  130377. for (var i = 0; i < len; i++) {
  130378. var mesh = meshes.data[i];
  130379. if (mesh.isBlocked) {
  130380. continue;
  130381. }
  130382. this._totalVertices.addCount(mesh.getTotalVertices(), false);
  130383. if (!mesh.isReady() || !mesh.isEnabled()) {
  130384. continue;
  130385. }
  130386. mesh.computeWorldMatrix();
  130387. // Intersections
  130388. if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionEnterTrigger, _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionExitTrigger)) {
  130389. this._meshesForIntersections.pushNoDuplicate(mesh);
  130390. }
  130391. // Switch to current LOD
  130392. var meshLOD = mesh.getLOD(this.activeCamera);
  130393. if (meshLOD === undefined || meshLOD === null) {
  130394. continue;
  130395. }
  130396. mesh._preActivate();
  130397. if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
  130398. this._activeMeshes.push(mesh);
  130399. this.activeCamera._activeMeshes.push(mesh);
  130400. mesh._activate(this._renderId);
  130401. if (meshLOD !== mesh) {
  130402. meshLOD._activate(this._renderId);
  130403. }
  130404. this._activeMesh(mesh, meshLOD);
  130405. }
  130406. }
  130407. this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this);
  130408. // Particle systems
  130409. if (this.particlesEnabled) {
  130410. this.onBeforeParticlesRenderingObservable.notifyObservers(this);
  130411. for (var particleIndex = 0; particleIndex < this.particleSystems.length; particleIndex++) {
  130412. var particleSystem = this.particleSystems[particleIndex];
  130413. if (!particleSystem.isStarted() || !particleSystem.emitter) {
  130414. continue;
  130415. }
  130416. var emitter = particleSystem.emitter;
  130417. if (!emitter.position || emitter.isEnabled()) {
  130418. this._activeParticleSystems.push(particleSystem);
  130419. particleSystem.animate();
  130420. this._renderingManager.dispatchParticles(particleSystem);
  130421. }
  130422. }
  130423. this.onAfterParticlesRenderingObservable.notifyObservers(this);
  130424. }
  130425. };
  130426. Scene.prototype._activeMesh = function (sourceMesh, mesh) {
  130427. if (this._skeletonsEnabled && mesh.skeleton !== null && mesh.skeleton !== undefined) {
  130428. if (this._activeSkeletons.pushNoDuplicate(mesh.skeleton)) {
  130429. mesh.skeleton.prepare();
  130430. }
  130431. if (!mesh.computeBonesUsingShaders) {
  130432. this._softwareSkinnedMeshes.pushNoDuplicate(mesh);
  130433. }
  130434. }
  130435. for (var _i = 0, _a = this._activeMeshStage; _i < _a.length; _i++) {
  130436. var step = _a[_i];
  130437. step.action(sourceMesh, mesh);
  130438. }
  130439. if (mesh !== undefined && mesh !== null
  130440. && mesh.subMeshes !== undefined && mesh.subMeshes !== null && mesh.subMeshes.length > 0) {
  130441. var subMeshes = this.getActiveSubMeshCandidates(mesh);
  130442. var len = subMeshes.length;
  130443. for (var i = 0; i < len; i++) {
  130444. var subMesh = subMeshes.data[i];
  130445. this._evaluateSubMesh(subMesh, mesh);
  130446. }
  130447. }
  130448. };
  130449. /**
  130450. * Update the transform matrix to update from the current active camera
  130451. * @param force defines a boolean used to force the update even if cache is up to date
  130452. */
  130453. Scene.prototype.updateTransformMatrix = function (force) {
  130454. if (!this.activeCamera) {
  130455. return;
  130456. }
  130457. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(force));
  130458. };
  130459. /**
  130460. * 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)
  130461. * @param alternateCamera defines the camera to use
  130462. */
  130463. Scene.prototype.updateAlternateTransformMatrix = function (alternateCamera) {
  130464. this._setAlternateTransformMatrix(alternateCamera.getViewMatrix(), alternateCamera.getProjectionMatrix());
  130465. };
  130466. Scene.prototype._renderForCamera = function (camera, rigParent) {
  130467. if (camera && camera._skipRendering) {
  130468. return;
  130469. }
  130470. var engine = this._engine;
  130471. this.activeCamera = camera;
  130472. if (!this.activeCamera) {
  130473. throw new Error("Active camera not set");
  130474. }
  130475. // Viewport
  130476. engine.setViewport(this.activeCamera.viewport);
  130477. // Camera
  130478. this.resetCachedMaterial();
  130479. this._renderId++;
  130480. this.updateTransformMatrix();
  130481. if (camera._alternateCamera) {
  130482. this.updateAlternateTransformMatrix(camera._alternateCamera);
  130483. this._alternateRendering = true;
  130484. }
  130485. this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera);
  130486. // Meshes
  130487. this._evaluateActiveMeshes();
  130488. // Software skinning
  130489. for (var softwareSkinnedMeshIndex = 0; softwareSkinnedMeshIndex < this._softwareSkinnedMeshes.length; softwareSkinnedMeshIndex++) {
  130490. var mesh = this._softwareSkinnedMeshes.data[softwareSkinnedMeshIndex];
  130491. mesh.applySkeleton(mesh.skeleton);
  130492. }
  130493. // Render targets
  130494. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  130495. if (camera.customRenderTargets && camera.customRenderTargets.length > 0) {
  130496. this._renderTargets.concatWithNoDuplicate(camera.customRenderTargets);
  130497. }
  130498. if (rigParent && rigParent.customRenderTargets && rigParent.customRenderTargets.length > 0) {
  130499. this._renderTargets.concatWithNoDuplicate(rigParent.customRenderTargets);
  130500. }
  130501. // Collects render targets from external components.
  130502. for (var _i = 0, _a = this._gatherActiveCameraRenderTargetsStage; _i < _a.length; _i++) {
  130503. var step = _a[_i];
  130504. step.action(this._renderTargets);
  130505. }
  130506. if (this.renderTargetsEnabled) {
  130507. this._intermediateRendering = true;
  130508. if (this._renderTargets.length > 0) {
  130509. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
  130510. for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
  130511. var renderTarget = this._renderTargets.data[renderIndex];
  130512. if (renderTarget._shouldRender()) {
  130513. this._renderId++;
  130514. var hasSpecialRenderTargetCamera = renderTarget.activeCamera && renderTarget.activeCamera !== this.activeCamera;
  130515. renderTarget.render(hasSpecialRenderTargetCamera, this.dumpNextRenderTargets);
  130516. }
  130517. }
  130518. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Render targets", this._renderTargets.length > 0);
  130519. this._renderId++;
  130520. }
  130521. for (var _b = 0, _c = this._cameraDrawRenderTargetStage; _b < _c.length; _b++) {
  130522. var step = _c[_b];
  130523. step.action(this.activeCamera);
  130524. }
  130525. this._intermediateRendering = false;
  130526. if (this.activeCamera.outputRenderTarget) {
  130527. var internalTexture = this.activeCamera.outputRenderTarget.getInternalTexture();
  130528. if (internalTexture) {
  130529. engine.bindFramebuffer(internalTexture);
  130530. }
  130531. else {
  130532. _Misc_logger__WEBPACK_IMPORTED_MODULE_28__["Logger"].Error("Camera contains invalid customDefaultRenderTarget");
  130533. }
  130534. }
  130535. else {
  130536. engine.restoreDefaultFramebuffer(); // Restore back buffer if needed
  130537. }
  130538. }
  130539. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  130540. // Prepare Frame
  130541. if (this.postProcessManager) {
  130542. this.postProcessManager._prepareFrame();
  130543. }
  130544. // Before Camera Draw
  130545. for (var _d = 0, _e = this._beforeCameraDrawStage; _d < _e.length; _d++) {
  130546. var step = _e[_d];
  130547. step.action(this.activeCamera);
  130548. }
  130549. // Render
  130550. this.onBeforeDrawPhaseObservable.notifyObservers(this);
  130551. this._renderingManager.render(null, null, true, true);
  130552. this.onAfterDrawPhaseObservable.notifyObservers(this);
  130553. // After Camera Draw
  130554. for (var _f = 0, _g = this._afterCameraDrawStage; _f < _g.length; _f++) {
  130555. var step = _g[_f];
  130556. step.action(this.activeCamera);
  130557. }
  130558. // Finalize frame
  130559. if (this.postProcessManager) {
  130560. this.postProcessManager._finalizeFrame(camera.isIntermediate);
  130561. }
  130562. // Reset some special arrays
  130563. this._renderTargets.reset();
  130564. this._alternateRendering = false;
  130565. this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
  130566. };
  130567. Scene.prototype._processSubCameras = function (camera) {
  130568. if (camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  130569. this._renderForCamera(camera);
  130570. return;
  130571. }
  130572. // rig cameras
  130573. for (var index = 0; index < camera._rigCameras.length; index++) {
  130574. this._renderForCamera(camera._rigCameras[index], camera);
  130575. }
  130576. this.activeCamera = camera;
  130577. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  130578. };
  130579. Scene.prototype._checkIntersections = function () {
  130580. for (var index = 0; index < this._meshesForIntersections.length; index++) {
  130581. var sourceMesh = this._meshesForIntersections.data[index];
  130582. if (!sourceMesh.actionManager) {
  130583. continue;
  130584. }
  130585. for (var actionIndex = 0; actionIndex < sourceMesh.actionManager.actions.length; actionIndex++) {
  130586. var action = sourceMesh.actionManager.actions[actionIndex];
  130587. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionEnterTrigger || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionExitTrigger) {
  130588. var parameters = action.getTriggerParameter();
  130589. var otherMesh = parameters instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameters : parameters.mesh;
  130590. var areIntersecting = otherMesh.intersectsMesh(sourceMesh, parameters.usePreciseIntersection);
  130591. var currentIntersectionInProgress = sourceMesh._intersectionsInProgress.indexOf(otherMesh);
  130592. if (areIntersecting && currentIntersectionInProgress === -1) {
  130593. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionEnterTrigger) {
  130594. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  130595. sourceMesh._intersectionsInProgress.push(otherMesh);
  130596. }
  130597. else if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionExitTrigger) {
  130598. sourceMesh._intersectionsInProgress.push(otherMesh);
  130599. }
  130600. }
  130601. else if (!areIntersecting && currentIntersectionInProgress > -1) {
  130602. //They intersected, and now they don't.
  130603. //is this trigger an exit trigger? execute an event.
  130604. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionExitTrigger) {
  130605. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  130606. }
  130607. //if this is an exit trigger, or no exit trigger exists, remove the id from the intersection in progress array.
  130608. if (!sourceMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionExitTrigger, function (parameter) {
  130609. var parameterMesh = parameter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameter : parameter.mesh;
  130610. return otherMesh === parameterMesh;
  130611. }) || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionExitTrigger) {
  130612. sourceMesh._intersectionsInProgress.splice(currentIntersectionInProgress, 1);
  130613. }
  130614. }
  130615. }
  130616. }
  130617. }
  130618. };
  130619. /** @hidden */
  130620. Scene.prototype._advancePhysicsEngineStep = function (step) {
  130621. // Do nothing. Code will be replaced if physics engine component is referenced
  130622. };
  130623. /**
  130624. * Render the scene
  130625. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  130626. */
  130627. Scene.prototype.render = function (updateCameras) {
  130628. if (updateCameras === void 0) { updateCameras = true; }
  130629. if (this.isDisposed) {
  130630. return;
  130631. }
  130632. this._frameId++;
  130633. // Register components that have been associated lately to the scene.
  130634. this._registerTransientComponents();
  130635. this._activeParticles.fetchNewFrame();
  130636. this._totalVertices.fetchNewFrame();
  130637. this._activeIndices.fetchNewFrame();
  130638. this._activeBones.fetchNewFrame();
  130639. this._meshesForIntersections.reset();
  130640. this.resetCachedMaterial();
  130641. this.onBeforeAnimationsObservable.notifyObservers(this);
  130642. // Actions
  130643. if (this.actionManager) {
  130644. this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnEveryFrameTrigger);
  130645. }
  130646. if (this._engine.isDeterministicLockStep()) {
  130647. var deltaTime = Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime)) + this._timeAccumulator;
  130648. var defaultFPS = (60.0 / 1000.0);
  130649. var defaultFrameTime = this.getDeterministicFrameTime();
  130650. var stepsTaken = 0;
  130651. var maxSubSteps = this._engine.getLockstepMaxSteps();
  130652. var internalSteps = Math.floor(deltaTime / (1000 * defaultFPS));
  130653. internalSteps = Math.min(internalSteps, maxSubSteps);
  130654. do {
  130655. this.onBeforeStepObservable.notifyObservers(this);
  130656. // Animations
  130657. this._animationRatio = defaultFrameTime * defaultFPS;
  130658. this._animate();
  130659. this.onAfterAnimationsObservable.notifyObservers(this);
  130660. // Physics
  130661. this._advancePhysicsEngineStep(defaultFrameTime);
  130662. this.onAfterStepObservable.notifyObservers(this);
  130663. this._currentStepId++;
  130664. stepsTaken++;
  130665. deltaTime -= defaultFrameTime;
  130666. } while (deltaTime > 0 && stepsTaken < internalSteps);
  130667. this._timeAccumulator = deltaTime < 0 ? 0 : deltaTime;
  130668. }
  130669. else {
  130670. // Animations
  130671. var deltaTime = this.useConstantAnimationDeltaTime ? 16 : Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime));
  130672. this._animationRatio = deltaTime * (60.0 / 1000.0);
  130673. this._animate();
  130674. this.onAfterAnimationsObservable.notifyObservers(this);
  130675. // Physics
  130676. this._advancePhysicsEngineStep(deltaTime);
  130677. }
  130678. // Before camera update steps
  130679. for (var _i = 0, _a = this._beforeCameraUpdateStage; _i < _a.length; _i++) {
  130680. var step = _a[_i];
  130681. step.action();
  130682. }
  130683. // Update Cameras
  130684. if (updateCameras) {
  130685. if (this.activeCameras.length > 0) {
  130686. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  130687. var camera = this.activeCameras[cameraIndex];
  130688. camera.update();
  130689. if (camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  130690. // rig cameras
  130691. for (var index = 0; index < camera._rigCameras.length; index++) {
  130692. camera._rigCameras[index].update();
  130693. }
  130694. }
  130695. }
  130696. }
  130697. else if (this.activeCamera) {
  130698. this.activeCamera.update();
  130699. if (this.activeCamera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  130700. // rig cameras
  130701. for (var index = 0; index < this.activeCamera._rigCameras.length; index++) {
  130702. this.activeCamera._rigCameras[index].update();
  130703. }
  130704. }
  130705. }
  130706. }
  130707. // Before render
  130708. this.onBeforeRenderObservable.notifyObservers(this);
  130709. // Customs render targets
  130710. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  130711. var engine = this.getEngine();
  130712. var currentActiveCamera = this.activeCamera;
  130713. if (this.renderTargetsEnabled) {
  130714. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  130715. this._intermediateRendering = true;
  130716. for (var customIndex = 0; customIndex < this.customRenderTargets.length; customIndex++) {
  130717. var renderTarget = this.customRenderTargets[customIndex];
  130718. if (renderTarget._shouldRender()) {
  130719. this._renderId++;
  130720. this.activeCamera = renderTarget.activeCamera || this.activeCamera;
  130721. if (!this.activeCamera) {
  130722. throw new Error("Active camera not set");
  130723. }
  130724. // Viewport
  130725. engine.setViewport(this.activeCamera.viewport);
  130726. // Camera
  130727. this.updateTransformMatrix();
  130728. renderTarget.render(currentActiveCamera !== this.activeCamera, this.dumpNextRenderTargets);
  130729. }
  130730. }
  130731. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  130732. this._intermediateRendering = false;
  130733. this._renderId++;
  130734. }
  130735. // Restore back buffer
  130736. if (this.customRenderTargets.length > 0) {
  130737. engine.restoreDefaultFramebuffer();
  130738. }
  130739. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  130740. this.activeCamera = currentActiveCamera;
  130741. for (var _b = 0, _c = this._beforeClearStage; _b < _c.length; _b++) {
  130742. var step = _c[_b];
  130743. step.action();
  130744. }
  130745. // Clear
  130746. if (this.autoClearDepthAndStencil || this.autoClear) {
  130747. this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil);
  130748. }
  130749. // Collects render targets from external components.
  130750. for (var _d = 0, _e = this._gatherRenderTargetsStage; _d < _e.length; _d++) {
  130751. var step = _e[_d];
  130752. step.action(this._renderTargets);
  130753. }
  130754. // Multi-cameras?
  130755. if (this.activeCameras.length > 0) {
  130756. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  130757. if (cameraIndex > 0) {
  130758. this._engine.clear(null, false, true, true);
  130759. }
  130760. this._processSubCameras(this.activeCameras[cameraIndex]);
  130761. }
  130762. }
  130763. else {
  130764. if (!this.activeCamera) {
  130765. throw new Error("No camera defined");
  130766. }
  130767. this._processSubCameras(this.activeCamera);
  130768. }
  130769. // Intersection checks
  130770. this._checkIntersections();
  130771. // Executes the after render stage actions.
  130772. for (var _f = 0, _g = this._afterRenderStage; _f < _g.length; _f++) {
  130773. var step = _g[_f];
  130774. step.action();
  130775. }
  130776. // After render
  130777. if (this.afterRender) {
  130778. this.afterRender();
  130779. }
  130780. this.onAfterRenderObservable.notifyObservers(this);
  130781. // Cleaning
  130782. if (this._toBeDisposed.length) {
  130783. for (var index = 0; index < this._toBeDisposed.length; index++) {
  130784. var data = this._toBeDisposed[index];
  130785. if (data) {
  130786. data.dispose();
  130787. }
  130788. }
  130789. this._toBeDisposed = [];
  130790. }
  130791. if (this.dumpNextRenderTargets) {
  130792. this.dumpNextRenderTargets = false;
  130793. }
  130794. this._activeBones.addCount(0, true);
  130795. this._activeIndices.addCount(0, true);
  130796. this._activeParticles.addCount(0, true);
  130797. };
  130798. /**
  130799. * Freeze all materials
  130800. * A frozen material will not be updatable but should be faster to render
  130801. */
  130802. Scene.prototype.freezeMaterials = function () {
  130803. for (var i = 0; i < this.materials.length; i++) {
  130804. this.materials[i].freeze();
  130805. }
  130806. };
  130807. /**
  130808. * Unfreeze all materials
  130809. * A frozen material will not be updatable but should be faster to render
  130810. */
  130811. Scene.prototype.unfreezeMaterials = function () {
  130812. for (var i = 0; i < this.materials.length; i++) {
  130813. this.materials[i].unfreeze();
  130814. }
  130815. };
  130816. /**
  130817. * Releases all held ressources
  130818. */
  130819. Scene.prototype.dispose = function () {
  130820. this.beforeRender = null;
  130821. this.afterRender = null;
  130822. this.skeletons = [];
  130823. this.morphTargetManagers = [];
  130824. this._transientComponents = [];
  130825. this._isReadyForMeshStage.clear();
  130826. this._beforeEvaluateActiveMeshStage.clear();
  130827. this._evaluateSubMeshStage.clear();
  130828. this._activeMeshStage.clear();
  130829. this._cameraDrawRenderTargetStage.clear();
  130830. this._beforeCameraDrawStage.clear();
  130831. this._beforeRenderTargetDrawStage.clear();
  130832. this._beforeRenderingGroupDrawStage.clear();
  130833. this._beforeRenderingMeshStage.clear();
  130834. this._afterRenderingMeshStage.clear();
  130835. this._afterRenderingGroupDrawStage.clear();
  130836. this._afterCameraDrawStage.clear();
  130837. this._afterRenderTargetDrawStage.clear();
  130838. this._afterRenderStage.clear();
  130839. this._beforeCameraUpdateStage.clear();
  130840. this._beforeClearStage.clear();
  130841. this._gatherRenderTargetsStage.clear();
  130842. this._gatherActiveCameraRenderTargetsStage.clear();
  130843. this._pointerMoveStage.clear();
  130844. this._pointerDownStage.clear();
  130845. this._pointerUpStage.clear();
  130846. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  130847. var component = _a[_i];
  130848. component.dispose();
  130849. }
  130850. this.importedMeshesFiles = new Array();
  130851. this.stopAllAnimations();
  130852. this.resetCachedMaterial();
  130853. // Smart arrays
  130854. if (this.activeCamera) {
  130855. this.activeCamera._activeMeshes.dispose();
  130856. this.activeCamera = null;
  130857. }
  130858. this._activeMeshes.dispose();
  130859. this._renderingManager.dispose();
  130860. this._processedMaterials.dispose();
  130861. this._activeParticleSystems.dispose();
  130862. this._activeSkeletons.dispose();
  130863. this._softwareSkinnedMeshes.dispose();
  130864. this._renderTargets.dispose();
  130865. this._registeredForLateAnimationBindings.dispose();
  130866. this._meshesForIntersections.dispose();
  130867. this._toBeDisposed = [];
  130868. // Abort active requests
  130869. for (var _b = 0, _c = this._activeRequests; _b < _c.length; _b++) {
  130870. var request = _c[_b];
  130871. request.abort();
  130872. }
  130873. // Events
  130874. this.onDisposeObservable.notifyObservers(this);
  130875. this.onDisposeObservable.clear();
  130876. this.onBeforeRenderObservable.clear();
  130877. this.onAfterRenderObservable.clear();
  130878. this.onBeforeRenderTargetsRenderObservable.clear();
  130879. this.onAfterRenderTargetsRenderObservable.clear();
  130880. this.onAfterStepObservable.clear();
  130881. this.onBeforeStepObservable.clear();
  130882. this.onBeforeActiveMeshesEvaluationObservable.clear();
  130883. this.onAfterActiveMeshesEvaluationObservable.clear();
  130884. this.onBeforeParticlesRenderingObservable.clear();
  130885. this.onAfterParticlesRenderingObservable.clear();
  130886. this.onBeforeDrawPhaseObservable.clear();
  130887. this.onAfterDrawPhaseObservable.clear();
  130888. this.onBeforeAnimationsObservable.clear();
  130889. this.onAfterAnimationsObservable.clear();
  130890. this.onDataLoadedObservable.clear();
  130891. this.onBeforeRenderingGroupObservable.clear();
  130892. this.onAfterRenderingGroupObservable.clear();
  130893. this.onMeshImportedObservable.clear();
  130894. this.onBeforeCameraRenderObservable.clear();
  130895. this.onAfterCameraRenderObservable.clear();
  130896. this.onReadyObservable.clear();
  130897. this.onNewCameraAddedObservable.clear();
  130898. this.onCameraRemovedObservable.clear();
  130899. this.onNewLightAddedObservable.clear();
  130900. this.onLightRemovedObservable.clear();
  130901. this.onNewGeometryAddedObservable.clear();
  130902. this.onGeometryRemovedObservable.clear();
  130903. this.onNewTransformNodeAddedObservable.clear();
  130904. this.onTransformNodeRemovedObservable.clear();
  130905. this.onNewMeshAddedObservable.clear();
  130906. this.onMeshRemovedObservable.clear();
  130907. this.onNewMaterialAddedObservable.clear();
  130908. this.onMaterialRemovedObservable.clear();
  130909. this.onNewTextureAddedObservable.clear();
  130910. this.onTextureRemovedObservable.clear();
  130911. this.onPrePointerObservable.clear();
  130912. this.onPointerObservable.clear();
  130913. this.onPreKeyboardObservable.clear();
  130914. this.onKeyboardObservable.clear();
  130915. this.onActiveCameraChanged.clear();
  130916. this.detachControl();
  130917. // Detach cameras
  130918. var canvas = this._engine.getRenderingCanvas();
  130919. if (canvas) {
  130920. var index;
  130921. for (index = 0; index < this.cameras.length; index++) {
  130922. this.cameras[index].detachControl(canvas);
  130923. }
  130924. }
  130925. // Release animation groups
  130926. while (this.animationGroups.length) {
  130927. this.animationGroups[0].dispose();
  130928. }
  130929. // Release lights
  130930. while (this.lights.length) {
  130931. this.lights[0].dispose();
  130932. }
  130933. // Release meshes
  130934. while (this.meshes.length) {
  130935. this.meshes[0].dispose(true);
  130936. }
  130937. while (this.transformNodes.length) {
  130938. this.removeTransformNode(this.transformNodes[0]);
  130939. }
  130940. // Release cameras
  130941. while (this.cameras.length) {
  130942. this.cameras[0].dispose();
  130943. }
  130944. // Release materials
  130945. if (this.defaultMaterial) {
  130946. this.defaultMaterial.dispose();
  130947. }
  130948. while (this.multiMaterials.length) {
  130949. this.multiMaterials[0].dispose();
  130950. }
  130951. while (this.materials.length) {
  130952. this.materials[0].dispose();
  130953. }
  130954. // Release particles
  130955. while (this.particleSystems.length) {
  130956. this.particleSystems[0].dispose();
  130957. }
  130958. // Release postProcesses
  130959. while (this.postProcesses.length) {
  130960. this.postProcesses[0].dispose();
  130961. }
  130962. // Release textures
  130963. while (this.textures.length) {
  130964. this.textures[0].dispose();
  130965. }
  130966. // Release UBO
  130967. this._sceneUbo.dispose();
  130968. if (this._alternateSceneUbo) {
  130969. this._alternateSceneUbo.dispose();
  130970. }
  130971. // Post-processes
  130972. this.postProcessManager.dispose();
  130973. // Remove from engine
  130974. index = this._engine.scenes.indexOf(this);
  130975. if (index > -1) {
  130976. this._engine.scenes.splice(index, 1);
  130977. }
  130978. this._engine.wipeCaches(true);
  130979. this._isDisposed = true;
  130980. };
  130981. Object.defineProperty(Scene.prototype, "isDisposed", {
  130982. /**
  130983. * Gets if the scene is already disposed
  130984. */
  130985. get: function () {
  130986. return this._isDisposed;
  130987. },
  130988. enumerable: true,
  130989. configurable: true
  130990. });
  130991. /**
  130992. * Call this function to reduce memory footprint of the scene.
  130993. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  130994. */
  130995. Scene.prototype.clearCachedVertexData = function () {
  130996. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  130997. var mesh = this.meshes[meshIndex];
  130998. var geometry = mesh.geometry;
  130999. if (geometry) {
  131000. geometry._indices = [];
  131001. for (var vbName in geometry._vertexBuffers) {
  131002. if (!geometry._vertexBuffers.hasOwnProperty(vbName)) {
  131003. continue;
  131004. }
  131005. geometry._vertexBuffers[vbName]._buffer._data = null;
  131006. }
  131007. }
  131008. }
  131009. };
  131010. /**
  131011. * This function will remove the local cached buffer data from texture.
  131012. * It will save memory but will prevent the texture from being rebuilt
  131013. */
  131014. Scene.prototype.cleanCachedTextureBuffer = function () {
  131015. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  131016. var baseTexture = _a[_i];
  131017. var buffer = baseTexture._buffer;
  131018. if (buffer) {
  131019. baseTexture._buffer = null;
  131020. }
  131021. }
  131022. };
  131023. /**
  131024. * Get the world extend vectors with an optional filter
  131025. *
  131026. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  131027. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  131028. */
  131029. Scene.prototype.getWorldExtends = function (filterPredicate) {
  131030. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  131031. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  131032. filterPredicate = filterPredicate || (function () { return true; });
  131033. this.meshes.filter(filterPredicate).forEach(function (mesh) {
  131034. mesh.computeWorldMatrix(true);
  131035. if (!mesh.subMeshes || mesh.subMeshes.length === 0 || mesh.infiniteDistance) {
  131036. return;
  131037. }
  131038. var boundingInfo = mesh.getBoundingInfo();
  131039. var minBox = boundingInfo.boundingBox.minimumWorld;
  131040. var maxBox = boundingInfo.boundingBox.maximumWorld;
  131041. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  131042. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  131043. });
  131044. return {
  131045. min: min,
  131046. max: max
  131047. };
  131048. };
  131049. // Picking
  131050. /**
  131051. * Creates a ray that can be used to pick in the scene
  131052. * @param x defines the x coordinate of the origin (on-screen)
  131053. * @param y defines the y coordinate of the origin (on-screen)
  131054. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  131055. * @param camera defines the camera to use for the picking
  131056. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  131057. * @returns a Ray
  131058. */
  131059. Scene.prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  131060. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  131061. var result = _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"].Zero();
  131062. this.createPickingRayToRef(x, y, world, result, camera, cameraViewSpace);
  131063. return result;
  131064. };
  131065. /**
  131066. * Creates a ray that can be used to pick in the scene
  131067. * @param x defines the x coordinate of the origin (on-screen)
  131068. * @param y defines the y coordinate of the origin (on-screen)
  131069. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  131070. * @param result defines the ray where to store the picking ray
  131071. * @param camera defines the camera to use for the picking
  131072. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  131073. * @returns the current scene
  131074. */
  131075. Scene.prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  131076. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  131077. var engine = this._engine;
  131078. if (!camera) {
  131079. if (!this.activeCamera) {
  131080. throw new Error("Active camera not set");
  131081. }
  131082. camera = this.activeCamera;
  131083. }
  131084. var cameraViewport = camera.viewport;
  131085. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  131086. // Moving coordinates to local viewport world
  131087. x = x / this._engine.getHardwareScalingLevel() - viewport.x;
  131088. y = y / this._engine.getHardwareScalingLevel() - (this._engine.getRenderHeight() - viewport.y - viewport.height);
  131089. 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());
  131090. return this;
  131091. };
  131092. /**
  131093. * Creates a ray that can be used to pick in the scene
  131094. * @param x defines the x coordinate of the origin (on-screen)
  131095. * @param y defines the y coordinate of the origin (on-screen)
  131096. * @param camera defines the camera to use for the picking
  131097. * @returns a Ray
  131098. */
  131099. Scene.prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  131100. var result = _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"].Zero();
  131101. this.createPickingRayInCameraSpaceToRef(x, y, result, camera);
  131102. return result;
  131103. };
  131104. /**
  131105. * Creates a ray that can be used to pick in the scene
  131106. * @param x defines the x coordinate of the origin (on-screen)
  131107. * @param y defines the y coordinate of the origin (on-screen)
  131108. * @param result defines the ray where to store the picking ray
  131109. * @param camera defines the camera to use for the picking
  131110. * @returns the current scene
  131111. */
  131112. Scene.prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  131113. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_16__["PickingInfo"]) {
  131114. return this;
  131115. }
  131116. var engine = this._engine;
  131117. if (!camera) {
  131118. if (!this.activeCamera) {
  131119. throw new Error("Active camera not set");
  131120. }
  131121. camera = this.activeCamera;
  131122. }
  131123. var cameraViewport = camera.viewport;
  131124. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  131125. var identity = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity();
  131126. // Moving coordinates to local viewport world
  131127. x = x / this._engine.getHardwareScalingLevel() - viewport.x;
  131128. y = y / this._engine.getHardwareScalingLevel() - (this._engine.getRenderHeight() - viewport.y - viewport.height);
  131129. result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());
  131130. return this;
  131131. };
  131132. Scene.prototype._internalPick = function (rayFunction, predicate, fastCheck) {
  131133. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_16__["PickingInfo"]) {
  131134. return null;
  131135. }
  131136. var pickingInfo = null;
  131137. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  131138. var mesh = this.meshes[meshIndex];
  131139. if (predicate) {
  131140. if (!predicate(mesh)) {
  131141. continue;
  131142. }
  131143. }
  131144. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  131145. continue;
  131146. }
  131147. var world = mesh.getWorldMatrix();
  131148. var ray = rayFunction(world);
  131149. var result = mesh.intersects(ray, fastCheck);
  131150. if (!result || !result.hit) {
  131151. continue;
  131152. }
  131153. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  131154. continue;
  131155. }
  131156. pickingInfo = result;
  131157. if (fastCheck) {
  131158. break;
  131159. }
  131160. }
  131161. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_16__["PickingInfo"]();
  131162. };
  131163. Scene.prototype._internalMultiPick = function (rayFunction, predicate) {
  131164. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_16__["PickingInfo"]) {
  131165. return null;
  131166. }
  131167. var pickingInfos = new Array();
  131168. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  131169. var mesh = this.meshes[meshIndex];
  131170. if (predicate) {
  131171. if (!predicate(mesh)) {
  131172. continue;
  131173. }
  131174. }
  131175. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  131176. continue;
  131177. }
  131178. var world = mesh.getWorldMatrix();
  131179. var ray = rayFunction(world);
  131180. var result = mesh.intersects(ray, false);
  131181. if (!result || !result.hit) {
  131182. continue;
  131183. }
  131184. pickingInfos.push(result);
  131185. }
  131186. return pickingInfos;
  131187. };
  131188. /** Launch a ray to try to pick a mesh in the scene
  131189. * @param x position on screen
  131190. * @param y position on screen
  131191. * @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
  131192. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  131193. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  131194. * @returns a PickingInfo
  131195. */
  131196. Scene.prototype.pick = function (x, y, predicate, fastCheck, camera) {
  131197. var _this = this;
  131198. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_16__["PickingInfo"]) {
  131199. return null;
  131200. }
  131201. var result = this._internalPick(function (world) {
  131202. _this.createPickingRayToRef(x, y, world, _this._tempPickingRay, camera || null);
  131203. return _this._tempPickingRay;
  131204. }, predicate, fastCheck);
  131205. if (result) {
  131206. result.ray = this.createPickingRay(x, y, _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity(), camera || null);
  131207. }
  131208. return result;
  131209. };
  131210. /** Use the given ray to pick a mesh in the scene
  131211. * @param ray The ray to use to pick meshes
  131212. * @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
  131213. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  131214. * @returns a PickingInfo
  131215. */
  131216. Scene.prototype.pickWithRay = function (ray, predicate, fastCheck) {
  131217. var _this = this;
  131218. var result = this._internalPick(function (world) {
  131219. if (!_this._pickWithRayInverseMatrix) {
  131220. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity();
  131221. }
  131222. world.invertToRef(_this._pickWithRayInverseMatrix);
  131223. if (!_this._cachedRayForTransform) {
  131224. _this._cachedRayForTransform = _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"].Zero();
  131225. }
  131226. _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"].TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  131227. return _this._cachedRayForTransform;
  131228. }, predicate, fastCheck);
  131229. if (result) {
  131230. result.ray = ray;
  131231. }
  131232. return result;
  131233. };
  131234. /**
  131235. * Launch a ray to try to pick a mesh in the scene
  131236. * @param x X position on screen
  131237. * @param y Y position on screen
  131238. * @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
  131239. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  131240. * @returns an array of PickingInfo
  131241. */
  131242. Scene.prototype.multiPick = function (x, y, predicate, camera) {
  131243. var _this = this;
  131244. return this._internalMultiPick(function (world) { return _this.createPickingRay(x, y, world, camera || null); }, predicate);
  131245. };
  131246. /**
  131247. * Launch a ray to try to pick a mesh in the scene
  131248. * @param ray Ray to use
  131249. * @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
  131250. * @returns an array of PickingInfo
  131251. */
  131252. Scene.prototype.multiPickWithRay = function (ray, predicate) {
  131253. var _this = this;
  131254. return this._internalMultiPick(function (world) {
  131255. if (!_this._pickWithRayInverseMatrix) {
  131256. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity();
  131257. }
  131258. world.invertToRef(_this._pickWithRayInverseMatrix);
  131259. if (!_this._cachedRayForTransform) {
  131260. _this._cachedRayForTransform = _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"].Zero();
  131261. }
  131262. _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"].TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  131263. return _this._cachedRayForTransform;
  131264. }, predicate);
  131265. };
  131266. /**
  131267. * Force the value of meshUnderPointer
  131268. * @param mesh defines the mesh to use
  131269. */
  131270. Scene.prototype.setPointerOverMesh = function (mesh) {
  131271. if (this._pointerOverMesh === mesh) {
  131272. return;
  131273. }
  131274. if (this._pointerOverMesh && this._pointerOverMesh.actionManager) {
  131275. this._pointerOverMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(this._pointerOverMesh));
  131276. }
  131277. this._pointerOverMesh = mesh;
  131278. if (this._pointerOverMesh && this._pointerOverMesh.actionManager) {
  131279. this._pointerOverMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(this._pointerOverMesh));
  131280. }
  131281. };
  131282. /**
  131283. * Gets the mesh under the pointer
  131284. * @returns a Mesh or null if no mesh is under the pointer
  131285. */
  131286. Scene.prototype.getPointerOverMesh = function () {
  131287. return this._pointerOverMesh;
  131288. };
  131289. // Misc.
  131290. /** @hidden */
  131291. Scene.prototype._rebuildGeometries = function () {
  131292. for (var _i = 0, _a = this.geometries; _i < _a.length; _i++) {
  131293. var geometry = _a[_i];
  131294. geometry._rebuild();
  131295. }
  131296. for (var _b = 0, _c = this.meshes; _b < _c.length; _b++) {
  131297. var mesh = _c[_b];
  131298. mesh._rebuild();
  131299. }
  131300. if (this.postProcessManager) {
  131301. this.postProcessManager._rebuild();
  131302. }
  131303. for (var _d = 0, _e = this._components; _d < _e.length; _d++) {
  131304. var component = _e[_d];
  131305. component.rebuild();
  131306. }
  131307. for (var _f = 0, _g = this.particleSystems; _f < _g.length; _f++) {
  131308. var system = _g[_f];
  131309. system.rebuild();
  131310. }
  131311. };
  131312. /** @hidden */
  131313. Scene.prototype._rebuildTextures = function () {
  131314. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  131315. var texture = _a[_i];
  131316. texture._rebuild();
  131317. }
  131318. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_TextureDirtyFlag);
  131319. };
  131320. // Tags
  131321. Scene.prototype._getByTags = function (list, tagsQuery, forEach) {
  131322. if (tagsQuery === undefined) {
  131323. // returns the complete list (could be done with Tags.MatchesQuery but no need to have a for-loop here)
  131324. return list;
  131325. }
  131326. var listByTags = [];
  131327. forEach = forEach || (function (item) { return; });
  131328. for (var i in list) {
  131329. var item = list[i];
  131330. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"].MatchesQuery(item, tagsQuery)) {
  131331. listByTags.push(item);
  131332. forEach(item);
  131333. }
  131334. }
  131335. return listByTags;
  131336. };
  131337. /**
  131338. * Get a list of meshes by tags
  131339. * @param tagsQuery defines the tags query to use
  131340. * @param forEach defines a predicate used to filter results
  131341. * @returns an array of Mesh
  131342. */
  131343. Scene.prototype.getMeshesByTags = function (tagsQuery, forEach) {
  131344. return this._getByTags(this.meshes, tagsQuery, forEach);
  131345. };
  131346. /**
  131347. * Get a list of cameras by tags
  131348. * @param tagsQuery defines the tags query to use
  131349. * @param forEach defines a predicate used to filter results
  131350. * @returns an array of Camera
  131351. */
  131352. Scene.prototype.getCamerasByTags = function (tagsQuery, forEach) {
  131353. return this._getByTags(this.cameras, tagsQuery, forEach);
  131354. };
  131355. /**
  131356. * Get a list of lights by tags
  131357. * @param tagsQuery defines the tags query to use
  131358. * @param forEach defines a predicate used to filter results
  131359. * @returns an array of Light
  131360. */
  131361. Scene.prototype.getLightsByTags = function (tagsQuery, forEach) {
  131362. return this._getByTags(this.lights, tagsQuery, forEach);
  131363. };
  131364. /**
  131365. * Get a list of materials by tags
  131366. * @param tagsQuery defines the tags query to use
  131367. * @param forEach defines a predicate used to filter results
  131368. * @returns an array of Material
  131369. */
  131370. Scene.prototype.getMaterialByTags = function (tagsQuery, forEach) {
  131371. return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
  131372. };
  131373. /**
  131374. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  131375. * This allowed control for front to back rendering or reversly depending of the special needs.
  131376. *
  131377. * @param renderingGroupId The rendering group id corresponding to its index
  131378. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  131379. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  131380. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  131381. */
  131382. Scene.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  131383. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  131384. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  131385. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  131386. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  131387. };
  131388. /**
  131389. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  131390. *
  131391. * @param renderingGroupId The rendering group id corresponding to its index
  131392. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  131393. * @param depth Automatically clears depth between groups if true and autoClear is true.
  131394. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  131395. */
  131396. Scene.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  131397. if (depth === void 0) { depth = true; }
  131398. if (stencil === void 0) { stencil = true; }
  131399. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil, depth, stencil);
  131400. };
  131401. /**
  131402. * Gets the current auto clear configuration for one rendering group of the rendering
  131403. * manager.
  131404. * @param index the rendering group index to get the information for
  131405. * @returns The auto clear setup for the requested rendering group
  131406. */
  131407. Scene.prototype.getAutoClearDepthStencilSetup = function (index) {
  131408. return this._renderingManager.getAutoClearDepthStencilSetup(index);
  131409. };
  131410. Object.defineProperty(Scene.prototype, "blockMaterialDirtyMechanism", {
  131411. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  131412. get: function () {
  131413. return this._blockMaterialDirtyMechanism;
  131414. },
  131415. set: function (value) {
  131416. if (this._blockMaterialDirtyMechanism === value) {
  131417. return;
  131418. }
  131419. this._blockMaterialDirtyMechanism = value;
  131420. if (!value) { // Do a complete update
  131421. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_AllDirtyFlag);
  131422. }
  131423. },
  131424. enumerable: true,
  131425. configurable: true
  131426. });
  131427. /**
  131428. * Will flag all materials as dirty to trigger new shader compilation
  131429. * @param flag defines the flag used to specify which material part must be marked as dirty
  131430. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  131431. */
  131432. Scene.prototype.markAllMaterialsAsDirty = function (flag, predicate) {
  131433. if (this._blockMaterialDirtyMechanism) {
  131434. return;
  131435. }
  131436. for (var _i = 0, _a = this.materials; _i < _a.length; _i++) {
  131437. var material = _a[_i];
  131438. if (predicate && !predicate(material)) {
  131439. continue;
  131440. }
  131441. material.markAsDirty(flag);
  131442. }
  131443. };
  131444. /** @hidden */
  131445. Scene.prototype._loadFile = function (url, onSuccess, onProgress, useOfflineSupport, useArrayBuffer, onError) {
  131446. var _this = this;
  131447. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadFile(url, onSuccess, onProgress, useOfflineSupport ? this.offlineProvider : undefined, useArrayBuffer, onError);
  131448. this._activeRequests.push(request);
  131449. request.onCompleteObservable.add(function (request) {
  131450. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  131451. });
  131452. return request;
  131453. };
  131454. /** @hidden */
  131455. Scene.prototype._loadFileAsync = function (url, useOfflineSupport, useArrayBuffer) {
  131456. var _this = this;
  131457. return new Promise(function (resolve, reject) {
  131458. _this._loadFile(url, function (data) {
  131459. resolve(data);
  131460. }, undefined, useOfflineSupport, useArrayBuffer, function (request, exception) {
  131461. reject(exception);
  131462. });
  131463. });
  131464. };
  131465. // Statics
  131466. Scene._uniqueIdCounter = 0;
  131467. /** The fog is deactivated */
  131468. Scene.FOGMODE_NONE = 0;
  131469. /** The fog density is following an exponential function */
  131470. Scene.FOGMODE_EXP = 1;
  131471. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  131472. Scene.FOGMODE_EXP2 = 2;
  131473. /** The fog density is following a linear function. */
  131474. Scene.FOGMODE_LINEAR = 3;
  131475. /**
  131476. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  131477. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131478. */
  131479. Scene.MinDeltaTime = 1.0;
  131480. /**
  131481. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  131482. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131483. */
  131484. Scene.MaxDeltaTime = 1000.0;
  131485. /** The distance in pixel that you have to move to prevent some events */
  131486. Scene.DragMovementThreshold = 10; // in pixels
  131487. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  131488. Scene.LongPressDelay = 500; // in milliseconds
  131489. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  131490. Scene.DoubleClickDelay = 300; // in milliseconds
  131491. /** If you need to check double click without raising a single click at first click, enable this flag */
  131492. Scene.ExclusiveDoubleClickMode = false;
  131493. return Scene;
  131494. }(_abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"]));
  131495. /***/ }),
  131496. /***/ "./sceneComponent.ts":
  131497. /*!***************************!*\
  131498. !*** ./sceneComponent.ts ***!
  131499. \***************************/
  131500. /*! exports provided: SceneComponentConstants, Stage */
  131501. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131502. "use strict";
  131503. __webpack_require__.r(__webpack_exports__);
  131504. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return SceneComponentConstants; });
  131505. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return Stage; });
  131506. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  131507. /**
  131508. * Groups all the scene component constants in one place to ease maintenance.
  131509. * @hidden
  131510. */
  131511. var SceneComponentConstants = /** @class */ (function () {
  131512. function SceneComponentConstants() {
  131513. }
  131514. SceneComponentConstants.NAME_EFFECTLAYER = "EffectLayer";
  131515. SceneComponentConstants.NAME_LAYER = "Layer";
  131516. SceneComponentConstants.NAME_LENSFLARESYSTEM = "LensFlareSystem";
  131517. SceneComponentConstants.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer";
  131518. SceneComponentConstants.NAME_PARTICLESYSTEM = "ParticleSystem";
  131519. SceneComponentConstants.NAME_GAMEPAD = "Gamepad";
  131520. SceneComponentConstants.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue";
  131521. SceneComponentConstants.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer";
  131522. SceneComponentConstants.NAME_DEPTHRENDERER = "DepthRenderer";
  131523. SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager";
  131524. SceneComponentConstants.NAME_SPRITE = "Sprite";
  131525. SceneComponentConstants.NAME_OUTLINERENDERER = "Outline";
  131526. SceneComponentConstants.NAME_PROCEDURALTEXTURE = "ProceduralTexture";
  131527. SceneComponentConstants.NAME_SHADOWGENERATOR = "ShadowGenerator";
  131528. SceneComponentConstants.NAME_OCTREE = "Octree";
  131529. SceneComponentConstants.NAME_PHYSICSENGINE = "PhysicsEngine";
  131530. SceneComponentConstants.NAME_AUDIO = "Audio";
  131531. SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER = 0;
  131532. SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  131533. SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
  131534. SceneComponentConstants.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  131535. SceneComponentConstants.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1;
  131536. SceneComponentConstants.STEP_BEFORECAMERADRAW_EFFECTLAYER = 0;
  131537. SceneComponentConstants.STEP_BEFORECAMERADRAW_LAYER = 1;
  131538. SceneComponentConstants.STEP_BEFORERENDERTARGETDRAW_LAYER = 0;
  131539. SceneComponentConstants.STEP_BEFORERENDERINGMESH_OUTLINE = 0;
  131540. SceneComponentConstants.STEP_AFTERRENDERINGMESH_OUTLINE = 0;
  131541. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;
  131542. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1;
  131543. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;
  131544. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1;
  131545. SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;
  131546. SceneComponentConstants.STEP_AFTERRENDERTARGETDRAW_LAYER = 0;
  131547. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER = 0;
  131548. SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 1;
  131549. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 2;
  131550. SceneComponentConstants.STEP_AFTERCAMERADRAW_LAYER = 3;
  131551. SceneComponentConstants.STEP_AFTERRENDER_AUDIO = 0;
  131552. SceneComponentConstants.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 0;
  131553. SceneComponentConstants.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1;
  131554. SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 2;
  131555. SceneComponentConstants.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3;
  131556. SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0;
  131557. SceneComponentConstants.STEP_POINTERMOVE_SPRITE = 0;
  131558. SceneComponentConstants.STEP_POINTERDOWN_SPRITE = 0;
  131559. SceneComponentConstants.STEP_POINTERUP_SPRITE = 0;
  131560. return SceneComponentConstants;
  131561. }());
  131562. /**
  131563. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  131564. * @hidden
  131565. */
  131566. var Stage = /** @class */ (function (_super) {
  131567. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Stage, _super);
  131568. /**
  131569. * Hide ctor from the rest of the world.
  131570. * @param items The items to add.
  131571. */
  131572. function Stage(items) {
  131573. return _super.apply(this, items) || this;
  131574. }
  131575. /**
  131576. * Creates a new Stage.
  131577. * @returns A new instance of a Stage
  131578. */
  131579. Stage.Create = function () {
  131580. return Object.create(Stage.prototype);
  131581. };
  131582. /**
  131583. * Registers a step in an ordered way in the targeted stage.
  131584. * @param index Defines the position to register the step in
  131585. * @param component Defines the component attached to the step
  131586. * @param action Defines the action to launch during the step
  131587. */
  131588. Stage.prototype.registerStep = function (index, component, action) {
  131589. var i = 0;
  131590. var maxIndex = Number.MAX_VALUE;
  131591. for (; i < this.length; i++) {
  131592. var step = this[i];
  131593. maxIndex = step.index;
  131594. if (index < maxIndex) {
  131595. break;
  131596. }
  131597. }
  131598. this.splice(i, 0, { index: index, component: component, action: action.bind(component) });
  131599. };
  131600. /**
  131601. * Clears all the steps from the stage.
  131602. */
  131603. Stage.prototype.clear = function () {
  131604. this.length = 0;
  131605. };
  131606. return Stage;
  131607. }(Array));
  131608. /***/ })
  131609. /******/ });
  131610. });
  131611. //# sourceMappingURL=babylon.max.js.map